Skip to content

Instantly share code, notes, and snippets.

View xoebus's full-sized avatar
🤖
beep beep

Christopher Brown xoebus

🤖
beep beep
  • San Francisco, CA
View GitHub Profile
bosh_q9qlsff59@c08689bb-b559-41be-878c-77c0c4142497:~$ ifconfig
lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
inet6 addr: ::1/128 Scope:Host
UP LOOPBACK RUNNING MTU:65536 Metric:1
RX packets:16011 errors:0 dropped:0 overruns:0 frame:0
TX packets:16011 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:3830284 (3.8 MB) TX bytes:3830284 (3.8 MB)
@xoebus
xoebus / gist:5130970
Created March 10, 2013 23:20
Download and install the latest version of Chromium for Mac.
#!/bin/sh
# Install the latest Chromium mac nightly build, but only
# if it's different from the currently installed version.
set -e
build_url="http://commondatastorage.googleapis.com/chromium-browser-snapshots/Mac"
install_dir="/Applications/Chromium.app"
# determine the currently installed chromium build number
current=0
@xoebus
xoebus / gist:3141032
Created July 19, 2012 05:48
The Misuse of Pull-to-Refresh

I've noticed a worrying trend in the misuse of the Pull-to-Refresh interface paradigm. For those that are not familiar with it, Pull-to-Refresh is a common interface pattern that is used to refresh a list of items on mobile devices. The user pulls down while at the top of the list before releasing to trigger an update action. Pull-to-Refresh was devised by [Loren Brichter][loren] for use in the Tweetie iPhone application.

The brilliance in the design of Pull-to-Refresh is that the motion of pulling the list down is the exact same action that the user would perform if they were scrolling up to see more items above the current view. This allows it to be simple, fast, discoverable and, above all, downright genius.

It's a testament to the brilliance of this interface element that it has become so widely used among iOS applications (even Apple has conceded and added it to the Mail application in iOS 6). Unfortunately, in the hurry to use it in their applications, some developers are putting it in places where it

@xoebus
xoebus / grades.rb
Created June 14, 2012 16:28
Get your UoE Exam Grades - MEGA HACKY
# Get your UoE grades.
# Usage: ruby grades.rb <username> <password>
require 'mechanize'
require 'terminal-table'
require 'rainbow'
agent = Mechanize.new
agent.user_agent_alias = 'Mac Safari'
@xoebus
xoebus / pester.rb
Created June 13, 2012 18:20
Pester Proxy
class PesterProxy
def initialize(target, methods={})
@__pester_target = target
@__pester_limit = methods
@__pester_count = Hash.new
methods.keys.each { |key| @__pester_count[key] = 0 }
end
def method_missing(sym, *args, &block)
@xoebus
xoebus / markov.rb
Created May 28, 2012 21:52
*Very* Hack-y Markov Chain Sentence Generator
#!/usr/bin/env ruby
# Usage: markov.rb [tweet|irc] [FILE]
# Trains on the FILE based on the formatting given in the first argument.
#
# tweet - parses the t twitter gem csv output
# irc - parses the standard irssi log
#
class MarkovChain
def initialize(words)
loop { p eval gets }
@xoebus
xoebus / primes.rb
Created May 14, 2012 20:31
Prime Sieve
#!/usr/bin/env ruby
def print_primes(n)
return if (n < 2)
primes = []
(2..n).each do |i|
is_prime = primes.none? { |prime| i % prime == 0}
primes << i if is_prime
#!/usr/bin/env sh
# A twitter backup script.
function line_count {
echo `cat $1 | wc -l | sed -e 's/^[ \t]*//'`
}
# Setup
mkdir -p `pwd`/archives
@xoebus
xoebus / magic-lists.rb
Created April 21, 2012 15:53
A Ruby Version of Steve Losh's Lightning Talk at BACON 2012: Pulling Lists out of Thin Air
# Pulling List's out of Thin Air
# Ruby Implementation of Steve Losh's Lightning Talk at BACON 2012
def prepend item, list
->(h) {
return h ? item : list
}
end
def head list