Skip to content

Instantly share code, notes, and snippets.

anonymous
anonymous / Trie.swift
Created June 7, 2014 07:23
//
// Trie.swift
// SceneTest
//
// Created by Greg Titus on 6/7/14.
// Copyright (c) 2014 The Omni Group. All rights reserved.
//
// This is essentially the same data structure as OFTrie in OmniFoundation, except that the OmniFoundation version is mutable and ephemeral,
// and this version is immutable and persistent. Every time you add a string to the trie, it replaces all the nodes along the string's path
@kmikael
kmikael / dispatch_async
Created June 13, 2014 15:06
Update `dispatch_async` to take a default `queue`
import Dispatch
func dispatch_async(queue: dispatch_queue_t = dispatch_get_main_queue(), block: dispatch_block_t) {
Dispatch.dispatch_async(queue, block)
}
dispatch_async {
// Update the UI
}
@siracusa
siracusa / rename.pl
Created August 16, 2014 16:29
Larry Wall's file renamer, slightly modified
#!/usr/bin/perl
use strict;
use warnings;
die "Usage: rename <expression> <files>\n" unless (@ARGV >= 2);
my $op = eval 'sub { ' . shift . ' }'; # crazily dangerous - type carefully!
die $@ if $@;
@jondkinney
jondkinney / setup_textmate_rails_dev.md
Created June 16, 2011 08:16
Setup Textmate for Rails Dev on OS X

##Setup Textmate for Rails Dev on OS X

This guide was written by Jon Kinney for the Green Bay Ruby User Group. Jon works at Intridea and they graciously sponsor the Green Bay RUG meetings.

These guides were also partially completed using time from Intridea's SparkTime initiative which aims to give employees "outside projects" to work on during their normal work week.

If you find any issues with these suggestions please let me know. I've amassed these tips/tricks over several years of full time Rails development using Textmate but just because it works on my system doesn't always mean it will be problem free universally. Thanks to all the blog authors whose articles helped me learn Textmate over the years but whose links/posts I've lost or forgotten over time. If you have a cool Textmate tip or trick please post it in the comments!

@simonwhitaker
simonwhitaker / UIColor+GSAdditions.h
Created September 15, 2011 11:19
A category on UIColor adding +(UIColor*)colorWithHexValue:(NSString*)hexValue;
//
//
// UIColor+GSAdditions.h
//
// Created by Simon Whitaker at Goo Software Ltd on 15/09/2011.
//
#import <UIKit/UIKit.h>
@interface UIColor (GSAdditions)
@jimweirich
jimweirich / cfb2.rb
Created July 9, 2012 01:25
Inspired by "Programming with Nothing" http://experthuman.com/programming-with-nothing. See comment below for some details.
require './interface'
puts to_strings(->(limit) {
->(lst) {
->(f) {
->(f) {
->(g) {
->(n) {
f.(g.(g)).(n)
}
}.(->(g) {
@ttscoff
ttscoff / text_score.rb
Created June 17, 2012 16:17
Readability stats for passed text using ipeirotis.appspot.com
#!/usr/bin/env ruby
# Uses the Readability Metrics API from http://ipeirotis.appspot.com/readability-api.html
# Accepts text from STDIN (piped) or as an argument
=begin examples
pbpaste|text_score.rb # copy text and run (on OS X) to get the stats for the clipboard.
cat myfile.md|text_score.rb # get scores for the contents of a file
=end
require 'open-uri'
require 'net/http'
ruby -rwebrick -e"s = WEBrick::HTTPServer.new(:Port => 3000, :DocumentRoot => Dir.pwd); trap('INT') { s.shutdown }; s.start"
@jaybaird
jaybaird / gist:6003951
Last active December 19, 2015 19:09
Binary Tree with NSArray
#import <Foundation/Foundation.h>
@interface Node : NSObject
@property (nonatomic) NSInteger identifier;
@property (nonatomic, copy) NSString *value;
+ (Node *)nodeWithIdentifier:(NSInteger)identifier value:(NSString *)value;
@end
@implementation Node
+ (Node *)nodeWithIdentifier:(NSInteger)identifier value:(NSString *)value {
@ttscoff
ttscoff / oft.sh
Created November 2, 2013 16:28
Open File Type script. Fuzzy matches extension fragment to open matching files.
oft() {
local target fnd app all
target="."
fnd=''
if [[ $# == 0 ]]; then
echo -n "Enter an ext or partial ext: "
read ext
else
[[ "$1" =~ -[h\?] ]] && echo "Usage: oft [-a \"app name\"] [path (fragments)] file extension (fragment)" && return
while [[ $# -gt 1 ]]; do