Skip to content

Instantly share code, notes, and snippets.

View avalanchy's full-sized avatar

Mariusz Osiecki avalanchy

  • Poland
View GitHub Profile
var ProductCategoryRow = React.createClass({
render: function() {
return (<tr><th colSpan="2">{this.props.category}</th></tr>);
}
});
var ProductRow = React.createClass({
render: function() {
var name = this.props.product.stocked ?
this.props.product.name :
for a, b, c in itertools.product([True, False], repeat=3):
print (a and (b or c)) is (a and b or c)
# True
# True
# True
# False
# True
# False
# True
"""Skrypt pozwala na pobieranie z napiprojekt.pl gdy nie posiadamy aplikacji.
ID z URL z wynikow wyszukiwania podajemy jako argument do skryptu. Np.
$ python napiprojekt.py e79975aa41dfecf52b81ac8231f4abde > napisy.txt
Wymagania:
* Python 2.7
* Paczki z requirements.txt
"""
// ==UserScript==
// @name Hacker News - Score like reddit
// @namespace http://avalanchy.tk/
// @version 0.1
// @description Swap score with the position
// @author avalanchy
// @match https://news.ycombinator.com/*
// @grant none
// ==/UserScript==
@avalanchy
avalanchy / ipega
Last active July 27, 2019 10:04
BlueZ (Andoroid) Keys mapping for Ipega (Bluetooth HID contoller) and GTA3.
Dpad Left DPAD_LEFT walk left
Dpad Right DPAD_RIGHT walk right
Dpad Up DPAD_UP walk forward
Dpad Down DPAD_DOWN walk backwards
Button A 3 jump / break or reverse
Button B 7 handbrake
Button X 1 run / accelerate
Button Y 2 shoot
Button L 6 change weapon down / look left in car
@avalanchy
avalanchy / dicts_diff.py
Created July 14, 2014 13:22
compare two dicts by showing diff #python
from difflib import ndiff
from pprint import pformat
def dicts_diff(d1, d2):
return '\n'.join(ndiff(*(pformat(d).splitlines() for d in (d1, d2))))
@avalanchy
avalanchy / cast.py
Created May 22, 2014 12:53
Python bool casting
>>> from dis import dis
>>> a = lambda: bool('')
>>> b = lambda: not not ''
>>> dis(a)
1 0 LOAD_GLOBAL 0 (bool)
3 LOAD_CONST 1 ('')
6 CALL_FUNCTION 1
9 RETURN_VALUE
>>> dis(b)
1 0 LOAD_CONST 1 ('')
@avalanchy
avalanchy / pre-push
Last active August 29, 2015 14:01
GIT: Display branch url and check for PDB when pushing into remote repository. #python #git #git-hook
#!/usr/bin/python
import subprocess
import sys
def branch_url():
remote = sys.argv[2]
command = 'git branch --contains'
branch_name = subprocess.check_output(command, shell=True).strip(' *\n')
@avalanchy
avalanchy / clear.py
Last active August 29, 2015 13:57 — forked from mildsunrise/clear.py
How to clear python interpreter console?
import os
import subprocess
if os.name in ('ce', 'nt', 'dos'):
def clear():
subprocess.call('cls', shell=True)
elif 'posix' in os.name:
def clear():
@avalanchy
avalanchy / walk_pybabel.py
Last active August 29, 2015 13:56
pybabel errors logging. runs pybabel and check if files with jinja2 wrappers are in messages.pot.
"""runs pybabel and check if files with jinja2 wrappers are in messages.pot"""
import os
# config some constants
ROOT_DIR = 'templates'
FILES_EXTENSIONS = ('.html', '.txt')
SEARCH_TAGS = ('{% trans', '_(')
OUTPUT_FILE = 'locales/messages.pot'