Skip to content

Instantly share code, notes, and snippets.

View tourist's full-sized avatar

Michał Oleniec tourist

View GitHub Profile
@tourist
tourist / maintenance.html
Last active August 29, 2015 14:26 — forked from pitch-gist/gist:2999707
HTML: Simple Maintenance Page (mobile friendly)
<!doctype html>
<title>Site Maintenance</title>
<style>
body { text-align: center; padding: 20px; }
@media (min-width: 768px){
body{ padding-top: 150px; }
}
h1 { font-size: 50px; }
body { font: 20px Helvetica, sans-serif; color: #333; }
article { display: block; text-align: left; max-width: 650px; margin: 0 auto; }
@tourist
tourist / ssh tunneling.md
Last active August 29, 2015 14:26 — forked from mhulse/ssh tunneling.md
SSH Tunneling: Map port from remote machine to your local machine so you can work from the remote DB (example using Django DB settings)...

SSH Tunneling

  1. In your local_settings.py file:

    DATABASES = {
    	'default': {
    		'ENGINE': 'django.db.backends.postgresql_psycopg2',
    		'NAME': 'django_%s' % (PROJECT_NAME,),
    

'USER': xxxx,

';alert(String.fromCharCode(88,83,83))//';alert(String.fromCharCode(88,83,83))//";
alert(String.fromCharCode(88,83,83))//";alert(String.fromCharCode(88,83,83))//--
></SCRIPT>">'><SCRIPT>alert(String.fromCharCode(88,83,83))</SCRIPT>
VM239:3 '';!--"<XSS>=&{()}
VM239:3 <SCRIPT SRC=http://ha.ckers.org/xss.js></SCRIPT>
VM239:3 <IMG SRC="javascript:alert('XSS');">
@tourist
tourist / gulpfile.js
Last active August 29, 2015 14:24 — forked from mlouro/gulpfile.js
'use strict';
var gulp = require('gulp');
var gutil = require('gulp-util');
var del = require('del');
var uglify = require('gulp-uglify');
var gulpif = require('gulp-if');
var exec = require('child_process').exec;
var notify = require('gulp-notify');
@tourist
tourist / mmr_workout_gpx_export.py
Last active December 5, 2022 16:12
Exports workouts data from MapMyFitness API (MapMyRun and other MapMy* apps) to *.gpx file including timestamps. Might be used to import to another apps. MapMyFitness web interface offers export to *.gpx but without timestamps. Originaly used to move my data to Endomondo.
# quick & dirty export of workouts to *.gpx file with timestamps from MapMyFitness API
# for purpose of moving to other apps (tested with Endomondo)
# based on: https://developer.mapmyapi.com/docs/read/Authentication2
# needs API access request "Request a key" @ https://developer.mapmyapi.com/
from __future__ import unicode_literals
import requests
import urlparse
import webbrowser
import json
from requests_oauthlib import OAuth2
@tourist
tourist / _xls.py
Last active March 28, 2022 06:08
modified _xls.py from tablib for auto row height & auto colum width and proper alignment
# -*- coding: utf-8 -*-
""" Tablib - XLS Support.
"""
import math
import sys
import itertools
from tablib.compat import BytesIO, xlwt
@tourist
tourist / custom_filterspec.py
Created May 17, 2012 08:09
FilterSpec custom queryset for Django 1.3
# models.py
class Link(models.Model):
.....
place = models.ManyToManyField("PlaceForLink", through="LinkPlace", related_name="link")
.....
place.hasplace_filter = True
# filters.py
class HasPlaceFilterSpec(FilterSpec):
def __init__(self, f, request, params, model, model_admin, field_path=None):
@tourist
tourist / sitecache.py
Created March 20, 2012 16:00 — forked from Ciantic/sitecache.py
My Site object cache
"""Cache of Site related settings
Site IDs and urlconfs are such that are testd on *all* requests thus they need
to be cached.
"""
from django.conf import settings
from django.contrib.sites.models import Site
@tourist
tourist / multisitedmiddleware.py
Created March 20, 2012 15:59 — forked from Ciantic/multisitedmiddleware.py
MultiSitedMiddleware
"""Allows serving multiple sites per Django instance
"""
from django.utils.cache import patch_vary_headers
from sitecache import get_site_id, get_urlconf
class MultiSitedMiddleware:
@tourist
tourist / Reviewing profiles
Created June 9, 2011 23:59 — forked from mmalone/Reviewing profiles
Replacement Django runserver command that does profiling... because I've rewritten this too many times.
>>> import pstats
>>> p = pstats.Stats('p.1258156459.52174278XcQE.prof')
>>> p.strip_dirs().sort_stats(-1).print_stats(5)
Fri Nov 13 15:54:20 2009 p.1258156459.52174278XcQE.prof
124278 function calls (122386 primitive calls) in 0.589 CPU seconds
Ordered by: standard name
List reduced from 1014 to 5 due to restriction <5>