Skip to content

Instantly share code, notes, and snippets.

@danvideo
danvideo / bottlesofbeer.rb
Last active January 7, 2020 03:00
X Bottles of Beer on the Wall
class BottlesOfBeer
def count_off
puts "How many bottles of beer have you got? "
numbers = gets.chomp.to_i
numbers.downto(1) do |number|
puts "#{number} bottles of beer on the wall, #{number} bottles of beer! Take one down, pass it around, #{number-1} bottles of beer on the wall!"
end
end
bottle = BottlesOfBeer.new
@danvideo
danvideo / talkio_email_parse.rb
Created December 23, 2013 21:23
grab recent email addresses listed in a talk.io chat room
require 'rest-client'
require 'json'
room_name = "INSERT_ROOM_NAME_HERE"
url = "http://tlk.io/" + room_name + "/messages"
result = RestClient.get(url)
parsed = JSON.parse result
parsed.each do |element|
# Compiled source #
###################
*.com
*.class
*.dll
*.exe
*.o
*.so
# Packages #
Final Projects from BEWD 5
Flash sale app
http://intense-stream-5307.herokuapp.com/
Ten Thousand Hours
http://infinite-basin-5033.herokuapp.com
Photobooth app
http://hidden-reaches-9583.herokuapp.com/
@danvideo
danvideo / s3.sh
Last active August 29, 2015 14:20 — forked from chrismdp/s3.sh
# You don't need Fog in Ruby or some other library to upload to S3 -- shell works perfectly fine
# This is how I upload my new Sol Trader builds (http://soltrader.net)
# Based on a modified script from here: http://tmont.com/blargh/2014/1/uploading-to-s3-in-bash
S3KEY="my aws key"
S3SECRET="my aws secret" # pass these in
function putS3
{
path=$1
@danvideo
danvideo / gist:8059473d654c43b7ce5342fb9f1ff98c
Created April 7, 2016 19:41 — forked from stuart11n/gist:9628955
rename git branch locally and remotely
git branch -m old_branch new_branch # Rename branch locally
git push origin :old_branch # Delete the old branch
git push --set-upstream origin new_branch # Push the new branch, set local branch to track the new remote
@danvideo
danvideo / System Design.md
Created April 19, 2016 13:59 — 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?
@danvideo
danvideo / latency.txt
Created November 17, 2016 19:36 — forked from jboner/latency.txt
Latency Numbers Every Programmer Should Know
Latency Comparison Numbers
--------------------------
L1 cache reference 0.5 ns
Branch mispredict 5 ns
L2 cache reference 7 ns 14x L1 cache
Mutex lock/unlock 25 ns
Main memory reference 100 ns 20x L2 cache, 200x L1 cache
Compress 1K bytes with Zippy 3,000 ns 3 us
Send 1K bytes over 1 Gbps network 10,000 ns 10 us
Read 4K randomly from SSD* 150,000 ns 150 us ~1GB/sec SSD
@danvideo
danvideo / haproxy.cfg
Created December 19, 2016 21:42 — forked from pedrocarrico/haproxy.cfg
Sample HAProxy configuration for testing in your local development environment
global
maxconn 4096
pidfile /tmp/haproxy-queue.pid
defaults
log global
mode http
timeout connect 300000
timeout client 300000
timeout server 300000
@danvideo
danvideo / udp-multi-socat.sh
Created December 21, 2016 17:41 — forked from mathieue/udp-multi-socat.sh
udp multiplexer with socat
socat - udp4-listen:8125,fork | tee >(socat - udp-sendto:127.0.0.1:8135) >(socat - udp-sendto:127.0.0.1:8140)