Skip to content

Instantly share code, notes, and snippets.

@jasonroelofs
jasonroelofs / master.bench
Created May 30, 2014 20:24
Liquid benchmarking comparing render profiling changes
Ruby 2.1.2 -- Master
$ ruby ./performance/benchmark.rb lax
Rehearsal ------------------------------------------------
parse: 4.180000 0.030000 4.210000 ( 4.205455)
parse & run: 8.670000 0.010000 8.680000 ( 8.687521)
-------------------------------------- total: 12.890000sec
user system total real
parse: 4.100000 0.020000 4.120000 ( 4.112649)
class Something
def
def my_method
puts "I got: #{my_method}"
end
end
s = Something.new
s.def("something")

Keybase proof

I hereby claim:

  • I am jasonroelofs on github.
  • I am jasonroelofs (https://keybase.io/jasonroelofs) on keybase.
  • I have a public key whose fingerprint is 97E0 6FE4 76E9 6B2E 1C02 03FA 9EB6 09A6 1157 F583

To claim this, I am signing this object:

@jasonroelofs
jasonroelofs / snitch.java
Created January 27, 2014 19:58
Simple Snitching in Java
// Using raw java.net.*
URL obj = new URL("https://nosnch.in/[snitch code]?m=[message]");
HttpURLConnection con = (HttpURLConnection) obj.openConnection();
con.setRequestMethod("GET");
con.getResponseCode();
// Apache HttpComponents http://hc.apache.org/httpcomponents-client-ga/quickstart.html
CloseableHttpClient httpclient = HttpClients.createDefault();
HttpGet httpGet = new HttpGet("https://nosnch.in/[snitch code]?m=[message]");
CloseableHttpResponse response1 = httpclient.execute(httpGet);
@jasonroelofs
jasonroelofs / simple-recurly.coffee
Created January 23, 2014 16:49
Simple Recurly.js. For when you want the "transparent redirect" but none of the form generation.
# Ripped from recurly.js
createObject = (o) ->
F = ->
F.prototype = o
return new F()
$ ->
$(".recurly-form").submit (e) ->
e.preventDefault()
$form = $(this)
@jasonroelofs
jasonroelofs / cli_plea.rb
Last active February 7, 2018 15:53
Is there any Ruby Command Line Parsing library out there that JUST DOES PARSING?
# The ones I've tried (almost all from http://www.awesomecommandlineapps.com/gems.html):
#
# OptParse -- Doesn't support commands
# Commander -- Everything is about procs
# Trollop -- Doesn't support commands
# GLI -- Relies on calling a proc
# Methadone -- See GLI
# Main -- Seems to require the use of a #run method or proc
# Thor -- Focused on running methods, resulting code very difficult to read
# CRI -- Requires #run method or proc (seeing a pattern here...)
require 'celluloid'
class TestActor
include Celluloid
def initialize
@handlers = []
end
def add_handler(&block)
class Minitest::Test
alias assert_not_nil refute_nil
alias assert_not refute
end
@jasonroelofs
jasonroelofs / gist:5951363
Created July 8, 2013 18:42
My current prompt
parse_git_branch() {
git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/(\1)/'
}
parse_git_dirty () {
if [[ $((git status 2> /dev/null) | tail -n1) = "" ]]; then
echo ""
elif [[ $((git status 2> /dev/null) | tail -n1) != "nothing to commit (working directory clean)" ]]; then
echo "✗"
else
@jasonroelofs
jasonroelofs / solo.rb
Last active December 14, 2015 05:59
Chef-Solo config doesn't match command line options. The following give me two different log outputs.
The command line options give me exactly the log output I want, old Chef 10 with enough info and not too verbose. One line per action, no printing of the templates being rendered
$ chef-solo --force-logger --log_level info
...
[2013-02-26T15:54:06+00:00] INFO: Processing service[syslog-ng] action enable (syslog-ng::default line 30)
[2013-02-26T15:54:06+00:00] INFO: Processing service[syslog-ng] action start (syslog-ng::default line 30)
[2013-02-26T15:54:06+00:00] INFO: Processing package[logrotate] action upgrade (logrotate::default line 1)
[2013-02-26T15:54:06+00:00] INFO: Processing package[sudo] action upgrade (sudo::default line 1)