Skip to content

Instantly share code, notes, and snippets.

View dirceu-jr's full-sized avatar

Dirceu Jr. dirceu-jr

View GitHub Profile
function getCoordsInLatLng(latlng) {
var tileSize = L.point(256, 256);
var pixelPoint = map.project(latlng, map.getZoom()).floor();
var coords = pixelPoint.unscaleBy(tileSize).floor();
coords.z = map.getZoom();
return coords;
}
var coords = getCoordsInLatLng(latlngs[latlng]);
console.log(layer.getTileLayer().getTileUrl(coords));
function getTileInLatLng(latlng) {
var tileSize = L.point(256, 256);
var pixelPoint = map.project(latlng, map.getZoom()).floor();
var coords = pixelPoint.unscaleBy(tileSize).floor();
coords.z = map.getZoom();
return coords;
}
function mToPx(metres) {
var C = 40075016.686;
var c = map.getCenter();
var l = c.lat;
var r = 180/Math.PI;
var z = map.getZoom();
var m = C * Math.abs(Math.cos(l * r)) / Math.pow(2, z + 8);
var px = Math.ceil(1 / m);
return px;
}
var m2px = 1;
function newM2px() {
var centerLatLng = map.getCenter();
var pointC = map.latLngToContainerPoint(centerLatLng);
var pointX = [pointC.x + 100, pointC.y];
var latLngC = map.containerPointToLatLng(pointC);
var latLngX = map.containerPointToLatLng(pointX);
var distanceX = latLngC.distanceTo(latLngX)/100;

Gama, a small town in Brazil’s central scrubland, was not the most obvious place for a budding computer scientist to grow up but Marco Gomes did not let that put him off.

At the age of 11, he built a computer using discarded parts from old desktops and taught himself how to write code. By 12, he was selling his services as one of Gama’s few website developers, creating designs for everyone from the owner of the local hardware shop to a language school.

The son of an evangelical pastor and a wedding photographer, Mr Gomes has made it to the forefront of Brazil’s social media scene. His company, boo-box, displays 1bn advertisements for clients every month across 500,000 blogs and other social media sites, and claims to reach about six in 10 internet users in Brazil.

Mr Gomes no longer works from his bedroom but from a trendy office in one of São Paulo’s upmarket business districts, complete with Google-esque relaxation areas.

“Even though we’re still small – there are about 40 people here – we are able to c

@dirceu-jr
dirceu-jr / Linchadores e bandidos.md
Last active October 16, 2022 06:22
Linchadores e bandidos

Linchadores e bandidos

Querem saber se acho que o Brasil melhorou desde os anos 1980.

Se estou de bom humor, digo que sim: falo da época em que o telefone era imóvel para investimento, a inflação transformava qualquer crédito em usura, carro usado custava mais que carro novo e comprar um notebook significava "conversar" com um comissário da Varig, para que ele trouxesse o aparelho de Miami.

Se estou de mau humor, digo que não: falo de nossos estudantes que se perdem no ranking internacional, da mediocridade de grande parte da classe política, da vagarosidade dos serviços básicos e, enfim, da produtividade pífia, da ganância e da corrupção, que tornam absurdamente caro tudo o que é nacional.

Seja qual for o humor, lembro que, nas últimas décadas, diminuiu substancialmente a percentagem dos excluídos, ou seja, diminuiu aquela miséria que situa alguém num barco à parte, na deriva e sem relação com o rumo comum.

/*
* JavaScript Pretty Date
* Copyright (c) 2008 John Resig (jquery.com)
* Licensed under the MIT license.
*/
// Takes an ISO time and returns a string representing how
// long ago the date represents.
TimeInWordsHelper = {
distanceInWords: function(time) {
/* docduplicate.c
Wrapper around Viliam Holub implementations of M. Charikar's document similarity hash
http://dsrg.mff.cuni.cz/~holub/sw/shash/
Distributed under the MIT open source license
Copyright (c) 2010 Dirceu Pauka Júnior, ([email protected])
Permission is hereby granted, free of charge, to any person obtaining a copy
require 'rubygems'
require 'simple-daemon'
require 'open-uri'
require 'hpricot'
require 'iconv'
require 'json'
require 'memcache'
class Crawler < SimpleDaemon::Base
SimpleDaemon::WORKING_DIRECTORY = "/Users/dirs/Sites/toy/iPhonePush/ruby"
require 'rubygems'
require 'typhoeus'
require 'json'
class Migreme
include Typhoeus
remote_defaults :on_success => lambda {|response| response.body},
:on_failure => lambda {|response| puts "error code: #{response.code}"},
:base_uri => "http://migre.me"