Skip to content

Instantly share code, notes, and snippets.

@michaelwills
michaelwills / gist:1053807
Created June 29, 2011 13:20
Extending a redbeanphp model to handle instantiation with IDE code hints
<?php
// in BaseSimpleModel.php
class BaseSimpleModel extends RedBean_SimpleModel {
/**
* Get or create a model with the bean set
* @static
* @param string $table
@michaelwills
michaelwills / gist:1075698
Created July 11, 2011 11:37 — forked from insin/gist:1031662
Boilerplate for serving a regular old HTML table as application/vnd.ms-excel, apropos acheiving Excel surround sound
<html xmlns:o="urn:schemas-microsoft-com:office:office"
xmlns:x="urn:schemas-microsoft-com:office:excel"
xmlns="http://www.w3.org/TR/REC-html40">
<head>
<meta http-equiv="expires" content="Mon, 06 Jan 1999 00:00:01 GMT">
<meta http-equiv=Content-Type content="text/html; charset=UTF-8">
<!--[if gte mso 9]><xml>
<x:ExcelWorkbook>
<x:ExcelWorksheets>
<x:ExcelWorksheet>
@michaelwills
michaelwills / makeapp.sh
Created January 6, 2012 16:20 — forked from demonbane/makeapp.sh
Create a Fluid-style app launcher for single-window Chrome instances on OSX
#!/bin/sh
echo "What should the Application be called (no spaces allowed e.g. GCal)?"
read inputline
name=$inputline
echo "What is the url (e.g. https://www.google.com/calendar/render)?"
read inputline
url=$inputline
@michaelwills
michaelwills / $.fn.redraw.js
Created January 17, 2012 04:11 — forked from hdragomir/$.fn.redraw.js
Quick jQuery plugin to force element redraws
(function($){
$.fn.redraw = function(){
return $(this).each(function(){
var n = document.createTextNode(' ');
$(this).append(n);
setTimeout(function(){n.parentNode.removeChild(n)}, 0);
});
}
})(jQuery)
@michaelwills
michaelwills / SASS_rouded_corner_mixins.sass
Created June 19, 2012 06:14 — forked from victorbstan/SASS_rouded_corner_mixins.sass
SASS cross browser rounded corner mixins
$default_rounded_amount: 5px
// Round corner at position by amount.
@mixin round-corner($position, $amount: $default_rounded_amount)
border-#{$position}-radius: $amount
-webkit-border-#{$position}-radius: $amount
@mixin round-corner-mozilla($position, $amount: $default_rounded_amount)
-moz-border-radius-#{$position}: $amount
// Round left corners by amount
@michaelwills
michaelwills / csvds.py
Created November 12, 2012 05:32 — forked from fawce/csvds.py
Rough draft, CSV data source for zipline
"""
Generator-style DataSource that loads from CSV.
"""
import pytz
import csv
import mmap
import os.path
# From http://stackoverflow.com/a/14674326/1524448
import collections
freq = collections.Counter()
# sample and output
# line = 'Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod'
# Counter({'ipsum': 1, 'amet,': 1, 'do': 1, 'sit': 1, 'eiusmod': 1, 'consectetur': 1, 'sed': 1, 'elit,': 1, 'dolor': 1, 'Lorem': 1, 'adipisicing': 1})
with open(filename) as f:
@michaelwills
michaelwills / HuesAppSampleColor
Created July 11, 2013 04:56
Simple Applescript to trigger the Hues app to sample a color
# For http://giantcomet.com/hues/
# inspired by https://twitter.com/JP_Sirois/status/132517964267261952
# with help from UIElementInspector
# Works as a workflow in AlfredApp
tell application "Hues" to activate
tell application "System Events"
tell process "Hues"
click first button of window 1
end tell