Skip to content

Instantly share code, notes, and snippets.

View inlanger's full-sized avatar
🍑

inlanger inlanger

🍑
View GitHub Profile
@inlanger
inlanger / clear.sh
Created April 12, 2012 09:13
Remove all pyc files from folder and subfolders
find . -type f -name '*.pyc' -exec rm {} \;
@inlanger
inlanger / settings.py
Created April 13, 2012 09:11
Split development and production settings
import platform
IS_LOCAL = False
if platform.node() != 'server':
IS_LOCAL = True
@inlanger
inlanger / settings.py
Created April 13, 2012 09:14
Johnny Cache
# pip install johnny-cache
# add johnny's middleware
MIDDLEWARE_CLASSES = (
'johnny.middleware.LocalStoreClearMiddleware',
'johnny.middleware.QueryCacheMiddleware',
# ...
)
# some johnny settings
CACHES = {
@inlanger
inlanger / gist:2634284
Created May 8, 2012 11:08
Link mysql.sock file from AMPPS folder to /tmp
# For Ampps
sudo ln -s /Applications/AMPPS/mysql/tmp/mysql.sock /tmp/mysql.sock
# For MAMP
sudo ln -s /Applications/MAMP/tmp/mysql/mysql.sock /tmp/mysql.sock
@inlanger
inlanger / .htaccess
Created June 15, 2012 12:15
Increase PHP memory limit
php_value memory_limit 128M
@inlanger
inlanger / gist:4318323
Created December 17, 2012 13:35
Fix "ValueError: unknown locale: UTF-8" error
# if "ValueError: unknown locale: UTF-8" error try
export LC_ALL=ru_RU.UTF-8
export LANG=ru_RU.UTF-8
@inlanger
inlanger / gist:5693890
Created June 2, 2013 15:43
Parse PHP file for variables like $var = value;
def parse_php_variables(php):
'''
Parse PHP file for variables like $var = value;
'''
reg = r'\$([a-z]\w*)\s*=\s*\'(.*?)\';'
rg = re.compile(reg)
raw_variables = rg.findall(php)
variables = {}
for key, var in raw_variables:
@inlanger
inlanger / monitor.sh
Created August 1, 2013 07:00
Apache and MySQL process state monitor and reloader.
#!/bin/bash
# APACHE SECTION
RESTART="/etc/init.d/apache2 restart"
PGREP="/usr/bin/pgrep"
HTTPD="apache"
$PGREP ${HTTPD}
if [ $? -ne 0 ]
then
$RESTART
fi
@inlanger
inlanger / new_gist_file
Created September 1, 2013 09:10
Check if val in array and return new array with or without element.
function pushIfUnique(array, val){
var status = true;
for (var i = 0; i < array.length; i++) {
if (array[i]===val) {
status = false;
}
}
if (status){
array.push(val);
return array;
@inlanger
inlanger / sitename.com
Created September 25, 2013 16:00
Apache virtualhost with gzip, expires and mod_wsgi django settings.
<VirtualHost *:80>
ServerAdmin webmaster@sitename.com
ServerName sitename.com
DocumentRoot /var/www/sitename.com
WSGIScriptAlias / /var/www/sitename.com/django.wsgi
ErrorLog /var/www/sitename.com/error.log
ExpiresActive on
ExpiresByType application/javascript "access plus 1 months"
ExpiresByType image/gif "access plus 1 months"