Skip to content

Instantly share code, notes, and snippets.

View lardissone's full-sized avatar

Leandro Ardissone lardissone

View GitHub Profile
@jgomezdans
jgomezdans / import_geonames.sql
Created July 1, 2010 13:14
Importing the geonames DB into Spatialite
CREATE TABLE geonames ( geoname_id int, name text, asciiname text, alternatenames text, latitude real, longitude real, feature_class text, feature_code text, country_code text, cc2 text, admin1 text, admin2 text, admin3 text, admin4 text, population integer, elevation integer, gtopo30 integer, timezone integer, modification_date text) ;
.separator \t
.import allCountries.txt geonames
ALTER TABLE geonames ADD COLUMN geom blob ;
UPDATE geonames SET geom = PointFromText ( 'POINT(' || longitude || ' ' || latitude || ')', 4326 ) ;
@isaacs
isaacs / node-and-npm-in-30-seconds.sh
Last active June 18, 2024 18:27
Use one of these techniques to install node and npm without having to sudo. Discussed in more detail at http://joyeur.com/2010/12/10/installing-node-and-npm/ Note: npm >=0.3 is *safer* when using sudo.
echo 'export PATH=$HOME/local/bin:$PATH' >> ~/.bashrc
. ~/.bashrc
mkdir ~/local
mkdir ~/node-latest-install
cd ~/node-latest-install
curl http://nodejs.org/dist/node-latest.tar.gz | tar xz --strip-components=1
./configure --prefix=~/local
make install # ok, fine, this step probably takes more than 30 seconds...
curl https://www.npmjs.org/install.sh | sh
@pazdera
pazdera / abstract_factory_example.py
Created July 24, 2011 13:37
Example of `abstract factory' design pattern in Python
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# Example of `abstract factory' design pattern
# Copyright (C) 2011 Radek Pazdera
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
@jonashaag
jonashaag / 0-howto-listfield-django-admin.rst
Created September 7, 2011 09:41
Howto use ListFields in Django's admin

Howto use ListFields in Django's admin

Problem

Consider this blog post model:

models.py

@mathewbyrne
mathewbyrne / slugify.js
Created October 12, 2011 04:34
Javascript Slugify
function slugify(text)
{
return text.toString().toLowerCase()
.replace(/\s+/g, '-') // Replace spaces with -
.replace(/[^\w\-]+/g, '') // Remove all non-word chars
.replace(/\-\-+/g, '-') // Replace multiple - with single -
.replace(/^-+/, '') // Trim - from start of text
.replace(/-+$/, ''); // Trim - from end of text
}
@lardissone
lardissone / mongodb_autoincrement.py
Created March 14, 2012 01:35
Implementation of auto_increment for MongoDB
"""
db.seq.insert({_id: 'pacientes', seq: 1})
"""
from django.conf import settings
from pymongo import Connection
DATABASES = settings.DATABASES
@hellerbarde
hellerbarde / latency.markdown
Created May 31, 2012 13:16 — forked from jboner/latency.txt
Latency numbers every programmer should know

Latency numbers every programmer should know

L1 cache reference ......................... 0.5 ns
Branch mispredict ............................ 5 ns
L2 cache reference ........................... 7 ns
Mutex lock/unlock ........................... 25 ns
Main memory reference ...................... 100 ns             
Compress 1K bytes with Zippy ............. 3,000 ns  =   3 µs
Send 2K bytes over 1 Gbps network ....... 20,000 ns  =  20 µs
SSD random read ........................ 150,000 ns  = 150 µs

Read 1 MB sequentially from memory ..... 250,000 ns = 250 µs

@Nurdok
Nurdok / python_conversion.md
Last active December 16, 2022 03:45
Python Conversion

Python Number Conversion Chart

From To Expression
@cheeaun
cheeaun / image-processing-services.md
Last active April 20, 2024 22:17
3rd-party image processing/manipulation/upscaling/enlarging services