Skip to content

Instantly share code, notes, and snippets.

Avatar

Michael Bleigh mbleigh

View GitHub Profile
@mbleigh
mbleigh / .travis.yml
Created Oct 30, 2014
Octopress + Travis CI + Divshot
View .travis.yml
language: ruby
rvm:
- 2.1.0
script: bundle exec rake generate
deploy:
provider: divshot
environment:
master: development
staging: staging
production: production
View Alternative.rb
# I hear that aliasing lambda is bad, but this is
# much more readable...
alias :this_block :lambda
this_block{ @this.destroy }.should change(Thing, :count).by(-1)
View gist:26189
#!/usr/bin/perl
# Present.ly Post-Commit Hook for Git
# change your subdomain, username and password, then copy this file as .git/hooks/post-commit
# then 'chmod +x .git/hooks/post-commit'
# it'll run every time you commit (not push, mind you)
$project='Project Name'
$subdomain='yoursubdomain'
$username='username';
View gist:46651
>> ActionController::UrlWriter.default_url_options
=> {:host=>nil}
>> ActionController::UrlWriter.default_url_options[:host] = 'abc.com'
=> "abc.com"
>> ActionController::UrlWriter.default_url_options[:host]
=> "abc.com"
>>
View twitter_search_plus.user.js
// ==UserScript==
// @name Twitter Search Plus
// @namespace intridea
// @description Find replies to a tweet in the Twitter Search timeline with the click of a button.
// @include http://search.twitter.com/search*
// ==/UserScript==
// Add jQuery
var GM_JQ = document.createElement('script');
GM_JQ.src = 'http://jquery.com/src/jquery-latest.js';
View github-project-puller.js
jQuery.githubUser = function(username, callback) {
jQuery.getJSON("http://github.com/api/v1/json/" + username + "?callback=?", callback);
}
$.githubUser('mbleigh', function(data) {
$('#github-projects').html('');
var repos = data.user.repositories;
repos.sort(function(a,b) {
return b.watchers - a.watchers;
View .autotest
Autotest.add_hook :initialize do |at|
at.add_mapping(/app\/shared\/.*\.rb/) do
at.files_matching /^app\/shared\/spec\/(models)\/.*_spec\.rb/
end
end
View twitter_app.rb
app_name = ask("What is your application called?")
puts "\nBefore this generator runs you will need to register your Twitter application for OAuth at http://twitter.com/oauth_clients, then enter the consumer key and secret below:\n\n"
consumer_key = ask("OAuth Consumer Key:")
consumer_secret = ask("OAuth Consumer Secret:")
run "rm public/index.html"
run "rm public/images/rails.png"
run "rm README"
run "cp config/database.yml config/database.yml.example"
View gist:100161
class User < TwitterAuth::GenericUser
def refresh_twitter_attributes!
update_twitter_attributes(twitter.get('/account/verify_credentials'))
end
end
View gist:100269
# OptionsProxy creates a proxy object with attribute accessors
# and defaults.
options = OptionsProxy.new(:fancy, :name, {
:fancy => true
})
options.fancy # => true
options.name # => nil
You can’t perform that action at this time.