It reads your torrents. Spit out magnet URIs.
$ ./magneto.rb magneto.rb.torrent
Results in:
# From a fresh install of squeeze | |
apt-get install ruby rubygems # Need ruby to use fpm | |
gem1.8 install fpm --no-ri --no-rdoc | |
apt-get install build-essential openssl libreadline6 libreadline6-dev zlib1g zlib1g-dev libssl-dev ncurses-dev libyaml-dev | |
wget ftp://ftp.ruby-lang.org/pub/ruby/1.9/ruby-1.9.3-p125.tar.gz | |
tar -zxvf ruby-1.9.3-p125.tar.gz | |
cd ruby-1.9.3-p125 | |
rm -rf /tmp/ruby193 |
source "https://rubygems.org" | |
gem "sinatra" | |
gem "tilt-jbuilder", ">= 0.4.0", :require => "sinatra/jbuilder" | |
gem "hashie" |
#!/bin/sh | |
# Install Java-8 | |
sudo add-apt-repository ppa:webupd8team/java -y | |
sudo apt-get update | |
sudo apt-get install oracle-java8-installer | |
# Install Maven-3 | |
cd ~/Downloads/ | |
wget http://mirror.rackcentral.com.au/apache/maven/maven-3/3.2.5/binaries/apache-maven-3.2.5-bin.tar.gz |
/** ********************************************************* | |
* API - Model - User | |
********************************************************* */ | |
module.exports = function (sequelize, DataTypes) { | |
return sequelize.define('User', { | |
username: DataTypes.STRING, | |
password: DataTypes.STRING, | |
firstName: DataTypes.STRING, | |
lastName: DataTypes.STRING, |
It reads your torrents. Spit out magnet URIs.
$ ./magneto.rb magneto.rb.torrent
Results in:
HTML and Sinatra really only support the GET and the POST methods. In order to be able to use the PUT and DELETE methods in Sinatra, you kind of have to "trick" the form to go to the right place. Then you can name the routes the proper way - otherwise you can only really work with GET and POST.
I used the Craiglist Jr challenge for some examples. Let's look at a quick example of a POST form/method/route- in this case, we're creating a new Craigslist article:
POST form and corresponding route:
<form action="/article/new" method="post">
--------------------------------
YOUR FORM FIELDS HERE
$:.unshift File.expand_path(File.dirname(__FILE__)) | |
require "viz" | |
run Sinatra::Application |
# 1) Create your private key (any password will do, we remove it below) | |
$ cd ~/.ssh | |
$ openssl genrsa -des3 -out server.orig.key 2048 | |
# 2) Remove the password | |
$ openssl rsa -in server.orig.key -out server.key |
import sys | |
import time | |
from watchdog.observers import Observer | |
from .events import ImagesEventHandler | |
class ImagesWatcher: | |
def __init__(self, src_path): | |
self.__src_path = src_path | |
self.__event_handler = ImagesEventHandler() |