Skip to content

Instantly share code, notes, and snippets.

Avatar

Rick Windham rickw

View GitHub Profile
View bumpme
Mon Aug 6 01:19:07 UTC 2018
View keybase.md

Keybase proof

I hereby claim:

  • I am rickw on github.
  • I am rcw (https://keybase.io/rcw) on keybase.
  • I have a public key whose fingerprint is ADA1 A75D B48A 86A8 4047 6D34 64C1 C602 D9CD 1760

To claim this, I am signing this object:

@rickw
rickw / StringScoreExtension.swift
Created Jul 7, 2015
StringScore in Swift - from the Objective-C then JavaScript repos of the same name
View StringScoreExtension.swift
//
// StringScoreExtension.swift
//
//
// Created by Rick Windham on 6/23/15.
//
//
import Foundation
@rickw
rickw / ReachabilityExample.swift
Last active Aug 29, 2015
Reachability Callback Setup
View ReachabilityExample.swift
import Foundation
import SystemConfiguration
var reach:SCNetworkReachability!
reach = SCNetworkReachabilityCreateWithName(kCFAllocatorDefault, "apple.com").takeRetainedValue()
typealias ChangeBlock = (UInt32) -> ()
let block:ChangeBlock = {status in
@rickw
rickw / xlog.swift
Last active Jun 25, 2017
Quick log to NSTextView in Swift
View xlog.swift
extension NSTextView {
func appendText(line: String) {
Async.main {
let attrDict = [NSFontAttributeName: NSFont.systemFontOfSize(18.0)]
let astring = NSAttributedString(string: "\(line)\n", attributes: attrDict)
self.textStorage?.appendAttributedString(astring)
let loc = self.string?.lengthOfBytesUsingEncoding(NSUTF8StringEncoding)
let range = NSRange(location: loc!, length: 0)
self.scrollRangeToVisible(range)
@rickw
rickw / Fibber.swift
Last active Nov 10, 2017
Fibonacci sequence in Swift
View Fibber.swift
func fibber(n:Int) -> Int {
switch n {
case 0:
return 0
case 1:
return 1
default:
return fibber(n-1) + fibber(n-2)
}
}
@rickw
rickw / gist:110596
Created May 12, 2009
a weighted random method
View gist:110596
#
# a weighted random
#
the_list = { "five" => 5, "three" => 3, "one" => 1 }
result_hash = { "five" => 0, "three" => 0, "one" => 0 }
count = 3
def weighted_random(list, count)
weighted_list = []
@rickw
rickw / gist:110522
Created May 12, 2009
A different way to "try"
View gist:110522
#
# method messing try a different way
#
class Object
def try
Try.new self
end
end
class Try
You can’t perform that action at this time.