Skip to content

Instantly share code, notes, and snippets.

View mourner's full-sized avatar
🔥
making stuff faster

Volodymyr Agafonkin mourner

🔥
making stuff faster
View GitHub Profile
@mourner
mourner / equation.html
Created July 7, 2011 13:50
Brute-force JS solution for Xopus task (see http://goo.gl/Zy0a9)
<!DOCTYPE html>
<head>
<title>Test</title>
</head>
<body>
<button onclick="displayResult()">Search</button>
<script>
var numEvals;
function displayResult() {
@mourner
mourner / TileLayer.CloudMade.js
Created October 27, 2011 14:18
Basic CloudMade tile layer for Leaflet
L.TileLayer.CloudMade = L.TileLayer.extend({
options: {
maxZoom: 18,
attribution: 'Map data &copy; 2011 <a href="http://openstreetmap.org">OpenStreetMap</a> contributors, <a href="http://creativecommons.org/licenses/by-sa/2.0/">CC-BY-SA</a>, Imagery &copy; 2011 <a href="http://cloudmade.com">CloudMade</a>'
},
initialize: function(key, styleId, options) {
var url = 'http://{s}.tile.cloudmade.com/{key}/{styleId}/256/{z}/{x}/{y}.png',
urlParams = {key: key, styleId: styleId || 997};
@mourner
mourner / codility-demo.js
Created January 7, 2012 09:49
Codility demo tests solutions
// 100-score solution for http://codility.com/demo/take-sample-test/
function equi(array) {
var i,
len = array.length,
sum = 0,
leftSum = 0,
rightSum;
for (i = 0; i < len; i++) {
@mourner
mourner / TileLayer.Common.js
Created February 11, 2012 23:11
Leaflet shortcuts for common tile providers
// Lefalet shortcuts for common tile providers - is it worth adding such 1.5kb to Leaflet core?
L.TileLayer.Common = L.TileLayer.extend({
initialize: function (options) {
L.TileLayer.prototype.initialize.call(this, this.url, options);
}
});
(function () {
@mourner
mourner / current-api.js
Created July 3, 2012 10:07
Leaflet API simplification proposal
var map = new L.Map('map');
map.setView(new L.LatLng(51.505, -0.09), 13);
var cloudmade = new L.TileLayer('http://{s}.tile.cloudmade.com/.../{z}/{x}/{y}.png', {
attribution: '[...]'
});
map.addLayer(cloudmade);
var marker = new L.Marker(new L.LatLng(51.5, -0.09));
marker.bindPopup("<b>Hello world!</b><br />I am a popup.").openPopup();
@mourner
mourner / geojson.js
Created July 6, 2012 21:40
Leaflet GeoJSON API proposal
var geojson = L.geoJson(data, {
// style for all vector layers (color, opacity, etc.), either function or object (optional)
style: function (feature) {
return feature.properties && feature.properties.style;
},
// function for creating layers for GeoJSON point features (optional)
pointToLayer: function (feature, latlng) {
return L.marker(latlng, {
@mourner
mourner / creating-icons.js
Created July 9, 2012 12:01
Leaflet 0.3 -> 0.4 Icon API upgrade
// 0.3 way
var icon = new L.Icon('icon.png');
// 0.4 way
var icon = new L.Icon({iconUrl: 'icon.png'}); // or just "L.icon(...)"
@mourner
mourner / spaces-vs-tabs-js.md
Created November 7, 2012 11:33
Whitespace conventions of popular JS libraries

Whitespace Conventions of Popular JS Libraries

Manually sorted by browsing most starred JS projects on GitHub (client-side only, all the Node crowd uses 2 spaces).

2 spaces

  • Backbone
  • Underscore
  • D3
@mourner
mourner / index.html
Created November 15, 2012 21:22 — forked from tmcw/index.html
SVG points and 3d transforms
<!DOCTYPE html>
<meta charset="utf-8">
<title>SVG Swarm</title>
<style>
svg {
position: absolute;
top: 0;
}
@mourner
mourner / example.js
Created December 12, 2012 10:58
New in Leaflet master: AOP-style constructor hooks for all classes. Example:
L.Marker.addInitHook(function () {
// do some additional stuff in the constructor, e.g.:
this.on('click', doExcitingStuff);
// will be called for all instances of Marker
});