We needed a locker at Co-Up co-working space. Alex and Aleks said there was a locker with a lost key that nobody was using anymore and joked that if we broke the padlock, the locker could be ours. Although they were only joking, we liked the sound of that challenge. Who doesn’t like destroying padlocks??
Then, as if planets were mysteriously aligning, coach Matt turned up and mentioned that he had a junior hacksaw at home. We cycled to his home, fetched the hacksaw, and wasted no time in using it:
Three minutes later, the door to the locker was open. Our first hardware hack!
Later that day we were having lunch together at a local restaurant. By chance we ended up sharing a table with Cristina. Cristina is an organiser of Rails Girls and helps coworking managers use Co-Up’s coworking tool, @cobot_me. It was the first time we had met her.
She asked about our day and we proudly told her we’d performed our very first hardware hack. We described breaking into locker number 7 and discovering its strange contents (a HUGE 5kg laptop charger from approx the year 1990). She looked confused.
“Locker number 7?” She asked, “A Hewlett Packard charger?”
“Um… yes,” we replied, our own confusion forming.
Yes. It was Christina’s locker. Sure, she hadn’t used it in a while, but no(!) she had not lost the key.
We immediately apologised, and, lucky for us, Cristina was totally cool. “It’s fine,” she said, “seriously. No Problem.”
We were relieved.
“But please,” she added, as we continued eating, “stay away from my home.”
We are happy to comply.
The search function now works, which is pretty amazing.
with a simple:
get '/' do
if params[:name]
@recipients = Recipient.where(Sequel.ilike(:name, "%#{params[:name]}%"))
else
@recipients = Recipient.all
end
erb :index
end
And once you click a link, you can see all the payments listed and even a tiny graph. We are graph-addicted!
A Ruby constant is like a variable, except that its value is supposed to remain constant for the duration of the program.
Today we needed a lot of
to survive the day. The weather makes us depressed.
Anyway, we are starting to put more structure into our project
and in the rakefile ;) A rakefile is needed to get more organized, run different ruby scripts in an specific order and that’s what we like.
The old rakefile:
namespace :db do
task :migrate do
require "sequel"
Sequel.extension :migration
DB = Sequel.postgres("farmsubsidy_development")
Sequel::Migrator.run(DB, './db/migrations', :use_transactions=>true)
end
task :set_up_performance_test_db do
require "sequel"
Sequel.extension :migration
#check to see if performance DB already exists
the_database_is_there = system("psql -l | grep farmsubsidy_performance")
if the_database_is_there
#if it does then drop the db
system("dropdb farmsubsidy_performance")
end
#and recreate it
system("createdb farmsubsidy_performance")
DB = Sequel.postgres("farmsubsidy_performance")
Sequel::Migrator.run(DB, './db/migrations', :use_transactions=>true)
end
task :run_any_new_migration do
require "sequel"
Sequel.extension :migration
DB = Sequel.postgres("farmsubsidy_performance_add_top_payments")
Sequel::Migrator.run(DB, './db/migrations', :use_transactions=>true)
end
end
The new rakefile:
require 'csv'
require 'logger'
require "sequel"
Sequel.extension :migration
#include all .rake files in lib/tasks directory
Dir.glob('lib/tasks/*.rake').each { |r| import r }
#take the database_name variable from command line input or fall back to default: test_db
#i.e. rake db:createandmigrate database_name=xxxx
@database_name = ENV['database_name'] || 'farmsubsidy_test_db'
Done!