Skip to content

Instantly share code, notes, and snippets.

View palawer's full-sized avatar

palawer palawer

View GitHub Profile
nohup python manage.py runserver 0.0.0.0:8000 &
@palawer
palawer / .bash_profile
Last active November 14, 2016 13:53
Bash prompt colors
export PS1="\[\033[36m\]\u\[\033[m\]@\[\033[32m\]\h:\[\033[33;1m\]\w\[\033[31m\]\$(parse_git_branch)\[\033[00m\]$\[\033[00m\] "
export CLICOLOR=1
export LSCOLORS=ExFxBxDxCxegedabagacad
parse_git_branch() {
git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/ (\1)/'
}
@palawer
palawer / arrayCopy.py
Created June 1, 2016 12:09
Python arrayCopy like Java
def arrayCopy(src, srcPos, dest, destPos, length):
for i in range(length):
dest[i + destPos] = src[i + srcPos]
@palawer
palawer / form.js
Created May 26, 2016 10:51
Generic ajax form handler
$('#FORM_ID').submit(function() {
$.ajax({
data: $(this).serialize(),
type: $(this).attr('method'),
url: $(this).attr('action'),
success: function(response) {
console.log(response);
}
});
return false;
@palawer
palawer / Sublime user settings
Last active January 16, 2019 11:12
Preferences.sublime-settings
{
"always_show_minimap_viewport": true,
"draw_minimap_border": true,
"draw_white_space": "all",
"file_exclude_patterns":
[
"*.log",
"*.out",
"*.pyc",
".gitignore",
@palawer
palawer / domain.com.conf
Created February 11, 2016 19:27
Apache + Django config
WSGIPythonPath /var/www/domain.com/project
<VirtualHost *:80>
ServerAdmin webmaster@localhost
ServerName domain.com
ServerAlias www.domain.com
DocumentRoot /var/www/domain.com/project/
WSGIScriptAlias / /var/www/domain.com/project/project/wsgi.py
#WSGIPythonPath /var/www/domain.com/project
@palawer
palawer / psef.sh
Last active May 17, 2022 17:09
View user running processes
ps -ef | grep python | grep username
@palawer
palawer / sorted.py
Created October 29, 2015 08:12
Sort dictionary by value
ordered_dict = sorted(dictionary.items(), key=lambda x:x[1], reverse=True)
@palawer
palawer / sshfs
Created October 8, 2015 11:51
SSHFS slow navigation
sshfs -o no_readahead,noappledouble,nolocalcaches user@host:/home/user ~/mnt
sshfs -o auto_cache,reconnect,defer_permissions,noappledouble user@host:/home/user ~/mnt
@palawer
palawer / django.md
Last active October 12, 2016 21:24
Django cheat sheat

Django cheat sheet

New project

django-admin startproject mysite
python manage.py migrate