Skip to content

Instantly share code, notes, and snippets.

@timothyandrew
timothyandrew / README.md
Last active December 16, 2023 17:05
Set up a seedbox (on DigitalOcean – Ubuntu) really quick

Introduction

  • This script lets you set up and use a temporary DigitalOcean droplet to download torrent files.
  • Once downloaded, they can be streamed down to your local machine.
  • This uses transmission-cli for the torrent client, and nginx to serve files.

Setup on Local Machine

  • This assumes that you have a DigitalOcean account and tugboat set up, as well as seedbox-setup.sh present in the current directory.
int add(int a, int b) {
if(b == 0) return a;
b--;
return 1 + add(a, b);
}
int subtract(int a, int b) {
if(b == 0) return a;
b--;
return subtract(a, b) - 1;
int add(int a, int b) {
if(b == 0) return a;
return 1 + add(a, b - 1);
}
int subtract(int a, int b) {
if(b == 0) return a;
return subtract(a, b - 1) - 1;
}
void swap(int a, int b, int* ref1, int* ref2) {
*ref2 = a;
*ref1 = b;
}
int subtract(int a, int b) {
if(b == 0) return a + 1;
return a + subtract(a, b - 1);
}
void swap(int a, int b, int* ref1, int* ref2) {
*ref2 = a;
*ref1 = b;
}
int main() {
int a = 5, b = 10;
swap(a, b, &a, &b);
printf("%d\n%d\n", a,b);
class Chest
attr_reader :type, :index, :keys
def initialize(array, index)
@type = array.shift.to_i
@keys = array.shift(array.shift.to_i).map(&:to_i)
@index = index
end
def unlock
@keys
@timothyandrew
timothyandrew / moth_podcast_scrape.rb
Created September 19, 2012 20:53
Scrape (links for) archived episodes of the Moth Podcast from podcast-directory.co.uk
require 'rubygems'
require 'mechanize'
def fetch_podcast_links_from_index_page(index_link)
agent = Mechanize.new
agent.get(index_link)
story_links = agent.page.links.find_all { |l| l.text.include? ':' }
story_links.map do |link|
link.click
@timothyandrew
timothyandrew / bootstrap_zsh.sh
Created July 18, 2012 18:43
Vagrant Setup Shell Script
#ZSH
echo "installing zsh"
sudo apt-get install -y zsh
#Git
echo "installing git"
sudo apt-get install -y git-core
#Oh My Zsh
echo "installing oh-my-zsh"
@timothyandrew
timothyandrew / inv_fizzbuzz.rb
Created May 5, 2012 07:27
Inverse Fizzbuzz
def fizzbuzz(n)
str = ""
str << (n % 3 == 0 ? "fizz" : "")
str << (n % 5 == 0 ? "buzz" : "")
end
list = ["fizz", "fizz", "buzz"]
arr = (1..100).map { |n| [n, fizzbuzz(n)] }.reject { |h| h.last.empty? }
res = arr.each_slice(list.length).to_a.find_all do |slice|
@timothyandrew
timothyandrew / image.png
Created November 18, 2011 16:31
Instagram Engineering Challenge
image.png