Skip to content

Instantly share code, notes, and snippets.

View brandonc's full-sized avatar
⚙️

Brandon Croft brandonc

⚙️
View GitHub Profile
@brandonc
brandonc / xfiles.cs
Created June 22, 2011 20:46
Reduce an array using regex in C# and ruby
using System;
using System.Linq;
using System.Text.RegularExpressions;
namespace Program
{
class XFiles
{
static int Main(string[] argv)
{
@brandonc
brandonc / SImpler
Created September 28, 2011 17:25 — forked from zznq/Ugly Conditions
Ugly Nested Conditions
$desc.has(':visible')(quick ? 'hide' : 'slideUp');
$desc.has(':hidden')(quick ? 'show' : 'slidedown');
def prime?
('1' * self) !~ /^1?$|^(11+?)\1+$/
end
@brandonc
brandonc / ex, Scan
Last active December 15, 2015 05:29
Examples for ex, the c# regex extension library: http://github.com/brandonc/ex
string beers = @"Bud Light Lime, Tecate, Fat Tire, Budweiser Clamato, Asahi, Budweiser Select";
beers.Scan(@"([\w\s]+),?\s*", (beername) => {
if(!beername.StartsWith("Bud")) {
Console.Writeline("I like {0}", beername);
}
});
@brandonc
brandonc / resign.md
Last active December 19, 2015 04:59

Friday, July 12th, 2013 will be my last day at Mondo Robot. That week of July also marks my 5th year of employment here.

It's hard to put into words what it's meant to work at Mondo Robot because my time here has been the most transformative period of my life. That transformation has come almost entirely from the influence of talent and culture that started during my first job interview here. Lucky is too weak a word to describe how fortunate I feel to have gotten to work on the projects we are known for and with the people that defined them and brought them to life.

What I'll miss most is the proximity and density of friends. The amount of personality and competence found in this room is hard to overstate. It's going to be difficult to lose the support and joy I feel by simply being among my friends and greatest friends all day, every day.

Mondo Robot is going to continue to build cool shit at an ass-blistering pace and I will be around to take part in celebrating those ass blisters right alongside you. T

@brandonc
brandonc / sublime text 2.md
Last active December 19, 2015 13:29
Sublime Text 2 Setup

Open the Console: ^`

import urllib2,os; pf='Package Control.sublime-package'; ipp=sublime.installed_packages_path(); os.makedirs(ipp) if not os.path.exists(ipp) else None; urllib2.install_opener(urllib2.build_opener(urllib2.ProxyHandler())); open(os.path.join(ipp,pf),'wb').write(urllib2.urlopen('http://sublime.wbond.net/'+pf.replace(' ','%20')).read()); print('Please restart Sublime Text to finish installation')

command-shift-p: Install

  • theme - soda
  • emmet
  • dotfiles syntax
  • gitgutter
require 'benchmark'
def make_array
(1..10000).map { Random.rand(10) }
end
Benchmark.bmbm do |x|
x.report("uniq") do
array = []
100.times do
@brandonc
brandonc / success.rb
Created August 2, 2013 17:45
Generate a compound success message
def create_success_message
result = @created_events.reduce("Post updated,") do |m, ev|
case ev.class
when PostAssignedEvent
m += " assigned to #{ev.assignee.name},"
when PostArchivedEvent
m += " archived,"
when PostUnassignedEvent
m += " assigned user cleared,"
when PostProposedEvent
@brandonc
brandonc / webhooks_sample.json
Last active December 23, 2015 00:49
Webhooks sample payload
{
"operation":"create",
"type":"content",
"payload":{
"full_post":{
"id":"523381424aaaaecc80000001",
"idea_title":null,
"content_title":null,
"creator_id":"51e477b9e1f419ecf4000004",
"assignee_id":"51e477b9e1f419ecf4000004",
"custom_fields": [
{
"id": "513fba45deeed40200000250",
"field_type": "select",
"display_label": "Primary CTA",
"name": "primary call to action",
"created_at": "2013-03-12T23:29:10Z",
"select_values": [
"Read More",
"Subscribe",