Skip to content

Instantly share code, notes, and snippets.

View marka2g's full-sized avatar
🎯
Focusing

Mark Sadegi marka2g

🎯
Focusing
View GitHub Profile
@marka2g
marka2g / class_eval on Kernal
Created January 17, 2012 22:19
What's Rails Loading? Slam this in ur app.rb/env.rb
Kernel.class_eval do
alias :old_require :require
def require(*args)
puts args
old_require(*args)
end
end
@marka2g
marka2g / parse_note_spec.rb
Created January 31, 2012 19:47
need an edge-case type test? simply add a new hash y'all!
describe Note do
describe 'notes with valid time entry' do
[ {text: 't:9h20m', parsed_entry: 33600},
{text: 't:20m', parsed_entry: 1200},
{text: 't: 9h', parsed_entry: 32400},
{text: 't: 20m', parsed_entry: 1200},
{text: 't: 09h', parsed_entry: 32400},
{text: 'time: 09h', parsed_entry: 32400},
{text: 'Time: 20m', parsed_entry: 1200}
].each do |note|
@marka2g
marka2g / group_redistribution.rb
Created February 1, 2012 23:31
BK Group Redistribution
#Reassign All Markets and children to a new region
def self.reasign_all_markets_to_new_region(old_region_id, new_region_id)
# old_southeast = Group.find_by_id(10870)
# new_southeast = Group.find_last_by_name('Southeast')
# sql.execute("UPDATE links SET parent_id = #{new_southeast.id} WHERE parent_id=#{old_southeast.id}");
#or
# g = Group.find_by_id(7283)
# ng = Group.find(12791)
# BurgerKing::GroupRedistribution.reasign_all_markets_to_new_region(g.id, ng.id)
@marka2g
marka2g / csbb_ch1
Created March 29, 2012 02:22
CodeSchool Backbone Ch1
var Appointment = Backbone.Model.extend({});
var appointment = new Appointment();
appointment.set('title', 'My knee hurts');
var AppointmentView = Backbone.View.extend({
render: function(){
$(this.el).html('
' + this.model.get('title') + ' ');
}
});
@marka2g
marka2g / ccbb_ch2
Created March 29, 2012 03:07
CodeSchool Ch2
//1. Defaults
var Appointment = Backbone.Model.extend({
defaults: {
title: 'Checkup',
date: new Date()
}
});
//2 Fixing Defutls
var Appointment = Backbone.Model.extend({
@marka2g
marka2g / ccbb_ch3
Created March 30, 2012 03:19
CodeSchool Backbone Ch3
// 1. Changing the class
var AppointmentView = Backbone.View.extend({tagName: 'li'});
// 2. adding a class
var AppointmentView = Backbone.View.extend({
tagName: 'li',
className: 'appointment'
});
//3. TOP-LEVEL JQUERY
@marka2g
marka2g / gist:5117963
Created March 8, 2013 16:59
Quickly Host a Git Repo - From Gray
# **Quickly Host a Git Repository**
REPO_ROOT='~/source/repos' # Can be anywhere
GIT_PROJECT_PATH='~/projects/my_cool_git_project' # Your local project using git
GIT_PROJECT_NAME=$(basename $GIT_PROJECT)
mkdir -p $REPO_ROOT
cd $REPO_ROOT
git clone --bare $GIT_PROJECT_PATH
cd $GIT_PROJECT_NAME.git
require 'rspec'
class Array
def custom_group_by(&block)
results = {}
each do |e|
(results[block.call(e)] ||= []) << e
end
tweet = Tweet.new('Ruby Bits!')
success = -> { puts "Sent!"}
error = -> { raise 'Auth Error' }
tweet.post(success, post)
@marka2g
marka2g / closures_and_lambdas.rb
Created March 18, 2013 01:48
#closures and lambdas
#closure and lambdas
def tweet_as(user)
lambda {|tweet| puts "#{user}: #{tweet}"}
end
mark_tweet = tweet_as("mark")
mark_tweet.call("This is awesome!")