Skip to content

Instantly share code, notes, and snippets.

View karolyi's full-sized avatar
🏠
Working from home

László Károlyi karolyi

🏠
Working from home
View GitHub Profile
@karolyi
karolyi / search_highlight.py
Last active June 10, 2019 17:09
Highlighter of search terms in HTML
from functools import lru_cache
from bs4 import BeautifulSoup as bs
from bs4 import Tag
from bs4.element import NavigableString
from django.utils.html import escape
from django.utils.functional import cached_property
from unidecode import unidecode
from . import memoized_method
{
"workbench.colorTheme": "Monokai",
"editor.fontFamily": "'Roboto Mono Light', 'Courier New', monospace, 'Droid Sans Fallback'",
"editor.fontSize": 18,
"editor.wordWrap": "bounded",
"editor.rulers": [
72, 79
],
"files.autoSave": "onFocusChange",
"editor.renderWhitespace": "all",
### Keybase proof
I hereby claim:
* I am karolyi on github.
* I am karolyi (https://keybase.io/karolyi) on keybase.
* I have a public key whose fingerprint is D0CC 28D1 8E86 673E C579 0034 372A A22D 38BD 5B13
To claim this, I am signing this object:
@karolyi
karolyi / pip_update.sh
Last active September 13, 2020 16:54
Script to update all PIP packages to latest version, with a user installed PIP
#!/usr/bin/env sh
# Packages necessary on ubuntu: python3-pip
USED_PYTHON_BINARY="python3.7"
set -x
# Install/update basic package handling tools
$USED_PYTHON_BINARY -m pip install --user -U pip wheel setuptools
@karolyi
karolyi / convoluted_select.py
Last active June 29, 2016 16:19
Django selecting newest values on a field by 'grouping' on the same table
# We have a Django `Updates` model with `product`, `date`, `version` fields.
# We want to fetch the newest versions of products without executing many queries, in a Django way.
from django.db.models import CharField, Value as V
from django.db.models.functions import Concat
a = Updates.objects.values('product_id').annotate(cc=Concat('product_id', V('-'), Max('date'), output_field=CharField())).values('cc')
b = Updates.objects.annotate(cc=Concat('product_id', V('-'), 'date', output_field=CharField())).filter(cc__in=a)
@karolyi
karolyi / osx_keyboardspeed.sh
Created November 19, 2015 20:54
Mac OS X super fast keyboard speed
#!/usr/bin/env bash
# http://papers.ch/speeding-up-your-mac-osx-terminal-input/
#echo "Disable press-and-hold for keys in favor of key repeat"
#defaults write NSGlobalDomain ApplePressAndHoldEnabled -bool false
echo "Set a blazingly fast keyboard repeat rate"
defaults write NSGlobalDomain KeyRepeat -int 0.02
@karolyi
karolyi / config.fish
Last active October 29, 2022 13:10
My fish-shell settings
# Path to Oh My Fish install.
set -q XDG_DATA_HOME
and set -gx OMF_PATH "$XDG_DATA_HOME/omf"
or set -gx OMF_PATH "$HOME/.local/share/omf"
# Customize Oh My Fish configuration path.
#set -gx OMF_CONFIG /Users/laszlokarolyi/.config/omf
# Reload user_abbreviations by executing:
. ~/.config/fish/abbreviations/fish_user_abbreviations.fish
@karolyi
karolyi / esc256.outlang
Created July 27, 2015 08:53
256 color source highlight for less on FreeBSD terminals
extension "txt"
# Path: /usr/local/share/source-highlight/
styletemplate "\x1b[$stylem$text\x1b[m"
color "00;38;05;$style"
colormap
"blue" "75"
"darkblue" "33"
#!/usr/bin/env bash
# Turns your smartplug on and off. Set the IP and the password in the variables below.
# Works with SP-1101w and SP-2101W plugs.
# http://www.edimax.com/images/Image/manual/HomeAutomation/SP-1101W/SP-1101W_manual.pdf
EDIMAX_IP='192.168.1.141'
EDIMAX_PASSWORD='password'
STATE='ON'
@karolyi
karolyi / termin.sh
Last active December 16, 2019 12:48
Best appointment date finder for the Berlin authorities
#!/usr/bin/env bash
RETCODE=1
# Change the URL in the curl commandline for yourself.
while [[ $RETCODE == 1 ]]; do
echo -n "$RANDOM ... "
OUT=$(curl -gs "https://service.berlin.de/terminvereinbarung/termin/tag.php?termin=1&anliegen[]=121598&dienstleisterlist=122210,122217,122219,122227,122231,122238,122243,122252,122260,122262,122254,122271,122273,122277,122280,122282,122284,122285,122286,122296,150230,122301,122297,122294,122312,122314,122304,122311,122309,317869,324433,325341,324434,122281,122276,122274,122267,122246,122251,122257,122208,122226,121646&herkunft=http%3A%2F%2Fservice.berlin.de%2Fdienstleistung%2F121598%2F&asd=$RANDOM"|grep '"buchbar'|head -1|grep 'datum=2015-10')
RETCODE=$?