Skip to content

Instantly share code, notes, and snippets.

@rondevera
rondevera / hubb.sh
Created October 19, 2010 19:45
OS X: Opens the specified file/directory in GitHub via your browser
# Usage from within a Git repo:
#
# hubb public/javascripts/app.js
# # Opens `https://github.com/<repo>/blob/<branch>/public/javascripts/app.js`
# # in your browser.
#
# hubb
# # Opens `https://github.com/<repo>` in your browser.
hubb(){
repo=$(git config remote.origin.url | sed "s/^git@github\.com:\(.*\)\.git$/\1/")
@rondevera
rondevera / gist:268213
Created January 4, 2010 00:53
Glossy text with CSS in WebKit
<style>
body {
background: #000;
}
p {
margin: 1em auto;
background: -webkit-gradient(
linear, left top, left bottom,
from(#fff), color-stop(50%, #777), color-stop(50%, #666), to(#111));
background: -webkit-linear-gradient(top, #fff, #777 50%, #666 50%, #111);
@rondevera
rondevera / copy_activerecord_attributes_to_globalize2_translation.rb
Created December 7, 2009 02:29
Using Globalize2 for Rails, copy existing attributes from ActiveRecord instances to their default translation proxy instances
# Using Globalize2: http://github.com/joshmh/globalize2
# Copy existing attributes from ActiveRecord instance to default translation
# proxy instance:
SomeClass.all.each do |x|
x.globalize_options[:translated_attributes].each do |a|
x.send(:"#{a}=", x.read_attribute(a))
end
x.save
end
@rondevera
rondevera / jquery-data-removal.js
Created December 1, 2009 19:34
jQuery $().data gotcha: A collection can be removed from and re-added to the DOM, but its data disappears.
// Using jQuery 1.3.2:
// Setup:
var $foo = $('<div id="foo"></div>').appendTo('body');
$foo; // => [div#foo]
$foo.data('bar', 123);
$foo.data('bar'); // => 123
// Teardown:
$foo.remove(); // => [div#foo]
@rondevera
rondevera / gist:237254
Created November 17, 2009 20:49
Add a spacer to the OS X Dock
# Add a spacer to the OS X Dock:
defaults write com.apple.dock persistent-apps -array-add '{"tile-type"="spacer-tile";}'; osascript -e 'tell app "Dock" to quit'
@rondevera
rondevera / css-to-select-range-of-children.html
Last active February 8, 2023 11:29
CSS selector for a range of children
<!DOCTYPE html>
<html>
<head>
<style>
/* How to select a range of children
* (Here, 3rd-7th children, inclusive):
*/
ul li:nth-child(n+3):nth-child(-n+7) {
outline: 1px solid #0f0;
}
@rondevera
rondevera / onblack.js
Created July 22, 2009 02:38
On Black bookmarklet: For quickly getting the On Black URL for a Flickr photo.
/*
On Black bookmarklet
rondevera.com
For quickly getting the On Black URL for a Flickr photo.
(On Black: http://bighugelabs.com/onblack.php)
Usage:
- Create a new item in your bookmark bar with "On Black" as the name, and the
code below as the location.
@rondevera
rondevera / gmail_bookmarklet.js
Created June 26, 2009 03:58
Gmail bookmarklet: For quickly e-mailing the current page's URL (and the selected text, if any) via Gmail.
/*
Gmail bookmarklet
rondevera.com
For quickly e-mailing the current page's URL (and the selected text, if any)
via Gmail.
Usage:
- Create a new item in your bookmark bar with the name "Gmail" (or just "Gm",
or your favorite Unicode character), and the code below as the location.