Skip to content

Instantly share code, notes, and snippets.

/*
* TOA = TON + NPI
* See TS 24.008 section 10.5.4.7 for details.
* These are the only really useful TOA values
*/
public static final int TOA_International = 0x91;
public static final int TOA_Unknown = 0x81;
@noahlt
noahlt / .flowconfig
Last active August 29, 2015 14:19
flow check: declare module
[ignore]
[include]
[libs]
./lib.js
[options]
@noahlt
noahlt / lintjs.sh
Created August 3, 2015 18:49
semiautomatic semicolon insertion
#!/usr/bin/env bash
# lintjs.sh
REPO_DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )/.." && pwd )
JS_FILES=$(find . \
-not -path '*node_modules*' \
-not -path '*module-cache*' \
-not -path '*/lib/*' \
-not -name '*.min.js' \
@noahlt
noahlt / code.sh
Created October 22, 2011 19:40
How do I make ack search through Mustache and ERB templates?
--type-set=mustache=.mustache
--type-set=rb=.rb
--type-set=erb=.erb
@noahlt
noahlt / code.sh
Created October 23, 2011 07:24
How can I quickly switch to the topmost directory in a git project?
function rcd {
prevdir=`pwd`
until ls -ld .git 1>/dev/null 2>/dev/null
do
cd ..
if [ `pwd` == '/' ]
then
cd $prevdir
return
@noahlt
noahlt / code.el
Created October 23, 2011 07:26
How do I make emacs' backward-kill-word not kill across line breaks?
(defun noah-backward-kill ()
"Exactly like backward-kill-word, except doesn't kill across line breaks."
(interactive)
(let ((init-pos (point))
(line-begin (line-beginning-position))
(word-begin (backward-word-position)))
(if (= (point) line-begin)
(backward-delete-char 1)
(if (< word-begin line-begin)
(kill-region line-begin init-pos)
@noahlt
noahlt / summary.md
Created October 23, 2011 07:30
Why does Apple think my email address has been already verified with another Apple ID?

Probably because it already has. In my case, I was trying to verify my email address (noah@gmail.com) with my Apple ID noahlt. Little did I know that I had already created a separate Apple ID noah@gmail.com, which was of course automatically bound to noah@gmail.com.

To solve this problem, I signed in to iTunes using noah@gmail.com and ignored my old noahlt Apple ID.

@noahlt
noahlt / summary.md
Created October 23, 2011 07:32
How do I pass a class in Scala?

In Java:

public class Foo { }

Foo.class

In Scala:

class Foo { }
@noahlt
noahlt / summary.md
Created October 23, 2011 21:35
How do I extract a particular column from text (like the output of ps)?

awk has a command for this:

$ awk '{print $2}' <filename>

You can, of course, also pipe in text output from another program:

$ who
noah     console  Oct 21 14:06 
noah     ttys000  Oct 23 13:08 

noah ttys001 Oct 23 14:00

@noahlt
noahlt / hi.html
Created April 22, 2012 18:25
why doesn't `body *:hover` work?
<html>
<head>
<style>
body * { background-color: #FCF0AD; }
body *:hover { background-color: blue; }
*:hover { background-color: blue; }
body li:hover { background-color: red; }
</style>
<body>