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
def run_concurrently(title, jobs, &block) | |
mutex = Mutex.new | |
work = Queue.new | |
jobs.each {|j| work << j} | |
pbar = ProgressBar.create(title: title, total: jobs.length, format: '%a |%w>%i| %e %t') | |
threads = 4.times.map do | |
Thread.new do | |
loop do | |
block.call(work.pop(:nonblocking)) | |
mutex.synchronize { pbar.increment } |
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
_hcl () { | |
local cur prev opts cmds tasks | |
COMPREPLY=() | |
cur="${COMP_WORDS[COMP_CWORD]}" | |
prev="${COMP_WORDS[COMP_CWORD-1]}" | |
opts="--help --version" | |
cmds="show tasks aliases set unset start stop resume note" | |
if [[ ${cur} == -* ]] ; then | |
COMPREPLY=($(compgen -W "${opts}" -- ${cur})) |
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
class TrueClass | |
def to_i | |
1 | |
end | |
end | |
class FalseClass | |
def to_i | |
0 | |
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
// ==UserScript== | |
// @name LGTM Button | |
// @namespace lgtm.github.com | |
// @description Add a LGTM button to pull requests. | |
// @include https://github.com/Skookum/*/pull/* | |
// @version 1 | |
// ==/UserScript== | |
var lgtmButton = document.createElement('button'), | |
buttonCont = document.querySelector('button[name="comment_and_close"]').parentNode, | |
commentBtn = buttonCont.querySelector('button:last-child'); |
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
Spree::User.joins('LEFT JOIN "spree_roles_users" ON "spree_roles_users"."user_id" = "spree_users"."id" LEFT JOIN "spree_roles" ON "spree_roles"."id" = "spree_roles_users"."role_id"').group('spree_users.id').having('count(spree_roles.id) = 0') |
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
function local_server() { | |
cp ~/lib/favicon.ico . | |
ruby -run -e httpd -- -b 127.0.0.1 -p 8080 . &> /dev/null & | |
local pid=$! | |
ngrok -subdomain=kennyp 8080 | |
kill $! | |
rm favicon.ico | |
} |
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
_make () { | |
local curw=${COMP_WORDS[COMP_CWORD]} | |
COMPREPLY=() | |
COMPREPLY=($(compgen -W "$(make -qp | grep : | grep '^[a-z]' | cut -d: -f1)" -- $curw)) | |
return 0 | |
} | |
complete -F _make make |
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
" Notes { | |
" vim: set foldmarker={,} foldlevel=0 spell: | |
" | |
" Kenny Parnell <[email protected]> | |
" } | |
" General { | |
execute pathogen#infect() | |
set background=dark | |
set cmdheight=2 |
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
# Sinatra/Ruby | |
[~]» wrk -t 12 -c400 -d30s http://127.0.0.1:4567/test | |
Running 30s test @ http://127.0.0.1:4567/test | |
12 threads and 400 connections | |
Thread Stats Avg Stdev Max +/- Stdev | |
Latency 215.89ms 283.31ms 1.06s 80.72% | |
Req/Sec 259.81 272.75 1.21k 84.97% | |
44630 requests in 30.11s, 9.92MB read | |
Socket errors: connect 0, read 0, write 0, timeout 4110 | |
Requests/sec: 1482.10 |
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
defmodule TestApp.PageController do | |
use Phoenix.Controller | |
plug :action | |
def test(conn, _params) do | |
conn |> text "OK" | |
end | |
end |