Skip to content

Instantly share code, notes, and snippets.

View technicalpickles's full-sized avatar

Josh Nichols technicalpickles

View GitHub Profile
@technicalpickles
technicalpickles / main.go
Last active February 23, 2024 16:50
lefthook stdin capture reproduction WIP for https://github.com/evilmartians/lefthook/issues/588
package main
import (
"context"
"io"
"os"
"os/exec"
"github.com/creack/pty"
)
@technicalpickles
technicalpickles / benchmark.rb
Last active September 11, 2023 21:25
Bundler::Settings#[] benchmark, see https://github.com/rubygems/rubygems/pull/6923
require "benchmark/ips"
require "benchmark/memory"
require 'bundler'
class Bundler::Settings
def original(name)
key = key_for(name)
value = configs.values.map {|config| config[key] }.compact.first
converted_value(value, name)
@technicalpickles
technicalpickles / benchmark.rb
Created August 24, 2023 13:30
AbstractController::Base#action_methods benchmark
# frozen_string_literal: true
require 'action_controller'
require 'benchmark/ips'
require 'benchmark/memory'
puts "ActionPack.version = #{ActionPack.version}"
module Actions
def foo
end
@technicalpickles
technicalpickles / benchmark.rb
Last active August 15, 2023 17:13
Benchmarking Net::HTTPHeader#capitalize
# frozen_string_literal: true
require 'benchmark/ips'
require 'benchmark/memory'
def original(name)
name.to_s.split(/-/).map {|s| s.capitalize }.join('-')
end
def string(name)
name.to_s.split('-').map {|s| s.capitalize }.join('-')
@technicalpickles
technicalpickles / benchmark.rb
Created August 8, 2023 21:43
Ruby performance: caller vs caller(1, n) vs stack_frame gem
require 'benchmark/ips'
require 'stack_frames'
STACK_FRAMES_BUFFER = StackFrames::Buffer.new(500)
def recurse(n, &block)
if n > 0
recurse(n - 1, &block)
else
yield
njero - http://neverlet.be
sutto - http://blog.ninjahideout.com
zapnap - http://blog.zerosum.org
tpope - http://tpope.net
reinh - http://reinh.com
bryanl - http://smartic.us
linoj - http://www.vaporbase.com
technicalpickles - http://technicalpickles.com
MaD15 - enlightsolutions.com/
qrush - http://litanyagainstfear.com/
@technicalpickles
technicalpickles / inspector
Last active November 8, 2020 20:59
hubot with debugging
#!/bin/bash
set -e
for opt in $* ; do
case "$opt" in
--debug) hubot_debug="coffee --nodejs --debug";;
esac
done
@technicalpickles
technicalpickles / deploy.rb
Created August 28, 2009 04:57
Capistrano recipe for using yaml_db to pull data into local database
namespace :db do
task :pull do
run "cd #{current_release} && RAILS_ENV=#{rails_env} rake db:data:dump"
download "#{current_release}/db/data.yml", "db/data.yml"
`rake db:reset db:data:load`
end
end
# Using Sonic-Pi
samps = "/Users/technicalpickles/Dropbox/sonicpi-samples/"
##| use_bpm 120
define :mario_waha do |options={}|
options ||= {}
sample samps, "mlpit_mario_waha.wav", options
end
@technicalpickles
technicalpickles / it.coffee
Created June 19, 2015 15:02
hubot script example with test
# Description:
# Get help from @yourorg/it for your information technology problems. Oh by the way.... Your Welcome.
#
# Commands:
# hubot it me <problem> - get help from @yourorg/it about your information technology <problem>
module.exports = (robot) ->
robot.respond /it(?: me)?(?: (.*))?/i, (msg) ->
problem = msg.match[1]