Skip to content

Instantly share code, notes, and snippets.

View marceldegraaf's full-sized avatar

Marcel de Graaf marceldegraaf

View GitHub Profile
@marceldegraaf
marceldegraaf / deploy.rb
Created September 14, 2012 17:11
Only run assets:precompile when assets have been changed
namespace :deploy do
namespace :assets do
task :precompile, :roles => :web, :except => { :no_release => true } do
precompile_command = %Q{cd #{latest_release} && #{rake} RAILS_ENV=#{rails_env} #{asset_env} assets:precompile}
if remote_file_exists?("#{current_path}/REVISION")
from = source.next_revision(current_revision)
if capture("cd #{latest_release} && #{source.local.log(from)} vendor/assets/ app/assets/ | wc -l").to_i > 0
run precompile_command
else
@marceldegraaf
marceldegraaf / gist:1316486
Created October 26, 2011 14:16
Pull disruptions from the NS (Dutch Railways) API and send them to Campfire
# A way to interact with the NS (Dutch Railways) API
#
# To configure, add NS_API_EMAIL and NS_API_PASSWORD to your Heroku config with "heroku config:add"
#
# train disruptions <station> - Retrieve the list of disruptions near <station>.
# Please note: <station> can be a station code (e.g. 'asd')
# or (part of) a station name (e.g. 'Amsterdam Centraal')
#
disruptionPageRoot = 'http://www.ns.nl/storingen/index.form#'
module.exports = (robot) ->
machine git.hostname.com
login johndoe
password supersecret
en_gb: &definitions
cake: lie
huge: success
en_us:
<<: *definitions
class ItemsController < ApplicationController
include JsonParams
def index
@items = Item.all
respond_to do |format|
format.json { render :json => @items.to_json }
end
end
"
" APIdock search for word under cursor
"
let g:browser = 'open -a /Applications/Google\ Chrome.app '
" On OSX - let g:browser = 'open -a /Applications/Firefox.app'
" Open the Ruby ApiDock page for the word under cursor, in a new Firefox tab
function! OpenRubyDoc(keyword)
let url = 'http://apidock.com/ruby/search/quick?query='.a:keyword
exec '!'.g:browser.' '.url.' &'
function! RemoveTrailingWhiteSpaces()
" Remove ALL trailing whitespaces
%s/\s\+$//
endfunction
noremap WW :call RemoveTrailingWhiteSpaces()<CR>
require 'worker'
require 'resque/tasks'
# In lib/query/base_query.rb
#
def to_params
params = {}
if @keywords
params[:q] = @keywords
params[:fl] = '* score'
params[:fq] = types_phrase
params[:qf] = text_field_names.join(' ')
params[:defType] = 'dismax'
namespace :csv do
desc "Makes sure all rows have a trailing ;"
task :cleanup do
file, new_file = ENV['FILE'], ENV['NEWFILE']
raise "Provile valid FILE and NEWFILE, e.g. FILE=./lib/prospects.csv" unless file or new_file
lines, new_file = File.open(file), File.open(new_file, 'wb')
lines.each_line do |line|
unless line.strip.last == ";"
line = line.strip + ";#{$/}"