Skip to content

Instantly share code, notes, and snippets.

View jamesdabbs's full-sized avatar

James Dabbs jamesdabbs

View GitHub Profile
@jamesdabbs
jamesdabbs / categories.md
Created July 2, 2019 15:22
Categories for the Working Programmer - a deckset presentation

[fit] Category Theory

[fit] For the Working Programmer

James Dabbs @jamesdabbs Santa Barbara JavaScript


inline fit

@jamesdabbs
jamesdabbs / sendPasswordReset.ts
Created July 2, 2019 15:18
Refactoring a `sendPasswordReset` to be a (monadic) chain
import uuid from 'uuid/v4'
import {
Envelope, Token, User,
allUsers, deliverEmail, prompt, saveToken
} from '../util'
const promptFor = (message: string): string => {
console.log(message)
return prompt()
@jamesdabbs
jamesdabbs / ant.rb
Last active March 15, 2017 04:43
ant.rb
require 'progressbar'
class Ant
attr_reader :x, :y
def initialize
@x, @y = 0, 0
end
def move
@jamesdabbs
jamesdabbs / 💩 🚌👏 .rb
Last active November 13, 2016 00:01
In response to @celeenr's (https://twitter.com/celeenr) RubyConf 2016 talk "Rhythmic Recursion"
class Voice
BASELINE = %w( there is no - poop ing - on - the bus - )
VOICES = `say -v '?'`.lines.map { |line| line.split.first }
def initialize &voice
@voice, @i = voice, -1
end
def perform
advance
@jamesdabbs
jamesdabbs / index.html
Created September 30, 2016 15:33
JavaScript explorations
<!DOCTYPE html>
<html>
<head>
<script src="https://code.jquery.com/jquery-3.1.1.slim.js" integrity="sha256-5i/mQ300M779N2OVDrl16lbohwXNUdzL/R2aVUXyXWA=" crossorigin="anonymous"></script>
<script src="people.js"></script>
</head>
<body>
<button id="asdf">Click Me!</button>
</body>
</html>
@jamesdabbs
jamesdabbs / simon.rb
Created July 29, 2016 12:52
Code from a Ruby crash course
require "pry"
puts "Hello!"
puts "What is your name?"
name = "James"
# name = gets
# puts "Hello, " + name
puts "Hello, #{name}"
@jamesdabbs
jamesdabbs / gems.md
Created June 29, 2016 16:29
Gems to know about

Gems

Kaminari

helper for paginating lists (e.g. of search results) and displaying page lists (<< < ... 10 11 12 .. > >>)

Sidekiq

run jobs outside the request-response loop, so that users don't have to wait e.g. for email to send before getting their response page. Also useful for running scheduled jobs (e.g. every 3 hours)

@jamesdabbs
jamesdabbs / iron_library.md
Last active June 27, 2016 17:46
Iron Library | A project idea

Iron Library

Write an application that helps us manage the books in the Iron Yard lending library

MVP

  • Have user accounts, with different roles for students and staff
  • Staff can manage (general CRUD) books
  • Anyone can check out a book, and are given a due date for when to return it
  • When looking at a book, anyone can see who has it checked out currently (if anyone)

GET /bots

Show your bots (usually only one)

State could be running, stopped or crashed (in which case error will be present)

[  
    {  
        "status":{  
Element = Struct.new :datum, :next do
def tail?
!self.next
end
end
class SimpleLinkedList
attr_reader :size, :head
def self.from_a values