Skip to content

Instantly share code, notes, and snippets.

View gshutler's full-sized avatar
📅
👨‍💻

Garry Shutler gshutler

📅
👨‍💻
View GitHub Profile
@gshutler
gshutler / table.markdown
Created August 11, 2012 21:02
Idea for creating a table in markdown

Possible Markdown for tables

I noticed that there isn't a format for creating tables in Markdown.

My idea is to just use the | (pipe) character to delimit columns in a table with the first line of "cells" always assumed to be a row of headings:

 | Number | Rider        | Time  |
 | 1      | Bullet Bob   | 56:07 |
 | 2 | Clumsy Colin | DNF |
var compare = function (a, b) {
var i = 0;
for (; i < a.length; i++) {
if (a[i] != b[i]) {
return (a[i] > b[i]) ? 1 : -1;
}
}
return 0;
@gshutler
gshutler / logstash.rb
Created July 26, 2012 20:16
Direct logstash TCP client
$:.unshift File.dirname(__FILE__)
require 'bundler/setup'
require 'logstash'
require 'logstash/event'
require 'logstash/outputs/tcp'
require 'socket'
e = LogStash::Event.new
e.message = "SOCKETS"
@gshutler
gshutler / generator.rb
Created July 1, 2012 16:26 — forked from karlseguin/gist:3016329
File-based score data
require 'digest'
require 'json'
require 'fileutils'
$leaderboard_count = 5
$user_count = 200000
def username(i)
Digest::SHA1.hexdigest(i.to_s)
end
@gshutler
gshutler / sketch.rb
Created June 29, 2012 16:04 — forked from mattwynne/sketch.rb
sketch for Matt Wynne
class Organization
def to_param
"42"
end
def saved?
rand > 0.5
end
end
class OrganizationCreator
var optionSet = new OptionSet
{
{"p|password=", "The password for each certificate", x => password = x},
{"f|format=", "The string format for certificate names", x => format = x}
};
var outputPath = optionSet.Parse(args).FirstOrDefault();
// Vessl e:\Export
// Vessl --password=foobar e:\Export
GET /users
Content-Type: application/json
Link: rel=page2;href=/users?page=2
{
page: 1,
total: 1111002324,
results: [
@gshutler
gshutler / DiffGenerator.cs
Created March 2, 2012 17:27 — forked from DominicFinn/DiffGenerator.cs
Two ways of generating the difference in between two lists
using System.Collections.Generic;
using System.Linq;
namespace Other.Something.Core.Tasks
{
public static class DiffGenerator
{
public static Diff<T> Generate<T>(IEnumerable<T> left, IEnumerable<T> right)
{
var added = right.Except(left);
public static class DiffGenerator
{
public Diff<T> Generate<T>(IEnumerable<T> left, IEnumerable<T> right)
{
var added = right.Except(left).ToList();
var removed = left.Except(right).ToList();
var leftList = left.ToList();
var common = right.Where(item => leftList.Contains(item)).ToList();
Approval resource URL is discovered through the base resource, no naughty URL templating.
GET /resource/5/approve
404 when not approved, 200 with the thingy-approval resource once approved.
PUT /resource/5/approve
Replaces the current approval message or whatever (you can always store a history of approval messages internally).