Skip to content

Instantly share code, notes, and snippets.

(defun isearch-anywhere ()
(interactive)
(save-excursion
(beginning-of-buffer)
(isearch-forward)))
(global-set-key (kbd "C-s") 'isearch-anywhere)
@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
@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 / 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
# If you've just missed your 12345th tweet..
# Getting it, the Python one-line way ^^
# By myfreeweb <[email protected]>.
# 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]
#!/bin/bash
# Small script that updates version controlled subdirs.
# Awesome for your django apps or jquery plugins collection.
# By myfreeweb <[email protected]>
# Licensed under Do The Fuck What You Want License.
upd_tmpl="Updating with";
find_opts="-maxdepth 1 -mindepth 1 -type d";
root=`pwd`/;
==> 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
@valpackett
valpackett / .emacs
Created May 28, 2010 22:21
my .emacs
(add-to-list 'load-path "~/Dropbox/emacs")
(load-file "~/Dropbox/emacs/config.el")
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