Skip to content

Instantly share code, notes, and snippets.

View cleac's full-sized avatar

@alexcleac cleac

View GitHub Profile
@cleac
cleac / monads.py
Created August 13, 2019 18:27
Some monads in python
class Monad:
def __init__(self, value):
self.value = value
def __iter__(self):
yield self
def do(self):
raise NotImplementedError()
@cleac
cleac / imort_dis_5.py
Created May 1, 2018 08:44
"import dis" article gist 5
>>> def string_generation_function(argument):
... return 'hello, {}'.format(argument)
...
>>> def function_for_dis(argument):
... return [[string_generation_function('world')]] * 10
...
>>> dis.dis(function_for_dis)
2 0 LOAD_GLOBAL 0 (string_generation_function)
3 LOAD_CONST 1 ('world')
6 CALL_FUNCTION 1
@cleac
cleac / import_dis_4.py
Created May 1, 2018 08:42
"import dis" article gist 4
>>> ['test'] * 20
['test', 'test', 'test', 'test', 'test', 'test', 'test', 'test', 'test', 'test', 'test', 'test', 'test', 'test', 'test', 'test', 'test', 'test', 'test', 'test']
@cleac
cleac / import_dis_3.py
Created May 1, 2018 08:38
"import dis" article gist 3
>>> def string_generation_function(argument):
... return 'hello, {}'.format(argument)
...
>>> def function_for_dis():
... return [[string_generation_function('world')] for _ in range(10)]
...
>>> dis.dis(function_for_dis)
2 0 BUILD_LIST 0
3 LOAD_GLOBAL 0 (range)
6 LOAD_CONST 1 (10)
@cleac
cleac / import_dis_2.py
Created May 1, 2018 08:36
"import dis" article gist 2
>>> def t():
... print 1
...
>>> dis.dis(t)
2 0 LOAD_CONST 1 (1)
3 PRINT_ITEM
4 PRINT_NEWLINE
5 LOAD_CONST 0 (None)
8 RETURN_VALUE
@cleac
cleac / import_dis_1.py
Created May 1, 2018 08:33
"import dis" article gist 1
def get_something_great(ids):
 # some cool operations
 # <…>
 return [url.somewhere.absolute(‘home’) for _ in id]
Section "InputClass"
Identifier "keyboard defaults"
MatchIsKeyboard "on"
Option "XkbLayout" "us,ua"
Option "XkbOptions" "grp:caps_switch"
EndSection

Keybase proof

I hereby claim:

  • I am cleac on github.
  • I am alexcleac (https://keybase.io/alexcleac) on keybase.
  • I have a public key whose fingerprint is EEA9 ED2F DB3A 5C82 0C3A E263 E7C3 F045 5726 FAF9

To claim this, I am signing this object:

@cleac
cleac / vagiclean
Created March 29, 2018 12:35
Script for all unused data from your workspace directory
#!/bin/bash
workspace_dir=$HOME/workspace
case "$1" in
activate)
for dr in $(ls "$workspace_dir"); do
cd "$workspace_dir/$dr"
vagga _clean --unused 2&>1 > /dev/null &
done;;
Python 2.7.12 (default, Dec 4 2017, 14:50:18)
[GCC 5.4.0 20160609] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> from trafaret_validator import TrafaretValidator
>>> import trafaret as t
>>> class T1(TrafaretValidator):
... id = t.Int()
...
>>> x = T1(id=1)
>>> x.test = 1