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
var request = require('request'); | |
function Bitcoind(url) { | |
this.url = url; | |
}; | |
Bitcoind.prototype.rpc = function(method, params, callback) { | |
this.request({jsonrpc: '2.0', method: method, params: params}, callback); | |
}; |
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
decode_raw_tx = do -> | |
{ Transaction, TransactionIn, TransactionOut } = Bitcoin | |
{ bytesToBase64 } = Crypto.util | |
# Parse an bytearray of length `size` as an integer | |
# Works for numbers up to 32-bit only | |
parse_int = (size) -> (bytes) -> | |
n = 0 | |
n += (bytes.shift() & 0xff) << (8 * i) for i in [0...size] |
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
net.ipv4.tcp_max_syn_backlog = 3240000 | |
net.core.somaxconn = 3240000 | |
net.ipv4.tcp_max_tw_buckets = 1440000 | |
net.core.rmem_default = 8388608 | |
net.core.rmem_max = 16777216 | |
net.core.wmem_max = 16777216 | |
net.ipv4.tcp_rmem = 4096 87380 16777216 | |
net.ipv4.tcp_wmem = 4096 65536 16777216 | |
net.ipv4.tcp_congestion_control = cubic | |
net.core.netdev_max_backlog = 30000 |
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
```ruby | |
require 'fileutils' | |
require 'securerandom' | |
2_000_000.times do |site| | |
site_name = SecureRandom.hex[0...20] | |
puts site_name | |
Dir.mkdir File.join('./', 'sites', site_name) | |
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
ssl_ciphers ECDHE-RSA-AES128-SHA256:AES128-GCM-SHA256:RC4:HIGH:!MD5:!aNULL:!EDH; |
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
server { | |
root /home/web/neocities-web/public; | |
server_name neocities.org www.neocities.org; | |
# location ~* \.(jpg|jpeg|png|gif|ico|css|js)$ { | |
# expires 60s; | |
# log_not_found off; | |
# } | |
try_files $uri @neocities; |
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
# So, the idea here is to take USERNAME.neocities.org, and have it serve | |
# from /home/web/neocities/public/sites/USERNAME/REQUESTED_FILENAME | |
# When I try to use it, I get in error.log: | |
# invalid number of arguments in "try_files" directive in /etc/nginx/sites-enabled/neocities:5 | |
server { | |
root /home/web/neocities/public/sites; | |
server_name neocities.org www.neocities.org ~^(?<subdomain>.+)\.neocities.org$; |
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 'openssl' | |
public_key = OpenSSL::PKey::RSA.new(File.read('./public.pem')) | |
cipher = OpenSSL::Cipher::Cipher.new('aes-256-cbc') | |
cipher.encrypt | |
cipher.key = random_key = cipher.random_key | |
cipher.iv = random_iv = cipher.random_iv | |
encrypted_data = cipher.update('SSN number') | |
encrypted_data << cipher.final |
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 'rbnacl' | |
# Idea for storing an SSN (or CC#, or anything confidential) on a database, preventing an attacker from looking at it by hiding the private key on an offline machine. | |
# Private key would be generated somewhere other than the web application. | |
private_key = Crypto::PrivateKey.generate | |
# Given to a web application: |
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 'rubygems' | |
require 'bundler' | |
Bundler.require | |
require './application' | |
namespace :assets do | |
desc 'compile assets' | |
task :compile => [:compile_js, :compile_css] do | |
end |