Skip to content

Instantly share code, notes, and snippets.

@k1000
k1000 / aiports.py
Created July 26, 2011 07:46
list of world aiports with codes
# -*- coding: utf-8 -*-
def get_airports():
airports = sorted(AIRPORTS, key=lambda airport: airport[0]) #sortear por el país
return [(a[2] , "%s - %s (%s)" % (a[0], a[1], a[2]) ) for a in airports]
AIRPORTS = [
( "Denmark", "Aalborg", "AAL" ),
( "Norway", "Aalesund", "AES" ),
( "Denmark - Bus service", "Aarhus", "ZID" ),
( "Denmark - Tirstrup", "Aarhus", "AAR" ),
# -*- coding: utf-8 -*-
LANGUAGES = {
"ab" : ["Abkhaz", u" аҧсуа бызшәа"],
"af" : ["Afrikaans", u"Afrikaans"],
"sq" : ["Albanian", u"shqip"],
"am" : ["Amharic", u" አማርኛ"],
"ar" : ["Arabic", u"العربية"],
"hy" : ["Armenian", u"Հայերեն"],
"az" : ["Azerbaijani", u"azərbaycan"],
"bm" : ["Bambara", u"Bamanankan"],
@k1000
k1000 / README
Created July 27, 2011 20:36 — forked from nicpottier/README
Basic Django template syntax highlighting support for the codemirror editor.
These two files provide limited syntax highlighting using the most
excellent codemirror syntax highlighter.
See:
http://marijn.haverbeke.nl/codemirror/
Stick the .js and .css files in the appropriate spots for your
codemirror installation.
You can enable it on a textarea using something like:
@k1000
k1000 / track_state_mixin.py
Created August 5, 2011 13:55
TrackStateMixin to track updated fields in django model
# -*- coding: utf-8 -*-
from django.db.models.signals import post_save
#https://github.com/citylive/django-states2
#inspired on http://stackoverflow.com/questions/110803/dirty-fields-in-django
class TrackStateMixin(object):
def __init__(self, *args, **kwargs):
super(TrackStateMixin, self).__init__(*args, **kwargs)
self._original_state = self._as_dict()
@k1000
k1000 / selenium_scrap.py
Created August 17, 2011 08:38
selenium scrap
"""
Basic script to scrap pages with selenium
requires:
- lxml
- selenium http://seleniumhq.org/download/
execution:
1. start selenium server
$ java -jar selenium-server-standalone-2.16.jar
@k1000
k1000 / git-rm-from-history.sh
Created August 17, 2011 09:04
permanently delete files/folders from your git repository
#!/bin/bash
set -o errexit
# Author: David Underhill
# Script to permanently delete files/folders from your git repository. To use
# it, cd to your repository's root and then run the script with a list of paths
# you want to delete, e.g., git-delete-history path1 path2
if [ $# -eq 0 ]; then
exit 0
@k1000
k1000 / gravatar.py
Created August 17, 2011 13:26
get gravatar
#http://blog.gravatar.com/2008/01/17/gravatars-in-python-25/
import urllib, hashlib
# Set your variables here
email = "Someone@somewhere.com"
default = "http://www.somewhere.com/homsar.jpg"
size = 40
def get_gravatar(email):
gravatar_url = "http://www.gravatar.com/avatar.php?"
@k1000
k1000 / scrap_imgs.py
Created August 30, 2011 11:09
downlod urls from list in file
import urllib
import os
IMG_DIR = "/Users/kamil/Desktop/PROJECTOS/webtenerife/scrap_actualidad-fr"
def download(url):
"""Copy the contents of a file from a given URL
to a local file.
"""
@k1000
k1000 / .gitconfig
Created August 31, 2011 09:33
my .gitconfig with aliases and other fancy staff
[core]
editor = mate -w
[user]
name = kamil
email = selwak@gmail.com
[color]
ui = auto
[alias]
ai = add --interactive
@k1000
k1000 / mapper.js
Created August 31, 2011 13:49
google maps v3 geocoder
/*
require: jquery
add:
<script type="text/javascript" src="http://maps.googleapis.com/maps/api/js?sensor=true"></script>
*/
var Mapper = function( map_canvas, options ){
var map_canvas = document.getElementById(map_canvas || "map_canvas");
this.markersArray = [];
this.infoWindow = new google.maps.InfoWindow();