Skip to content

Instantly share code, notes, and snippets.

Avatar

James Dabbs jamesdabbs

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

[fit] Category Theory

[fit] For the Working Programmer

James Dabbs @jamesdabbs Santa Barbara JavaScript


inline fit

@jamesdabbs
jamesdabbs / sendPasswordReset.ts
Created Jul 2, 2019
Refactoring a `sendPasswordReset` to be a (monadic) chain
View sendPasswordReset.ts
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()
View ant.rb
require 'progressbar'
class Ant
attr_reader :x, :y
def initialize
@x, @y = 0, 0
end
def move
@jamesdabbs
jamesdabbs / 💩 🚌👏 .rb
Last active Nov 13, 2016
In response to @celeenr's (https://twitter.com/celeenr) RubyConf 2016 talk "Rhythmic Recursion"
View 💩 🚌👏 .rb
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 Sep 30, 2016
JavaScript explorations
View index.html
<!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 Jul 29, 2016
Code from a Ruby crash course
View simon.rb
require "pry"
puts "Hello!"
puts "What is your name?"
name = "James"
# name = gets
# puts "Hello, " + name
puts "Hello, #{name}"
@jamesdabbs
jamesdabbs / gems.md
Created Jun 29, 2016
Gems to know about
View gems.md

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 Jun 27, 2016
Iron Library | A project idea
View iron_library.md

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)
View bot-api.md

GET /bots

Show your bots (usually only one)

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

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