Skip to content

Instantly share code, notes, and snippets.

@pgdaniel
pgdaniel / simple_util.rb
Created August 1, 2014 23:39
my fun spinner
module SimpleUtil
# Simple class to show status via stdout on really long rake tasks
class Spinner
attr_accessor :position
def initialize
@position = 0
@status_marker = ['|', '/', '-', '\\']
$stdout.sync = true
end
@thebengeu
thebengeu / change_crashplan_backup_service_port.sh
Last active February 2, 2016 21:58
Change CrashPlan Backup Service Port (Default 4243 Conflicts with Docker / boot2docker)
#!/bin/sh
PORT=4200
sudo launchctl unload /Library/LaunchDaemons/com.crashplan.engine.plist
sudo sed -i '' "s/\(<servicePort>\)[^<]*/\1$PORT/" /Library/Application\ Support/CrashPlan/conf/my.service.xml
sed -i '' "s/#*\(servicePort=\).*/\1$PORT/" /Applications/CrashPlan.app/Contents/Resources/Java/conf/ui.properties
defaults write /Applications/CrashPlan.app/Contents/Resources/CrashPlan\ menu\ bar.app/Contents/Info CPPort $PORT
sudo launchctl load /Library/LaunchDaemons/com.crashplan.engine.plist
@bloudermilk
bloudermilk / memoized-helper-methods.md
Last active June 20, 2024 23:35
Explaining the rationale behind using memoized helper methods for controller resources

Last year I started playing around with using memoized private helper methods in my controllers instead of the traditional instance variable assigns we see in RoR controllers. Here's an example:

class PostsController < ApplicationController
  helper_method :new_post, :post, :posts
  
  def new; end
  def show; end
  def edit; end
 def index; end
@xively-gists
xively-gists / xively.conf
Last active December 17, 2015 16:58
Upstart config for Xively Raspberry Pi tutorial
# Upstart config file for Xively Raspberry Pi tutorial
#
# This file should be saved into /etc/init/xively.conf
description "xively tutorial example"
# start the daemon on system boot, and stop on shutdown
start on runlevel [2345]
stop on runlevel [!2345]
@tehpeh
tehpeh / db.rake
Created September 17, 2012 02:05
Enable hstore on rake db:schema:load
namespace :db do
namespace :enable do
desc "enable hstore extension"
task :hstore => [:environment, :load_config] do
ActiveRecord::Base.connection.execute('CREATE EXTENSION IF NOT EXISTS hstore;')
end
end
Rake::Task['db:schema:load'].enhance ['db:enable:hstore']
end
@terryjray
terryjray / gist:3296171
Created August 8, 2012 15:55
Enabling hstore for new postgresql 9.1 and rails 3 install on ubuntu 12.04
RAILS_ENV=production rake db:setup
# produces the error below.....hmmm.....it's a no-worky
psql:/yourprojectpath/yourproject/db/structure.sql:29: ERROR: could not open extension control file "/usr/share/postgresql/9.1/extension/hstore.control": No such file or directory
# hstore postgresql extension needs to be installed, so....
sudo apt-get install postgresql-contrib
# now your extension should be available to enable so log in with psql
psql -d yourproject_production -U yourdbuser -W
@inopinatus
inopinatus / hstore_accessor.rb
Last active June 29, 2024 17:26
hstore accessor class method for AR
# include from an initializer
module HstoreAccessor
def self.included(base)
base.extend(ClassMethods)
end
module ClassMethods
def hstore_accessor(hstore_attribute, *keys)
Array(keys).flatten.each do |key|
@nbqx
nbqx / cmd.coffee
Created January 24, 2012 06:19
hubot script test - exec any command
# hubot-scripts test
# usage:
# hubot cmd ls -la
#
fs = require('fs')
spawn = require('child_process').spawn
module.exports = (robot) ->
robot.respond /(cmd) (.*) (.*)/i, (msg) ->
cmd = msg.match[2]
arg = msg.match[3]
/*!
* jQuery Tiny Pub/Sub - v0.6 - 1/10/2011
* http://benalman.com/ see https://gist.github.com/661855
*
* Copyright (c) 2010 "Cowboy" Ben Alman
* Dual licensed under the MIT and GPL licenses.
* http://benalman.com/about/license/
*
* (removed pre 1.4.3 support, added $.pubsubdebug())
*/