Skip to content

Instantly share code, notes, and snippets.

View stepankuzmin's full-sized avatar
🥡

Stepan Kuzmin stepankuzmin

🥡
View GitHub Profile
@stepankuzmin
stepankuzmin / euler10.erl
Created April 2, 2012 08:15
Project Euler. Problem 10.
module(euler10).
-compile(export_all).
start() ->
sieve(lists:seq(2, 2000000)).
sieve(List) ->
sieve(List, 0).
sieve([], Acc) ->
Acc;
sieve([H|T], Acc) ->
@stepankuzmin
stepankuzmin / geolocation.cljs
Created May 13, 2012 04:29
Geolocation using ClojureScript
(def urls (array "http://a.tile.openstreetmap.org/${z}/${x}/${y}.png"
"http://b.tile.openstreetmap.org/${z}/${x}/${y}.png"
"http://c.tile.openstreetmap.org/${z}/${x}/${y}.png"))
(def OSM (js/OpenLayers.Layer.XYZ. "OSM (with buffer)" urls (extend-object! (js-obj) {"transitionEffect" "resize"
"buffer" 2
"wrapDateLine" true
"sphericalMercator" true})))
(def plot (js/OpenLayers.Map. (extend-object! (js-obj) {"div" "plot"
@stepankuzmin
stepankuzmin / views-view-field--field-reference.tpl.php
Created June 26, 2012 14:38
Вывод поля field_image из ноды, на которую ссылается поле field_reference во Views Drupal 7
<?php
/**
* This template is used to print a single field in a view. It is not
* actually used in default Views, as this is registered as a theme
* function which has better performance. For single overrides, the
* template is perfectly okay.
*
* Variables available:
* - $view: The view object
* - $field: The field handler object that can process the input
<?php
$url = url('http://maps.googleapis.com/maps/api/geocode/json', array('query' => array('address' => 'Екатеринбург, Чайковского 86/3', 'sensor' => 'false')));
$contents = file_get_contents($url);
$response = drupal_json_decode($contents);
if ($response['status'] == 'OK') {
drupal_add_js('https://maps.google.com/maps?file=api&amp;v=2&amp;key=AIzaSyD4iE2xVSpkLLOXoyqT-RuPwURN3ddScAI', 'external');
foreach ($response['results'] as $address) {
$lat = $address['geometry']['location']['lat'];
$lng = $address['geometry']['location']['lng'];
@stepankuzmin
stepankuzmin / sleepsort.erl
Created October 10, 2012 15:48
Sleep sort in Erlang
-module(sleepsort).
-export([sort/1]).
sort(List) ->
sort(List, [], []).
sort([], NewList, []) ->
lists:reverse(NewList);
sort(List, [], []) ->
Pids = lists:map(fun(Element) -> spawn(sleepsort, sleep, [self(), Element]) end, List),
#include <fstream>
#include <iostream>
using namespace std;
int main() {
// File headers
int version;
int datarate;
int samples_count;
int mode;

Step 1: Clone the bundles into your Sublime Text packages directory

cd ~/Library/Application\ Support/Sublime\ Text\ 2/Packages
git clone git://github.com/jashkenas/coffee-script-tmbundle CoffeeScript
git clone https://github.com/miksago/jade-tmbundle.git Jade
git clone https://github.com/LearnBoost/stylus.git Stylus

Step 2: Restart Sublime Text 2

#!/usr/bin/env coffee
'''
Yelp TERM in CITY and render results as geojson (or map).
Examples:
yelp tacos
yelp --in Louisville brewpubs
yelp --in Nashville "chinese takeout"
yelp --map --in Milwaukee "bowling alleys" # render results as map via geojson.io
@stepankuzmin
stepankuzmin / style.mss
Created September 28, 2013 11:26
Terrain style
Map {
buffer-size: 0;
background-color: @water;
}
@land: #E9E2DF;
@water: #6FB5E7;
#slope {
raster-opacity: 1;
@stepankuzmin
stepankuzmin / build_gmted.py
Created October 2, 2013 11:44
See http://erouault.blogspot.ru/2011/12/seamless-access-to-remote-global-multi.html Don't know when this happened, but the machine 'igskmncngs506' is now 'gmted'.
#!/usr/bin/env python
###############################################################################
# $Id$
#
# Purpose: Builds global VRT for GMTED2010 data.
# Author: Even Rouault, <even dot rouault at mines dash paris dot org>
#
###############################################################################
# Copyright (c) 2011, Even Rouault, <even dot rouault at mines dash paris dot org>
#