Skip to content

Instantly share code, notes, and snippets.

export type FetchSuccess = { response?: Response } & { responseObject?: JsonObject };
export type FetchError = FetchSuccess & {
errors: ReadonlyArray<object | string>;
}
export const post = (
url: string,
body: object,
) => {
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) == "" {
-- 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
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
import Data.List
main = print $ largestPalindrome 3
isPalindrome :: Integer -> Bool
isPalindrome n =
let s = show n
in reverse s == s
largestPalindrome :: Integer -> Integer
;;; 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
@ColemanGariety
ColemanGariety / fib-server.js
Last active April 27, 2016 02:49
A koa server that always responds with the next number in a fibonacci sequence and stops after the 100th number.
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
}
(define (stuff-peak a ls)
(let loop ((pair ls))
(display pair)
(newline)
(cond ((lat? pair) (begin (set! pair a)
ls))
(else (loop (car pair))))))))
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
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);