Skip to content

Instantly share code, notes, and snippets.

View simeonwillbanks's full-sized avatar
☀️
😎

Simeon Willbanks simeonwillbanks

☀️
😎
View GitHub Profile
@simeonwillbanks
simeonwillbanks / client.rb
Last active January 25, 2023 17:49
Faraday, Minitest, and VCR
# frozen_string_literal: true
require "faraday"
require "faraday/retry"
require "httpx/adapters/faraday"
module App
class Client
def connection
Faraday.new(url) do |f|
# https://github.com/lostisland/faraday-retry#usage
@simeonwillbanks
simeonwillbanks / gist_fork_of.js
Last active September 8, 2022 00:03
GitHub API discussion - filter associations via url. #api #github
// $ curl -i https://api.github.com/gists/4567703/fork_of
//
// HTTP/1.1 200 OK
// Server: GitHub.com
// Date: Wed, 23 Jan 2013 17:05:28 GMT
// Content-Type: application/json; charset=utf-8
// Connection: keep-alive
// Status: 200 OK
// X-Content-Type-Options: nosniff
// Cache-Control: public, max-age=60, s-maxage=60
class Cool
def self.yeah
":yesparty:"
end
end
puts Cool.yeah
@simeonwillbanks
simeonwillbanks / app.js.coffee
Last active June 25, 2019 06:32
#AngularJS templates and #rails with eager loading -- prefill the AngularJS $templateCache. Inspired by @minhajuddin -- http://minhajuddin.com/2013/04/28/angularjs-templates-and-rails-with-eager-loading
# /code/railsapp/app/assets/javascripts/thing/app.js.coffee
#= require angular/templates
angular.module("thing", ["app.templates"]).value("appName", "thing")
#!/usr/bin/env bash
say "I'll do my best" && sleep 0.5 && say "To rhyme without rest"
@simeonwillbanks
simeonwillbanks / barrier.rb
Created January 24, 2014 18:04
Create resource contention. http://rubygems.org/gems/barrier "barrier", "~> 1.0.0" #gem #ruby
require 'thread'
# A synchronization barrier enables multiple threads to wait until all threads
# have all reached a particular point of execution before any thread
# continues.
class Barrier
# Initialize new barrier. The _count_ argument specifies the number of threads
# that must call #wait before any of them successfully return from the call.
# The value specified by _count_ must be greater than zero.
@simeonwillbanks
simeonwillbanks / benchmark.rb
Last active January 3, 2016 07:19
Copy Hash #ruby #benchmark
require 'benchmark'
puts "\n\n"
puts RUBY_VERSION
iterations = 100_000
Benchmark.bmbm do |bm|
bm.report 'Hash#dup' do
WHITELIST1 = { :protocols => { :from => 'constant' } }
@simeonwillbanks
simeonwillbanks / .vimrc
Created January 10, 2014 16:21 — forked from robmiller/.vimrc
#writing #TechWordsToAvoid #vim
highlight TechWordsToAvoid ctermbg=red ctermfg=white
autocmd FileType markdown match TechWordsToAvoid /\c\<\(obviously\|basically\|simply\|of\scourse\|clearly\|just\|everyone\sknows\|however\|so,\|easy\)\>/
autocmd BufWinEnter *.md match TechWordsToAvoid /\c\<\(obviously\|basically\|simply\|of\scourse\|clearly\|just\|everyone\sknows\|however\|so,\|easy\)\>/
autocmd InsertEnter *.md match TechWordsToAvoid /\c\<\(obviously\|basically\|simply\|of\scourse\|clearly\|just\|everyone\sknows\|however\|so,\|easy\)\>/
autocmd InsertLeave *.md match TechWordsToAvoid /\c\<\(obviously\|basically\|simply\|of\scourse\|clearly\|just\|everyone\sknows\|however\|so,\|easy\)\>/
autocmd BufWinLeave *.md call clearmatches()
@simeonwillbanks
simeonwillbanks / byebye.sh
Created December 18, 2013 03:14
Kill development processes #bash #ruby
$ export BYEBYE=ruby
$ ps x | grep $BYEBYE | cut -d' ' -f1 | xargs kill -9
@simeonwillbanks
simeonwillbanks / bulk.sh
Created October 2, 2013 18:20
Redis Bulk Operations #redis #xargs #wc #unix
# Count all keys which match a wildcard from database 1
redis-cli -n 1 KEYS "foo:*" | wc -l
# Delete all keys which match a wildcard from database 1
redis-cli -n 1 KEYS "foo:*" | xargs redis-cli -n 1 DEL