Skip to content

Instantly share code, notes, and snippets.

View mnelson's full-sized avatar

Mike Nelson mnelson

View GitHub Profile
class Effect < AR::Base
scope :my_scope, select('project_id, taskType, user_id, SUM(hours)').joins(:project_task).where(:project_tasks => {:project_id => 2, :taskType => 'Pre-Sales'}).group('user_id')
end
##### USAGE #####
#
# The StaticValue class gives you access to globally accessible constants through a human-readable and compact format.
#
# To define a new set of static values just define a class in this file such as:
# StaticValue.register('MyValues')
#
# Once your class is present you can add values to it via the add_item method:
# MyValues.add_item :Default, 0
# MyValues.add_item :Custom, 1
$(".call-to-action").live("click",function(e){
register_user_modal($(this).attr("href"));
e.preventDefault();
return false;
});
function register_user_modal(target_link){
var options = {
open:function(){
$.get(target_link,{},
function(r){
$(".call-to-action").live("click",function(e){
try{
register_user_modal($(this).attr("href"));
} catch(err){alert(err);}
e.preventDefault();
return false;
});
function register_user_modal(target_link){
alert("wtf1");
var options = {
@mnelson
mnelson / application.json.jbuilder
Created November 24, 2012 06:42
Use jbuilder to render jsonp responses.
raw_content = JSON.parse(yield)
json.content raw_content
json.jsonp! params[:callback] if jsonp?
@mnelson
mnelson / tddium.rake
Created November 24, 2012 19:19
Utilize S3 as a storage mechanism for Rails assets
namespace :tddium do
class AssetS3
BUCKET = "tddium_assets"
KEEP_AROUND = 7.days
def initialize(branch)
@branch = branch
end
# fully resizable. just make sure you have it inside a relatively position element.
def modal(options = {}, &block)
options.merge!({:class => [options[:class], "modal clearfix"].join(' ')})
render :layout => '/shared/modal', :locals => {:options => options}, &block
end
@mnelson
mnelson / database.yml
Created December 9, 2012 19:01
Example makara development database.yml
development: &DEV
adapter: makara
sticky_slaves: true
sticky_master: true
verbose: true
ansi_colors: true
db_adapter: mysql2
host: localhost
encoding: utf8
@mnelson
mnelson / tenanct_mixins.scss
Created May 15, 2014 19:18
Tenant mixin for sass variables.
/*
$listvar:
"appname1" "blue",
"appname2" "red"
;
.my-selector {
@include tenant($listvar) {
background-color: $var;
{
// JSHint Default Configuration File (as on JSHint website)
// See http://jshint.com/docs/ for more details
"maxerr" : 50, // {int} Maximum error before stopping
// Enforcing
"bitwise" : false, // true: Prohibit bitwise operators (&, |, ^, etc.)
"camelcase" : false, // true: Identifiers must be in camelCase
"curly" : false, // true: Require {} for every new block or scope