Skip to content

Instantly share code, notes, and snippets.

@nfekete
nfekete / check_if_array_is_empty.zsh
Created September 15, 2023 22:38 — forked from fhuitelec/check_if_array_is_empty.zsh
[Check if array is empty] #zsh #shell #cheatsheet
#!/usr/bin/env zsh
#
# Check if array is empty
#
typeset -A knock_sequences
if [ ${#knock_sequences[@]} -eq 0 ]; then
echo "No knock sequence found."
@nfekete
nfekete / path component extraction.sh
Last active April 10, 2023 00:04 — forked from zfenj/gist:43dc107ab0685343d558d2c8024081fd
Zsh: Get Filename or Extension from Path
# https://zaiste.net/zsh_get_filename_extension_path/#!/bin/zsh
# Filename
fullpath="/etc/nginx/nginx.conf"
filename=$fullpath:t
echo $filename
# result: nginx.conf
# Path
fullpath="/etc/nginx/nginx.conf"
{
"Key Mappings": {
"0x2a-0x200000": {
"Action": 12,
"Text": "*"
},
"0x2b-0x200000": {
"Action": 12,
"Text": "+"
},
@nfekete
nfekete / remove-fb-tracking.user.js
Created March 2, 2021 20:18 — forked from k-barton/remove-fb-tracking.user.js
Greasemonkey user script: Remove Facebook's external link tracking
// ==UserScript==
// @name Remove Facebook's external link tracking (updated for the new FB)
// @description Removes redirection and "FB click identifier" from external FB links
// @namespace https://gist.github.com/k-barton
// @include https://*.facebook.com*
// @include http://*.facebook.com*
// @version 0.3.2
// @grant unsafeWindow
// @run-at document-start
// ==/UserScript==
@nfekete
nfekete / -etc-wsl.conf
Created September 24, 2018 22:45
wsl.conf that sets up windows filsystem integration with proper file attribute defaults and metadata overlay
[automount]
enabled = true
options = "metadata,umask=027,fmask=117"
[interop]
appendWindowsPath = false
#!/bin/bash
while [[ $# > 0 ]] ; do
case "$1" in
--not-in-head)
NOT_IN_HEAD=true
;;
esac
shift
done
@nfekete
nfekete / dns-sync.sh
Created August 8, 2018 03:49 — forked from matthiassb/dns-sync.sh
Init.d script for keeping WSL resolv.conf in-sync with Windows
#! /bin/bash
### BEGIN INIT INFO
# Provides: dns-sync
# Required-Start:
# Required-Stop:
# Default-Start: S
# Default-Stop:
# Short-Description: Synchronizes /etc/resolv.conf in WLS with Windows DNS - Matthias Brooks
### END INIT INFO
@nfekete
nfekete / wsl-fix-resolvconf.sh
Created August 8, 2018 03:05
Fix resolv.conf in Windows Subsystem for Linux, when WSL doesn't correctly generate it.
#!/bin/bash
TMP=`mktemp`
trap ctrlC INT
removeTempFiles() {
rm -f $TMP
}
ctrlC() {
@nfekete
nfekete / color-git-prompt-bashrc.sh
Last active June 15, 2018 23:06
.bashrc snippet that sets up a git aware color prompt with xterm window title support
export GIT_PS1_SHOWDIRTYSTATE=true
export GIT_PS1_SHOWCOLORHINTS=true
#PS1='[\u@\h \W$(__git_ps1 " (%s)")]\$ '
#export PROMPT_COMMAND='__git_ps1 "\u@\h:\w" "\\\$ "'
export PROMPT_COMMAND='\
__git_ps1 "\[\033]0;\u@\h: \w\007\]\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]" "\\\$ "\
'
@nfekete
nfekete / GeoJson.java
Created May 22, 2018 13:33 — forked from ibaca/GeoJson.java
GWT JsInterop DTOs inheritance
import static com.fasterxml.jackson.annotation.JsonTypeInfo.As.EXISTING_PROPERTY;
import static com.fasterxml.jackson.annotation.JsonTypeInfo.Id.NAME;
import static jsinterop.annotations.JsPackage.GLOBAL;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonSubTypes;
import com.fasterxml.jackson.annotation.JsonTypeInfo;
import com.fasterxml.jackson.annotation.JsonTypeName;
import javax.annotation.Nullable;
import jsinterop.annotations.JsOverlay;