This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
declare -A git_status | |
while IFS= read -r -d $'\0' line ; do git_status[${line:3}]="${line:0:2}" ; done < <(git status $@ --porcelain -z) | |
while IFS= read line ; do [ ! "${git_status[$line]}" ] && git_status[$line]=" " ; done | |
for file in "${!git_status[@]}" ; do | |
echo "$file" >&3 | |
echo "${git_status[$file]}" >&4 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
git_tree_status_entries=$(mktemp -p /tmp/$USER/ git_tree_status_entries_XXXXXXXX) | |
git_tree_status_status=$(mktemp -p /tmp/$USER/ git_tree_status_status_XXXXXXXX) | |
# find, output must be like git-status, IE: no . at beginning | |
# git ls-files -z | tr '\0' '\n' | |
# git status --porcelain -z | tr '\0' '\n' | cut -c4- | |
[[ "$1" == '--ignored' ]] && extra_options=" --ignored" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
[[ $1 == -0 ]] && { shift ; while read -d $'\0' -r I ; do eval "$1" ; done ; } || { while read -r I ; do eval "$1" ; done ; } | |
#!/usr/bin/env -S perl -p | |
chomp ; $_.="\0" | |
# example where everything is zero ended | |
find -size +5M -mtime -700 -not -path "*/video_backup/*" -group nadim -print0 | \ | |
perl -0ne 'chomp ; !-e "$_.sha256" && print "$_\n"' | +0 | \ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
echo process a given input depending on options in a pipeline | |
echo -------------------------------------------------------------------------------- | |
echo | |
inputs=("2 xxx" "1 hi" "3 abc") | |
# options to sort or limit the number of answers | |
opt_sort=1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package AI::Pathfinding::AStar::Test; | |
use base AI::Pathfinding::AStar; | |
use strict ; | |
use warnings ; | |
use feature qw/say/ ; | |
sub new | |
{ | |
my $invocant = shift; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
L=({A..Z}) | |
ToAA() { AA= ; local i=$1 ; (($i == 0)) && AA='@' ; while ((i)) ; do AA="${L[((--i % 26))]}$AA" ; ((i /= 26)) ; done ; } | |
st() | |
{ | |
cat <<EOF | |
color "type=DEFAULT fg=WHITE bg=DEFAULT_COLOR" | |
color "type=HEADINGS fg=CYAN bg=BLACK bold=0" | |
color "type=HEADINGS_ODD fg=CYAN bg=BLACK bold=0" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
get_key() | |
{ | |
OIFS="$IFS" ; IFS= | |
[[ "$1" ]] && { read -rsn 1 -t "$1" || REPLY=ERROR_$? ; } || { read -rsn 1 || REPLY=ERROR_$? ; } | |
read -rsn 4 -t 0.004 E1 E2 E3 E4 | |
case "$REPLY$E1$E2$E3$E4" in |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
# find which repositories have changes, input: lib local_commit repo_commit | |
while IFS=$'\t' read -r -a revs ; do [[ "${revs[1]}" == "${revs[2]}" ]] || changed[${revs[0]}]=1 ; done < revisions | |
# find what test they trigger, input: repo test1 test2 ... and tests list | |
while IFS=$'\t' read -r -a deps ; do ((changed[${deps[0]}])) && { printf "%s\n" "${deps[@]:1}" | grep -f tests ; } ; done < dependencies | |
# add previously failed tests, input: faile test1 tes2 ... | |
awk '{ OFS="\n" ; /failed/ ; $1="" }1' < status | |
} | sed '/^$/d' | sort -u |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/env bash | |
bff() # Inspired by fff. Run: bbf 3> some_file, to get exit-time selection | |
{ | |
shopt -s checkwinsize ; trap 'rdir' SIGWINCH ; | |
declare -A dir_file filters marks tags ; show_dirs=1 ;kolumn=1 | |
local BFF=(/ /home/nadim /home/nadim/nadim /home/nadim/nadim/downloads) | |
pushd "$1" &>/dev/null ; tabs+=("$PWD") ; tab=0 ; rdir |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use Data::TreeDumper ; | |
@a = (1, 3, 5, 6, 7, 8 ); | |
@b = ( 2, 3, 5, 7, 9); | |
# one loop | |
@union = @isect = @diff = (); | |
%union = %isect = %diff = (); | |
foreach $e (@a, @b) |
NewerOlder