Skip to content

Instantly share code, notes, and snippets.

View ciscou's full-sized avatar

Francis Pérez Padilla ciscou

View GitHub Profile
% https://statistics.worldcubeassociation.org/database-query
SELECT Persons.wca_id, Persons.name, gold.total AS gold, silver.total AS silver, bronze.total AS bronze FROM Persons
LEFT JOIN (
Select personId, count(*) total from Results where roundTypeId IN ('c', 'f') AND pos = 1 AND best > 0 AND countryId = 'Spain' GROUP BY personId
) AS gold ON Persons.wca_id = gold.personId
LEFT JOIN (
Select personId, count(*) total from Results where roundTypeId IN ('c', 'f') AND pos = 2 AND best > 0 AND countryId = 'Spain' GROUP BY personId
) AS silver ON Persons.wca_id = silver.personId
LEFT JOIN (
@ciscou
ciscou / supported_time_zones.txt
Last active January 30, 2023 09:16
List of time zone identifiers supported by `ActiveSupport::TimeZone`
Africa/Algiers
Africa/Cairo
Africa/Casablanca
Africa/Harare
Africa/Johannesburg
Africa/Monrovia
Africa/Nairobi
America/Argentina/Buenos_Aires
America/Bogota
America/Caracas
# before running, download and unzip the latest TSV export from https://www.worldcubeassociation.org/results/misc/export.html
# usage: cat WCA_export_Results.tsv | ruby spanish_podia.rb
s = gets
s.chomp!
headers = {}
s.split("\t").each_with_index do |header, i|
headers[header] = i
end
@ciscou
ciscou / marionette-f7-demo.html
Last active February 2, 2017 14:10
Example of a minimal Backbone Marionette + Framework7 application
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>JS Bin</title>
<script src="https://code.jquery.com/jquery-2.2.4.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/underscore.js/1.8.3/underscore-min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/backbone.js/1.3.3/backbone-min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/backbone.radio/2.0.0/backbone.radio.js"></script>
@ciscou
ciscou / cities.txt
Last active August 29, 2015 14:06
top 400 cities postcodes
1 Madrid 3.207.247 Comunidad de Madrid Flag of the Community of Madrid.svg Comunidad de Madrid
2 Barcelona 1.611.822 Barcelona Flag of Catalonia.svg Cataluña
3 Valencia 792.303 Valencia Flag of the Valencian Community (2x3).svg Comunidad Valenciana
4 Sevilla 700.169 Sevilla Flag of Andalucía.svg Andalucía
5 Zaragoza 682.004 Zaragoza Flag of Aragon.svg Aragón
6 Málaga 568.479 Málaga Flag of Andalucía.svg Andalucía
7 Murcia 438.246 Región de Murcia Flag of the Region of Murcia.svg Murcia
8 Palma de Mallorca 398.162 Islas Baleares Flag of the Balearic Islands.svg Islas Baleares
9 Las Palmas de G. C. 383.050 Las Palmas Flag of the Canary Islands (simple).svg Canarias
10 Bilbao 349.356 Vizcaya Flag of the Basque Country.svg País Vasco
@ciscou
ciscou / mr_distinct_year_month.rb
Created September 4, 2014 12:38
mr_distinct_year_month.rb
map = %Q{
function() {
emit("" + this.year + this.month, 1)
}
}
reduce = %Q{
function(key, values) {
return 1;
}
class PocController
before_filter :redirect_to_root_url, only: :show4
def show1
redirect_to_root_url
render # => Double render error!!!
end
def show2
redirect_to_root_url
@ciscou
ciscou / show.html.erb
Last active August 29, 2015 14:05
yes no i18n helper
is 1 == 1? <%= yesno 1 == 1 %>
is 1 == 2? <%= yesno 1 == 2 %>
@ciscou
ciscou / kw_args.rb
Last active August 29, 2015 14:04
ruby 2.0 keyword arguments
2.0.0-p451 :016 > def omg(foo: 42, bar: "hello world!")
2.0.0-p451 :017?> puts [foo, bar].inspect
2.0.0-p451 :018?> end
=> nil
2.0.0-p451 :019 > omg
[42, "hello world!"]
=> nil
2.0.0-p451 :020 > omg(1, "one")
module ActiveRecord
class Base
def self.scope(name, callable)
define_singleton_method name do
options = callable.respond_to?(:call) ? callable.call : callable
puts "Fetching records with options #{options.inspect}"
end
end
end
end