Skip to content

Instantly share code, notes, and snippets.

⚱️
vase?

clmn JacksonGariety

⚱️
vase?
View GitHub Profile
View fetch.ts
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
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
-- 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
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
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
;;; 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
@JacksonGariety
JacksonGariety / fib-server.js
Last active Apr 27, 2016
A koa server that always responds with the next number in a fibonacci sequence and stops after the 100th number.
View fib-server.js
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
(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
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
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);
You can’t perform that action at this time.