TCP client and multithreaded server in 14 lines of Ruby code
require "socket" server = TCPServer.open(2626) loop do Thread.fork(server.accept) do |client| client.puts("Hello, I'm Ruby TCP server", "I'm disconnecting, bye :*")
|# wol.rb: sends out a magic packet to wake up your PC|
|# Copyright (c) 2004 zunda <zunda at freeshell.org>|
|# Modified by scharfie <scharfie at gmail dot com>|
|# This program is free software. You can re-distribute and/or|
|# modify this program under the same terms of ruby itself ---|
|# Ruby Distribution License or GNU General Public License.|
Cian Johnston, July 2017
A couple of weeks ago, I decided I should put my gaming rig to work crypto mining. I did not expect to make any significant profit on this, it was more of a fun project to set up. However, there were a large number of tutorials and guides already out there, and many were more than a year out of date.
This guide assumes the reader already has a crypto wallet set up, is comfortable with Linux and the command line, and knows how to use Google if they run into problems.
The end result is an Ubuntu 16.04 LTS headless server running CUDA ethminer via systemd.
|# post_loc.txt contains the json you want to post|
|# -p means to POST it|
|# -H adds an Auth header (could be Basic or Token)|
|# -T sets the Content-Type|
|# -c is concurrent clients|
|# -n is the number of requests to run in the test|
|ab -p post_loc.txt -T application/json -H 'Authorization: Token abcd1234' -c 10 -n 2000 http://example.com/api/v1/locations/|