Skip to content

Instantly share code, notes, and snippets.

@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 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 ([email protected]) with my Apple ID noahlt. Little did I know that I had already created a separate Apple ID [email protected], which was of course automatically bound to [email protected].

To solve this problem, I signed in to iTunes using [email protected] and ignored my old noahlt Apple ID.

@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 / 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.sh
Created October 23, 2011 07:19
How do I kill whatever process is listening to a particular port?
function killport {
if [ $1 == '-h' ] || [ -z $1 ]; then
echo '`killport <PORT>` finds the process listening to the specified port and kills it.'
else
process_line=`sudo lsof -i :$1 | tail -1`
if [ "$process_line" == "" ]; then
echo "no processes listening on $1"
else
process_name=`echo "$process_line" | awk '{print $1}'`
echo "killing $process_name"
@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