Skip to content

Instantly share code, notes, and snippets.

View rfletcher's full-sized avatar

Rick Fletcher rfletcher

View GitHub Profile
##
# append a command to the bash history without executing it
#
# scenario: you've typed out a long command and realized you need to do
# something else before running it. ^a and prefix with "savecommand".
#
# usage:
# $ savecommand echo foo
# (do something else)
# $ !echo
// add a log() method to all function objects
Function.prototype.log = function() {
var __method = this;
return function() {
var name = /function\s*(.*)\s*\(/.exec( __method );
console.log( "called " + ( name[1] || "[unknown]" ) + "()", arguments );
return __method.apply( null, arguments );
}
}
background-image: -moz-linear-gradient(rgba(255,255,255,0.05), rgba(255,255,255,0.2) 50%, rgba(0,0,0,0.01) 50%, rgba(0,0,0,0.05));
background-image: -webkit-gradient( linear, left bottom, left top, from(rgba(0, 0, 0, 0.05)), color-stop(0.7, transparent));
alias stripansi="perl -ple 's/\033\[(?:\d*(?:;\d+)*)*m//g;'"
alias urlencode='perl -MURI::Escape -ne "\$/=\"\"; print uri_escape \$_"'
# use STDIN as the body of a new email in the default email client
# usage: git show head | mail
alias mail='open "mailto:?body=$(cat - | stripansi | urlencode)"'
#$if Bash
"\e\e[C": forward-word
"\e\e[D": backward-word
#$endif
$include /etc/inputrc
$.on( some_element, "mouseover", function( e ) {
setTimeout( function() {
// reference some property of e. throws a "member not found" exception in IE.
var mouseX = e.pageX || e.clientX + document.body.scrollLeft + document.documentElement.scrollLeft;
// ...
}, 1000 );
} );
getMousePos = function( e ) {
return ( e.pageX || e.pageY ) ? {
x: e.pageX,
y: e.pageY
} : ( e.clientX || e.clientY ) ? {
x: e.clientX + document.body.scrollLeft + document.documentElement.scrollLeft,
y: e.clientY + document.body.scrollTop + document.documentElement.scrollTop
} : null;
},
$ git rb explain publish
git_remote_branch version 0.3.0
List of operations to do to publish an exiting local branch:
git push origin branch_to_publish:refs/heads/branch_to_publish
git fetch origin
git config branch.branch_to_publish.remote origin
git config branch.branch_to_publish.merge refs/heads/branch_to_publish
git checkout branch_to_publish
$ cat /etc/avahi/services/device-info.service
<?xml version="1.0" standalone='no'?><!--*-nxml-*-->
<!DOCTYPE service-group SYSTEM "avahi-service.dtd">
<!-- $Id: sftp-ssh.service 1294 2006-08-31 15:48:34Z lennart $ -->
<service-group>
<name replace-wildcards="yes">%h</name>
<service>
<type>_device-info._tcp</type>
@rfletcher
rfletcher / to_hash.rb
Created February 3, 2011 00:15 — forked from wmw/to_hash.rb
class Balls
def initialize()
@name = 'blah'
@caption = 'blah'
end
def to_hash
self.instance_variables.inject({}) do |a, e|
a[e[1..-1].to_sym] = self.instance_variable_get(e)