Skip to content

Instantly share code, notes, and snippets.

TypeError: Object #<a ServerResponse> has no method 'end'
at Server.<anonymous> (/Users/myfreeweb/Documents/test.js:6:9)
at /usr/lib/node/libraries/http.js:450:23
at ServerSideConnection.<anonymous> (/usr/lib/node/libraries/http.js:373:37)
at node.js:845:9
@valpackett
valpackett / .emacs
Created May 28, 2010 22:21
my .emacs
(add-to-list 'load-path "~/Dropbox/emacs")
(load-file "~/Dropbox/emacs/config.el")
==> Build Environment
CC: /usr/bin/cc
CXX: /usr/bin/c++
LD: /usr/bin/cc
CFLAGS: -O3 -march=prescott -mfpmath=sse -w -pipe
CXXFLAGS: -O3 -march=prescott -mfpmath=sse -w -pipe
MAKEFLAGS: -j2
PATH: /opt/local/bin:/opt/local/sbin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11/bin:/opt/local/bin:/usr/local/git/bin
==> Cloning git://repo.or.cz/MacVim.git
Updating /Library/Caches/Homebrew/macvim-HEAD
#!/bin/bash
# Small script that updates version controlled subdirs.
# Awesome for your django apps or jquery plugins collection.
# By myfreeweb <me@myfreeweb.ru>
# Licensed under Do The Fuck What You Want License.
upd_tmpl="Updating with";
find_opts="-maxdepth 1 -mindepth 1 -type d";
root=`pwd`/;
# If you've just missed your 12345th tweet..
# Getting it, the Python one-line way ^^
# By myfreeweb <me@myfreeweb.ru>.
# Follow me on Twitter: @myfreeweb in English, @myfreeweb_ru in Russian.
import json
import urllib2
# Imports don't count!
# We get 12344th tweet because Python counts from 0 and Twitter - from 1. Twitter loves humans :D
print json.loads(urllib2.urlopen('http://api.twitter.com/1/statuses/user_timeline.json?screen_name=myfreeweb&count=200').read())[json.loads(urllib2.urlopen('http://api.twitter.com/1/statuses/user_timeline.json?screen_name=myfreeweb&count=2').read())[0]['user']['statuses_count']-12344]
@valpackett
valpackett / gist:666161
Created November 7, 2010 14:55
Coda-like swapping in Emacs
(defun coda-swap (expr)
(interactive "sExpr: ")
(query-replace-regexp
(replace-regexp-in-string "$[1-2]" "\\\\([0-9a-zA-Z]*\\\\)" expr)
(replace-regexp-in-string "$[1-2]" (lambda (m) (if (equal m "$1") "\\\\2" "\\\\1")) expr)))
;; Example:
; enter
; width="$1" height="$2"
; and it will replace
@valpackett
valpackett / gist:666202
Created November 7, 2010 15:59
Refreshing Safari from Emacs
;;; Refreshing Safari on save, Mac only
;; Don't forget to enable assistive devices access
;; in System Preferences -> Universal Access
(if (featurep 'aquamacs)
(add-hook 'after-save-hook
'(lambda ()
(when (string-match "\.html$" (buffer-name))
(do-applescript (concat "tell application \"Safari\"
if \"file://" buffer-file-name "\" = URL of document 1 then
activate
@valpackett
valpackett / Get Lyrics.scpt
Created November 20, 2010 17:57
Fetching full lyrics from LyricWiki
(*
Getting Lyrics
by myfreeweb
thanks to pepelsbey for "Year to Album Sort", based on it
*)
tell application "iTunes"
set sel to selection
if sel is not {} then
set ofi to fixed indexing
(defun isearch-anywhere ()
(interactive)
(save-excursion
(beginning-of-buffer)
(isearch-forward)))
(global-set-key (kbd "C-s") 'isearch-anywhere)
@valpackett
valpackett / README.md
Created March 17, 2011 19:09
Yandex.Anthroponym client

Yandex.Anthroponym is a web service which translates names from English to Russian and vice versa. This is a little script (designed for TextExpander, but works fine in a shell) which gets the current Mac OS X clipboard content, translates it and prints back the output.

So you have copied "Ray William Johnson", for example. Type the abbreviation you've defined in TextExpander and "Рей Вильям Джонсон" will be pasted.

If you don't have PyPy (you should, it's really fast), change the first line to "#!/usr/bin/env python". Don't forget to pip install requests. And, of course, to set snippet type to "Shell Script" when adding to TextExpander.