Parse XML or HTML with Nokogiri
To parse XML-documents, I recommend the gem nokogiri.
A few hints:
-
xml = Nokogiri::XML("<list><item>foo</item><item>bar</item></list>")parses an xml string. You can also callNokogiri::HTMLto be more liberal about accepting invalid XML. -
xml / 'list item'returns all matching nodes;list itemis used like a CSS selector -
xml / './/list/item'also returns all matching nodes, but.//list/itemis now an XPath selector- XPath seems to be triggered by a leading
....
- XPath seems to be triggered by a leading
Automatically build sprites with Lemonade
How it works
See the lemonade descriptions.
Unfortunately, the gem has a few problems:
- it does not work with Sass2
- it always generates all sprites when the sass file changes, which is too slow for big projects
- it expects a folder structure quite different to our usual
All these problems are solved for us, in our own lemonade fork. This fork has since been merged to the original gem, maybe we can use t...
Convert Haml to ERB
This is about converting Haml to ERB and not the other way round which you probably want!
This process can not be automated 100%, but you can still save time.
First do
script/plugin install http://github.com/cgoddard/haml2erb.git
Then in the console type
hamls = Dir["app/views/**/*.haml"] - ['app/views/layouts/screen.html.haml'];
hamls.each do |haml|
puts haml
erb = haml.sub(/\.haml$/, '.erb')
File.open(erb, 'w') do |file|
file.write Haml2Erb.convert(File.read(haml))
end
end
After th...
Typical .gitignore
log/*
tmp/*
storage/*
db/*.sqlite3
db/schema.rb
db/structure.sql
public/system
.project
.idea/
public/javascripts/all*
public/stylesheets/all*
public/stylesheets/*.css
config/database.yml
*~
*#*
.#*
.DS_Store
webrat-*.html
capybara-*.html
rerun.txt
coverage.data
coverage/*
dump_for_download.dump
.~lock.*
.*.swp
C:\\nppdf32Log\\debuglog.txt
Configuring Git with .gitconfig
Basic configuration
Please keep this config simple. It should be a starting point for new developers learning Git.
[user]
name = Your Name
email = your.name@domain.com
[branch]
sort = -committerdate
[color]
ui = auto
[color "branch"]
current = yellow reverse
local = yellow
remote = green
[color "diff"]
whitespace = white reverse
meta = blue reverse
frag = blue reverse
old = red
new = green
[color "status"]
added = green
changed = yellow
untracked = cyan
[interactive]
singlekey = true # Do not requir...
Slugs with FriendlyId
Gem to provide nice looking urls ("/blog/the-greatest-bug-i-never-fixed"). If you don't need anything too special (like i18n for the urls) it works as a drop-in-replacement. It basically overwrites #to_param to return the slug, and .find to search by the slug.
Make sure, everywhere you build paths, you use model_path(:id => model) instead of model_path(:id => model.id). You also need to adapt all code using something like .find_by_id. The regular .find is fine.
See the github README for installation instructions.
Don't forget ...
Sanitize: A whitelist-based Ruby HTML sanitizer
Given a list of acceptable elements and attributes, Sanitize will remove all unacceptable HTML from a string.
Bill de hÓra: Managing large stories on agile projects
I've seen this granularity problem on every project, product or program I've worked on. Often in non-agile methods it comes it up in the form of traceability requirements on top of the actual requirements.
clemens's later_dude at master - GitHub
LaterDude is a small calendar helper with i18n support
Reflective Surface » Tests: Pragmatism or ideology?
The argument that using tests is a ideologic waster of time fails when one considers how it can help to insure architectural decisions.
mca blog [REST Upside Down]
i keep looking for ways to help people 'get' REST. not URLs or HTTP Methods; but REST itself - in a nutshell. so here's a new angle i've started playing with: "REST Upside Down."
Recreating the button | stopdesign
Until some future version of HTML gives us new native controls to use in a browser, at Google, we’ve been playing and experimenting with controls we call “custom buttons” in our apps (among other custom controls).
Welcome to WebIS.net - Pocket Informant iPhone
Pocket Informant for the iPhone doesn't just simply let you view your daily events but lets you really work with them. So many calendar or task applications are either too hard to use or too simple to be useful. Pocket Informant takes eight years of mobile experience and brings a fresh perspective to the iPhone user.
Rails 2.3 Nested Object Forms: I’m not Crazy about Them « SmartLogic Solutions Blog
I just finished reviewing Rails 2.3 Nested Object Forms. While a very nice and “magical” feature, I’ve got to admit that I’m really not that crazy about how it works.
Tagaholic - Console Update With Your Editor
Rails’ script/console makes it easy to fetch, view and edit your database records. But can you edit those records as quickly as you edit code in your text editor? Riiight, like editing our database records in an editor is gonna happen? It already has.
Tagaholic - Hirb - Irb On The Good Stuff
Hirb provides a mini view framework for console applications, designed with irb in mind.
QuirksBlog: Making <code><time></code> safe for historians
I believe that the current specification of the element is vague because it avoids the question whether the element is safe for historians. Right now it hurts historical research more than it helps
PragDave: The RADAR Architecture: RESTful Application, Dumb-Ass Recipient
So, as a result, people using RESTful ideas to talk to browsers have to put the smarts back on the server. They invent new URLs which (for example) return a resource, but return it all wrapped up in the HTML needed to display it as a form for browser-based editing.
Darkfish Rdoc
This is a project to make a complete replacement for the default HTML generator for Rdoc, the API documentation-extraction system for Ruby.
mislav's hanna at master - GitHub
Hanna is an RDoc template that scales. It's implemented in Haml, making the sources clean and readable. It's built with simplicity, beauty and ease of browsing in mind.
ModPorter - Painless file uploads
Porter is essentially the inverse of X-SendFile. It parses the multipart post in C inside your apache process and writes the files to disk. Once that work is done it changes the request to look like a regular form POST which contains pointers to the temp files on disk.
SlickMap CSS — A Visual Sitemapping Tool for Web Developers
SlickMap CSS is a simple stylesheet for displaying finished sitemaps directly from HTML unordered list navigation.