Skip to content

Instantly share code, notes, and snippets.

devdave / background.js
Created Oct 16, 2018 — forked from akirattii/background.js
Message passing of Chrome Extension example
View background.js
* onMessage from the extension or tab (a content script)
function(request, sender, sendResponse) {
if (request.cmd == "any command") {
sendResponse({ result: "any response from background" });
} else {
sendResponse({ result: "error", message: `Invalid 'cmd'` });
devdave / run.js
Created Apr 9, 2018 — forked from ChuckJHardy/run.js
Express Server for ZeroMQ, and Angular.js
View run.js
'use strict';
var express = require('express'),
app = express(),
http = require('http'),
server = http.createServer(app),
path = require('path'),
io = require('').listen(server),
fs = require('fs'),
zmq = require('zmq'),
devdave /
Created Apr 5, 2016 — forked from mkropat/
Python wrapper around the SHGetKnownFolderPath Windows Shell function
import ctypes, sys
from ctypes import windll, wintypes
from uuid import UUID
class GUID(ctypes.Structure): # [1]
_fields_ = [
("Data1", wintypes.DWORD),
("Data2", wintypes.WORD),
("Data3", wintypes.WORD),
("Data4", wintypes.BYTE * 8)
View config.json
"vars": {
"@gray-darker": "lighten(#000, 13.5%)",
"@gray-dark": "lighten(#000, 20%)",
"@gray": "lighten(#000, 33.5%)",
"@gray-light": "lighten(#000, 46.7%)",
"@gray-lighter": "lighten(#000, 93.5%)",
"@brand-primary": "#428bca",
"@brand-success": "#5cb85c",
"@brand-info": "#5bc0de",
View gist:9495505
import email
def get_decoded_email_body(message_body):
""" Decode email body.
Detect character set if the header is not set.
We try to get text/plain, but if there is not one then fallback to text/html.
:param message_body: Raw 7-bit message body input e.g. from imaplib. Double encoded in quoted-printable and latin-1
#!/usr/bin/env python
Recipe for creating and updating security groups programmatically.
import collections
import boto
set -e
sudo apt-get install openjdk-7-jdk git-core curl -y # Ubuntu 12.04 meets no problem
mkdir -p ~/bin
curl > ~/bin/lein
chmod 755 ~/bin/lein
# Add ~/bin to your $PATH, it has been done if in Ubuntu 12.04
View tmux-cheatsheet.markdown

tmux shortcuts & cheatsheet

start new:


start new with session name:

tmux new -s myname
class ReloaderEventHandler(FileSystemEventHandler):
Listen for changes to modules within the Django project
On change, reload the module in the Python Shell
Custom logic required to reload django modules
Due to the singleton AppCache, which caches model references.
For those models files, we must clear and repopulate the AppCache
def __init__(self, *args, **kwargs):
devdave /
Created Apr 24, 2012 — forked from jonah-williams/
Command line iOS project builds and over-the-air distribution
# command line OTA distribution references and examples