Skip to content

Instantly share code, notes, and snippets.

@ryancrum
ryancrum / add-file-to-git.sh
Created March 4, 2013 22:12
Add file to git history
#!/bin/bash
# adds a file to all commits in a git repository, as if it had always been there
# first arg is the path to the file to add
# second arg is relative path within the repository where the file should go
# this is much faster than `git filter-branch --tree-filter 'cp /path/to/file repo/path && git add repo/path' -- --all
cat $1 > /tmp/file-to-add
git filter-branch --index-filter "cat /tmp/file-to-add | git hash-object -w --stdin | xargs -L 1 -I X git update-index --add --cacheinfo 100644 X $2" --tag-name-filter cat -- --all
@ryancrum
ryancrum / pommed_increased_intervals.diff
Created February 26, 2012 14:59
pommed power/dbus/keyboard backlight check interval increase (this has consequences, but the decrease in CPU utilization is worth it)
diff --git pommed/dbus.h pommed/dbus.h
index d6c42a9..597dd1f 100644
--- pommed/dbus.h
+++ pommed/dbus.h
@@ -5,7 +5,7 @@
#ifndef __MBPDBUS_H__
#define __MBPDBUS_H__
-#define DBUS_TIMEOUT 200
+#define DBUS_TIMEOUT 1500
@ryancrum
ryancrum / jquerytest.cljs
Created July 21, 2011 02:24
How to use jQuery from ClojureScript
(ns jquerytest.core)
(def jquery (js* "$"))
(jquery
(fn []
(-> (jquery "div.meat")
(.html "This is a test.")
(.append "<div>Look here!</div>"))))
@ryancrum
ryancrum / gist:801082
Created January 28, 2011 21:59
post-buffer
(defun post-buffer (arg)
(interactive "P")
(let ((url (if (or arg (not last-http-post-url))
(read-from-minibuffer "URL:" last-http-post-url)
last-http-post-url)))
(setq last-http-post-url url)
(http-post-body url (buffer-string) "text/plaintext" 'utf-8)))