Skip to content

Instantly share code, notes, and snippets.

View pierrenel's full-sized avatar
:shipit:

Pierre Nel pierrenel

:shipit:
View GitHub Profile
@jdp
jdp / refactor.py
Created December 7, 2010 04:59
A toy tail-recursive concatenative language implementation
#!/usr/bin/env python
import sys
import types
import operator
class Runtime:
def __init__(self, env={}, stack=[]):
self.env = {
# Primitive words, not an impressive base but it works
@nathansmith
nathansmith / moz-webkit.css
Created March 22, 2011 01:51
Target Firefox and WebKit via hacky CSS.
/*
Read more here:
https://developer.mozilla.org/en/CSS/@-moz-document
For more browser-specific hacks:
http://paulirish.com/2009/browser-specific-css-hacks
*/
@-moz-document url-prefix() {
/* Put your Firefox specific code here. */
@ScottPhillips
ScottPhillips / .htaccess
Created February 2, 2012 04:30
Common .htaccess Redirects
#301 Redirects for .htaccess
#Redirect a single page:
Redirect 301 /pagename.php http://www.domain.com/pagename.html
#Redirect an entire site:
Redirect 301 / http://www.domain.com/
#Redirect an entire site to a sub folder
Redirect 301 / http://www.domain.com/subfolder/
@xxx
xxx / view_attachment.sh
Created June 16, 2012 23:35
view_attachment.sh file for mutt on OSX. Tweaked from others available on the net to handle filenames with multiple dots in them, as well as correctly parsing the output of `file -bi` when a type is not specified.
#!/bin/bash
#
# Author: Eric Gebhart
#
# Purpose: To be called by mutt as indicated by .mailcap to handle mail attachments.
#
# Function: Copy the given file to a temporary directory so mutt
# Won't delete it before it is read by the application.
#
# Along the way, discern the file type or use the type
@rayfranco
rayfranco / APACHE: .htaccess pushstate
Created July 30, 2012 23:04
.htaccess for HTML5 Pushstate support
<ifModule mod_rewrite.c>
Options +FollowSymLinks
IndexIgnore */*
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule (.*) index.html
</ifModule>
@searbe
searbe / parse_xlsx.php
Created August 7, 2012 09:48
Parse simple XLSX in PHP with SimpleXML and ZipArchive
<?php
/**
* I had to parse an XLSX spreadsheet (which should damn well have been a CSV!)
* but the usual tools were hitting the memory limit pretty quick. I found that
* manually parsing the XML worked pretty well. Note that this, most likely,
* won't work if cells contain anything more than text or a number (so formulas,
* graphs, etc ..., I don't know what'd happen).
*/
# Colorize PS1 according to privileges
if [[ ${EUID} == 0 ]] ; then
PS1="\[\033[01;31m\][\h]"
else
PS1="\[\033[01;32m\][\u@\h]"
fi
# git branch
function parse_git_branch {
ref=$(git symbolic-ref HEAD 2> /dev/null) || return
@vhata
vhata / campfire.py
Last active October 11, 2015 23:47
Campfire notifications
import requests
def campfire(token, subdomain, room_id, message, msgtype):
requests.post(
'https://%s.campfirenow.com/room/%s/speak.json' % (
subdomain, room_id
),
auth=(token, 'x'),
headers={
'Content-type': 'application/json'
@pies
pies / ExcelFormulas.js
Created November 29, 2012 04:55
Few Excel formulas - PMT, PPMT, XIRR - expressed in Javascript
/* Based on
* - EGM Mathematical Finance class by Enrique Garcia M. <egarcia@egm.co>
* - A Guide to the PMT, FV, IPMT and PPMT Functions by Kevin (aka MWVisa1)
*/
var ExcelFormulas = {
PVIF: function(rate, nper) {
return Math.pow(1 + rate, nper);
},
@snipe
snipe / goatse
Created March 14, 2013 08:03
Goatse ASCII art that won't break your W3C validation. (The original used double-hyphens inside the HTML comment, which would not validate.)
<!--
* * * * * * * * * * * * * * * * * * * * * * * * *
* *
* / \ \ / \ *
*| | \ | | *
*| `. | | : *
*` | | \| | *
* \ | / / \\\ ____ \\ : *
* \ \/ ___~~ ~____| \ | *
* \ \__~ ~__\ | *