Skip to content

Instantly share code, notes, and snippets.

@FLamparski
FLamparski / ipnotify.py
Created February 13, 2014 09:23
For those who don't want to or can't use dynamic DNS but need to be able to access their network from anywhere
#!/usr/bin/env python3
from time import sleep
from urllib.parse import urlencode
import subprocess as sp
import httplib2
import json
import sys
import re
@FLamparski
FLamparski / readout_preprocess.py
Created June 14, 2014 22:00
Prepare a bunch of text for being read out loud by Festival TTS.
#!/usr/bin/env python3
import sys, re, os
from itertools import chain
# Maps various currency signs to their names.
# TODO: collect keys from this to build the currency regex.
CURRENCY_MAP = {'$': 'dollars', '£': 'pounds', '€': 'euro'}
# Maps certain suffixes with to full word equivalents
EXPONENT_MAP = {'b': 'billion', 'm': 'million', 'k': 'thousand', 't': 'trillion'}
@FLamparski
FLamparski / drawer.js
Created August 2, 2014 12:34
A simple to use jQuery plugin for sliding drawers.
(function($){
// Declare the class
function Drawer($el, edge){
console.log('Drawer(%s)', edge);
this.$el = $el;
this.edge = edge;
this._edgeType = (function(edge){
if(edge === 'top' || edge === 'bottom'){
return 'h';
} else {
@FLamparski
FLamparski / pyglet-delaunay.py
Created August 10, 2014 11:37
Using SciPy, generate a Delaunay-triangulated mesh between randomly distributed points, and display it using pyglet.
#!/usr/bin/env python
# vim: et:ts=4:sw=4
import random, pyglet
from pyglet.gl import *
from numpy import array
from scipy.spatial import Delaunay
N_POINTS = 200;
SCALE = 2;
@FLamparski
FLamparski / index.html
Created September 4, 2014 20:13
Reactivity in vanilla JS? Yes you can!
<!DOCTYPE html>
<html>
<head>
<title>Object.observe</title>
</head>
<body>
<h1 reactive>Title here</h1>
<p reactive>Text here</p>
<hr />
<p><b>Hey!</b> Open up the console and change the <tt>title</tt>
@FLamparski
FLamparski / kuler.py
Created January 1, 2015 14:42
Get swatches from Adobe Color CC
from urllib.parse import parse_qs
from itertools import islice
def get_colors_from_kuler(kuler_url, count=5):
"""Get colors from a Adobe Kuler/Color CC URL.
You can't easily export these colour schemes, since the only
save feature Adobe implemented uses the Adobe account. However,
raw color values are stored in the URL in a somewhat unwieldy
but still straightforward format. Basically,
@FLamparski
FLamparski / COPYING
Last active August 29, 2015 14:17
A CSS3 spinnin' loader.
The MIT License (MIT)
Copyright (c) 2015 Filip Wieland
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
@FLamparski
FLamparski / gist:072f43cab3bab669c016
Created April 16, 2015 09:25
A function to serialise an object to JSON which also tries to pull in non-enumerable properties. Example usage: turning exceptions to JSON.
function serialiseAll(object) {
var properties = Object.getOwnPropertyNames(object);
var plainObject = _.reduce(properties, function(obj, prop) {
obj[prop] = object[prop];
return obj;
}, {});
return JSON.stringify(plainObject);
}
@FLamparski
FLamparski / index.es6.html
Created April 16, 2015 18:11
Dynamically changing prototypes in Js
<html>
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>Brian Blessed demo</title>
<style type="text/css">
.out {
font-weight: bold;
}
body {
@FLamparski
FLamparski / first_class_fns.php
Created September 16, 2015 08:48
In PHP, functions "are" "first" "class" "objects"
// Psy Shell v0.4.4 (PHP 5.6.4-4ubuntu6.2 — cli) by Justin Hileman
>>> function foo($x) { return $x * 2; }
=> null
>>> foo(5)
=> 10
>>> is_callable(foo)
PHP error: Use of undefined constant foo - assumed 'foo' on line 1
>>> is_callable('foo')
=> true
>>> 'foo'(5)