Posts

Send People your Files

So you have a large file. You want to send it to someone. You can use Netcat!

#!/bin/bash
{ echo -ne "HTTP/1.0 200 OK\r\nContent-Type: $(file -b --mime-type "$2")\r\nContent-Length: $(stat -c%s "$2")\r\n\r\n"; cat "$2"; } | nc -l "$1"

This script is based on wikipedia’s netcat example. It is updated to include some information which allows streaming videos (VLC wants a file type and length).

To make the file ‘file.mp4’ available on port 1080, you run the bash script:

./fileserver 1080 file.mp4

Once your friend downloads it, the script returns - it only makes the file available once.

When you run the script, all the other person needs to do is point their web browser (or VLC/mplayer) at your ip and port number.


Watch youtube on the Raspberry Pi

The raspberry pi, however awesome, does not have the power to run youtube well in the default distro. Even if you don’t have X installed, a simple script allows you to take a youtube video’s URL and instantly start streaming its video!

To use this, you will have to get a working omxplayer and the awesome youtube-dl library. If you are using debian, they should be available using apt-get.

#!/bin/bash
#Different formats are: 18-360p, 22-720p, 37-1080p
omxplayer -o hdmi $(youtube-dl -g "$1") #Standard def
#omxplayer -o hdmi $(youtube-dl -f 22 -g "$1") #720
#omxplayer -o hdmi $(youtube-dl -f 37 -g "$1") #1080

Voila, instant streaming youtube videos!


nDB



Nova