This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from string import letters | |
def calc_excel_column_number(string): | |
""" | |
Return number representing the column index in MS excel | |
A is the first column - return 1 | |
B is the second column - return 2 | |
... | |
Z is the 26th column - return 26 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
# -*- coding: utf-8 -*- | |
# | |
# eik_checker.py | |
# | |
# Copyright 2012 Venelin Stoykov <[email protected]> | |
# | |
# 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 2 of the License, or |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<html> | |
<head> | |
<style type="text/css"> | |
html, body { width: 100%; height: 100%; overflow: hidden; padding: 0; margin: 0; border: 0;} | |
.bg-white { background: #FFFFFF; } | |
.bg-red { background: #FF0000; } | |
.bg-green { background: #00FF00; } | |
.bg-blue { background: #0000FF; } | |
.bg-cyan { background: #00FFFF; } | |
.bg-yellow { background: #FFFF00; } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
# coding: utf-8 | |
""" | |
Program that convert text files from one encoding to another. | |
By default it is used to convert windows-1251 encoded subtitles | |
into ISO-8859-5 ecoded because this is encoding for cyrilic | |
characters in Panasonic Viera TV | |
Tested on Python 2.7+ and Python 3.2+ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export GIT_PS1_SHOWDIRTYSTATE=true | |
export GIT_PS1_SHOWUNTRACKEDFILES=true | |
if [ "$color_prompt" = yes ]; then | |
PS1='${debian_chroot:+($debian_chroot)} `if [ $? = 0 ]; then echo "\[\e[32m\]✔"; else echo "\[\e[31m\]✘"; fi` \[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\] `__git_ps1 "(%s)"`\n \[\033[01;34m\]\$\[\033[00m\] ' | |
else | |
PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w$(__git_ps1 " (%s) ")\$ ' | |
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var intcomma = function(value, delimiter) { | |
/* | |
Original script found here https://gist.github.com/559757 | |
Added optional argument delimiter to choose witch symbol | |
to use for thousand delimiter | |
*/ | |
var origValue = String(value); | |
if (typeof(delimiter) == 'undefined') delimiter = ','; | |
var newValue = origValue.replace(/^(-?\d+)(\d{3})/, '$1'+delimiter+'$2'); | |
if (origValue == newValue){ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
One To One field that does not rise an Exception | |
In your models you now can write: | |
class Profile(models.Model): | |
user = AdvancedOneToOneField(User, related_name="profile") | |
And using in code like this: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
if [ `whoami` != 'root' ]; then | |
echo "You must to be root" | |
exit | |
fi | |
DOWNLOAD_URL="http://geolite.maxmind.com/download/geoip/database/GeoLiteCity.dat.gz" | |
TEMPFILE="/tmp/GeoIPCity.dat" | |
TEMPFILEGZ="$TEMPFILE.gz" | |
GEOIP_DIR="/usr/local/share/GeoIP" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from django.contrib import admin | |
from django.conf.urls.defaults import patterns, url | |
from django.shortcuts import redirect, Http404 | |
class ActionForObjectAdmin(admin.ModelAdmin): | |
""" | |
Admin that add some urls wich can call an action for given object. | |
Example: | |
if url is /admin/myapp/mymodel/object_id/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
################################################################# | |
# Startup script for Django server, that will be placed | |
# in /usr/local/bin for example. It may be symlinked | |
# in project dir with name "run" like: |