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 |
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
#!/usr/bin/env ruby | |
require 'celluloid/io' | |
require 'json' | |
require 'websocket' | |
class WebsocketClient | |
include Celluloid::IO | |
def initialize(host, port) |
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
#!/usr/bin/env ruby | |
require 'celluloid/io' | |
require 'json' | |
require 'websocket' | |
class FileWriter | |
include Celluloid | |
def initialize |
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 'json' | |
require 'bson' | |
require 'msgpack' | |
require 'benchmark' | |
#require 'ruby_protobuf' | |
test_hash = {'string' => 'test string', 'float' => 5} | |
json_results = Benchmark.measure do | |
100_000.times do |
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 'tempfile' | |
require 'openssl' | |
require 'escape' # gem install escape | |
class CommandFailError < StandardError; end | |
def p12_to_pem_text(p12, pass='') | |
pass = '' if pass.nil? | |
# Use shell command for JRuby (see https://github.com/jruby/jruby-ossl/issues/8) |
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
# Due to recent concerns regarding password safety, Geoloqi has decided to publicly release the code | |
# that we use to do password hashing. After consulting with the community, this code now uses BCrypt for hashing | |
# (http://codahale.com/how-to-safely-store-a-password), which is based on blowfish, uses an integrated | |
# salting mechanism, and makes brute forcing expensive for attackers. It is widely used in the industry for | |
# production environments. | |
# | |
# Improvement suggestions are always welcome. Geoloqi takes security very seriously, and designs our systems to | |
# be as security-oriented as practically possible. We also believe in security transparency, because it leads to | |
# better security than obscurity, and is a more honest interaction with our customers. | |
# |