Skip to content

Instantly share code, notes, and snippets.

View robroc's full-sized avatar

Roberto Rocha robroc

View GitHub Profile
@robroc
robroc / gist:c13b273c7b15899b2176
Created August 4, 2014 20:28
Mining Montreal's library calaogue
{
"metadata": {
"name": "",
"signature": "sha256:edbadb450210414c6ea44c2940914fd552299a2ed5624b1c1a1d7acf253e8144"
},
"nbformat": 3,
"nbformat_minor": 0,
"worksheets": [
{
"cells": [
@robroc
robroc / gist:8600265
Created January 24, 2014 16:04
Tourisme Quebec scraper
import scraperwiki
import lxml.html
base_url = "http://www.tourisme.gouv.qc.ca/publications/bulletins_info/bulletin/heb_frequentation.php?mois="
year_url = "&anneeHaut="
tail_url = "&anneeBas=2012&soumettre=Comparer"
# Loop through years between 2000-2013 and months 1-12
for year in range(2000,2014):
for month in range(1,13):
@robroc
robroc / gist:5750407
Last active December 18, 2015 07:59
$('.button').click(function(e) {
e.preventDefault();
$href = $(this).attr('href');
$('#viewer').scrollTo( $($href), 800, {offset: {top:-5} });
});
<script id="handlebars-template" type="text/x-handlebars-template">
<div id="card">
<div id="{{rowNumber}}"></div>
<div class="top"><span class="title">{{team}} </span></div>
<div class="team column">
<strong>Established: </strong>{{established}}<br />
<strong>First Grand Prix:</strong> {{firstgrandprix}} <br />
<strong>First victory:</strong> {{firstvictory}}<br />
<script type="text/javascript">
// Assign Google spreadsheet URL to variable
var public_spreadsheet_url = 'https://docs.google.com/spreadsheet/pub?key=0ArP8859PKYs8dEpUQ3hLejA1TVo1cWxPbnBVNy11TGc&output=html';
$(document).ready( function() {
// Initialize Tabletop with whatever options you want
Tabletop.init( { key: public_spreadsheet_url,
callback: showInfo,
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js" type="text/javascript"></script>
<script type="text/javascript" src="js/handlebars.js"></script>
<script type="text/javascript" src="js/tabletop.js"></script>
$('#mothertongue,#knowledge').change(function (element) {
layer.setOptions({
styles: getStyles(element)
});
});
var step = maxima[column] / 5;
var styles = [];
for (var i = 0; i <= 4; i++) {
styles.push({
where: "'" + column + "' >= " + (step * i) + " AND '" + column + "' < " + (step * (i + 1)),
polygonOptions: {
fillOpacity: 0.4,
fillColor: colors[i]
}
function getStyles(element) {
var $mothertongue = $('#mothertongue'),
$knowledge = $('#knowledge'),
mothertongue = $mothertongue.val(),
knowledge = $knowledge.val();
if (mothertongue == 'NO' || knowledge == 'Both' || knowledge == mothertongue) {
column = 'MT: ' + mothertongue + ', Kn: ' + knowledge;
}
else {
var maxima= {
'MT: Eng, Kn: Eng': 1500,
'MT: Eng, Kn: Both': 3250,
'MT: Fra, Kn: Fra': 7660,
'MT: Fra, Kn: Both': 4700,
'MT: NO, Kn: Eng': 2290,
'MT: NO, Kn: Fra': 1830,
'MT: NO, Kn: Both': 2980,
};