Skip to content

Instantly share code, notes, and snippets.

View justinxreese's full-sized avatar
:shipit:
hello

Justin Reese justinxreese

:shipit:
hello
View GitHub Profile
@justinxreese
justinxreese / mute.php
Created September 8, 2010 12:18
Script to mute Mac OSX via a web browser
<html>
<head>
<title>Mute My Mac</title>
<link href="muteIcon.png" rel="apple-touch-icon">
</head>
<body>
<?php exec("osascript -e \"set Volume 0\""); ?>
<h1>Mac Muted!</h1>
@justinxreese
justinxreese / time_to_float.rb
Created April 12, 2011 15:41
Convert time to a float
# If you come across the need to store time as a float in ruby (I won’t judge you),
# you can use this bit of code. It assumes that each subpart of the time string is
# 60 parts of the previous part. This works for hours, minutes and seconds,
# regardless of how it is entered, and will always use the first "part" as the base
# measurement, i.e. 12:30 minutes becomes 12.5 minutes
j = 0
timer = 0
@justinxreese
justinxreese / download_pages.rb
Created April 12, 2011 15:44
Limit open threads in ruby
# Pretty simple solution to harness the capability of multithreading without running into problems
# caused by doing too many things at once.
# In this example, I was trying to download hundreds of web pages, but opening all those connections
# simultaneously caused a variety of errors
# Contains download_link(link,save_dir,save_name) to download and save webpages locally (irrelevant)
require 'download_page'
# keep the threads in here
@justinxreese
justinxreese / domain_check.rb
Created April 12, 2011 15:46
Domain availability check
# Check to see if a domain is available (unregistered)
def available?(domain_name)
# Use Net::DNS library via ruby gems
require 'rubygems'
require 'net/dns/resolver'
res = Net::DNS::Resolver.new
# Use Google public DNS for speed
res.nameservers = ["8.8.8.8","8.8.4.4"]
res.udp_timeout=(60)
@justinxreese
justinxreese / api_call.js
Created April 12, 2011 15:55
Turn any PHP file into an API
var http = false;
if(navigator.appName = "Microsoft Internet Explorer"){
http = new ActiveXObject("Microsoft.XMLHTTP");
} else {
http = new XMLHttpRequest();
}
function doSomething(some_param){
http.abort();
@justinxreese
justinxreese / fizzbuzz.rb
Created September 16, 2011 15:37
FizzBuzz
1.upto(100){|n|p n%15==0&&"fizzbuzz"||n%5==0&&'buzz'||n%3==0&&'fizz'||''}
- line_item.ordered_values.each do |val|
"blah"
@justinxreese
justinxreese / gist:3436694
Created August 23, 2012 13:40
RVM Y U NO WORK
09:35 AM jreese@Macintosh-2 (ruby-1.9.3-p194) ~/redacted
$ bundle exec rspec
bash: bundle: command not found
09:36 AM jreese@Macintosh-2 (ruby-1.9.3-p194) ~/redacted
$ rvm use system
Now using system ruby.
09:36 AM jreese@Macintosh-2 (system) ~/redacted
$ bundle exec rspec
module Spree
class PaymentMethod::Accpac < PaymentMethod
attr_accessible :preferred_client_id, :preferred_client_secret
#preference :client_id, :integer
#preference :client_secret, :string
def payment_profiles_supported?
false
end
@justinxreese
justinxreese / gist:5247372
Last active December 15, 2015 10:39
bank-account.html log
pid-57053 thread-4502503424 (CP Server Thread-7) Traceback (most recent call last):
pid-57053 thread-4502503424 (CP Server Thread-7) File "/Users/jreese/Dropbox/Code/python/www.gittip.com/env/lib/python2.7/site-packages/aspen/website.py", line 66, in handle_safely
pid-57053 thread-4502503424 (CP Server Thread-7) response = self.handle(request)
pid-57053 thread-4502503424 (CP Server Thread-7) File "/Users/jreese/Dropbox/Code/python/www.gittip.com/env/lib/python2.7/site-packages/aspen/website.py", line 99, in handle
pid-57053 thread-4502503424 (CP Server Thread-7) response = request.resource.respond(request)
pid-57053 thread-4502503424 (CP Server Thread-7) File "/Users/jreese/Dropbox/Code/python/www.gittip.com/env/lib/python2.7/site-packages/aspen/resources/dynamic_resource.py", line 47, in respond
pid-57053 thread-4502503424 (CP Server Thread-7) exec self.pages[1] in context
pid-57053 thread-4502503424 (CP Server Thread-7) File "/Users/jreese/Dropbox/Code/python/www.gittip.com/www/bank-acco