Archive

Archive for the ‘bash’ Category

JSON Path

May 20, 2017 1 comment

I wrote a command-line program that outputs the full path of every key / value in a JSON file.

Example

$ ./json_path.py sample.json
root.a => 1
root.b.c => 2
root.b.friends[0].best => Alice
root.b.friends[1].second => Bob
root.b.friends[2][0] => 5
root.b.friends[2][1] => 6
root.b.friends[2][2] => 7
root.b.friends[3][0].one => 1
root.b.friends[3][1].two => 2

More information at the project’s github page.

Categories: bash, python Tags: ,

streamlink

Streamlink is a command-line utility that allows you to watch online video streams in popular video players, such as VLC, MPlayer or mpv.

(Under Manjaro it’s installable with yaourt.)

Example:

$ streamlink twitch.tv/sscait 
[cli][info] Found matching plugin twitch for URL twitch.tv/sscait
Available streams: 720p_alt, audio_only, 160p (worst), 360p, 480p, 720p (best)

$ streamlink twitch.tv/sscait best

If you just want to listen to it, select “audio_only” instead of “best”. It has lots of options, see the man for more info. For scripting, there is also a “-j” switch to produce a JSON output instead of normal text.

When is it useful? For instance you have a favourite channel that is streaming right now, but you don’t want to open it in the browser. Just launch it from the command-line and watch it in VLC. Or, if it’s a talk show, you just want to listen to it (see “audio_only”).

Categories: bash Tags: , , ,

sending e-mails from your app.

If you want to send e-mails from your application, check out https://www.mailgun.com/. You can register for free and with your free account you can also send a good number of e-mails. And if you pay for it, you can send thousands of mails if you want. Their service can be used from Bash, Python, PHP, etc.

On my VPS I used a command-line solution (see here) that sends e-mails with sendmail. Unfortunately, Gmail treats these mails as spam, so it’s not appropriate for sending messages to other people. Mailgun is a better solution.

Categories: api, bash, python Tags: ,

increase sudo timeout

February 12, 2017 Leave a comment

Problem
You want to increase the sudo password remember timeout.

Solution
Run “sudo visudo“, then add this line to the end:

Defaults    timestamp_timeout=60

Where 60 means 60 minutes. If you specify -1, then the password is never forgotten (which is not a good idea IMO).

Tip from here.

Categories: bash, linux Tags: ,

Don’t paste blindly to your terminal

January 27, 2017 2 comments

Most of the time when we see a code snippet online to do something, we often blindly copy paste it to the terminal.

Well, the copied text may contain some malicious code. Here is a post about that with a demo.

Categories: bash Tags: , ,

VPN list

January 23, 2017 Leave a comment

Autovpn is a nice and simple project to easily connect to a VPN in a country of your choice.

If you need a VPN list, you can find the necessary URL in its source.

Here is a Python implementation too (link).

Categories: bash Tags: ,

grab a Twitch video in mp3

January 17, 2017 Leave a comment

Problem
You want to grab a Twitch video in mp3. For instance, you want to listen to it offline.

Solution
You need two programs for it: youtube-dl and ffmpeg. Let’s take a concrete example:

$ youtube-dl -g "https://www.twitch.tv/wearethevr/v/115335579"
https://vod067-ttvnw.akamaized.net/v1/AUTH_system/vods_c631/wearethevr_24261824064_585034506/chunked/index-dvr.m3u8
$ ffmpeg -i "https://vod067-ttvnw.akamaized.net/v1/AUTH_system/vods_c631/wearethevr_24261824064_585034506/chunked/index-dvr.m3u8" -f mp3 out.mp3

Where https://www.twitch.tv/wearethevr/v/115335579 is the URL of this particular Twitch video.

I wrote a script for it to automate the whole process: twitch2mp3.

Categories: bash, python Tags: , ,