Skip to content

Instantly share code, notes, and snippets.

View dainmiller's full-sized avatar
🗺️

Dain Miller dainmiller

🗺️
  • 19:56 (UTC -04:00)
View GitHub Profile
@dainmiller
dainmiller / blockchain.rb
Created April 14, 2020 08:59
Simplest possible Blockchain implementation in ruby
require 'minitest/autorun'
require 'digest'
require 'pki'
class Block
NUM_ZEROES = 4
attr_reader :own_hash, :prev, :transaction
def self.create_genesis_block(pub, priv)
@dainmiller
dainmiller / crawler.rb
Created April 14, 2020 06:19
Crawler prototype
# 1. Initialize with a root URL `crawler = Crawler.new(root: '')`
# 2. Calls fetch on that URL
# 3. Boots HTTParty and stores the response in class
# 4. Returns `#.body` of the HTTParty response
# 5. Maybe helps store the response body in an optional
# 6. `crawler.next` called to crawl through pages, finding more pages to crawl
# 7. If there are no more pages to crawl, we know we're on a leaf
# 8. If we have a file on this leaf, upload to our DataStore
#
require 'httparty'
@dainmiller
dainmiller / state_manager.rb
Last active April 14, 2020 05:47
Ruby state manager API (Modeled from a famous state management algorithm & data structure)
class FeedConfig
def initialize(name=nil, url=nil)
end
end
class StateMachine
attr_accessor :feeds, :webhooks, :states
def initialize(name=nil, feeds=nil, webhooks=nil, states=nil)
@feeds = feeds
@webhooks = webhooks
@dainmiller
dainmiller / tdd-example.rb
Last active April 13, 2020 07:44
TDD Example
require 'minitest/autorun'
require 'json'
require 'httparty'
class Movie
CHILDRENS = "0"
REGULAR = "1"
NEW_RELEASE = "2"
attr_accessor :price_code, :title
@dainmiller
dainmiller / fav-podcasts.md
Last active July 2, 2019 18:33
Favorite Podcasts

Favorite Podcasts

These are the best podcasts out there, bar none.

  • Accidental Tech Podcast
  • Clockwise
  • Cool tools
  • Cortex
  • Dialog
  • Focused
@dainmiller
dainmiller / must-have-mac-apps.md
Created June 24, 2019 07:29
Must Have Mac Apps