Skip to content

Instantly share code, notes, and snippets.

View sjl's full-sized avatar

Steve Losh sjl

View GitHub Profile
{ :score AVERAGE-RATING
:stddev STANDARD-DEVIATION
:total TOTAL-RATINGS }
(defn db-personality-user
[uid]
(let [faved (brains.db/user-site-faved-count uid)
mehed (brains.db/user-mehed-count uid)
hated (brains.db/user-hated-count uid)]
(assoc (personality faved mehed hated)
:uid uid)))
(defn db-personality-users
[]
(defn usable-personalities
[personalities]
(filter #(> (:total %) 5) personalities))
(defn render-personality
[personality]
(str (:stddev personality)
","
(:score personality)
","
@sjl
sjl / correct_shift_keys.xml
Created April 8, 2011 14:36
A snippet for KeyRemap4MacBook that will teach you to use the correct shift keys.
<list>
<item>
<name>Use the correct goddamed shift keys.</name>
<identifier>private.fucking_shift_keys_how_do_they_work</identifier>
<autogen>--KeyToKey-- KeyCode::Q, ModifierFlag::SHIFT_L, KeyCode::VK_NONE</autogen>
<autogen>--KeyToKey-- KeyCode::W, ModifierFlag::SHIFT_L, KeyCode::VK_NONE</autogen>
<autogen>--KeyToKey-- KeyCode::E, ModifierFlag::SHIFT_L, KeyCode::VK_NONE</autogen>
<autogen>--KeyToKey-- KeyCode::R, ModifierFlag::SHIFT_L, KeyCode::VK_NONE</autogen>
<autogen>--KeyToKey-- KeyCode::T, ModifierFlag::SHIFT_L, KeyCode::VK_NONE</autogen>
\sR - Open a REPL
\et - Eval current toplevel form
\ef - Eval current file
\lw - Look up documentation for current word
C-X C-O - Autocomplete current word smartly
Firefox
|
V
OS X Laptop port 4565 on OS X Linux VM
Nginx on port 80 -------> is forwarded to 80 on ------> Nginx on port 80
the VM |
V
Gunicorn server
import sys, os
old_file = sys.argv[1].rsplit('.', 2)[0]
if os.path.exists(old_file):
os.system('osascript -e \'tell app "Finder" '
+ 'to move the POSIX file "'
+ os.path.abspath(old_file) + '" to trash\'')
Index: templatetags/fb_versions.py
===================================================================
--- templatetags/fb_versions.py (revision 692)
+++ templatetags/fb_versions.py (working copy)
@@ -11,6 +11,7 @@
# filebrowser imports
from filebrowser.settings import MEDIA_ROOT, MEDIA_URL, VERSIONS
+from filebrowser.fields import FileBrowseField
from filebrowser.functions import path_to_url, get_version_path, version_generator
@sjl
sjl / filebrowser.diff
Created June 1, 2011 19:59
Allow empty values in FileBrowseField's with blank=True, null=False
diff --git a/filebrowser/fields.py b/filebrowser/fields.py
--- a/filebrowser/fields.py
+++ b/filebrowser/fields.py
@@ -96,10 +96,12 @@
return FileObject(url_to_path(value))
def get_db_prep_value(self, value, connection, prepared=False):
if value is None:
return None
+ if not value:
@sjl
sjl / gist:1006307
Created June 3, 2011 13:11
Stop apps from spamming the system logs (both files are in /etc/, use `killall syslogd` to restart it after editing).
We couldn’t find that file to show.