Skip to content

Instantly share code, notes, and snippets.

View straydogstudio's full-sized avatar

Noel Peden straydogstudio

View GitHub Profile
class User < ActiveRecord::Base
acts_as_authentic # I use authlogic
scope :with_role, lambda { |role| {:conditions => "roles_mask & #{1 << ROLES.index(role.to_s)} > 0"} }
ROLES = %w[admin manager client coordinator employee volunteer]
ROLE_DESCRIPTIONS = {
:admin => "Administers the entire site",
:manager => "Manages the entire site",
@straydogstudio
straydogstudio / without_runner.rb
Last active August 29, 2015 14:05
Render a template outside of Rails
require 'abstract_controller'
require 'action_controller'
require 'action_view'
require 'active_record'
# require any helpers
require './app/helpers/application_helper'
# active record only if data is here
require './app/models/widget'
@straydogstudio
straydogstudio / adapters_application.js
Last active August 29, 2015 14:10
Ember-CLI-101 sortable issue
import DS from 'ember-data';
export default DS.ActiveModelAdapter.extend({
namespace: 'api/v4',
coalesceFindRequests: true
});
@straydogstudio
straydogstudio / .bash_aliases
Created January 8, 2015 18:07
Bash aliases
#upload changed/new files to rails with capistrano
function capdu {
if [ -z "$1" ]
then
FILES=`gst --porcelain | grep '^ M\|^\?\?' | ruby -e 'puts ARGF.map {|l| l.split()[1]}.join(",")' | xargs echo`
else
FILES=`gst --porcelain | grep '^ M\|^\?\?' | grep $1 | ruby -e 'puts ARGF.map {|l| l.split()[1]}.join(",")' | xargs echo`
fi
if [ -z "$FILES" ]
then
@straydogstudio
straydogstudio / newsbottom.css
Last active August 29, 2015 14:17
CSS for FilmRoll headline
#newsbottom {
position: absolute;
bottom: 10px;
left: 15px;
right: 15px;
padding: 0;
/* black with white text */
background: rgba(0,0,0,0.3);
color: white;
/* or white with black text */
@straydogstudio
straydogstudio / gist:0541e83bc30abe2636fb
Last active August 29, 2015 14:27 — forked from tonymtz/gist:d75101d9bdf764c890ef
Uninstall nodejs from OSX Yosemite
# First:
lsbom -f -l -s -pf /var/db/receipts/org.nodejs.pkg.bom | while read f; do sudo rm /usr/local/${f}; done
sudo rm -rf /usr/local/lib/node /usr/local/lib/node_modules /var/db/receipts/org.nodejs.*
# To recap, the best way (I've found) to completely uninstall node + npm is to do the following:
#go to /usr/local/lib and delete any node and node_modules
cd /usr/local/lib
sudo rm -rf node*
import Ember from "ember";
// This is an error. It should be 'ember-simple-auth/authenticators/base'
// Left to link to a github comment
import Base from 'ember-simple-auth/authorizers/base';
export default Base.extend({
tokenEndpoint: '/api/user_sessions',
authenticate: function(credentials) {
var _this = this;
return new Ember.RSVP.Promise(function(resolve, reject) {
@straydogstudio
straydogstudio / .pryrc
Created June 13, 2012 19:18 — forked from renz45/.pryrc
Pry: .pryrc configuraton
#switch default editor for pry to sublime text
Pry.config.editor = "sublime"
#format prompt to be <Rails version>@<ruby version>(<object>)>
Pry.config.prompt = proc do |obj, level, _|
prompt = "\e[1;30m"
prompt << "#{Rails.version} @ " if defined?(Rails)
prompt << "#{RUBY_VERSION}"
"#{prompt} (#{obj})>\e[0m"
end
@straydogstudio
straydogstudio / .irbrc
Created June 13, 2012 20:07
IRB: Simple irb with gems loaded outside of Gemfile
# switch default editor for pry to sublime text
Pry.config.editor = "subl"
# format prompt to be <Rails version>@<ruby version>(<object>)>
Pry.config.prompt = proc do |obj, level, _|
prompt = "\e[1;30m"
prompt << "#{Rails.version} @ " if defined?(Rails)
prompt << "#{RUBY_VERSION}"
"#{prompt} (#{obj}:#{level})>\e[0m"
end
@straydogstudio
straydogstudio / gist:2926239
Created June 13, 2012 20:13
CSS: Image Replacement
.ir {
border:0;
font: 0/0 a;
text-shadow: none;
color: transparent;
background-color: transparent;
}