Skip to content

Instantly share code, notes, and snippets.

View ajsharp's full-sized avatar

Alex Sharp ajsharp

View GitHub Profile
@ajsharp
ajsharp / email_example.rb
Last active August 29, 2015 14:01
This describes two potential API for running jobs in the future. One is a simple, abstract job, where the logic lives in your application, and is triggered via a webhook at the scheduled time. The other is a SMS notification that is due to fire at some point in the future.
# Often times we need to send emails on a delayed basis. We could make this really easy on the client
# side by automatically mounting an endpoint with rack middleware, and firing the mailer with the
# arguments supplied.
#
# Under the hood, this would use the same architecture as an abstract job, where a webhook is hit
# at the specified time, but by focusing on the email / action mailer use case the client doesn't need
# to write any boilerplate code.
Tick::EmailJob.create!(
:at => appointment.start_time - 1.hour,
:message => "Don't forget, your appointment starts in 1 hour!",
@ajsharp
ajsharp / heroku-env-to-opsworks
Created April 23, 2015 00:38
This handy little script makes it super easy to add all your heroku environment configuration to an AWS Opsworks app. Very handy if you're moving off Heroku and onto opsworks.
#!/usr/bin/env ruby
require 'json'
app_name = 'APP_NAME'
opsworks_app_id = 'APPID'
config = `heroku config -s --app #{app_name}`.strip
json = []
@tmm1
tmm1 / gist:450736
Created June 23, 2010 23:36
patch to add sequel support to a new rails3 app
diff --git a/app/models/model.rb b/app/models/model.rb
new file mode 100644
index 0000000..14c4620
--- /dev/null
+++ b/app/models/model.rb
@@ -0,0 +1,2 @@
+class Model < Sequel::Model
+end
\ No newline at end of file
diff --git a/config/application.rb b/config/application.rb
require 'spec/runner/formatter/progress_bar_formatter'
class NescafeFormatter < Spec::Runner::Formatter::ProgressBarFormatter
def example_failed(example, counter, failure)
super
dump_failure(counter, failure)
end
end
#!/usr/bin/env ruby
begin
require 'rev'
rescue LoadError
puts "############## WARNING!!! ##############"
puts "You do not have the rev gem installed.\nIt is highly recommended to install this."
puts "The rev gem uses filesystem events rather than cpu polling to see if files have changed."
puts "\n"
puts "Please run `gem install rev` to install"
# require 'rubygems'
['wirble-0.1.3', 'awesome_print-0.2.1'].each do |g|
$:.unshift("/usr/local/lib/ruby/gems/1.8/gems/#{g}/lib")
end
require 'ap'
require 'wirble'
Wirble.init
Wirble.colorize
@ajsharp
ajsharp / airbrakeapp.com.js
Created August 17, 2011 23:48
DotJS script to create github issues from AirbrakeApp error pages
// NOTE: You need dotjs installed to use this: https://github.com/defunkt/dotjs
//
// You must name this file with your airbrakeapp subdomain prepended to the filename.
// Example: So myairbrakesubdomain.airbrakeapp.com.js
var login = "<GITHUB USERNAME>";
var token = "<GITHUB TOKEN>";
var title = $("#notice_heading h2").text();
var link = document.location.href;
@ajsharp
ajsharp / losangeles.craigslist.org.js
Created August 25, 2011 21:39
Craigslist live filtering
// Adds a live filter box to the results screen on craigslist
// that filters the results that are currently on the page by
// the search term. Like Cmd-F, but better.
// NOTE: Requires dotjs.
// Cmd-F live search
var searchBox = $('<input type="text" id="result-search" />')
$("h4.ban:first").before(searchBox)
@ajsharp
ajsharp / fading_nav.js
Last active October 6, 2015 00:43
Fading navbar implementation on http://frothlogic.com
$(window).on('scroll', function() {
var scrollY = window.scrollY;
var $jumbotron = $('.jumbotron');
var $nav = $('nav:first');
var fullBlack = $jumbotron.height() - $jumbotron.position().top;
var blackNess = (scrollY / fullBlack);
$nav.css({'background-color' : 'rgba(0,0,0,'+blackNess+')'});
});
@mjallday
mjallday / example.py
Created October 23, 2012 22:38
Balanced - Minimum fields for a business
import balanced
import random
balanced.configure('7b7a51ccb10c11e19c0a026ba7e239a9') # test marketplace
business = {
'type': 'business',
'name': 'Bobs Used Auto Emporium',