Skip to content

Instantly share code, notes, and snippets.

View triangletodd's full-sized avatar

Todd Edwards triangletodd

View GitHub Profile
@triangletodd
triangletodd / benchmark_tr_vs_gsub.rb
Created September 23, 2016 20:33
Ruby tr vs. gsub
#!/usr/bin/env ruby
require 'benchmark/ips'
SLUG = 'writing-fast-ruby'
def slow
SLUG.gsub('-', ' ')
end
def fast
@triangletodd
triangletodd / soma.rb
Last active December 12, 2020 22:42
Ruby SOMA.fm
#!/usr/bin/env ruby
$:.push(File.expand_path('../', __FILE__))
require 'soma_fm'
puts SomaFM.to_json
@triangletodd
triangletodd / http_server.rb
Last active December 12, 2020 22:42
Ruby HTTP Server
#!/usr/bin/env ruby
require 'pry'
require 'rack'
require 'thin'
class TestingServer
def self.start
builder = Rack::Builder.new { run Rack::Directory.new('') }
Rack::Handler::Thin.run builder, :port => 3000
end
@triangletodd
triangletodd / working_verify_slack.go
Created February 7, 2019 23:29
Golang Verify Slack
package middlewares
import (
"crypto/hmac"
"crypto/sha256"
"encoding/hex"
"github.com/gin-gonic/gin"
)
@triangletodd
triangletodd / .bash_colors
Created December 13, 2018 19:16
Bash Colors
#!/usr/bin/env bash
#░█ ██ ██
#░█ ░██ ░░
#░█ █████ ██████ ░██ ██████ ██████ ██ ██████ █████
#░█ ██░░░██ ██░░░░██ ░██ ██░░░░██░░██░░█░██░░░░██ ██░░░██
#░█ ░██ ░░ ░██ ░██ ░██░██ ░██ ░██ ░ ░██ ██ ░███████
#░█ ░██ ██░██ ░██ ░██░██ ░██ ░██ ░██ ██ ░██░░░░
#░█ ░░█████ ░░██████ ███░░██████ ░███ ░██ ██████░░██████
#░█ ░░░░░ ░░░░░░ ░░░ ░░░░░░ ░░░ ░░ ░░░░░░ ░░░░░░
@triangletodd
triangletodd / feature_flipper.rb
Last active December 12, 2020 22:41
Ruby Feature Flipper
#!/usr/bin/env ruby
require 'redis'
require 'flipper'
require 'flipper/adapters/redis'
class Feature
ENABLED = Flipper::Actor.new(true)
DISABLED = Flipper::Actor.new(false)
def initialize
@triangletodd
triangletodd / keybase.md
Last active December 12, 2020 22:41
Keybase proof

Keybase proof

I hereby claim:

  • I am triangletodd on github.
  • I am triangletodd (https://keybase.io/triangletodd) on keybase.
  • I have a public key ASBIK4ohhlMTNaunJK6ta18ibDLO7SUNbJJrTswY9S9n8go

To claim this, I am signing this object:

@triangletodd
triangletodd / whatthecommit.sorted.log
Last active December 12, 2020 22:41
What the Commit
- Temporary commit.
#GrammarNazi
(\ /)<br/>(O.o)<br/>(&gt; &lt;) Bunny approves these changes.
(c) Microsoft 1988
-m \'So I hear you like commits ...\'
.
...
/sigh
640K ought to be enough for anybody
8==========D
@triangletodd
triangletodd / gce_ip_ranges.log
Last active November 8, 2019 13:12
Google Compute Engine GCE IP Ranges
8.34.208.0/20
8.35.192.0/21
8.35.200.0/23
23.236.48.0/20
23.251.128.0/19
35.184.0.0/14
35.188.0.0/15
35.190.0.0/17
35.190.128.0/18
35.190.192.0/19
@triangletodd
triangletodd / cloudflare.inc.sh
Created November 5, 2019 06:35
Bash functions for interacting with the Cloudflare v4 API
#!/usr/bin/env bash
export CF_CURL_OPTS=()
export CF_V4_API='https://api.cloudflare.com/client/v4'
_cf_exit() {
# if being called directly, don't exit
if [ ${#FUNCNAME[@]} -eq 0 ]; then
return 1
fi
exit 1