Skip to content

Instantly share code, notes, and snippets.

View dimitrov's full-sized avatar

Dimitar Dimitrov dimitrov

View GitHub Profile
@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",
{
"TxnID": "667B-1055542407",
"TimeCreated": "2003-06-13T15:13:27-08:00",
"TimeModified": "2019-12-14T11:35:28-08:00",
"EditSequence": "1576351936",
"TxnNumber": "1276",
"CustomerRef": {
"ListID": "6D0000-1046201334",
"FullName": "Pete Harbin Contractor:Oak Street"
},
#!/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
@dimitrov
dimitrov / Mapping Script
Created March 9, 2015 14:05
Jenkins Warnings Plugin mapping script for flake8
import hudson.plugins.warnings.parser.Warning
import hudson.plugins.analysis.util.model.Priority
String fileName = matcher.group(1)
String type = matcher.group(4)
String lineNumber = matcher.group(2)
String message = matcher.group(5)
String typeCategory = String.valueOf(type.charAt(0));
String category
Priority priority = Priority.NORMAL
@dimitrov
dimitrov / messages.html
Created April 26, 2015 20:30
Bootstrap Alerts for Django
{% if messages %}
{% for message in messages %}
<div class="alert alert-{{ message.tags }} alert-dismissible text-center" role="alert">
<button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">&times;</span></button>
<strong>{% if message.level == DEFAULT_MESSAGE_LEVELS.ERROR %}Error{% else %}{{ message.tags|title }}{% endif %}!</strong> {{ message }}
</div>
{% endfor %}
{% endif %}