Skip to content

Instantly share code, notes, and snippets.

@gennad
gennad / gist:5056896
Created February 28, 2013 13:55
My .vimrc
set nocompatible
"Включаем распознавание типов файлов и типо-специфичные плагины:
filetype on
filetype plugin on
filetype plugin indent on
"Настройки табов для Python, согласно рекоммендациям
set tabstop=4
set shiftwidth=4
@gennad
gennad / gist:5056883
Created February 28, 2013 13:54
my .tmux.conf
set prefix C-a
unbind-key C-b
bind-key C-a send-prefix
@gennad
gennad / gist:5056635
Created February 28, 2013 13:14
My .vrapperrc
set incsearch
set hlsearch
autocmd CursorMoved * exe printf('match IncSearch /\V\<%s\>/', escape(expand('<cword>'), '/\''))
@gennad
gennad / gist:3955478
Created October 25, 2012 21:18
Python type checker
import types
classobj = types.ClassType
def check_base_type(arg, nested=False):
msgs = []
if isinstance(arg, tuple) and not nested:
[check_base_type(a, True) for a in arg]
@gennad
gennad / 144-2-1.cc
Created August 24, 2012 23:02
144-2-1
#include <iostream>
#include <string>
#include <sstream>
#include <assert.h>
class Time {
public:
std::string whatTime(int seconds);
};
@gennad
gennad / gist:3396504
Last active October 8, 2015 22:17
latest .emacs
(package-initialize)
(require 'whitespace)
;; (setq whitespace-style '(face empty tabs lines-tail trailing))
(setq whitespace-style '(face empty tabs trailing))
(global-whitespace-mode t)
(setq whitespace-line-column 300)
(setq org-directory "~/Dropbox/org/")
(setq next-line-add-newlines nil)
@gennad
gennad / gist:2894234
Created June 8, 2012 07:32
Python database populate
import random
import MySQLdb
db=MySQLdb.connect(db="task", user='root')
def get_query():
def get_date():
year = str(random.randint(2011, 2012))
month = str(random.randint(1, 12))
@gennad
gennad / gist:2851140
Created June 1, 2012 10:52
Simple interview question Python
# What's wrong in the code?
# A: No call to parent __init__. To call, uncomment the code
class A:
def __init__(self):
self._greeting = 'hello'
def greet(self):
print self._greeting
@gennad
gennad / gist:2851103
Created June 1, 2012 10:43
Tricky question Python
class A:
def __init__(self):
# self = B instance, when mangled, __value is replaced
# by _CurrentClass__value , so self.__dict__['_A__value'] = 1
self.__value = 1
self.__a = 123
def getvalue(self):
print self.__a # OK
return self.__value # Error - because of assignment in B.__init__