- C-a == Ctrl-a
- M-a == Alt-a
:q close
:w write/saves
:wa[!] write/save all windows [force]
:wq write/save and close
| <?php | |
| /** | |
| * Iterates over a CSV file using the first | |
| * row (column names) as the array keys for | |
| * each subsequent entry returned | |
| */ | |
| class AssociativeCsvFileIterator extends FilterIterator | |
| { | |
| protected | |
| /** |
| git remote add github [EMAIL PROTECTED]:myaccount/myapp.git | |
| git remote add heroku [EMAIL PROTECTED]:myapp.git | |
| Then you can do “git push heroku” and “git push github”, or pull, or | |
| From: http://blog.mindtonic.net/using-github-and-heroku-together |
| function slugify(text) | |
| { | |
| return text.toString().toLowerCase() | |
| .replace(/\s+/g, '-') // Replace spaces with - | |
| .replace(/[^\w\-]+/g, '') // Remove all non-word chars | |
| .replace(/\-\-+/g, '-') // Replace multiple - with single - | |
| .replace(/^-+/, '') // Trim - from start of text | |
| .replace(/-+$/, ''); // Trim - from end of text | |
| } |
| for (var i=1; i <= 20; i++) | |
| { | |
| if (i % 15 == 0) | |
| console.log("FizzBuzz"); | |
| else if (i % 3 == 0) | |
| console.log("Fizz"); | |
| else if (i % 5 == 0) | |
| console.log("Buzz"); | |
| else | |
| console.log(i); |
| # USAGE: Hash.from_libxml(YOUR_XML_STRING) | |
| # http://movesonrails.com/articles/2008/02/25/libxml-for-active-resource-2-0 | |
| require 'nokogiri' | |
| # updated because original version is written in 2 years ago. - memerelics | |
| class Hash | |
| class << self | |
| def from_libxml(xml) | |
| begin | |
| result = Nokogiri::XML(xml) | |
| return { result.root.name.to_s.to_sym => xml_node_to_hash(result.root)} |
| $ redis-cli | |
| > config set stop-writes-on-bgsave-error no |
| /* | |
| fmod for Javascript, will work with any ECMA-262 implementation. | |
| If you need a precision higher than 8, please use another implementation of fmod. | |
| 1.05 % 0.05 | |
| => 0.04999999999999999 | |
| Math.fmod(1.05, 0.05) | |
| => 0 |
| function string_to_slug (str) { | |
| str = str.replace(/^\s+|\s+$/g, ''); // trim | |
| str = str.toLowerCase(); | |
| // remove accents, swap ñ for n, etc | |
| var from = "àáäâèéëêìíïîòóöôùúüûñç·/_,:;"; | |
| var to = "aaaaeeeeiiiioooouuuunc------"; | |
| for (var i=0, l=from.length ; i<l ; i++) { | |
| str = str.replace(new RegExp(from.charAt(i), 'g'), to.charAt(i)); | |
| } |
| # Thanks to this post: | |
| # http://blog.ikato.com/post/15675823000/how-to-install-consolas-font-on-mac-os-x | |
| $ brew install cabextract | |
| $ cd ~/Downloads | |
| $ mkdir consolas | |
| $ cd consolas | |
| $ curl -O http://download.microsoft.com/download/f/5/a/f5a3df76-d856-4a61-a6bd-722f52a5be26/PowerPointViewer.exe | |
| $ cabextract PowerPointViewer.exe | |
| $ cabextract ppviewer.cab |