Skip to content

Instantly share code, notes, and snippets.

@ranbena
ranbena / server.py
Last active August 29, 2015 14:11 — forked from amirnissim/server.py
import tornado.httpserver
import tornado.ioloop
import tornado.web
class Handler(tornado.web.RequestHandler):
def error(self):
self.set_header("Access-Control-Allow-Credentials", "true")
self.set_header("Access-Control-Allow-Origin", "")
self.set_header("Access-Control-Allow-Methods", "GET, POST")
@ranbena
ranbena / pr.sh
Created June 21, 2014 20:23 — forked from amirnissim/pr.sh
cd my-repo
git fetch upstream
git checkout --detach upstream/master
git pull --no-commit upstream refs/pull/<pr-id>/head
# local repo now has (uncommited) changes from pull request
@ranbena
ranbena / pre-commit
Last active December 14, 2015 23:09 — forked from omribahumi/pre-commit
#!/bin/sh
# pre-commit git hook to make sure developers don't accidentally commit code they didn't mean to commit :)
REMOVEME_STRING="REMOVEME"
DEBUGGER_STRING="debugger"
ALLOW_COMMITTING_REMOVEME=`git config hooks.allowcommittingremoveme`
# redirect stdout to stderr
exec 1>&2
//Open the file directly in the browser and run this script from the console
//Assumptions: The browser uses a <pre/> tag for showing the CSS code
var file = document.querySelector("pre");
var fileContent = file.innerHTML;
var newContent = fileContent.replace(/([\d.]+)(px)/g, function(m){
var measure = parseFloat(m.split("px")[0]);
var newMeasure = measure / 10;
newMeasure = newMeasure.toFixed(2);
newMeasure = newMeasure.replace(/(\.[0-9]*?)0+$/, "$1"); // remove trailing zeros