Skip to content

Instantly share code, notes, and snippets.

@esmooov
esmooov / checkout.md
Created May 31, 2012 15:54
The Secret Passions of Git Checkout

The Secret Passions of Git Checkout


The Hand of God

Master Hand

Git checkout can do almost anything ... or, at least, many things. It can switch branches. It can mix and match branches. It can resolve merge conflicts. It can give you a scratchpad to test things. It can even be used to interactively patch files. It's so powerful because it's so abstract. But much like numinous mystics, abstraction makes it confusing.

Basically git checkout does two things:

@esmooov
esmooov / ctrr.md
Created May 25, 2012 16:50
Carats and Tildes, Resets and Reverts

Until last night I lived in fear of tildes, carats, resets and reverts in Git. I cargo culted, I destroyed, I laid waste the tidy indicies, branches and trees Git so diligently tried to maintain. Then Zach Holman gave a talk at Paperless Post. It was about Git secrets. He didn't directly cover these topics but he gave an example that made me realize it was time to learn.

A better undo

Generally, when I push out bad code, I panic, hit git reset --hard HEAD^, push and clean up the pieces later. I don't even really know what most of that means. Notational Velocity seems to be fond of it ... in that I just keep copying it from Notational Velocity and pasting it. Turns out, this is dumb. I've irreversibly lost the faulty changes I made. I'll probably even make the same mistakes again. It's like torching your house to get rid of some mice.

Enter Holman. He suggests a better default undo. git reset --soft HEAD^. Says it stag

Format layout

An rdb file begins with "REDIS0003" encoded as a bytestring. [9 bytes]


For each database in the dump

  • The first byte is the SELECT_DB opcode (0xfe) [1 byte]
  • The second byte is the length-encode database number (See below) [1-4 byte(s)]
@esmooov
esmooov / p74.hs
Created May 29, 2011 14:31
Project Euler 74
{- Runs in 14 seconds -}
import Data.List
import Data.Array
import Data.Digits
{- Is this the fastest factorial? Nope. Is it a fun, recursive and dynamic? Yup. -}
fac :: Integer -> Integer
fac n = facs !! (fromIntegral n) where
function(){
var $$ = function(query){
!!(query && query.nodeType == 1) ?
this.dom = query
:
this.dom = document.getElementById(query);
};
$$.prototype.remove = function(){
this.dom.parentNode.removeChild(this.dom);
var hide = {
the: function(el){
this.and_the = function(sel){
$(el).hide();
$(sel).hide();
}
return this;
}
};
hide.the("overlay").and_the("gatewayCreative");
<style>
.mw_retweet{
-moz-background-clip:border;
-moz-background-inline-policy:continuous;
-moz-background-origin:padding;
background-attachment:scroll;
background-color:#e7e7e7;
background-image:none;
background-position:0 0;
background-repeat:repeat;
$('.toolbarTab').click(function(){
var type;
$(this).addClass("selected");
$('.toolbarTab').not(this).removeClass("selected");
type = $(this).children('h4').html();
});
////////
When there's a state up congro.unmagnified === false and congro.mag_state !== undefined it === some state
require 'rubygems'
require 'faker'
open('fakeclass.txt',"w") do |f|
250.times do
f.puts Faker::Company.name + " seeks " + ["youth","hard worker","prodigy","student","fun-loving adult","gifted employee","individual","associate","employee","forward-thinker"].rand + " to "+Faker::Company.bs+"."
f.puts ["Call us at ","Give us a ring at ","Dial us at "].rand + Faker::PhoneNumber.phone_number
f.puts Faker::Address.street_address(true) +", "+ Faker::Address.city + ", "+Faker::Address.us_state
f.puts ["Email us at ","Drop us an email- ","Contact us on the world wide web at "].rand + Faker::Internet.email
<div style="font-family:Helvetica,arial,sans-serif;">
<div style="width:600px;padding-top:10px;padding-bottom:10px;">
<div style="font-weight:bold;font-size:16px;padding:0;padding-left:25px;padding-bottom:8px;margin:0;"><span style="color:#990000;">TPM</span> DayBreaker</span> <span style="font-family:Georgia,Times,serif;font-size:12px;">September 13, 2010</div>
<div style="font-family:Georgia,Times,serif;font-size:12px;padding:0;padding-left:25px;margin:0;">
Good morning,<br />
Welcome to TPM's DayBreaker for Monday, September 13. Here's what we're tracking today:
</div>
</div>