Skip to content

Instantly share code, notes, and snippets.

clmn JacksonGariety

Block or report user

Report or block JacksonGariety

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 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);
@JacksonGariety
JacksonGariety / gist:05004b669cfd699c2c2b
Created Jan 16, 2015
kill link click-throughs for Backbone
View gist:05004b669cfd699c2c2b
// Kill link click-throughs
$(document).on('click', 'a:not([data-bypass])', function (event) {
if (history.pushState && this.host === window.location.host) {
event.preventDefault()
event.stopPropagation()
App.getInstance().router.navigate(this.pathname, true)
$.reset(this)
}
})
You can’t perform that action at this time.