Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View yb66's full-sized avatar
🤔
Wondering if Github is going to become a fully fledged social network

Iain Barnett yb66

🤔
Wondering if Github is going to become a fully fledged social network
View GitHub Profile
@yb66
yb66 / cacert-refresh.plist
Last active February 20, 2021 04:33
Refresh/check cacert once every week to keep curl updated
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<!-- Run the cacert refresh once a week -->
<!-- ~/Library/LaunchAgents/cacert-refresh.plist -->
<plist version="1.0">
<dict>
<key>Label</key>
<string>cacert-refresh</string>
<key>EnableGlobbing</key>
# Because I don't like being tracked by Facebook around the web
# This function, which I load via my ~/.zshrc,
# - takes the url on the clipboard (when run)
# - decodes the querystring to find the original link
# - removes the FB id from the resulting query string
# - pops it back onto the clipboard
fb-uri(){
str=${1:-`pbpaste`}
ruby -W0 -ruri -r'rack/utils' -e "print URI(Rack::Utils.parse_query(URI('$str').query)['u']).then{|uri| %Q(#{uri.scheme}://#{uri.host}#{uri.path}#{ (hs = Rack::Utils.parse_query(uri.query).reject{|k,_| k == 'fbclid'}).empty? ? '' : %Q(?#{Rack::Utils.build_query hs}) }) }" | pbcopy
}
@yb66
yb66 / bench_str_building.rb
Last active March 20, 2019 05:06 — forked from alno/bench_str_building.rb
Benchmark: interpolation vs concatenation in Ruby
require 'benchmark'
count = 1_000_000
Benchmark.bmbm do |bm|
bm.report("to_s + ") { count.times { 11.to_s + '/' + 12.to_s } }
bm.report("+ ") { count.times { "11" + '/' + "12" } }
bm.report('#{} to_s ') { count.times { "#{11}/#{12}" } }
bm.report('#{} ') { count.times { %Q!#{"11"}/#{"12"}! } }
bm.report("to_s << ") { count.times { 11.to_s << "/" << 12.to_s } }
bm.report("<< ") { count.times { "11" << "/" << "12" } }
@yb66
yb66 / yb66.pem
Created January 15, 2019 07:38
yb66's Ruby gem signing certificate
-----BEGIN CERTIFICATE-----
MIIEbjCCAtagAwIBAgIBATANBgkqhkiG9w0BAQsFADAwMS4wLAYDVQQDDCVoZWxw
ZnVsLWlhaW4vREM9dGhlcHJpbnRlZGJpcmQvREM9Y29tMB4XDTE5MDExNTA3MjAw
OVoXDTIwMDExNTA3MjAwOVowMDEuMCwGA1UEAwwlaGVscGZ1bC1pYWluL0RDPXRo
ZXByaW50ZWRiaXJkL0RDPWNvbTCCAaIwDQYJKoZIhvcNAQEBBQADggGPADCCAYoC
ggGBALhp1KlrdriWAuhXhM3I0oZblbOUAgk8UZSyI6vLQ4oK8uHWmdBkrzUublq4
7cU1T0IIFeKOzjN2aXS660q2Ev7Bpwt1oBjMVqLMZYJM4gixwzXW9labQhnjefEy
CTWRa/i4gL8NbwOg/UeX5rHiCy/xaqyxj//24E7m5e72JrpK11ZZ5/4TUvxDfOJr
w+16BAxH3ELBRjXoOXnlb7SzA2ohNnwuoom5gi9Ju6z0ooSa9cegqauHBbme8wgO
5bPwGi+MbiLKoMDcnakuUoKqWL6qA+/QofNnrmtgBmMe08dd9/ermztT/dBdNQiE

Keybase proof

I hereby claim:

  • I am yb66 on github.
  • I am iainb (https://keybase.io/iainb) on keybase.
  • I have a public key ASBMPFBvFnJ5Uzq_5zUgktL0pK8uomtYcnFoVATS5iC6xgo

To claim this, I am signing this object:

@yb66
yb66 / luhn.rb
Last active April 23, 2018 23:08
Luhn algorithm with the broken Syncthing implementation
# Implemented because Syncthing (kind of) uses it
# @example
# @luhn = Luhn.new Base32.table
# @luhn.check_character "P56IOI7MZJNU2"
# # => "S"
class Luhn
def initialize alphabet
@alphabet = alphabet
@table_alpha = Hash[ @alphabet.split(//).zip(0 .. @alphabet.length - 1) ]
@table_code = Hash[ (0 .. @alphabet.length - 1).zip(@alphabet.split(//))]
#!/usr/bin/env ruby
require 'optparse'
require 'pathname'
require 'psych'
options = {}
optparse = OptionParser.new do |opts|
@yb66
yb66 / app.rb
Created April 15, 2013 15:33
Shared *and* individual configuration in Sinatra.
require 'sinatra'
configure :development do
set :one, 1
end
configure :production do
set :one, 11
end
@yb66
yb66 / app.rb
Created January 21, 2013 12:40 — forked from Heliosmaster/app.rb
require 'sinatra'
require 'haml'
class Something
def self.all( h= {} )
[]
end
def self.get( id=1 )
obj = Object.new
class << obj