It reads your torrents. Spit out magnet URIs.
$ ./magneto.rb magneto.rb.torrent
Results in:
cable: WEB_CONCURRENCY=0 PORT=28080 bundle exec puma config/cable.ru |
<?php | |
// Config | |
$host = '127.0.0.1'; | |
$port = 0; // Random port | |
// Setup | |
$socket = socket_create(AF_INET, SOCK_STREAM, SOL_TCP); | |
$clients = array(); | |
// Bind, listen and disable blocking |
require 'net/http' | |
require 'uri' | |
def download(url) | |
Thread.new do | |
thread = Thread.current | |
body = thread[:body] = [] | |
url = URI.parse url | |
Net::HTTP.new(url.host, url.port).request_get(url.path) do |response| |
require 'rack' | |
class Object | |
def to_webapp | |
def self.call(env) | |
func, *attrs = env['PATH_INFO'].split('/').reject(&:empty?) | |
[200, {}, send(func || :inspect, *attrs)] | |
end | |
self | |
end |
class Fixnum | |
# Runs a block, catching any exceptions matching the exceptions in the | |
# input parameters. After +self+ number of tries, the exception is | |
# re-raised and the attempts will terminate. | |
# | |
# @yield +self+ | |
# @param [Exception, …] exs Exceptions that will be caught and recovered from. | |
# @return Whatever the block returns. | |
def tries(*exs) | |
exs = [StandardError] if exs.empty? |
superman 127.0.0.1 Kim whoami | |
database 127.0.0.1 Kim sleep 1 && echo "Database says Hello!" | |
localhost 127.0.0.1 Kim date |
It reads your torrents. Spit out magnet URIs.
$ ./magneto.rb magneto.rb.torrent
Results in:
##################################################################### | |
# BTT Octopus Pin Aliases | |
# See https://github.com/VoronDesign/VoronUsers/tree/master/firmware_configurations/klipper/revnull/btt_octopus_pins | |
##################################################################### | |
[board_pins] | |
aliases: | |
# Stepper drivers | |
MOT0_EN=PF14, MOT0_STEP=PF13, MOT0_DIR=PF12, MOT0_CS=PC4, # MOTOR0 | |
MOT1_EN=PF15, MOT1_STEP=PG0, MOT1_DIR=PG1, MOT1_CS=PD11, # MOTOR1 |
# Ruby Thread Pool | |
# ================ | |
# A thread pool is useful when you wish to do some work in a thread, but do | |
# not know how much work you will be doing in advance. Spawning one thread | |
# for each task is potentially expensive, as threads are not free. | |
# | |
# In this case, it might be more beneficial to start a predefined set of | |
# threads and then hand off work to them as it becomes available. This is | |
# the pure essence of what a thread pool is: an array of threads, all just | |
# waiting to do some work for you! |
import class Foundation.NotificationCenter | |
import struct Foundation.Notification | |
/* | |
Swift does not allow us to have static members of a generic class, which | |
means we won't be able to use the dot short hand for any method that takes | |
an Event<T> as parameter. | |
However, we can work around this by having a superclass, `Events`, and then | |
inherit it from it in our `Event<T>`. Any static members of `Events` will |