Skip to content

Instantly share code, notes, and snippets.

@lobodin
lobodin / README.md
Last active March 30, 2023 06:23
Import GeoNames.org cities data to mongodb.

#Generate cities data

  1. wget http://download.geonames.org/export/dump/cities15000.zip
  2. unzip cities15000.zip
  3. node geonames.js cities15000.txt

The result is json array of cities in the following format:

{

_id:

@lobodin
lobodin / gist:2730359
Created May 19, 2012 10:17
Poisson equation solution using TDMA
import math
import matplotlib.pyplot as plt
def tdma(a, b, c, d):
'''
a[i] * x[i-1] + b[i] * x[i] + c[i] * x[i+1] = d[i]
'''
length = len(a)
for i in xrange(1, length):
tmp = a[i] / b[i-1]
/*
Pascal scanner
*/
var Lexeme = function(name, type, nextLexemePos) {
this.name = name;
this.type = type;
this.nextLexemePos = nextLexemePos;
}
import sqlite3
from bottle import route, run, request
from datetime import datetime
import re
from cgi import escape
def articles_json(articles_tuple):
articles = list(({'date': escape(date),
'title': escape(title),
from urlparse import parse_qs
from datetime import datetime
def dates(environ, start_response):
dates = parse_qs(environ['QUERY_STRING'])
get_date = lambda d: datetime.strptime(dates[d][0], '%m/%d/%Y')
try:
start = get_date('start')
end = get_date('end')
.calendar {
position: fixed;
width: 210px;
height: 200px;
background: #DAD9DD;
font-family: Helvetica;
color: #3F4E5E;
font-weight: bold;
display: block;
}
function Point(x, y) {
this.x = x;
this.y = y;
}
function Figure(position) {
this.position = position;
}
function Line(position, endPosition) {
ul.menu a {
border-bottom: 1px solid #888;
}
ul.menu > li:last-child {
border-right: 1px solid #888;
}
ul.menu > li {
float: left;
/* Written using http://en.wikipedia.org/wiki/Heapsort pseudocode */
function Sorter() {
var array;
this.heapsort = function(a) {
array = a;
heapify();