Skip to content

Instantly share code, notes, and snippets.

View adamgamble's full-sized avatar

Adam Gamble adamgamble

View GitHub Profile
mysqldump -uroot --routines --no-data --quick --opt insight_card_services_development > ~/mysql.sql
cat ~/mysql.sql | mysql -uroot insight_card_services_test
@agents = @bucket.find(:all, :joins => {:store => [:agent]}, :select => "agents.name as agent_name, COUNT(card_creation_transactions.id) as card_creation_transaction_count, card_creation_transactions.store_id, card_id", :group => "agents.name", :order => "agents.name")
@agents.map! {|cct| {"agent_name" => cct.attributes["agent_name"], "card_creation_transaction_count" => cct.attributes["card_creation_transaction_count"]}}
class Quiz
def initialize
@f = {}
@f['en.steps.foo'] = 'bar'
@f['en.steps.bar'] = 'wiggity'
@f['en.boogie.foo'] = 'liar'
@f['en.boogie.baz.noodles'] = 'potatosack'
@new_hash = {}
end
def return_hash f
{ 'en' => { 'steps' => { 'foo' => 'bar', 'bar' => 'wiggity' }, 'boogie' => { 'foo' => 'liar', 'baz' => { 'noodles' => 'potatosack' } } } }
end
sc () {
[[ `rails -v` =~ ([0-9]) ]]
if [[ "$BASH_REMATCH" == "3" ]]; then rails c; else script/console; fi
}
<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<meta name="viewport" content="width=device-width; initial-scale=1.0; maximum-scale=1.0; user-scalable=0;" />
<title>Geolocation Test</title>
<script language="javascript" type="text/javascript">
function getLocation() {
// Get location no more than 10 minutes old. 600000 ms = 10 minutes.
Then /^the "([^"]*)" select field(?: within "([^"]*)")? should contain "([^"]*)"$/ do |field, selector, value|
with_scope(selector) do
field = find_field(field)
values = field.native.children.map {|e| e.children[0].to_s}
assert(values.include?(value), true)
end
end
def self.fee_plans_for_agent(agent)
Region::FEE_PLANS.delete_if{|item| agent.code != "CS" && item[0] == "Checksmart Tax"}
end
class ActiveRecord::Relation
def explain
result = self.connection.execute("EXPLAIN #{self.to_sql}")
fields = result.fetch_fields
info = ""
fields.each do |field|
info << "| #{field.name} \t"
end
info << "|\n"
begin
def bang_x(x,ob)
bang_str = ""
x.times do
bang_str += "!"
end
eval("#{bang_str}ob")
end