Skip to content

Instantly share code, notes, and snippets.

@urbanautomaton
urbanautomaton / core.clj
Last active August 29, 2015 14:02
Overtone code to play the amen break
(ns amen.core
(:require [overtone.live :refer :all]))
(def snare (freesound 26903))
(def crash (freesound 26884))
(def ride (freesound 26889))
(def kick (freesound 26888))
(def amen-tabs
[{:sound crash, :tab "----------------|----------------|----------------|----------x-----"}
@urbanautomaton
urbanautomaton / example
Last active August 29, 2015 14:19
Set GOPATH and PATH if .goworkspace present
$ echo $GOPATH
$ echo $PATH
/bin:/usr/bin:/usr/local/bin
$ mkdir -p /tmp/some_project
$ touch /tmp/some_project/.goworkspace
$ cd /tmp/some_project
$ echo $GOPATH
/tmp/some_project
$ echo $PATH
302 Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping.
72 Extra empty line detected at block body end.
71 Extra empty line detected at block body beginning.
52 Extra empty line detected at class body beginning.
47 Final newline missing.
45 Extra empty line detected at class body end.
40 Align the operands of an expression in an assignment spanning multiple lines.
35 Extra blank line detected.
22 Trailing whitespace detected.
22 Tab detected.
scss:
enabled: false
ruby:
config_file: .ruby-style.yml
javascript:
config_file: .jshintrc
module Paperclip
class Padder < Thumbnail
def transformation_command
super + ["-gravity center",
"-background white",
"-extent", %["#{geometry_extent}"]]
end
def geometry_extent
"#{target_geometry.width.to_i}x#{target_geometry.height.to_i}"
class User < ActiveRecord::Base
has_attached_file :image,
:styles => {
:large => "280x280#",
:medium => "130x130#",
:small => "50x50#",
:tiny => "30x30#" },
:processors => [:thumbnail, :timestamper],
:date_format => "%Y%m%d%H%M%S"
end
@urbanautomaton
urbanautomaton / Timestamper.rb
Created March 22, 2011 14:40
Simple Paperclip Processor to timestamp attachment filenames on upload
module Paperclip
class TimeStamper < Processor
def initialize(file, options={}, attachment=nil)
super(file,options,attachment)
timestamp_filename
end
def timestamp_filename
original_filename = attachment.instance_read(:file_name)
extension = File.extname(original_filename)
@urbanautomaton
urbanautomaton / gist:972217
Created May 14, 2011 13:38
ActiveAdmin join scope error: stack trace
Mysql2::Error: Column 'id' in order clause is ambiguous: SELECT COUNT(*) AS count_all, users.id AS users_id FROM `users` LEFT JOIN followings ON users.id = followings.followee_id GROUP BY users.id WHERE COUNT(followings.followee_id) > 10 ORDER BY id desc
activerecord (3.0.7) lib/active_record/connection_adapters/abstract_adapter.rb:207:in `rescue in log'
activerecord (3.0.7) lib/active_record/connection_adapters/abstract_adapter.rb:199:in `log'
mysql2 (0.2.6) lib/active_record/connection_adapters/mysql2_adapter.rb:314:in `execute'
mysql2 (0.2.6) lib/active_record/connection_adapters/mysql2_adapter.rb:635:in `select'
activerecord (3.0.7) lib/active_record/connection_adapters/abstract/database_statements.rb:7:in `select_all'
activerecord (3.0.7) lib/active_record/connection_adapters/abstract/query_cache.rb:54:in `block in select_all'
activerecord (3.0.7) lib/active_record/connection_adapters/abstract/query_cache.rb:68:in `cache_sql'
activerecord (3.0.7) lib/active_record/connection_adapters/abstract/query_cac
module LayoutHelper
def page_description
description = case
when @question then @question.background
when @user && @user.bio.present? then @user.bio
when @user && @user.sports.present? then @user.sports_list
when @user && !@user.new_record? then "Tribesports user: #{@user.short_name}"
when @topic then @topic.body
when @tribe then @tribe.description
# -*- encoding: utf-8 -*-
Gem::Specification.new do |s|
s.name = %q{draper}
s.version = "0.7.0"
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
s.authors = ["Jeff Casimir"]
s.date = %q{2011-08-17 00:00:00.000000000Z}
s.description = %q{Draper reimagines the role of helpers in the view layer of a Rails application, allowing an object-oriented approach rather than procedural.}