Skip to content

Instantly share code, notes, and snippets.

class SomeComplicatedMess
def initialize(keyword:, occasionally_required_keyword: required_now?(keyword))
end
private
def required_now?(keyword)
throw 'occasionally_required_keyword is required when keyword is banana' if keyword == 'banana'
end
end
@JerrySeto
JerrySeto / System Design.md
Created April 18, 2016 13:48 — forked from vasanthk/System Design.md
System Design Cheatsheet

#System Design Cheatsheet

Picking the right architecture = Picking the right battles + Managing trade-offs

##Basic Steps

  1. Clarify and agree on the scope of the system
  • User cases (description of sequences of events that, taken together, lead to a system doing something useful)
    • Who is going to use it?
    • How are they going to use it?
@JerrySeto
JerrySeto / repeat.rb
Created December 10, 2015 17:10
Interface for repeating
require 'pry'
module Repeats
def n_times(n)
Repeats::Repeater.new(self, n)
end
class Repeater
def initialize(parent, times)
@parent = parent
@JerrySeto
JerrySeto / Vagrantfile
Created September 17, 2015 18:49
Configure the host port for vagrant's ssh port forwarding
# -*- mode: ruby -*-
# vi: set ft=ruby :
# All Vagrant configuration is done below. The "2" in Vagrant.configure
# configures the configuration version (we support older styles for
# backwards compatibility). Please don't change it unless you know what
# you're doing.
Vagrant.configure(2) do |config|
config.vm.box = "rhel6_6"
config.vm.network :forwarded_port, guest: 22, host: 3000, id: "ssh"
require 'mechanize'
agent = Mechanize.new
agent.get('http://jobs.startupnorth.ca/recent') do |page|
jobs = page.search('.job-link')
jobs.each do |job|
title = job.text
job_page = agent.get(job.attributes['href'].value)
description = job_page.search('.job-description').text
end
require 'mechanize'
agent = Mechanize.new
agent.get('http://www.producthunt.com/tech?page=1') do |page|
content = page.search('.post--content')
title = content.map do |post|
title = post.search('a.title').text
description = post.search('.description').text
end
end
<
%3C
&lt
&lt;
&LT
&LT;
&#60
&#060
&#0060
&#00060