Skip to content

Instantly share code, notes, and snippets.

View vkolev's full-sized avatar

Vladimir Kolev vkolev

View GitHub Profile
from flask import Flask
from flask.ext.sqlalchemy import SQLAlchemy
from app.views.index import IndexView
app = Flask(__name__)
app.config.from_object('config')
db = SQLAlchemy(app)
IndexView.register(app)
@vkolev
vkolev / stupidity.vbs
Created July 15, 2013 11:03
At work I was amazed with this ... scientific explanation of programming stupidity ... Really! And this IS used in production system...
'Here is where all starts he actually counted the characters from the SOAP response
projectname = Mid(xmlhttp.responseText, 339, 30)
'And here the explaned stupidity
'Aufgrund fehlender Funktionalität händische Überprüfung
'auf schließendes Tag </projektname> und dessen Teil-Mengen
'mit anschließender Entfernung aus der Variablen
If InStr(projektname, "</projectname>") Then
@vkolev
vkolev / gist:5582229
Created May 15, 2013 07:36
Execute function by string
def test():
print "Call from global"
globals()["test"]()
@vkolev
vkolev / app.py
Created September 17, 2012 17:50
gi.repository Granite with Python
#!/usr/bin/env python2.7
# -*- coding: utf-8 -*-
#
# app.py
#
# Copyright 2012 Vladimir Kolev <vladi@elementos>
#
# This is a semple application using the Granite widgets
# from the ElementaryOS project
#
@vkolev
vkolev / prettyjson.py
Created January 29, 2012 16:22 — forked from edufelipe/prettyjson.py
Script to prettyprint and highlight json to terminal
#!/usr/bin/env python
import cStringIO
import json
import sys
from pygments import highlight
from pygments.formatters import Terminal256Formatter
from pygments.lexers.web import JavascriptLexer
from pygments import styles
@vkolev
vkolev / setup.py
Created April 17, 2011 16:05
pyexe setup file for windows
from distutils.core import setup
import py2exe
opts = {
'py2exe': {
'includes': 'pango,atk,gobject',
'dll_excludes': [
'iconv.dll', 'intl.dll', 'libatk-1.0-0.dll',
'libgdk_pixbuf-2.0-0.dll', 'libgdk-win32-2.0-0.dll',
'libglib-2.0-0.dll', 'libgmodule-2.0-0.dll',
;; Tab indention for Python
(setq-default indent-tabs-mode nil)
(setq default-tab-width 4)
;; Pymacs configuration
(add-to-list 'load-path "~/.emacs.d/vendor")
(require 'pymacs)
(pymacs-load "ropemacs" "rope-")
(setq ropemacs-enable-autoimport t)
# First method to run a function from string
# here we use the dir method to get the available functions in django
# and we know that the 7-th result in the array is the function get_version() since
# I have tested it, but it can be any other
import django
test = dir(django)
print "\nFirst example is running function from django called %s" % test[7]
print "result: %s" % django.__getattribute__(test[7])()
# Second method to run a function from string
#!/usr/bin/env python
#
# formatter.py
#
# Copyright 2010 Vladimir Kolev <admin@vladimirkolev.com>
#
# 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
# (at your option) any later version.
sub on_join {
# get our connection object and the event object, which is passed
# with this event automatically
my ($conn, $event) = @_;
# this is the nick that just joined
my $nick = $event->{nick};
# say hello to the nick in public
$conn->privmsg($conn->{channel}, "Hello, $nick!");