Skip to content

Instantly share code, notes, and snippets.

$ ruby
puts "Hello, World!"
^D
Hello, World!
$ ruby -e 'puts "Hello, World!"'
Hello, World!
$ irb
>> puts "Hello, World!"
require 'rubygems'
require 'nokogiri'
require 'open-uri'
Nokogiri::HTML(open('http://www.google.com/search?q=tenderlove')).xpath('//h3/a[@class="l"]').each do |link|
puts link.content
end
jQuery(function($){
$('ol.reversed > li').each(function(){
$(this).prependTo($(this).parent());
});
});
<?php
$story = <<<FOO
Lorem ipsum dolor sit amet, consectetur adipiscing elit.
Etiam lacinia nibh eleifend mauris dignissim bibendum.
Suspendisse vitae turpis sit amet velit vehicula malesuada.
FOO;
?>
@abernier
abernier / GIT
Created September 20, 2010 09:58
// Recursive submodule init update
git submodule foreach --recursive 'git submodule init && git submodule update'
// Push de la branche locale 'machin' vers la branche distante 'chose'
git push origin/machin:chose
// Renommer une branche
git branch -m <nouveau-nom>
// Stashing for later
mkdir myapp && cd $_
git init
git submodule add http://github.com/symfony/symfony1.git lib/vendor/symfony
git submodule foreach --recursive 'git submodule init && git submodule update'
php lib/vendor/symfony/data/bin/symfony generate:project myapp
ln -s ../lib/vendor/symfony/data/web/sf web/
./symfony generate:app frontend
function walkTheDOM(node, func) {
func(node);
node = node.firstChild;
while (node) {
walkTheDOM(node, func);
node = node.nextSibling;
}
}
function getElementsByClassName(className) {
var results = [];
walkTheDOM(document.body, function (node) {
var a, c = node.className, i;
if (c) {
a = c.split(' ');
for (i = 0; i < a.length; i += 1) {
if (a[i] === className) {
results.push(node);
break;
@abernier
abernier / gist:815228
Created February 7, 2011 21:10
My link is a form...
<a href="/legalbox/lb_js_scalableApp/issues/1/close" class="minibutton btn-close-pull-request bigger lighter" onclick="var f = document.createElement('form'); f.style.display = 'none'; this.parentNode.appendChild(f); f.method = 'POST'; f.action = this.href;var s = document.createElement('input'); s.setAttribute('type', 'hidden'); s.setAttribute('name', 'authenticity_token'); s.setAttribute('value', 'a6f416ab5b919087af9f2fbabc7748e298f495ff'); f.appendChild(s);f.submit();return false;">
<span><span class="icon"></span>Close Pull Request</span>
</a>
curl -X POST --header "X-Requested-With: XMLHttpRequest" http://example.org/time.json