Skip to content

Instantly share code, notes, and snippets.

View giacecco's full-sized avatar

Gianfranco Cecconi giacecco

View GitHub Profile
@giacecco
giacecco / gist:6371150
Created August 28, 2013 20:55
Crash of example 2 at https://code.google.com/p/python-tesseract/ after a fresh install of python-tesseract
Process: Python [39969]
Path: /usr/local/Cellar/python/2.7.5/Frameworks/Python.framework/Versions/2.7/Resources/Python.app/Contents/MacOS/Python
Identifier: Python
Version: 2.7.5 (2.7.5)
Code Type: X86-64 (Native)
Parent Process: bash [96576]
User ID: 503
Date/Time: 2013-08-28 21:55:40.720 +0100
OS Version: Mac OS X 10.8.4 (12E55)
HOMEBREW_VERSION: 0.9.4
ORIGIN: https://github.com/mxcl/homebrew
HEAD: 72ee11d988eff7e4af82eec813381f3f82950b08
HOMEBREW_PREFIX: /usr/local
HOMEBREW_CELLAR: /usr/local/Cellar
CPU: 8-core 64-bit ivybridge
OS X: 10.8.4-x86_64
Xcode: 4.6.3
CLT: 4.6.0.0.1.1365549073
LLVM-GCC: build 2336
@giacecco
giacecco / The original function by Chris Veness, made into a standalone script for testing
Last active December 24, 2015 05:39
Testing consistency between dbamber/UkGeoTool (https://github.com/dbamber/UkGeoTool) and the source by Chris Veness (http://www.movable-type.co.uk/scripts/latlong-gridref.html). With easting 510350 / northing 179950 as an input, the first function outputs { latitude: 51.50721000898611, longitude: -0.40978487356944765 } , while the second { lat: …
// Source http://www.movable-type.co.uk/scripts/latlong-gridref.html
Number.prototype.toDeg = function() { // convert radians to degrees (signed)
return this * 180 / Math.PI;
}
osGridToLatLong = function(gridref) {
var E = gridref.easting;
var N = gridref.northing;
@giacecco
giacecco / Output
Last active December 24, 2015 23:48
Checking Telefonica's 9 - 15 December 2012 data for completeness...
> checkFootfallCompleteness2()
[1] "The total number of grid id areas referenced in the file is 23152"
[1] "Checking 10/12/2012"
[1] "The missing areas are"
[1] "1122333312233" "1122333312341" "1122333312344" "1122333312432" "1122333321343"
[1] "Checking 11/12/2012"
[1] "The missing areas are"
[1] "1122333312341" "1122333312343" "1122333312344" "1122333312432" "1122333313212" "1122333321343"
[7] "1122333432334"
[1] "Checking 12/12/2012"
@giacecco
giacecco / The non-vectorised function
Last active December 25, 2015 18:59
Problem: I would like to write a vectorised version of 'findClosestOutputArea' below, so that I could do something like: incidents$outputAreaGridId <- findClosestOutputAreaVectorised(incidents$davetazLongitude, incidents$davetazLatitude)$gridId 'spDistsN1' comes from package sp http://cran.r-project.org/web/packages/sp/sp.pdf and calculates the …
findClosestOutputArea <- function (incident) {
distances <- spDistsN1(data.matrix(outputAreas[, c('longitudeCentre', 'latitudeCentre')]), matrix(c(incident$davetazLongitude, incident$davetazLatitude), nrow = 1, ncol = 2, byrow = TRUE), longlat = TRUE)
outputAreas[match(min(distances), distances), ]
}
[EMPTY FOLDER!]
@giacecco
giacecco / package.json
Created October 30, 2013 15:16
Strange behaviour of node-canvas that I can't understand. I expect this code to write 10 .png files each of which contains a "Page [n]" text. Instead, I get one .png only called page11.png (??? the last should be 10) with "Page 8" in it! There must be something about timing that I am missing.
{
"name": "test",
"version": "0.0.1",
"author": "Gianfranco Cecconi <[email protected]>",
"description": "Does what it says on the tin",
"contributors": [
{
"name": "Gianfranco Cecconi",
"email": "[email protected]"
}
@giacecco
giacecco / example.txt
Last active December 27, 2015 02:09
To reproduce the bug described in issue 23 https://github.com/soldair/node-qrcode/issues/23 in soldair/node-qrcode
Ode to Autumn
by John Keats
Season of mists and mellow fruitfulness,
Close bosom-friend of the maturing sun;
Conspiring with him how to load and bless
With fruit the vines that round the thatch-eaves run;
To bend with apples the moss'd cottage-trees,
And fill all fruit with ripeness to the core;
To swell the gourd, and plump the hazel shells
"SPORTS_ID","EVENT_ID","SETTLED_DATE"
"999","123456789","2013-01-07 01:19:45"
var async = require('async'),
cheerio = require('cheerio'),
request = require('request'),
argv = require('yargs').argv,
_ = require('underscore');
var baseUrl = "http://journalisted.com/search?q=" + encodeURIComponent(argv._.join(' ')) + "&o=date&type=article";
var getNoOfPages = function (callback) {
request(baseUrl, function (err, response, body) {