Skip to content

Instantly share code, notes, and snippets.

View peterhil's full-sized avatar

Peter H. peterhil

View GitHub Profile
@140bytes
140bytes / LICENSE.txt
Created May 9, 2011 16:13
140byt.es -- Click ↑↑ fork ↑↑ to play!
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
Version 2, December 2004
Copyright (C) 2011 YOUR_NAME_HERE <YOUR_URL_HERE>
Everyone is permitted to copy and distribute verbatim or modified
copies of this license document, and changing it is allowed as long
as the name is changed.
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
@Alquimista
Alquimista / bezdraw.py
Created October 9, 2011 20:45 — forked from jl2/bezdraw.py
Draw Bezier curves using Python and PyQt
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import sys
import math
from PyQt4 import QtGui, QtCore
def binomial(i, n):
@ChrisWills
ChrisWills / .screenrc-main-example
Created November 3, 2011 17:50
A nice default screenrc
# GNU Screen - main configuration file
# All other .screenrc files will source this file to inherit settings.
# Author: Christian Wills - cwills.sys@gmail.com
# Allow bold colors - necessary for some reason
attrcolor b ".I"
# Tell screen how to set colors. AB = background, AF=foreground
termcapinfo xterm 'Co#256:AB=\E[48;5;%dm:AF=\E[38;5;%dm'
@clooth
clooth / places.json
Created August 15, 2012 10:09
PK-seudun baarit
[{"phonenumber": "(09) 7533 100", "name": "3. linja", "address": "Kolmas linja 6", "latitude": 60.1817299628, "tags": ["olutravintola"], "homepage": "", "longitude": 24.9509723639, "description": "Minikokoinen kivijalkapubi 3:nnella linjalla, jota Fredikin kulki takaisin. Baarissa kaksi televisiota. Halpa tuoppi."}, {"phonenumber": "(09) 343 2814", "name": "4 Vuodenaikaa", "address": "Rusthollarintie 2", "latitude": 60.2122766079, "tags": [""], "homepage": "", "longitude": 25.0960335589, "description": ""}, {"phonenumber": "0400 211 921", "name": "A21", "address": "Annankatu 21", "latitude": 60.1662143231, "tags": ["cocktail", "drinkkej\u00e4", "drinkkibaari", "juhlapaikka", "kokoustila"], "homepage": "http://www.a21.fi/", "longitude": 24.9378044239, "description": "Cocktail Lounge A21 keskittyy hyviin drinkkeihin eli ns. \"Fine Drinkingiin\". Cocktail-lista on jaettu nelj\u00e4\u00e4n kategoriaan, joiden kautta cocktailien laaja kirjo aukeaa maallikollekin. Tarjolla on makuja suomalaisesta luonnosta, kauden
@HeinrichApfelmus
HeinrichApfelmus / GameLoop.hs
Created October 2, 2012 16:49
Game loop in reactive-banana
{------------------------------------------------------------------------------
reactive-banana
Implementation of an "industry strength" game loop with fixed time step
and variable fps.
See also http://gafferongames.com/game-physics/fix-your-timestep/
-------------------------------------------------------------------------------}
{-# LANGUAGE NoMonomorphismRestriction #-}
module Main where
# coding=UTF-8
import nltk
from nltk.corpus import brown
# This is a fast and simple noun phrase extractor (based on NLTK)
# Feel free to use it, just keep a link back to this post
# http://thetokenizer.com/2013/05/09/efficient-way-to-extract-the-main-topics-of-a-sentence/
# Create by Shlomi Babluki
# May, 2013
@jed
jed / how-to-set-up-stress-free-ssl-on-os-x.md
Last active May 31, 2024 18:32
How to set up stress-free SSL on an OS X development machine

How to set up stress-free SSL on an OS X development machine

One of the best ways to reduce complexity (read: stress) in web development is to minimize the differences between your development and production environments. After being frustrated by attempts to unify the approach to SSL on my local machine and in production, I searched for a workflow that would make the protocol invisible to me between all environments.

Most workflows make the following compromises:

  • Use HTTPS in production but HTTP locally. This is annoying because it makes the environments inconsistent, and the protocol choices leak up into the stack. For example, your web application needs to understand the underlying protocol when using the secure flag for cookies. If you don't get this right, your HTTP development server won't be able to read the cookies it writes, or worse, your HTTPS production server could pass sensitive cookies over an insecure connection.

  • Use production SSL certificates locally. This is annoying

@pyrtsa
pyrtsa / progress.py
Last active December 26, 2015 03:09
Print progress information when iterating over Python iterators.
#!/usr/bin/env python3
# encoding: utf-8
# Public domain.
# 2013, Pyry Jahkola.
from __future__ import print_function
import sys, time
def progress(iterable, n=None, **kwargs):
@Kartones
Kartones / postgres-cheatsheet.md
Last active June 7, 2024 13:13
PostgreSQL command line cheatsheet

PSQL

Magic words:

psql -U postgres

Some interesting flags (to see all, use -h or --help depending on your psql version):

  • -E: will describe the underlaying queries of the \ commands (cool for learning!)
  • -l: psql will list all databases and then exit (useful if the user you connect with doesn't has a default database, like at AWS RDS)
@runeb
runeb / js-exif-rotate.html
Created May 23, 2014 10:49
Auto-rotate images locally in the browser by parsing exif data
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<input id="file" type="file" accept="image/*" />
<br/>
<h2>As read:</h2>
<img id="placeholder1" width=300/><br/>
<h2>Rotated by exif data:</h2>
<img id="placeholder2" width=300/>
<script>