Skip to content

Instantly share code, notes, and snippets.

View e3krisztian's full-sized avatar

Krisztián Fekete e3krisztian

  • Budapest, Hungary
View GitHub Profile
@e3krisztian
e3krisztian / fzf-git-hash.sh
Created December 8, 2020 07:49
fzf-git-hash
#!/bin/bash
KEEP_ONLY_GIT_HASH='sed "s/^[*|\\\\/ ]*\\([^ ]*\\) .*/\\1/"'
GIT_LOG=(
git log
--color=always
--graph
--pretty=format:'%Creset%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset'
--abbrev-commit
--date=relative
@e3krisztian
e3krisztian / converter.py
Last active August 14, 2018 07:21
Python @converter decorator
import functools
def converter(convert):
"""Decorator for making decorators converting function return values.
Take a single argument function and make it into a decorator
converting return values of other functions.
"""
@functools.wraps(convert)
@e3krisztian
e3krisztian / flake8junit.py
Created March 21, 2018 08:27
experimental Junit wrapper for flake8
import sys
from xml.etree.ElementTree import ElementTree, XML, tostring as xml_tostring
JUNIT_SINGLE_SUCCESS = '''\
<?xml version="1.0" encoding="UTF-8"?>
<testsuite tests="1">
<testcase name="Clean code!"/>
</testsuite>
'''
JUNIT_SINGLE_FAILURE = '''\
@e3krisztian
e3krisztian / template.py
Created November 17, 2017 06:48 — forked from jamescasbon/template.py
Pure python templates using with statement
"""
A really stupid python template language inspired by coffeekup, markaby.
Do not use this code, it will ruin your day. A byproduct of insomnia.
TL;DR
-----
This module defines a template language that allows us to do:
d = Doc()
@e3krisztian
e3krisztian / nb-conda-kernels.sh
Last active March 18, 2017 20:49
setup jupyter notebook to get kernels from conda envs
conda install -c defaults -c conda-forge nb_conda_kernels
#!/usr/bin/env python2
import Tkinter as tk
f = tk.Frame()
f.pack()
w1 = tk.Label(f, text='widget1')
w1.grid(column=0, row=0)
w2 = tk.Label(f, text='widget2')
w2.grid(column=120, row=12)
#!/bin/bash
# This worked kind of, now brother suggests using another driver - HL-1118
# https://www.reddit.com/r/linuxquestions/comments/2pupp3/linux_print_driver_for_brother_hl1110/
# http://support.brother.com/g/s/id/linux/en/download_prn.html#HL-1110
# exit on error
set -e
wget http://www.brother.com/pub/bsc/linux/dlf/hl1110cupswrapper-3.0.1-1.i386.rpm
def tohex1(n):
assert 0 <= n <= 15
return '0123456789ABCDEF'[n]
def tohex2(n):
assert 0 <= n <= 255
return tohex1(n // 16) + tohex1(n % 16)
@e3krisztian
e3krisztian / class4-tasks-loops-and-strings.ipynb
Created March 8, 2016 12:17
class4 tasks: loops and strings
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

Convert code from last class to functions

function: tohex1(n) n in {0..15}

assert tohex1(0) == '0'
assert tohex1(15) == 'F'

function: tohex2(n)