Skip to content

Instantly share code, notes, and snippets.

// Just before switching jobs:
// Add one of these.
// Preferably into the same commit where you do a large merge.
//
// This started as a tweet with a joke of "C++ pro-tip: #define private public",
// and then it quickly escalated into more and more evil suggestions.
// I've tried to capture interesting suggestions here.
//
// Contributors: @r2d2rigo, @joeldevahl, @msinilo, @_Humus_,
// @YuriyODonnell, @rygorous, @cmuratori, @mike_acton, @grumpygiant,
@wowkin2
wowkin2 / daemon.py
Last active August 29, 2015 14:24 — forked from Apkawa/daemon.py
'''
Simple usage as cherrypy daemon as example
'''
import soaplib
from soaplib.core.server import wsgi
from cherrypy.wsgiserver import CherryPyWSGIServer
HOST = "0.0.0.0"
PORT = 45124
@wowkin2
wowkin2 / parse_signed_request
Created April 5, 2016 14:34 — forked from albertobajo/parse_signed_request
Python implementation of Facebook's php signed_request parser: http://developers.facebook.com/docs/authentication/canvas
import hmac
import simplejson as json
from base64 import urlsafe_b64decode
from hashlib import sha256
def parse_signed_request(signed_request, secret):
[encoded_sig, payload] = signed_request.split('.')
# decode data
@wowkin2
wowkin2 / get-browser-locale.js
Created August 23, 2016 12:57 — forked from asleepwalker/get-browser-locale.js
Boilerplate browser locale detector
function getLocale() {
var lang;
if (navigator.languages) {
// chrome does not currently set navigator.language correctly https://code.google.com/p/chromium/issues/detail?id=101138
// but it does set the first element of navigator.languages correctly
lang = navigator.languages[0];
} else if (navigator.userLanguage) {
// IE only
lang = navigator.userLanguage;
@wowkin2
wowkin2 / gist:8b7f43a4f2b5c6957cf51be60a7b8268
Created November 29, 2016 14:34 — forked from signed0/gist:2031157
Google Polyline encoder & decoder
'''Provides utility functions for encoding and decoding linestrings using the
Google encoded polyline algorithm.
'''
def encode_coords(coords):
'''Encodes a polyline using Google's polyline algorithm
See http://code.google.com/apis/maps/documentation/polylinealgorithm.html
for more information.
@wowkin2
wowkin2 / attack.md
Created January 17, 2017 21:21 — forked from timruffles/attack.md
Chrome/Gmail attack received 11/03/2016. Not sure if the Chrome meta refresh + data:text,html technique is novel.

The following attack will display a "you've been signed out" page for GMail, and attempt to steal your account credentials.

DO NOT PUT ANY ACCOUNT CREDENTIALS INTO ANY TABS CREATED AFTER VISITING THESE LINKS :)

I received an email in my GMail inbox with a fake attachment image, styled to look like the real GMail attachment UI:

fake

This linked to a page that ended up displaying a fake "you've been signed out" link, via the data:text/html... URL feature of Chrome:

@wowkin2
wowkin2 / gist:dc30a3f12abc77f2afc750fbe3464d3b
Created August 18, 2017 13:49 — forked from rchrd2/gist:6179550
How to link django-social-auth with google-api-python-client I am creating a gist, because this took me way to long to figure out. Maybe it can save you some time!
import httplib2
from apiclient.discovery import build
from oauth2client.client import AccessTokenCredentials
def connect_helper(user):
c = user.social_auth.get(provider='google-oauth2')
access_token = c.tokens['access_token']
credentials = AccessTokenCredentials(access_token, 'my-user-agent/1.0')
http = httplib2.Http()
@wowkin2
wowkin2 / Email Server (Windows Only).md
Created January 17, 2018 12:13 — forked from raelgc/Email Server (Windows Only).md
Setup a Local Only Email Server (Windows Only)
@wowkin2
wowkin2 / aes_example_in_python.py
Created May 4, 2018 14:29 — forked from dokenzy/aes_example_in_python.py
AES Encrytion Example in Python
#-*- coding: utf-8 -*-
# Python 3.4
# author: http://blog.dokenzy.com/
# date: 2015. 4. 8
# References
# http://www.imcore.net/encrypt-decrypt-aes256-c-objective-ios-iphone-ipad-php-java-android-perl-javascript/
# http://stackoverflow.com/questions/12562021/aes-decryption-padding-with-pkcs5-python
# http://stackoverflow.com/questions/12524994/encrypt-decrypt-using-pycrypto-aes-256
@wowkin2
wowkin2 / dijkstra.py
Created October 7, 2018 20:41 — forked from mdsrosa/dijkstra.py
Modified Python implementation of Dijkstra's Algorithm (https://gist.github.com/econchick/4666413)
from collections import defaultdict, deque
class Graph(object):
def __init__(self):
self.nodes = set()
self.edges = defaultdict(list)
self.distances = {}
def add_node(self, value):