Lifesaving snippets

Some snippets that make my life easier.

I’m creating this post mostly for myself so I don’t have to remember all the specifics, if someone else finds it helpful – even better.

cUrl a SOAP service:

curl "https://www.example.com/Service.svc" -H "SOAPAction: ""urn:service.example.com/IService/PresentationGet""" --data-binary @post.txt --comcodessed -k -D responseHeaders.txt -v -o response.txt

(optional headers)

-H "Pragma: no-cache" -H "Accept-Encoding: gzip, deflate" -H "Content-Type: text/xml; charset=UTF-8" -H "Accept: application/xml, text/xml, */*; q=0.01" -H "Cache-Control: no-cache"

https://keybase.io/

nslookup www.bjelic.net 8.8.8.8

*nix / Mac

delete a folder with contents:

rm -rf [folder]

Create a “soft” symbolic link to a folder:

ln -s /path/to/original/ /path/to/link

Simple python based http server in the current folder:

python -m http.server 8000

The same as above with Python 2:

python -m SimpleHTTPServer 8000

OpenSSL encrypt / decrypt:

openssl des3 -in file.txt -out encrypted.txt
openssl des3 -d -in encrypted.txt -out normal.txt

File character garbage cleanup:

tr -cd '\11\12\15\40-\176' < 'original.csv' > 'cleaned.csv'

Start Apache

sudo apachectl start

Zip with password

zip -er archive.zip *.*

Tasks:

jobs -l
kill 861
kill `jobs -p`

Switch to stopped task:

fg [%n]

Powershell

curl like

Invoke-WebRequest https://www.example.com/hello-world.html http://proxy.int:8080 -TimeoutSec 10

(New-Object System.Net.WebClient).DownloadString(“http://www.example.com/hello-world.html”)

create guid

[guid]::NewGuid()

touch

(ls testFile.txt).LastWriteTime = Get-Date

Windows

echo %USERPROFILE%
%ALLUSERSPROFILE% %APPDATA% %CD% (current folder) %DATE% %COMPUTERNAME% %CMDEXTVERSION% %RANDOM% %TIME% %USERDOMAIN% %USERNAME% %USERPROFILE% %WINDIR%

Excel

Placing

sep=<delimiter>

as the first line of a csv file will automatically tell Excel to use that character as the separator instead of the default comma.

Bojan Bjelić
Working hard on bunch of stuff, positive future above all. I'm blogging mostly about software, productivity and digital world.

Leave a Comment

Your email address will not be published. Required fields are marked *