This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from sanic import response, Sanic | |
from sanic.exceptions import SanicException | |
from sanic.request import Request | |
from sanic.response import HTTPResponse | |
# NOTE: This error should only be raised after add_custom_error_handler() | |
# has been called to register a custom error handler on the | |
# currently-running app. | |
class CustomSanicException(SanicException): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Example: ruby read_multiple_streams.rb a <(for x in $(seq 10); do echo $x; sleep 1; done) <(echo bs98dfh8dhf9dshfdshf9shdf98shd98fshd98fhs98fhds) asdf <(sleep 2; echo ababababababababababababababababababababab) | |
io_objects = [] | |
ARGV.each do |arg| | |
if arg =~ /^\/dev\/fd\/[0-9]+$/ | |
io_objects << IO.new(IO.sysopen(arg)) | |
end | |
end | |
ARGV.clear |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'socket' | |
require 'io/wait' # Provides socket#ready? | |
require 'timeout' | |
if ARGV.length != 1 | |
abort 'Usage: ruby p2p_chat.rb their_ip_address' | |
end | |
my_port = 2000 | |
their_host = ARGV[0] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Below, "telnet curl" means curl telnet://localhost:8080/ | |
# "http curl" means curl http://localhost:8080/ | |
# telnet curl is sometimes used here because it approximates a raw tcp mode for | |
# curl. On OS X telnet curl waits for more input on the client side, not sure | |
# why. Linux telnet curl exits immediately, which is desirable for these tests. | |
require 'socket' | |
file_counter = 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# SQLite version 3.x | |
# gem install sqlite3 | |
# | |
# Ensure the SQLite 3 gem is defined in your Gemfile | |
# gem 'sqlite3' | |
development: | |
adapter: sqlite3 | |
database: db/development.sqlite3 | |
pool: 5 | |
timeout: 5000 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'open-uri' | |
require 'csv' | |
require 'pry' | |
file1 = '/tmp/1-1000.txt' | |
file2 = '/tmp/4000-most-common-english-words-csv.csv' | |
if File.exist?(file1) | |
words1 = File.read(file1).split | |
else | |
uri1 = URI.parse('https://gist.githubusercontent.com/deekayen/4148741/raw/01c6252ccc5b5fb307c1bb899c95989a8a284616/1-1000.txt') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class A | |
attr_accessor :b | |
def initialize | |
b = 1 | |
end | |
def foo | |
p b | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | |
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> | |
<modelVersion>4.0.0</modelVersion> | |
<groupId>io.github.vinietskyzilla</groupId> | |
<artifactId>my-app</artifactId> | |
<packaging>jar</packaging> | |
<version>1.0-SNAPSHOT</version> | |
<name>my-app</name> | |
<url>http://maven.apache.org</url> | |
<build> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ RAILS_ENV=development bundle exec pumactl -F /var/www/puma_config.rb start | |
Puma starting in single mode... | |
* Version 2.11.2 (rbx 2.1.0), codename: Intrepid Squirrel | |
* Min threads: 0, max threads: 16 | |
* Environment: development | |
* Daemonizing... | |
$ RAILS_ENV=development bundle exec pumactl -F /var/www/puma_config.rb start | |
Puma starting in single mode... | |
* Version 2.11.2 (rbx 2.1.0), codename: Intrepid Squirrel | |
* Min threads: 0, max threads: 16 |
NewerOlder