Skip to content

Instantly share code, notes, and snippets.

View worldspawn's full-sized avatar

Sam Critchley worldspawn

  • Melbourne, Australia
View GitHub Profile
@worldspawn
worldspawn / gist:7983836
Created December 16, 2013 08:24
Bitta APIARY

Group Flavours

Flavour related resources of Mealstrom API

Flavour Collection [/flavours]

A collection of flavours

  • Model

    HAL + JSON representation of flavour resource

@worldspawn
worldspawn / twoWayBinder
Last active August 29, 2015 14:16
Two Way Binder - For use in non-isolated scope scenarios
.factory('twoWayBinder', function ($parse) {
function twoWayBind($scope, remote, local){
var remoteSetter = $parse(remote).assign;
var localSetter = $parse(local).assign;
$scope.$watch(remote, function (value) {
localSetter($scope, value);
});
$scope.$watch(local, function (value) {

Does a rudimentary merge. It uses the pofile package to read po files. It adds missing entries from pot files to po files and replaces existing entries references and extracted comments. Usage example is at the bottom.

  • Added a lookup to check for entries in the po file that cannot be found in the catalog. If an entry is not found a comment is added indicating that, if the entry is found then if that comment is there it is removed.
@worldspawn
worldspawn / jsdi.js
Last active August 29, 2015 14:20
JS Di COntainer
module.exports = function (Q) {
function Builder() {
this.registrations = {};
}
Builder.prototype = {
register: function (name, factory, lifecycle) {
lifecycle = lifecycle || 'perdependency';
if (!this.registrations[lifecycle]) {
this.registrations[lifecycle] = {};
@worldspawn
worldspawn / sample.cs
Created May 19, 2015 01:24
Protected+Audited domain actions
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Manager
{
class Program
{
@worldspawn
worldspawn / 4k gtx 9 series
Last active August 29, 2015 14:22
Compare 9 series cards for a 4k setup
GTX 970 (x3) - $1677
Total Ram --- 12, Total Cores - 4992, Total GigaTexels/s - 327, Total Watts - 435
(Scaled) --- GigaTexels/s - 250, GTS/Watt - 0.57, GTS/$ - 0.15
Value Score --- 1.02
GTX 980 (x2) - $1558
Total Ram --- 8, Total Cores - 4096, Total GigaTexels/s - 288, Total Watts - 330
(Scaled) --- GigaTexels/s - 274, GTS/Watt - 0.83, GTS/$ - 0.18
Value Score --- 1.16
@worldspawn
worldspawn / ev.cs
Created June 18, 2015 04:40
event funk
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Text;
using Newtonsoft.Json;
using Newtonsoft.Json.Serialization;
using NPoco;
using NPoco.FluentMappings;
@worldspawn
worldspawn / Order.cs
Last active February 29, 2016 05:11
Order a queryable based on a string input. "Members" can be a value like: "Name, Company.Type desc, Company.Name". Handles nested property references, ascending/descending and nullable/nonnullable targets.
private IQueryable<T> Order<T>(IQueryable<T> list, string members)
{
var param = Expression.Parameter(list.ElementType, "r");
bool thenMode = false;
foreach (var member in members.Split(','))
{
MemberExpression memberExpression = null;
var chop = member.Split(' ');
foreach (var memberPart in chop[0].Split('.'))
@worldspawn
worldspawn / .iisexpressrc
Last active April 22, 2016 04:11
Powershells script to launch iisexpress. Allows user to specify process env variables, use a unique applicationhost.config and more
{
"name": "testapp",
"path": "wwwroot",
"variables": {
"something": null,
"foo": "bar"
}
}
<?xml version="1.0" encoding="UTF-8"?>
<SecurePayMessage>
<MessageInfo>
<messageID>test1234</messageID>
<messageTimestamp>20160520150545000000+600</messageTimestamp>
<timeoutValue>60</timeoutValue>
<apiVersion>xml-4.2</apiVersion>
</MessageInfo>
<MerchantInfo>
<merchantID>ABC0001</merchantID>