Skip to content

Instantly share code, notes, and snippets.

@antoni
antoni / hashmap.sh
Created May 16, 2017 11:54
Hashmap in Bash
declare -A hashmap
hashmap["key"]="value"
hashmap["key2"]="value2"
echo "${hashmap["key"]}"
for key in ${!hashmap[@]}; do echo $key; done
for value in ${hashmap[@]}; do echo $value; done
@antoni
antoni / hide_keystrokes.c
Created September 17, 2015 11:21
Hide & show keystrokes in a Linux terminal
#include <termios.h>
void hide_keystrokes() {
struct termios tty;
tcgetattr(STDIN_FILENO, &tty);
tty.c_lflag &= ~ECHO;
tcsetattr(STDIN_FILENO, TCSANOW, &tty);
}
void show_keystrokes() {
@antoni
antoni / gist:ab29e5d2a9aee3aeea41
Last active December 29, 2022 14:30
Git cheat sheet
# Move code from one repo to another, preserving commit history
# Source: http://stackoverflow.com/a/17373088/963881
cd repo2
git checkout master
git remote add r1remote **url-of-repo1**
git fetch r1remote
git merge r1remote/master
git remote rm r1remote
# Push to master without having to --set-upstream-to first
@antoni
antoni / remove-all-from-docker.sh
Created June 22, 2022 10:21 — forked from beeman/remove-all-from-docker.sh
Remove all from Docker
# Stop all containers
docker stop `docker ps -qa`
# Remove all containers
docker rm `docker ps -qa`
# Remove all images
docker rmi -f `docker images -qa `
# Remove all volumes
@antoni
antoni / getScrollableParent.js
Created June 8, 2022 21:31 — forked from twxia/getScrollableParent.js
Get Scrollable Parent
function getScrollParent(node) {
const isElement = node instanceof HTMLElement;
const overflowY = isElement && window.getComputedStyle(node).overflowY;
const isScrollable = overflowY !== 'visible' && overflowY !== 'hidden';
if (!node) {
return null;
} else if (isScrollable && node.scrollHeight >= node.clientHeight) {
return node;
}
@antoni
antoni / sbt-centos.md
Created May 27, 2022 10:22 — forked from diegopacheco/sbt-centos.md
Install Scala SBT on Amazon Linux | CentOS

Setup proxy

export https_proxy="https://my-proxy.com:443"
export http_proxy="https://my-proxy.com:80"

sudo vim /etc/yum.conf

add proxy on first line proxy=https://my-proxy.com:80

[main]
@antoni
antoni / AcademicDegree.java
Last active June 25, 2021 12:28
Random enum value in Java
public enum AcademicDegree {
DEGREE_MSC, DEGREE_PHD, DEGREE_PHD_HAB, DEGREE_PROF;
private static final AcademicDegree[] VALUES = values();
private static final int SIZE = VALUES.length;
private static final Random RANDOM = new Random();
public static AcademicDegree getRandomLetter() {
return VALUES[RANDOM.nextInt(SIZE)];
// Intended to be run on https://google.pl
function executeSearchTypingScript() {
const googleDomain = 'google.pl';
if (window.location.href.indexOf('google.pl') === -1) {
throw new Error(`This script should be run on ${googleDomain}`);
}
const searchInputField = document.querySelector('[aria-label=Szukaj]');
### Keybase proof
I hereby claim:
* I am antoni on github.
* I am antoni (https://keybase.io/antoni) on keybase.
* I have a public key ASAPlJzPyid_8vQoMmG2Dj5nzdugiKAYEtNIAJFGIA0AFgo
To claim this, I am signing this object:
@antoni
antoni / keybase.md
Created March 18, 2019 09:36 — forked from webframp/keybase.md
Signing git commits on github using keybase.io gpg key

Probably one of the easiest things you'll ever do with gpg

Install Keybase: https://keybase.io/download and Ensure the keybase cli is in your PATH

First get the public key

keybase pgp export | gpg --import

Next get the private key