Skip to content

Instantly share code, notes, and snippets.

View flashingpumpkin's full-sized avatar
🏠
Working from home

Alen Mujezinovic flashingpumpkin

🏠
Working from home
View GitHub Profile
<div style="display: none;">
<form action="." method="post" name="save-user"></form>
</div>
<script type="text/javascript">
$('form[name=save-user]').submit();
</script>
function _bash_git_status(){
[[ $(git status 2> /dev/null | tail -n1) != "nothing to commit (working directory clean)" ]] && echo " *"
}
function _bash_git(){
git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/ ~\1$(_bash_git_status)/'
}
function _virtual_env_name(){
[[ $(basename $VIRTUAL_ENV 2>/dev/null) ]] && echo "($(basename $VIRTUAL_ENV))"
}
function prompt(){
# application.forms
# I'm assuming that you'd want to play with the forms too.
from django import forms
from registration.forms import RegistrationFormUniqueEmail
from socialregistration.forms import UserForm
class NormalRegistrationForm(RegistrationFormUniqueEmail):
first_name = forms.CharField()
last_name = forms.CharField()
@flashingpumpkin
flashingpumpkin / mysql_to_sqlite.sh
Created January 24, 2011 12:25
Move a MySQL dump to SQLite
# Modified from: http://stackoverflow.com/questions/489277/script-to-convert-mysql-dump-sql-file-into-format-that-can-be-imported-into-sqlit
# Dump: mysqldump -u root -p --compatible=ansi <DatabaseName> > db.sql
# Convert & import: mysql_to_sqlite.sh db.sql | sqlite3 db.sqlite
# This works on my setup - you might have to modified the pipes!
#!/bin/bash
if [ "$1" == "-h" ];
@flashingpumpkin
flashingpumpkin / gist:934844
Created April 21, 2011 15:59
Swiss German Keyboard Mapping For Macs OS
<?XML version="1.1" encoding="UTF-8"?>
<!DOCTYPE keyboard PUBLIC "" "file://localhost/System/Library/DTDs/KeyboardLayout.dtd">
<!--Last edited by Ukelele version 2.1.5 on 2011-10-05 at 16:36 (GMT+01:00)-->
<keyboard group="126" id="0" name="Swiss German Keyboard - Flashingpumpkin" maxout="9">
<layouts>
<layout first="0" last="17" modifiers="Modifiers" mapSet="ANSI"/>
<layout first="18" last="18" modifiers="Modifiers" mapSet="JIS"/>
<layout first="21" last="23" modifiers="Modifiers" mapSet="JIS"/>
<layout first="30" last="30" modifiers="Modifiers" mapSet="JIS"/>
<layout first="33" last="33" modifiers="Modifiers" mapSet="JIS"/>
public JSONObject getDevices() throws ConnectionException {
return get(ALLOWED_UNITS);
}
public JSONObject getDownstream() throws ConnectionException {
return get(downstream());
}
public JSONObject getDownstream(String device) throws ConnectionException{
return get(downstream(device));
# Tests performed on a Linode 512 instance.
# Keep in mind that Nginx is writing logs and Spooky is not.
# Kudos definitely go to http://twitter.com/ostinelli for Misultin!
########################################################################
###################### Nginx ###########################################
########################################################################
## Testing Nginx with http://owns.ch/pong
;; Because my musclememory is used to :wq - don't shoot me
(global-unset-key "\M-:")
(global-set-key "\M-:wq" 'save-buffers-kill-terminal)
~ $ python
>>> import os
>>> os.path.abspath("../foo")
'/home/foo'
~ $ erl
1> filename:absname("../foo").
"/home/alen/../foo"
abspath(Path)->
Bits = filename:split(Path),
Folder = fun(Elem, Acc)->
case Elem of
".." ->
[ lists:nth(Seq, Acc) || Seq <- lists:seq(1, length(Acc)), Seq < length(Acc) ];
_ ->
Acc ++ [Elem]
end