Skip to content

Instantly share code, notes, and snippets.

@mgax
mgax / Readme.md
Last active August 29, 2015 13:56

D3 + Leaflet, improved

This example builds on Mike Bostock's D3 + Leaflet example, and fixes a clipping problem: if you zoom in and pan around, in the original example, the SVG is not big enough to cover the extent of the D3 layer, so the features get clipped. Here instead, we size the SVG to cover the entire world, -180 to 180 longitude and 90 to -90 latitude, and update its offset after zoom.

@mgax
mgax / deploy.sh
Last active August 29, 2015 13:56
#!/bin/bash
set -e
PRJHOME='/home/mgax/zechat'
source $PRJHOME/venv/bin/activate
set -x
echo "Deploying zechat:"
cd $PRJHOME/zechat
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@mgax
mgax / simplify.py
Last active August 29, 2015 13:56
simplify geojson
import simplejson as json; from path import path
trim_5 = lambda v: float('%.5s' % v)
l = json.loads(path(SRC_PATH).bytes().decode('latin-1'))
for f in l['features']:
f['properties'] = {'id': int(f['properties']['SIRUTA'])}
f['geometry']['coordinates'] = map(trim_5, f['geometry']['coordinates'])
path(DST_PATH).write_text(json.dumps(l))
Nu da vrabia din mână pentru cioara de pe gard.
Lumea muncește și sapă și eu duc câinii la apă.
Caută o femeie care-ți place ție, nu la alții.
A bate găina cu lanțul.
Cine nu-ncearcă, nici nu câștigă.
Cine fură azi un ou, mâine va fura un bou.
Tinerii înaintea bătrânilor, să aibă urechi, nu gură!
Nu e dracul așa de negru.
Toate drumurile/căile duc la Roma.
Cine seamănă vânt, culege furtună.
@mgax
mgax / Readme.md
Last active August 29, 2015 14:01
digitalocean dokku checklist
  • swap

    mkdir -p /var/local/swap
    dd if=/dev/zero of=/var/local/swap/1 bs=1M count=256
    mkswap /var/local/swap/1
    chmod 600 /var/local/swap/1
    swapon /var/local/swap/1
    echo 10 > /proc/sys/vm/swappiness
    

echo "/var/local/swap/1 none swap sw 0 0" >> /etc/fstab

@mgax
mgax / run.sh
Last active August 29, 2015 14:02
run osmose for Romania
#!/bin/bash
set -e
set -x
cd /data/project/osmose/backend
sudo -u osmose ./osmose_run.py --country=romania $@
@mgax
mgax / runserver.sh
Created June 5, 2014 11:45
run php-cgi
#!/bin/bash
set -x
exec /usr/bin/php-cgi -b $PORT -d fastcgi.logging=0
@mgax
mgax / size.sql
Created June 19, 2014 11:49
postgresql on-disk size
SELECT pg_size_pretty(pg_total_relation_size('name'));
SELECT pg_size_pretty(pg_database_size('name'));
@mgax
mgax / backup.py
Last active August 29, 2015 14:02
#!/usr/bin/env python
from datetime import date
import subprocess
DB_NAME = 'awesome'
BACKUP_PATH = '/var/local/awesome/backup/awesome-%s.sql.gz'
def main():