Skip to content

Instantly share code, notes, and snippets.

View ktprezes's full-sized avatar

Tadeusz Kurpiel ktprezes

View GitHub Profile
@ktprezes
ktprezes / pacman-specific-repo-update.txt
Last active July 20, 2023 01:29
Linux - bash - pacman - update packages FROM SPECIFIC REPOSITORY ONLY
/*
* Linux, bash, pacman
* how to upgrade packages only from specific repository - eg. 'core'
* of course you can change 'core' to any other desired ;)
*/
pacman -S --needed $(comm -12 <(pacman -Qq | sort) <(pacman -Slq core | sort))
/*
* longer description of this command - see:
@ktprezes
ktprezes / Caesar-cipher-naive-implementation.py
Last active March 1, 2021 10:08
Python - Szyfr Cezara - przykładowa implementacja - (Caesar cipher naive implementation)
#!/usr/bin/python
# -*- coding: UTF-8 -*-
# Szyfr Cezara - przykładowa implementacja
# dla zdekodowania zaszyfrowanego tekstu trzeba podać przesunięcie o przeciwnym znaku
# np: kodowanie z przesunięciem '7', to dekodowanie - z przesunięciem '-7'
# lub kodowanie z przesunięciem '-100', to dekodowanie - z przesunięciem '100'
alfabet = 'aAąĄbBcCćĆdDeEęĘfFgGhHiIjJkKlLłŁmMnNńŃoOóÓpPqQrRsSśŚtTuUvVwWxXyYzZźŹżŻ'
@ktprezes
ktprezes / python_custom_thousand_separator.py
Last active April 5, 2019 00:35
Python - formatted output - custom thousand separator - własny znak separatora tysięcy
#!/usr/bin/env python
# -*- coding: UTF-8 -*-
# suppose you want (or have to) change in output string
# default thousand separator to custom one (and not your locale flavour)
# try e.g. this kind of format string:
your_long_number=12345678901234567890
print( f"{your_long_number:26_d}".replace("_", "`") )
@ktprezes
ktprezes / VSCode-and-python.txt
Last active March 12, 2019 15:37
MS Visual Studio Code (VS Code) and Python
# problem:
# VS Code with installed python extension doesn't see python interpreter I want to use
# (I've faced it in windows 8.1 with Python 3.7 installed
# and minor (older versions) python installations distributed with emacs and msys64)
# solution (it worked for me ;) ):
# 0. install virtualenv package, eg:
pip install virtualenv
@ktprezes
ktprezes / graphqlhello.py
Last active March 12, 2019 18:52
Graphene Python GraphQL library 'Hello World!' file with links to documentation
#!python3
# -*- coding: utf-8 -*-
'''
graphqlhello.py - "Hello World" file for Graphene
Graphene is GraphQL library for Python
see:
https://graphql.org/
https://graphene-python.org/
https://docs.graphene-python.org/en/latest/
@ktprezes
ktprezes / gaderypoluki.py
Created March 18, 2019 16:26
Python - szyfr 'gaderypoluki' - przykładowa implementacja - można podać inny klucz - z innymi parami
#!/usr/bin/python
# -*- coding: UTF-8 -*-
# Szyfr GaDeRyPoLuKi - przykładowa implementacja
# założenie: znaki w kluczu są unikalne - nie muszą to być litery; klucz ma parzystą długość
# wymieniane są między sobą parami: klucz[0] <-> klucz[1], ..., klucz[10] <-> klucz[11], itd...
# kończy działanie po podaniu pustego tekstu - np po naciśnięciu samego 'Enter'
klucz_def:str = 'GADERYPOLUKI' # klucz default / domyślny
klucz_we :str =""
@ktprezes
ktprezes / gaderypoluki-dict-version.py
Created March 19, 2019 12:03
Python - szyfr 'gaderypoluki' - wersja ze słownikiem generowanym w 'runtime' na podstawie podanego klucza - by Piotrek S.
# coding: utf-8
klucz = "gaderypoluki"
# tu klucz podany na sztywno - ale można wczytać od usera
substytucje = dict(zip(klucz[::2], klucz[1::2]))
substytucje.update(zip(klucz[1::2], klucz[::2]))
# tworzenie słownika 'w obie strony' na podstawie podanego klucza
# pierwsze zip wstawia 'parzyste' znaki jako klucze słownika, a 'nieparzyste' jako wartości
# a drugie zip - na odwrót
@ktprezes
ktprezes / chrome.md
Last active April 5, 2019 18:07
web browsers-tips and tricks-przeglądarki-sztuczki i chwyty

Some of chrome tips&tricks

chrome://chrome-urls/ - list of "chrome url's" - some of most popular one's:

  • chrome://about/ - same as chrome://chrome-urls/
  • chrome://apps/
  • chrome://bookmarks/
  • chrome://components/
  • chrome://conflicts/
  • chrome://discards/
@ktprezes
ktprezes / what-forces-layout.md
Created April 14, 2019 14:13 — forked from paulirish/what-forces-layout.md
What forces layout/reflow. The comprehensive list.

What forces layout / reflow

All of the below properties or methods, when requested/called in JavaScript, will trigger the browser to synchronously calculate the style and layout*. This is also called reflow or layout thrashing, and is common performance bottleneck.

Element

Box metrics
  • elem.offsetLeft, elem.offsetTop, elem.offsetWidth, elem.offsetHeight, elem.offsetParent
  • elem.clientLeft, elem.clientTop, elem.clientWidth, elem.clientHeight
  • elem.getClientRects(), elem.getBoundingClientRect()
@ktprezes
ktprezes / python-empty-list-dict-set-creation.py
Created April 14, 2019 16:56
Python - how to create empty list / dict / set
# creating empty objects
empty_l = [] # list
empty_d = {} # dictionary
empty_s1= set() # set
# type check method #1
type(empty_l)
type(empty_d)
type(empty_s1)