Skip to content

Instantly share code, notes, and snippets.

@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>
# /etc/nginx/sites-available/app
upstream app_server {
server unix:/tmp/.unicorn_app.sock fail_timeout=0;
}
server {
listen 80;
server_name app.com;
file = "#{File.expand_path File.dirname(__FILE__)}/dripmain_is_running.tmp"
File.open(file, "w") { |f| f.write("Yay") }
require_relative 'config/application'
#!/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%
@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)
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)
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
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']
require 'benchmark'
# $ ruby -v
# => ruby 1.9.3p392 (2013-02-22 revision 39386) [x86_64-darwin12.2.0]
#
# N.times { |i| RINDEX.deconstantize(A::B::C::D.name) }
# user system total real
# rindex 0.160000 0.000000 0.160000 ( 0.164055)
# gsub 0.580000 0.010000 0.590000 ( 0.683018)
#
# lib/augury/queues/incoming.rb
def self.push(messages)
messages = normalize_and_validate(messages)
messages.each do |msg|
# insert message into mongo collection
collection.insert(msg.inspect)