Skip to content

Instantly share code, notes, and snippets.

Tim Buckley timbuckley

  • 2U
  • NYC
Block or report user

Report or block timbuckley

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
@timbuckley
timbuckley / basic-fizzbuzz-haskell.hs
Last active Dec 21, 2017
Comparing fizzbuzz implementations in Haskell and JavaScript
View basic-fizzbuzz-haskell.hs
fizzes = cycle ["", "", "Fizz"]
buzzes = cycle ["", "", "", "", "Buzz"]
fbs = zipWith (++) fizzes buzzes
nums = map show [1..]
fizzbuzz n = take n (zipWith max nums fbs)
-- Usage:
-- fizzbuzz 3
-- -> ["1", "2", "Fizz"]
@timbuckley
timbuckley / schema.js
Created Dec 20, 2017
Example schema setup of normalizr
View schema.js
import { Schema, arrayOf } from 'normalizr'
let userSchema = new Schema('user', options)
let nbhdSchema = new Schema('nbhd', options)
let itemSchema = new Schema('item', options)
let commentSchema = new Schema('comment', options)
let nbhdsSchema = arrayOf(nbhdSchema)
userSchema.define({
nbhds: nbhdsSchema
@timbuckley
timbuckley / hangman-no-types-w-arrow.hs
Last active Aug 7, 2018
Solving Hangman in Haskell
View hangman-no-types-w-arrow.hs
module HangmanGuesser (main) where
import Data.List (intersect, nub, sort)
import Data.Char (toLower)
import Data.Tuple (swap)
import Data.Map as M (Map, fromListWith, toList)
main = do
corpus <- readFile "web2"
View menu-items-gist.hs
import qualified Data.Map as M (Map, empty, insertWith, toList)
import Data.Foldable
import Data.List
example_csv = "rest1,item1\nrest1,item2\nrest3,item1\nrest3,item2\nrest2,item3\nrest1,item5\nrest2,item2"
csvToDict :: String -> M.Map String [String]
csvToDict = foldToDict . map splitOnComma . lines
where
splitOnComma = words . map (\c -> if c == ',' then ' ' else c)
@timbuckley
timbuckley / how-effective-sampling-is.py
Last active Jun 4, 2017
Simulates doing a thousand polls at a 1.5k sample size from a population of 256 million. Most any poll was off was by 4.5%, while average variance was just 1.19%.
View how-effective-sampling-is.py
import random
american_adult_population = int(245e6)
# Warning: This array is HUGE!
# The array is just the numbers from 0 to 245,000,000
usa_array = range(american_adult_population)
actual_average = float(american_adult_population / 2)
sample_amount = 1500
@timbuckley
timbuckley / EmployeeList.js
Created Dec 19, 2016
Helping ppl on the internet
View EmployeeList.js
export class EmployeeList extends React.Component {
state = {
employees: [],
isLoading: true
}
componentDidMount() {
if (localStorage.token) {
this.loadEmployeesData()
}
View actions.js
// === Action Creators ===
export function posItemRequest(itemBody) {
return {
type: 'ITEM_POST_REQUEST',
payload: {
itemBody: itemBody
}
}
}
View herdulikecomposition.js
function itemsReducer(state, action) {
switch(action.type) {
case 'UPDATE_ITEM':
return state.items.map(i => itemReducer(i, action))
default:
return state
}
}
function itemReducer(state, action) {
You can’t perform that action at this time.