Skip to content

Instantly share code, notes, and snippets.

@neoneye
neoneye / gist:cef81456451a79a10281
Created December 23, 2014 18:11
color extension
import UIKit
extension UIColor {
// usage:
// myButton.backgroundColor = UIColor.rgb(240, 10, 20)
class func rgb(red: Int, _ green: Int, _ blue: Int) -> UIColor {
return rgba(red, green, blue, 255)
}
// usage:
@neoneye
neoneye / gist:af985fac27bc7cdc7836
Created December 18, 2014 19:18
Curiously recurring template pattern in swift is not working
// https://en.wikipedia.org/wiki/Curiously_recurring_template_pattern
class Foo <T: Any> : T {
func hello() { println("hello") }
}
class Bar {
func world() { println("world") }
}
@neoneye
neoneye / rakefile.rb
Created July 17, 2014 09:42
Count total number of lines in a project
def count_number_of_lines(path, suffix)
count = 0
Dir.chdir(path) do
cmd = 'find . -type f -name "*.SUFFIX" -print0 | xargs -0 cat | wc -l'
cmd.gsub!('SUFFIX', suffix)
result = `#{cmd}`
count = result.to_i
end
return count
end