Skip to content

Instantly share code, notes, and snippets.

@macool
macool / failing specs
Created February 5, 2014 15:57
failing specs
Pending:
GoogleAccessToken add some examples to (or delete) /Users/macool/Documents/development/TrussellTrust/FoodbankWeb/spec/models/google_access_token_spec.rb
# No reason given
# ./spec/models/google_access_token_spec.rb:4
Failures:
1) Donor should correctly summaries donations by event for a foodbank in a defined date range
Failure/Error: result = Donor.find_donation_weight_by_event_for_foodbank_in_date_range(FoodbankProject.first.id, start_date, end_date)
NoMethodError:
describe 'If a geographical area has a parent geographical area group then the
validity period of the parent geographical area group must span the validity
period of the geographical area' do
describe "GA5" do
let(:geographical_area) {
build(:geographical_area,
validity_end_date: Date.today,
parent_geographical_area_group_sid: parent_id)
}
def material_pictograms_for_region(region)
return "" unless material.pictograms_of(region).present?
hazard_pictograms = []
pictograms_path = Rails.root.join("app/assets/images/hazard-pictograms/")
image_names = Dir[pictograms_path + "*.png"].map { |f| f.split("/").last }
image_names.map! {|n| File.basename(n,File.extname(n)) } # remove png extension
image_names = image_names.sort.reverse # so that we select latest coincidence
material.pictograms_of(region).map { |pic|
pic.image_name if pic.image_name.present?
}.compact.map { |pictogram_name|
@macool
macool / terminal output
Created February 4, 2015 21:48
travis vm debugging sxt specs
travis@debug-hs-12736-matthewford-ruby-1423060806:~/bitzesty/sxt$ bundle install --without development deployment --jobs=3 --retry=3
Fetching source index from https://rubygems.org/
Fetching git://github.com/joshk/bitly.git
Fetching git://github.com/bitzesty/clickatell.git
Fetching https://github.com/dmgarland/jcarousel-rails.git
Fetching https://github.com/getsentry/raven-ruby.git
Installing Platform 0.4.0
Installing rake 10.3.2
Installing i18n 0.7.0
Installing multi_json 1.10.1
@macool
macool / queries.sql
Last active August 29, 2015 14:14
Foodbank vouchers query results
/* Original query */
SELECT CONCAT(clientFirstName, clientLastName) AS fullName, count(*) AS ocurrences
FROM vouchers
WHERE vouchers.date BETWEEN "2011-01-01" AND "2011-12-31"
GROUP BY fullName
HAVING count(*) >= 2 AND count(*) <= 20
/* taking ~457ms */
/* for 2012: ~1.79s */
/* for 2013: ~5.24s */
/* for 2014: ~2.63s */
@macool
macool / facebook_sdk.js.coffee
Created August 23, 2015 19:17
make facebook sdk work with turbolinks on rails 4
appId = *******
$ ->
loadFacebookSDK()
bindFacebookEvents() unless window.fbEventsBound
bindFacebookEvents = ->
$(document)
.on('page:fetch', saveFacebookRoot)
.on('page:change', restoreFacebookRoot)
@macool
macool / gauges-with-turbolinks.js
Created September 5, 2015 18:08
gauges to work with turbolinks on rails
@macool
macool / psql_encoding.sql
Created November 16, 2015 00:46 — forked from turboladen/psql_encoding.sql
Script for dealing with creating Postgres databases that complain with: ``` PG::InvalidParameterValue: ERROR: encoding UTF8 does not match locale en_US DETAIL: The chosen LC_CTYPE setting requires encoding LATIN1. ``` ...when trying to create the production DB. Taken from: http://stackoverflow.com/questions/13115692/encoding-utf8-does-not-match-…
sudo su postgres
psql
update pg_database set datistemplate=false where datname='template1';
drop database Template1;
create database template1 with owner=postgres encoding='UTF-8'
lc_collate='en_US.utf8' lc_ctype='en_US.utf8' template template0;
update pg_database set datistemplate=true where datname='template1';
descripcion tags
prueba uno tag1,tag2
Apellido1 Apellido2 Nombre1
Apellido1 Apellido3 Nombre2
Apellido1 Apellido4 Nombre1
Peter González Parker
Peter González Parker