Skip to content

Instantly share code, notes, and snippets.

@d630
d630 / x.sh
Last active December 5, 2016 20:07
bash bash bash
#!/usr/bin/env bash
myscript () {
typeset a i k;
# setup cmd; declare functions
for i in "${!g_@}"; do
typeset -n j=$i;
typeset "action_${!j}";
for k in ${j}; do
@d630
d630 / x.sh
Last active October 1, 2018 15:16
bash: any idea how to use the readline function 'history-and-alias-expand-line' in a recursive way?!
#!/usr/bin/env bash
# Method 1
bind -x '"\C-x4": history_and_alias_expand_line';
bind '"\C-x3": history-and-alias-expand-line';
bind -x '"\C-x2": READLINE_LINE_OLD="$READLINE_LINE"';
bind '"\C-x1": "\C-x2\C-x3\C-x4\C-x5"';
function history_and_alias_expand_line {
@d630
d630 / x.sh
Last active March 28, 2017 18:55
bash
fn () { tput setaf 1; printf '<%s>\n' "$BASH_COMMAND"; tput sgr0; }
shopt -s extdebug
trap fn DEBUG
# then type:
: && $(:)
# diagnosis:
bash: $'\E[31m<:>': command not found
@d630
d630 / 0.16.2.md
Last active January 26, 2017 13:28
fzf - a command-line fuzzy finder

fzf - a command-line fuzzy finder

Internal opts struct

opts.Field Type Default
Ansi bool false
Black bool false
Bold bool true
Case Case CaseSmart
@d630
d630 / x.sh
Last active May 10, 2017 11:24
bash
#/usr/bin/env bash
function bar {
[[ -n $READLINE_LINE ]] || return 0;
eval "
function f {
$READLINE_LINE
};
" 2> /dev/null || { bind '"\C-x3": edit-and-execute-command' && i=1; };
@d630
d630 / br.md
Last active May 30, 2018 22:15
  1. Vervollständigen Sie folgende Tabelle[18P]:

    Dezimale Zahl Binäre Zahl Hexadezimale Zahl
    327
    1100 1101
    0xA4
    18
    1000 1111

| | | 0x4A|

@d630
d630 / kap12.java
Created February 22, 2018 15:24
kap12
package kap12;
public class Kap12 {
static int[] array = {
1,
2,
3,
4,
5,
6,
/**
* Warum müssen sie ein Array zurückgeben und können nicht die Werte für die
* Tage, Stunden, Minuten und Sekunden "zurückgeben"?
*
* In Java kann scheinbar nur eine Variable bzw. eine Referenz auf ein Objekt zurückgegeben werden.
*
* Weitere Lösungen:
* - Für jede Zeiteinheit eine Methode.
* - globale Variablen bzw. Membervariablen benutzen statt internem Array.
*/
@d630
d630 / Playground1.java
Last active April 17, 2018 21:22
Uebungsaufgaben
// TODO
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.Random;
import java.util.Scanner;
public class MatrixGame {
private char[][] mArray;