Skip to content

Instantly share code, notes, and snippets.

View dimitrov's full-sized avatar

Dimitar Dimitrov dimitrov

View GitHub Profile
#!/usr/bin/env python
import urllib2
import zipfile
import MySQLdb
class AlexaUpdater():
def __init__(self, user, password, db_name, table_name, host='localhost',
charset='utf8'):
self.host = host
// compile using valac app.vala -o app --pkg gtk+-2.0
using Gtk;
namespace MyApp
{
class MyApp: Gtk.Window
{
public MyApp()
{
@dimitrov
dimitrov / application.py
Created May 3, 2011 16:05
A decorator function for preventing cross-site scriting attacks for bottle.py
#!/usr/bin/env python
import bottle
from bottle import route
def websafe(func):
"""
A decorator function for preventing cross-site scriting attacks
"""
def wrapper(*args, **kwargs):
#!/usr/bin/env python
import signal
import logging
import base64
import routes
import routes.middleware
import webob
#!/bin/bash
COMMON_DIRS=(bin doc etc tests)
COMMON_FILES=(README ABOUT INSTALL TODO NEWS CHANGELOG LICENSE Makefile)
BASE_PATH=$PROJECT_PATH/$PROJECT_NAME
function create_directories {
mkdir -p $BASE_PATH/$PROJECT_NAME
@dimitrov
dimitrov / Makefile
Created June 18, 2013 20:03
An example Makefile for a python project
PACKAGE=mypackage
MIN_COVERAGE=90
# NOTE: Be careful, rm -rf will be called on this!
COVERAGE_HTML_DIR=coverage/
VERBOSITY=2
.PHONY: all dev install test coverage clean
all: test
{
"color_scheme": "Packages/User/Tomorrow-Night (SL).tmTheme",
"draw_white_space": "all",
"ensure_newline_at_eof_on_save": true,
"find_selected_text": true,
"fold_buttons": false,
"folder_exclude_patterns":
[
".svn",
".git",
@dimitrov
dimitrov / gist:11290347
Created April 25, 2014 13:53
django-rosetta - Gunicorn auto reload
import os
from django.dispatch import receiver
from rosetta.signals import post_save
@receiver(post_save)
def restart_server(sender, **kwargs):
os.system('supervisorctl pid <gunicorn process> | xargs kill -HUP')
import os
from django.dispatch import receiver
from rosetta.signals import post_save
@receiver(post_save)
def restart_server(sender, **kwargs):
os.system('initctl reload <myapp>')
@dimitrov
dimitrov / Preferences.sublime-settings
Last active August 29, 2015 14:03
Preferences.sublime-settings
{
"auto_complete_triggers":
[
{
"characters": ".",
"selector": "source.python"
}
],
"close_windows_when_empty": false,
"color_scheme": "Packages/User/Tomorrow-Night (SL).tmTheme",