View rbf_test.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View pac_rules.rb
This file contains 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
############### | |
# Rules # | |
############### | |
FIND the most valuable path within range | |
# I could only do 5 cells away/levels deep before my code was timing out | |
# Partly because Ruby is not the fastest | |
# Partly because I started to think about performance too late | |
IF enemy 1 cell away and possible to eat them |
View enum_struct_procotol.swift
This file contains 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 Foundation | |
protocol Addable { | |
func add(tx: Transaction) -> Double | |
} | |
enum TransactionType { | |
case credit | |
case debit | |
} |
View Redis to redis data copy
This file contains 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
redisSrc = Redis.connect :timeout => 20, :url => "redis://some.host.com:11111" | |
redisDest = Redis.connect :timeout => 20, :url => "redis://other.host.com:22222" | |
redisSrc.keys("*").each do |key| | |
data = redisSrc.dump key | |
redisDest.restore key, 0, data | |
end |
View gist:7713078
This file contains 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
class Proc | |
def *(f) | |
->(*args) { self.(f.(*args)) } | |
end | |
end | |
plus2 = ->(n) { n+2 } | |
plus3 = ->(n) { n+3 } | |
plus5 = plus2 * plus3 |
View gist:7239146
This file contains 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 Data.Monoid | |
data Point = Point { x :: Float, y :: Float} deriving (Show, Eq) | |
data Dir = DL | DR | DS deriving (Show) | |
instance Ord Point where | |
compare (Point x y) (Point x' y') = mappend (compare y y') (compare x x') | |
distance :: Point -> Point -> Float | |
distance p0 p1 = sqrt ((x p0 - x p1)**2 + (y p0 - y p1)**2) |
View gist:5843359
This file contains 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
class Iter | |
def initialize(arr) | |
@f = Fiber.new do | |
while item = arr.shift | |
Fiber.yield item | |
end | |
end | |
end | |
def next | |
@f.resume |
View gist:49fee95a49525a729e91
This file contains 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 :: IO() | |
main = mapM_ putStrLn $ take 30 fizzBuzz | |
fizzBuzz = let nums = map show [1..] | |
fizzs = cycle $ ["", "", "Fizz"] | |
buzzs = cycle $ ["", "", "", "", "Buzz"] | |
in zipWith3 (\f b n -> if f++b == "" then n else f++b) fizzs buzzs nums |