Skip to content

Instantly share code, notes, and snippets.

@pixelhandler
pixelhandler / pre-push.sh
Last active May 17, 2024 12:12
Git pre-push hook to prevent force pushing master branch
#!/bin/sh
# Called by "git push" after it has checked the remote status,
# but before anything has been pushed.
#
# If this script exits with a non-zero status nothing will be pushed.
#
# Steps to install, from the root directory of your repo...
# 1. Copy the file into your repo at `.git/hooks/pre-push`
# 2. Set executable permissions, run `chmod +x .git/hooks/pre-push`
@embolalia
embolalia / gist:5660363
Last active December 17, 2015 19:29
A quick script that makes my raspi light up for different ping times. It's a terrible hack, and was not written with the intent of making it public. Please don't hurt me.
#!/usr/bin/env python
import RPi.GPIO as gpio
from time import sleep
import re
import sys
gpio.setmode(gpio.BCM)
red = 23
yel = 24
@vindolin
vindolin / bitcoin_watch.py
Last active December 16, 2015 01:18
Simply shows the bitcoin price in $ from mtgox.com and the total price of all the bitcoins you own. Screenshot: http://i.imgur.com/UatFwkM.png
# -*- coding: utf-8 -*-
# Simply shows the bitcoin price in $ from mtgox.com and the total price of all the bitcoins you own.
# Screenshot: http://i.imgur.com/UatFwkM.png
# Donations --> 1HpQQds9wUFykgwKyzXp747SAb6374RjUL
import requests
import json
from time import sleep
from sys import stdout
@ndarville
ndarville / secret-key-gen.py
Created August 24, 2012 17:01
Generating a properly secure SECRET_KEY in Django
"""
Two things are wrong with Django's default `SECRET_KEY` system:
1. It is not random but pseudo-random
2. It saves and displays the SECRET_KEY in `settings.py`
This snippet
1. uses `SystemRandom()` instead to generate a random key
2. saves a local `secret.txt`
@zwaldowski
zwaldowski / Solarized.crtheme
Created January 15, 2012 18:05
Solarized Dark for CodeRunner
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>BackgroundColor</key>
<string>0d2733</string>
<key>CharColor</key>
<string>cc256f</string>
<key>ClassColor</key>
<string>c1371f</string>
@simonw
simonw / gist:104413
Created April 30, 2009 11:19
Turn a BeautifulSoup form in to a dict of fields and default values - useful for screen scraping forms and then resubmitting them
def extract_form_fields(self, soup):
"Turn a BeautifulSoup form in to a dict of fields and default values"
fields = {}
for input in soup.findAll('input'):
# ignore submit/image with no name attribute
if input['type'] in ('submit', 'image') and not input.has_key('name'):
continue
# single element nome/value fields
if input['type'] in ('text', 'hidden', 'password', 'submit', 'image'):