Skip to content

Instantly share code, notes, and snippets.

Matjaz Muhic depy

Block or report user

Report or block depy

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
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 gist:49fee95a49525a729e91
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
View Redis to redis data copy
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
@depy
depy / gist:7713078
Created Nov 29, 2013
Simple composition of ruby lambdas.
View gist:7713078
class Proc
def *(f)
->(*args) { self.(f.(*args)) }
end
end
plus2 = ->(n) { n+2 }
plus3 = ->(n) { n+3 }
plus5 = plus2 * plus3
@depy
depy / gist:7239146
Created Oct 30, 2013
Need to sort list of points depending on angle between each of them and another point and axis x.
View gist:7239146
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
class Iter
def initialize(arr)
@f = Fiber.new do
while item = arr.shift
Fiber.yield item
end
end
end
def next
@f.resume
You can’t perform that action at this time.