Skip to content

Instantly share code, notes, and snippets.

View gyula-ny's full-sized avatar

Gyula Nyirfalvi gyula-ny

View GitHub Profile
@gyula-ny
gyula-ny / bashrc.sh
Created November 22, 2020 08:29
Change the window title of X terminals
case ${TERM} in
[aEkx]term*|rxvt*|gnome*|konsole*|interix)
PS1='\[\033]0;\u@\h:\w\007\]'
;;
screen*)
PS1='\[\033k\u@\h:\w\033\\\]'
;;
*)
unset PS1
;;
@gyula-ny
gyula-ny / control-i3-with-mid.md
Last active September 6, 2022 23:50
Control i3 via IPC with a MIDI device.

We need two NPM packages:

npm install midi i3

The "midi" pacakge is a native package, and has its own dependencies and you'll need have build tools installed. (e.g. build-essential package, python, ALSA (which is typically already installed in any linux environment, and libasound2-dev (in ubuntu) or alsa-lib-devel (in fedora/redhat) package).

We typically need to start with finding the port number of the midi device we want to use:

// Available variables:
// - Machine
// - interpret
// - assign
// - send
// - sendParent
// - spawn
// - raise
// - actions
@gyula-ny
gyula-ny / machine.js
Last active January 28, 2020 13:41
Generated by XState Viz: https://xstate.js.org/viz
// Available variables:
// - Machine
// - interpret
// - assign
// - send
// - sendParent
// - spawn
// - raise
// - actions
@gyula-ny
gyula-ny / has-only-empty-arr-fields.js
Created February 6, 2019 10:02
check whether all fields of an object that are arrays are empty
const hasOnlyEmptyArrFields = obj => {
return Object.keys(obj).filter(key => Array.isArray(obj[key]))
.reduce((result, incoming) => {
return result && obj[incoming].length === 0
}, true)
}
@gyula-ny
gyula-ny / bclock.js
Created December 19, 2018 12:30
binary clock for a rp3 sense-hat-led driven LED-matrix (playing in the ramda REPL)
const COLORED = [220, 0, 0]; // RGB values for sense-hat-led package "setPixel" func
const UNCOLORED = [0, 0, 0];
const VERTICAL_OFFSET = 4; // clock will appear at bottom half of the 8x8 matrix
const coloredOrNot = bit => [UNCOLORED, COLORED][bit];
const zeroPad = num => str => str.padStart(num, "0");
const toBinary = num => num.toString(2);
const explode = str => str.split("");
const eachToNumber = R.map(Number);
const explodeAsBinary = R.pipe(toBinary, zeroPad(4), explode, eachToNumber); // 9 => [1, 0, 0, 1]
const explodeTimePiece = R.pipe(String, zeroPad(2), explode, eachToNumber); // "8" => [0, 8]
@gyula-ny
gyula-ny / partof.bashrc.sh
Created November 23, 2017 12:13
FZF && fd
[ -f ~/.fzf.bash ] && source ~/.fzf.bash
export FZF_DEFAULT_COMMAND="fd . $HOME"
export FZF_CTRL_T_COMMAND="$FZF_DEFAULT_COMMAND"
export FZF_ALT_C_COMMAND="fd -t d . $HOME"
@gyula-ny
gyula-ny / verboseObject.js
Created November 23, 2017 09:49
returns [value, exists] tuple for object property access
var handler = {
get: function(target, name) {
if (name in target) {
return [target[name], true]
} else {
return [null, false]
}
}
@gyula-ny
gyula-ny / keybase.md
Last active November 2, 2017 10:58
keybase.md

Keybase proof

I hereby claim:

  • I am gyula-ny on github.
  • I am gznyirfa (https://keybase.io/gznyirfa) on keybase.
  • I have a public key ASA13fVdunAf65wdJByXbFW_IaTq8kDQbCMi4pcFYyJcDgo

To claim this, I am signing this object: