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 'sinatra' | |
require 'geoloqi' | |
GEOLOQI_REDIRECT_URI = 'http://yourwebsite.net' | |
enable :sessions | |
configure do | |
Geoloqi.config :client_id => 'YOUR OAUTH CLIENT ID', :client_secret => 'YOUR CLIENT SECRET' |
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
### TEST 1: Simple Rack app RAW AND DUMB | |
class HelloRubinius | |
def call(env) | |
return [ | |
200, | |
{'Content-Type' => 'text/html'}, | |
['Hello #rbxday!'] | |
] | |
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
require 'rubygems' | |
require 'sinatra/base' | |
require 'kirk' | |
require 'ruby-debug' | |
run Sinatra.new { | |
get '/' do | |
# debugger | |
$stdout.puts 'Testing $stdout!' | |
$stderr.puts 'Testing $stderr!' | |
'hi' |
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
# This is Neocities' Rainbows! config file. We are using this in production to run all our web apps. | |
# It works really well for us and has been heavily load tested, so I wanted to share it with the community. | |
# | |
# In my opinion, this is the best way to deploy a ruby web application. Unlike EventMachine based solutions, | |
# it uses real ruby threads, which allows it to take advantage of the internal non-blocking IO pattern | |
# in MRI. | |
# | |
# Contrary to popular belief, MRI doesn't block execution to wait on IO when you are using threads, even | |
# with the GIL. The requests are done concurrently for anything that is based on the IO class. This | |
# includes things like Net::HTTP and even `system commands`. Grep the MRI Ruby source code for |
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 'aws/s3' | |
class D7Obj < AWS::S3::S3Object | |
set_current_bucket_to "kd-test" | |
end | |
class S3Handler | |
AWS::S3::Base.establish_connection!( | |
:access_key_id => 'ID', |
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
module Sequel | |
module ParanoidDelete | |
def self.included(base) | |
base.extend(ClassMethods) | |
end | |
# Instead of actually deleting, we just set is_deleted to true, | |
# and look for it with our default dataset filter. | |
def delete |
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
# Put this in a logrotate file (like /etc/logrotate.d/yourcompany): | |
/var/log/yourcompany/website.log | |
{ | |
daily | |
rotate 7 | |
compress | |
missingok | |
notifempty | |
sharedscripts | |
size 5M |
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
# This is a configuration script for using Rainbows with EventMachine. I'm providing it incase somebody finds it useful. But honestly, you | |
# should stop using EventMachine and use threads instead. The ThreadPool version of this is also in my gist list, and I recommend taking a look at that instead. | |
# NO, SERIOUSLY, STOP USING EVENTMACHINE. | |
Rainbows! do | |
name = 'yourappname' | |
use :EventMachine | |
client_max_body_size nil # This is set in nginx | |
# keepalive_timeout 1 |
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. | |
# |
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) |
OlderNewer