Skip to content

Instantly share code, notes, and snippets.

Brian Storti brianstorti

Block or report user

Report or block brianstorti

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@brianstorti
brianstorti / timing
Created Mar 14, 2018
timing - script to prefix stdout with the executing time
View timing
#!/usr/bin/env bash
# Usage:
# $ command | timing
#
# Example:
# $ rails server | timing
# 00:00:00 | rails server -b 0.0.0.0
# 00:00:04 | => Booting Puma
# 00:00:04 | => Rails 5.1.3 application starting in development on http://0.0.0.0:3000
View preload.rb
begin
require 'bundler/inline'
rescue LoadError => e
$stderr.puts 'Bundler version 1.10 or later is required. Please update your Bundler'
raise e
end
gemfile(true) do
source 'https://rubygems.org'
# Activate the gem you are reporting the issue against.
@brianstorti
brianstorti / gist:4f0c4ff0b5cfc092aa7f5a5f187b6f8b
Created Apr 7, 2016
rabbitmq_delayed_message_exchange.log
View gist:4f0c4ff0b5cfc092aa7f5a5f187b6f8b
=ERROR REPORT==== 7-Apr-2016::21:31:31 ===
Error on AMQP connection <0.3317.0> (127.0.0.1:49193 -> 127.0.0.1:5672, vhost: '/', user: 'guest', state: running), channel 1:
{{{undef,
[{time_compat,erlang_system_time,[milli_seconds],[]},
{rabbit_delayed_message,internal_delay_message,4,
[{file,"src/rabbit_delayed_message.erl"},{line,179}]},
{rabbit_delayed_message,handle_call,3,
[{file,"src/rabbit_delayed_message.erl"},{line,118}]},
{gen_server,try_handle_call,4,[{file,"gen_server.erl"},{line,607}]},
{gen_server,handle_msg,5,[{file,"gen_server.erl"},{line,639}]},
View stacktrace
{
"query" => "\"\\n query IntrospectionQuery {\\n __schema {\\n queryType { name }\\n mutationType { name }\\n types {\\n ...FullType\\n }\\n directives {\\n name\\n description\\n args {\\n ...InputValue\\n }\\n onOperation\\n onFragment\\n onField\\n }\\n }\\n }\\n\\n fragment FullType on __Type {\\n kind\\n name\\n description\\n fields(includeDeprecated: true) {\\n name\\n description\\n args {\\n ...InputValue\\n }\\n type {\\n ...TypeRef\\n }\\n isDeprecated\\n deprecationReason\\n }\\n inputFields {\\n ...InputValue\\n }\\n interfaces {\\n ...TypeRef\\n }\\n enumValues(includeDeprecated: true) {\\n name\\n description\\n isDeprecated\\n deprecationReason\\n }\\n possibleTypes {\\n ...TypeRef\\n }\\n }\\n\\n fragment InputValue on __InputValue {\\n name\\n de
View gist:45d9742c3a20233d42a0
Java Virtual Machine statistics monitoring tool (jstat -options for all the options)
$ jstat -gcutil process_id 1000
S0 -> Survivors 0
S1 -> Survivors 1
E -> Eden
O -> Old
P -> Perm
YGC -> Young GC
@brianstorti
brianstorti / priority_queue.rb
Last active Oct 29, 2019
Priority queue implementation in Ruby
View priority_queue.rb
class PriorityQueue
attr_reader :elements
def initialize
@elements = [nil]
end
def <<(element)
@elements << element
bubble_up(@elements.size - 1)
View gist:2237e30386817287ace4
Generated with:
rvm-restart
rvm get head
echo 1.26.4 >| $rvm_path/VERSION
rvm-restart
(
export PS4="+ %* %F{red}%x:%I %F{green}%N:%i%F{white} %_"
set -o xtrace
rvm --trace install 2.2.0 2>&1 | tee big.log
View gist:8a2b96c65457905829bb
Found old RVM 1.26.4 - updating.
Downloading https://get.rvm.io
No GPG software exists to validate rvm-installer, skipping.
Downloading https://github.com/wayneeseguin/rvm/archive/master.tar.gz
Upgrading the RVM installation in /Users/brianstorti/.rvm/
RVM PATH line found in /Users/brianstorti/.bashrc /Users/brianstorti/.zshrc.
RVM sourcing line found in /Users/brianstorti/.bash_profile /Users/brianstorti/.zlogin.
Upgrade of RVM in /Users/brianstorti/.rvm/ is complete.
@brianstorti
brianstorti / client.rb
Created Dec 10, 2014
dumb client/server socket
View client.rb
require 'socket'
class Client
private
attr_reader :host, :port
public
def initialize(host, port)
@host, @port = host, port
end
@brianstorti
brianstorti / rack_middleware.rb
Last active Aug 29, 2015
Example rack middlewares
View rack_middleware.rb
class Canadianize
def initialize(app, arg = "")
@app = app
@arg = arg
end
def call(env)
status, headers, content = @app.call(env)
content[0] += @arg + ", eh?"
[ status, headers, content ]
You can’t perform that action at this time.