This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Githubs syntax highlighter doesn't see _ spaced numbers correctly | |
println(1_000_000) | |
println(0xFF_FF_FF_FF) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// MakeImageTemplate | |
// Turn those badly coloured template images into a normalized color | |
// | |
// | |
// This program is free software: you can redistribute it and/or modify | |
// it under the terms of the GNU General Public License as published by | |
// the Free Software Foundation, either version 3 of the License, or | |
// (at your option) any later version. | |
// |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// main.m | |
// Scratch | |
// | |
// Created by Kim Hunter on 12/06/2014. | |
// Copyright (c) 2014 Kim Hunter. All rights reserved. | |
// | |
// Here I do similar test while the code does some actual task in the loops | |
// The results: the nsscanner approach takes less than a tenth of the time |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Cocoa | |
extension Array { | |
func myMap<A,B>(items: Array<A>, f:((A) -> B)) -> Array<B> { | |
var xs: Array<A> = items | |
return xs.count == 0 ? [] : [f(xs.removeAtIndex(0))] + myMap(xs,f) | |
} | |
func myMap<B>(f:((T) -> B)) -> Array<B> { | |
return myMap(self,f) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Cocoa | |
var nums: Int[] = [] | |
for var i = 0; i < 10; i++ { | |
nums.append(Int(arc4random()) % 200) | |
} | |
nums | |
func qSort(var arr: Int[]) -> Int[] { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
inspired by ruby's 4.times {} method, created becasue I can and it was fun to do. | |
Usage: | |
for (NSNumber *i in @100) | |
{ | |
NSLog(@"%@", i); | |
} | |
*/ | |
@interface NSNumber (FastEnum)<NSFastEnumeration> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
M[16], X = 16, W, k; | |
main() | |
{ | |
T(system("stty cbreak")); | |
puts(W & 1 ? "WIN" : "LOSE"); | |
} | |
K[] = { 2, 3, 1 }; | |
s(f, d, i, j, l, P) | |
{ | |
for (i = 4; i--;) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// main.cpp | |
// testSeeEl | |
// | |
// Created by Kim on 21/07/2013. | |
// Copyright (c) 2013 Kim. All rights reserved. | |
// | |
// | |
// clang -framework OpenCL -o testSeeEl testSeeEl.c && ./testSeeEl | |
// |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'nokogiri' | |
doc = Nokogiri::HTML(File.open("Videoswwdc.html")) | |
items = {} | |
doc.xpath("//li[@class='session']").each do |session| | |
session_id = session['id'].sub('-video', '').to_i | |
title = session.children.xpath("li[@class='title']").text | |
items[session_id] = title | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'nokogiri' | |
doc = Nokogiri::HTML(File.open("Videoswwdc.html")) | |
items = {} | |
doc.xpath("//li[@class='session']").each do |session| | |
session_id = session['id'].sub('-video', '').to_i | |
title = session.children.xpath("li[@class='title']").text | |
items[session_id] = title | |
end |
NewerOlder