Skip to content

Instantly share code, notes, and snippets.

View nickbuddendotcom's full-sized avatar

Nick Budden nickbuddendotcom

View GitHub Profile
@nickbuddendotcom
nickbuddendotcom / gist:5792710
Last active August 16, 2019 11:26
Scrape wikipedia's country flags from http://commons.wikimedia.org/wiki/Sovereign-state_flags. All of Wikipedia's country flags are stored as SVG, so they can be scaled. Their width is stored in the flag's URL, so this can be changed to download whatever size of a flag you'd like. For my purposes I needed to limit my flags by height, but I wasn'…
<?php
scrape_wikipedia_flags();
function scrape_wikipedia_flags( $max_height = 60 ) {
// Create a 'flags' directory inside whatever directory we're working in.
// We'll download our flags here
$dir = realpath(dirname(__FILE__)) . "/flags/";
if(!is_dir($dir)) mkdir($dir,0777,true);
def index
@weights = current_user.weights.all
@startdate = 30.days.ago.to_date
@pounds = (30.days.ago.to_date..Date.today).map { |date| Weight.pounds_on(date).to_f }
@h = LazyHighCharts::HighChart.new('graph') do |f|
f.options[:title][:text] = " "
f.options[:chart][:defaultSeriesType] = "area"
f.options[:chart][:inverted] = false