Skip to content

Instantly share code, notes, and snippets.

require 'endpoint_base'
require 'multi_json'
class HelloEndpoint < EndpointBase
post '/' do
process_result 200, { 'message_id' => @message[:message_id] }
end
post '/product_existence_check' do
passed_in_name = @message[:payload]['product']['name']
module DummyShip
def self.validate_address(address)
## Zipcode must be within a given range.
unless (20170..20179).to_a.include?(address['zipcode'].to_i)
raise "There was a problem with this address."
end
end
end
18670 futex(0x8510848, FUTEX_WAIT_PRIVATE, 56984, NULL <unfinished ...>
18687 clock_gettime(CLOCK_REALTIME, {1371052434, 447034689}) = 0
18687 munmap(0xb13bf000, 3411968) = 0
18687 write(56, "\25\3\1\0\30\355\336\10\343\222~\374\265\0[\365\351\240\352\351\203zHhO\342\251\37\372", 29) = -1 EBADF (Bad file descriptor)
18687 write(27, "\25\3\1\0\30\323\270n;\307\226\227\313Wr\2539\214\fT\375*\352\217\377\275\306{\277", 29) = 29
18687 read(27, <unfinished ...>
18682 <... ppoll resumed> ) = 1 ([{fd=83, revents=POLLIN}])
18682 futex(0x8510848, FUTEX_WAIT_PRIVATE, 56985, NULL <unfinished ...>
26949 <... select resumed> ) = 0 (Timeout)
26949 select(4, [3], NULL, NULL, {0, 100000}) = 0 (Timeout)
@phstc
phstc / test.rb
Last active December 18, 2015 05:49
=begin
~ ruby test.rb
n = 10000
user system total real
0.010000 0.000000 0.010000 ( 0.002855)
0.000000 0.000000 0.000000 ( 0.005343)
--
n = 20000
user system total real
0.010000 0.000000 0.010000 ( 0.005923)
#!/usr/bin/env bash
if [[ "${rvm_ruby_string}" =~ "jruby" ]]
then
export JAVACMD=`which drip`
export DRIP_INIT_CLASS=org.jruby.main.DripMain
# settings from: https://github.com/jruby/jruby/wiki/Improving-startup-time
export JRUBY_OPTS="-J-XX:+TieredCompilation -J-XX:TieredStopAtLevel=1 -J-noverify"
fi%
file = "#{File.expand_path File.dirname(__FILE__)}/dripmain_is_running.tmp"
File.open(file, "w") { |f| f.write("Yay") }
require_relative 'config/application'
# /etc/nginx/sites-available/app
upstream app_server {
server unix:/tmp/.unicorn_app.sock fail_timeout=0;
}
server {
listen 80;
server_name app.com;
@phstc
phstc / index.html
Last active December 14, 2015 16:38
Call me maybe
<ul id="user-list" data-token="eyJ0...">
<li>
Pablo Cantero - <a href="#" rel="phone-number">+551199...</a>
</li>
</ul>
# /usr/bin/notify-site-is-down.rb
require "rubygems"
require "twilio-ruby"
account_sid = ENV["TWILIO_ACCOUNT_SID"]
auth_token = ENV["TWILIO_AUTH_TOKEN"]
@client = Twilio::REST::Client.new account_sid, auth_token
### Environment variables ###
export PATH="/usr/local/bin:/usr/local/sbin:/opt/local/bin:/opt/local/sbin:/usr/local/mysql/bin:~:$PATH:."
export CDPATH=".:~:~/projects/personal:~/projects/sandbox"
export LANG="en_US.UTF-8"
export NODE_PATH="/usr/local/lib/node:/usr/local/lib/node_modules"
export CLICOLOR=1
export TERM=xterm-256color