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. */
@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
@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.)
<!--
* * * * * * * * * * * * * * * * * * * * * * * * *
* *
* / \ \ / \ *
*| | \ | | *
*| `. | | : *
*` | | \| | *
* \ | / / \\\ ____ \\ : *
* \ \/ ___~~ ~____| \ | *
* \ \__~ ~__\ | *
@james2doyle
james2doyle / scrollTo.js
Last active October 25, 2024 14:12
a native scrollTo function in javascript that uses requestAnimationFrame and easing for animation
// easing functions http://goo.gl/5HLl8
Math.easeInOutQuad = function (t, b, c, d) {
t /= d/2;
if (t < 1) {
return c/2*t*t + b
}
t--;
return -c/2 * (t*(t-2) - 1) + b;
};
@pierrenel
pierrenel / html.tpl.php
Last active December 18, 2015 00:38
Adding other javascript to it's own variable, and getting Drupal to aggregate it nicely on cache refresh.
<?php print $footer_js; ?>