Skip to content

Instantly share code, notes, and snippets.

@onlyleft
onlyleft / common.conf
Created July 3, 2019 13:37
nginx config
# favicon.ico
location = /favicon.ico {
log_not_found off;
access_log off;
}
# robots.txt
location = /robots.txt {
log_not_found off;
access_log off;
@onlyleft
onlyleft / fib.hs
Last active August 29, 2015 14:05
Learning Haskell with Project Euler - Problem 2 (Fibonacci Sequence Sum with Limit)
-- Base formula, but this is exponential time
fib :: Int -> Int
fib 0 = 0
fib 1 = 1
fib x
| x < 0 = error "No Negatives allowed"
| otherwise = fib (x-2) + fib (x-1)
-- When doing an unbounded sequence, where should we stop?
fibLimit:: Int -> Int -> Int
@onlyleft
onlyleft / fib2.hs
Created August 22, 2014 10:22
Learning Haskell with Project Euler - Second attempt at Problem 2 (Fibonacci Sequence Sum with Limit)
-- Get the fibonacci sequence up to a limit
fml :: Int -> [Int] -> [Int]
fml limit seed
| null seed = fml limit [1, 1]
| nextNumber < limit = fml limit (seed ++ [nextNumber])
| otherwise = seed
where nextNumber = ((last (init seed)) + (last seed))
-- Implementation to retrieve a specific fibonacci number
fm :: Int -> [Int] -> Int