Skip to content

Instantly share code, notes, and snippets.

View gusgollings's full-sized avatar

Gus Gollings gusgollings

View GitHub Profile
// This snippet is an example on how the detecting overlaping annotations
// was implemented inside the Substance Composer app.
function annotate(type) {
// Check for existing annotation
var sel = this.surface.selection();
if (!sel) return;
if (_.include(["em", "str"], type)) {
#!/usr/bin/env ruby
require 'rubygems'
require 'sinatra'
require 'spira'
require 'rack/linkeddata'
use Rack::LinkedData::ContentNegotiation, :default => 'text/turtle'
include RDF
class SignupController < ActionController::Base
def step_two
@signup = Signup.find(params[:id])
@signup.advance_step do |signup|
signup.attributes = params[:signup]
signup.save!
end
end
end
require 'lib/usher'
u = Usher::Interface.for(:text) do
on('my name is :name') { |name|
puts "hey #{name}, nice to meet you"
}
on('hey :first_name( :last_name)') {|first_name, last_name|
puts last_name ?
"how are you doing #{first_name} #{last_name}?" :
# Make port 80 "real life" speeds
# You can also use Mongrel ports.
function slow_port {
# Set the port variable if no port inputted. Defaulted to 80 (for Passenger).
if [ -z "$1" ]
then port=80
else port=$1
fi
# Slow the ports.

Poor Man's Deploy

  • Start a Sinatra server on port 4000
  • GET / to that server triggers a git pull and mod_rails restart
  • Hit port 4000 locally after pushing

Why?

class AddAccountNotes < TableMigration
migrates :accounts, :multi_pass => false, :create_temp_table => false, :dry_run => false
schema_changes.push <<-SQL
ALTER TABLE :new_table_name
ADD COLUMN `notes` VARCHAR(255)
SQL
schema_changes.push <<-SQL
ALTER TABLE :new_table_name
// only outputs if console available and does each argument on its own line
function log() {
if (window && window.console && window.console.log) {
var i, len;
for (i=0, len=arguments.length; i<len; i++) {
console.log(arguments[i]);
}
}
}