Skip to content

Instantly share code, notes, and snippets.

View triangletodd's full-sized avatar

Todd Edwards triangletodd

View GitHub Profile
@triangletodd
triangletodd / bashorg_cowsay.sh
Created March 21, 2012 09:52
Random quote from bash.org in a random Cowsay template
#!/bin/bash
bashorg=$(curl -s http://bash.org/?random1|grep -oE "<p class=\"quote\">.*</p>.*</p>"|grep -oE "<p class=\"qt.*?</p>"|sed -e 's/<\/p>/\n/g' -e 's/<p class=\"qt\">//g' -e 's/<p class=\"qt\">//g'|perl -ne 'use HTML::Entities;print decode_entities($_),"\n"'|head -1)
files=($(cowsay -l|sed 's#Cow files in /usr/share/cowsay/cows:##'))
num_files=${#files[@]}
cowsay -f "${files[$((RANDOM%num_files))]}" ${bashorg}
unset bashorg files num_files
@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 / Changelog.yml
Last active August 19, 2016 16:36
Changelog - Class representation of a project's changelog
---
-
version: 5.2.2
version_code: 5000202
changes:
- Fixed an issue where some photo galleries would crash the app
- Photo credits added
- High res photos added to stories
- Other bug fixes
-
@triangletodd
triangletodd / fizzbuzz.rb
Last active December 12, 2020 22:43
Ruby Fizzbuzz
#!/usr/bin/env ruby
# Requires Ruby 2.1
# BUT.. Keeps the code clean without monkey patching
module Refinements
refine Integer do
def div_by?(int)
self % int == 0
end
end
@triangletodd
triangletodd / gdrive_to_yml.rb
Last active December 12, 2020 22:43
GDrive to YAML
#!/usr/bin/env ruby
require 'pry'
require 'yaml'
require 'google_drive'
GDRIVE_USER = ENV['GDRIVE_USER'] || raise('Please set the GDRIVE_USER environment variable')
GDRIVE_PASS = ENV['GDRIVE_PASS'] || raise('Please set the GDRIVE_USER environment variable')
YML_FILE = 'apple_app_info.yml'
data = {}
@triangletodd
triangletodd / debugging_ios_uiautomation.js
Last active December 12, 2020 22:44
IOS UIAutomation Debugging
function dumpElementTree() {
UIALogger.logStart("Logging element tree ...");
UIATarget.localTarget().logElementTree();
UIALogger.logPass();
}
function inspect(obj) {
var log = UIALogger;
var methods = [];
@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 / 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 / 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 / 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