Skip to content

Instantly share code, notes, and snippets.

View sophistifunk's full-sized avatar

Josh McDonald sophistifunk

  • Expantra
  • Brisbane, Australia
View GitHub Profile
public function getBreakdown(measuringLocationId:Number, fromDate:Date, toDate:Date):AsyncToken
{
return helper.newResponseDecoder()
.createInstanceOf(DisplaySet)
.on(helper.newSoapInvocation()
.onService(service)
.methodNamed("getFugitiveBreakdown")
.addParameter("measuringLocationId", measuringLocationId)
.addParameter("dateRange", { fromDate:fromDate, toDate:toDate })
.addUserCredentials("carbon","carbon")
public function Tag()
{
super();
invalidator = InvalidationManager.forComponent(this);
invalidator.forProperty("node").commitFunctionIs(commitNode);
}
[Bindable]
public var node:XML;
@sophistifunk
sophistifunk / findInHavingOf.as
Created May 19, 2011 02:09
Find:In:Having:Of:
package intelligentpathways.utils
{
/**
* Search a collection, returning the object where object[fieldName] == value. Because I'm sick of writing this ugly loop for every combobox in a system :(
*/
public function findInHavingOf(collection:*, fieldName:String, value:*):*
{
for each (var testee:* in collection)
if (testee && fieldName in testee && testee[fieldName] == value)
return testee;
@sophistifunk
sophistifunk / make-ios-icons.rb
Created July 2, 2012 10:29
Create a bunch of resized icons for iOS projects
#!/usr/bin/ruby
# Takes one large image (say, 512 or 1024 px) and creates some iOS icons:
#
# Icon-72.png
# Icon-Small-50.png
# Icon-Small.png
# Icon-Small@2x.png
# Icon.png
# Icon@2x.png
@sophistifunk
sophistifunk / hosts
Created September 5, 2012 02:21
Hosts file additions to block tracking, ads, and evil
#general tracking sites, ad servers, and general evil pulled from chrome tracking graph plugin
127.0.0.1 buysellads.com
127.0.0.1 newrelic.com
127.0.0.1 polldaddy.com
127.0.0.1 quantserve.com
127.0.0.1 googlesyndication.com
127.0.0.1 google-analytics.com
127.0.0.1 chartbeat.com
127.0.0.1 netshelter.net
127.0.0.1 skimresources.com
@sophistifunk
sophistifunk / regex
Created September 25, 2012 12:55 — forked from anonymous/regex
regex
String inputLine = "append \"bow wow wow yippee-o yippee-ay\" dir1/dir2/file.txt";
Pattern regex = Pattern.compile("^(\\w+)\\s+\"(.*?)\"\\s+([\\w.\\/]+)$");
Matcher m = regex.matcher(inputLine);
String cmd = m.group(1); // append
String data = m.group(2); // snooplish
String path = m.group(3); // What's left
// Calc whole pixel widths using Bresenham's line algorithm (useful thing, innit?)
function distributeWidthAsColumns(width, numColumns) {
var columnWidths = [];
var columnWidthIdeal = width / numColumns;
var totalWholePixels = 0;
var errorTotal = 0;
var pixelWidth = Math.floor(columnWidthIdeal);
var errorPerColumn = columnWidthIdeal - pixelWidth;
@sophistifunk
sophistifunk / SaveFile.java
Created April 22, 2014 14:08
Simple, poorly factored proof of concept for de-duping data store algorithm.
package com.expantra;
import com.expantra.buzhash.BuzHash;
import javax.xml.bind.DatatypeConverter;
import java.io.*;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import static java.lang.System.out;
package com.expantra.buzhash;
/**
* Created by josh on 16/04/2014.
* Not thread-safe, not nothin not nohow :)
*/
public class BuzHash {
// via sublime text column mode, and cat /dev/random | hexdump
static private final int[] randomInts = {
package main
// Originally ripped from here: http://www.ostree.org/code-snippet/91/csv-comma-separated-values-example-in-golang and modified.
import (
"encoding/csv"
"fmt"
"os"
"unicode/utf8"
"strings"