View fetch.ts
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
export type FetchSuccess = { response?: Response } & { responseObject?: JsonObject }; | |
export type FetchError = FetchSuccess & { | |
errors: ReadonlyArray<object | string>; | |
} | |
export const post = ( | |
url: string, | |
body: object, | |
) => { |
View gist:88cfec5a7ce7b2e0b8e2c33ae46d191b
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
type LoginForm struct { | |
utils.Flash | |
Username string | |
Password string | |
} | |
func (form *LoginForm) Validate() bool { | |
form.Errors = make(map[string]string) | |
if strings.TrimSpace(form.Password) == "" { |
View ugly function.hs
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 qualified Data.Map as Map | |
import Debug.Trace | |
data Expr = Nil | Phrase String | Not Expr | And Expr Expr | Or Expr Expr | |
deriving (Show, Eq) | |
dne :: Expr -> Expr | |
dne (Not (Not p)) = p | |
dne _ = Nil |
View euler_008.hs
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
partitionAll :: Int -> Int -> [a] -> [[a]] | |
partitionAll _ _ [] = [] | |
partitionAll w s xs = (take w xs) : partitionAll w s (drop s xs) | |
largestProductInSeries :: Int -> [Int] -> Int | |
largestProductInSeries l xs = maximum $ map (product) $ partitionAll l 1 xs | |
main = do | |
f <- readFile "008.txt" | |
let s = filter isDigit f |
View 004.hs
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.List | |
main = print $ largestPalindrome 3 | |
isPalindrome :: Integer -> Bool | |
isPalindrome n = | |
let s = show n | |
in reverse s == s | |
largestPalindrome :: Integer -> Integer |
View .emacs
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
;;; Nudity | |
(setq visible-bell t) ; disable visual beep | |
(transient-mark-mode t) ; show region, drop mark | |
(global-font-lock-mode t) ; for all buffers | |
(global-visual-line-mode t) ; word-wrap | |
(show-paren-mode t) ; show matching parentheses | |
(setq initial-scratch-message "") | |
(setq inhibit-startup-screen t) | |
;; Packages |
View fib-server.js
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 'babel-polyfill' | |
import Koa from 'koa' | |
const app = new Koa(); | |
function* fibonacci () { | |
let [a, b] = [0, 1] | |
while (true) { | |
[a, b] = [b, a + b] | |
yield a | |
} |
View gist:29f0a0ebe24a0f26c3758dc6c6c67cf2
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
(define (stuff-peak a ls) | |
(let loop ((pair ls)) | |
(display pair) | |
(newline) | |
(cond ((lat? pair) (begin (set! pair a) | |
ls)) | |
(else (loop (car pair)))))))) |
View euler_74.rs
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
extern crate fnv; | |
use std::collections::HashSet; | |
use std::hash::{BuildHasherDefault}; | |
use self::fnv::FnvHasher; | |
type Fnv = BuildHasherDefault<FnvHasher>; | |
struct FactorialDigitChain { | |
n: u32, // this is the current link in the chain |
View euler74.rs
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
pub fn solve(max:u32, terms:usize) -> usize { | |
(1..max) | |
.filter(|&i| { | |
let mut v = Vec::with_capacity(terms); | |
let mut start = i; | |
let mut j = 0; | |
while !v.contains(&start) { | |
v.push(start); | |
start = digit_factorial_sum(start); |
NewerOlder