Skip to content

Instantly share code, notes, and snippets.

View neonbadger's full-sized avatar

Shijie F neonbadger

View GitHub Profile
@gonz
gonz / gist:1686815
Created January 27, 2012 03:28
T9 python
import re, sys
keys = ('abc', 'def', 'ghi', 'jkl', 'mno', 'pqrs', 'tuv', 'wxyz')
m = dict((l, str(n)) for n, letters in enumerate(keys, start=2) for l in letters)
data, ocurrences = {}, {}
wmatch = re.compile('[^a-z]+')
def learn(word):
num = ''.join(m[c] for c in word)
for i in xrange(1, len(word) + 1):
@jbgo
jbgo / git-recover-branch.md
Last active May 23, 2024 12:29
How to recover a git branch you accidentally deleted

UPDATE: A better way! (August 2015)

As pointed out by @johntyree in the comments, using git reflog is easier and more reliable. Thanks for the suggestion!

 $ git reflog
1ed7510 HEAD@{1}: checkout: moving from develop to 1ed7510
3970d09 HEAD@{2}: checkout: moving from b-fix-build to develop
1ed7510 HEAD@{3}: commit: got everything working the way I want
70b3696 HEAD@{4}: commit: upgrade rails, do some refactoring
function LetterCountI(str) {
str = str.split(" ");
var answer = "";
var mostRep = 1;
for (i = 0; i < str.length; i++)
if (eachWord(str[i]) > mostRep) {
mostRep = eachWord(str[i]);
answer = str[i];
}
if (mostRep === 1)