It reads your torrents. Spit out magnet URIs.
$ ./magneto.rb magneto.rb.torrent
Results in:
source :rubygems | |
gem 'sinatra' | |
gem 'json' | |
gem 'omniauth' | |
gem 'omniauth-oauth2' | |
gem 'omniauth-github' | |
# gem 'omniauth-att', :path => File.expand_path("./../../omniauth-att", __FILE__) | |
gem 'thin' |
guard 'shell' do | |
watch(/relation_tree_spec\.rb/) { `clear && ruby relation_tree_spec.rb` } | |
end |
It reads your torrents. Spit out magnet URIs.
$ ./magneto.rb magneto.rb.torrent
Results in:
source "https://rubygems.org" | |
gem "sinatra" | |
gem "tilt-jbuilder", ">= 0.4.0", :require => "sinatra/jbuilder" | |
gem "hashie" |
# 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 |
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
#!/bin/sh | |
# Install Java-8 | |
#sudo add-apt-repository ppa:webupd8team/java -y | |
#sudo apt-get update | |
#echo oracle-java8-installer shared/accepted-oracle-license-v1-1 select true | sudo /usr/bin/debconf-set-selections | |
#echo oracle-java9-installer shared/accepted-oracle-license-v1-1 select true | sudo /usr/bin/debconf-set-selections | |
#sudo apt-get install oracle-java8-installer oracle-java9-installer oracle-java9-set-default | |
sudo apt-get install openjdk-8-jdk |
import random | |
class TicTacToe: | |
def __init__(self, playerX, playerO): | |
self.board = [' ']*9 | |
self.playerX, self.playerO = playerX, playerO | |
self.playerX_turn = random.choice([True, False]) | |
def play_game(self): |
Ref : stackoverflow
The best solution in my opinion is to use the unittest
[command line interface][1] which will add the directory to the sys.path
so you don't have to (done in the TestLoader
class).
For example for a directory structure like this:
new_project
├── antigravity.py