Installing transmission daemon on Raspberry pi

This covers installing transmission and downloading to system sd card. I will also add downloading to external hdd or usb drive. Source

$ sudo apt update
$ sudo apt install transmission-daemon
$ sudo service transmission-daemon stop
$ getent passwd |grep trans
$ sudo usermod -a -G pi debian-transmission
$ sudo chmod 775 /etc/transmission-daemon/settings.json
$ sudo vim /etc/transmission-daemon/settings.json

In this file I chose to be able to log in from any IP by setting:

"rpc-whitelist-enabled": false,

Also set the login username and password by editing:

"rpc-password": "password",
"rpc-username": "transmission",

Set umask to 002 so new files have the right permissions in the download folder:

"umask": 002,

Now restart transmission:

$ sudo service transmission-daemon restart

Now you can go to pi’s ip:9091 in your browser and should be able to see the web gui.

Using a USB drive for downloads:
FAT / FAT32 formatted drives don’t support file permissions. The permissions for everything are determined by how the drive is mounted.

$ sudo mount /dev/sdb2 /home/storage -o umask=000

As for it not auto mounting on reboot

UUID=8C52-C1CD /home/storage auto user,umask=000,utf8, –>noauto<– 0 0
The "noauto" makes this NOT automatically mount when the system starts and parses the /etc/fstab file. Remove that option and it will mount on startup. You can set the permissions on the mount point once it's mounted with chmod or specify them in /etc/fstab.

If you need the media user to access it, you can set the permissions to 764, and add them to the security group. Root always has access to everything.

Standard

Random decimal numbers from uniform binary numbers

Let’s generate a list of 0s and 1s first, I would like each a 50% chance for each ┬ánumber to come up so the binary list would be uniform.

Create a random binary file

import os

with open('output_file', 'wb') as fout:
    fout.write(os.urandom(1024))

def bits(f):
    bytes = (ord(b) for b in f.read())
    for b in bytes:
        for i in xrange(8):
            yield (b >> i) & 1

for b in bits(open('output_file', 'r')):
    print b

Now let’s check if these are uniformly distributed. First let’s check the number of 0s and 1s, there should be approximately the same number of both.

one ,zero = 0,0
binaryList = []
for b in bits(open('output_file', 'r')):
    binaryList.append(b)
    if b == 1:
        one=one+1
    if b == 0:
        zero=zero+1

print "In the entire set"
print "ones =",one
print "zeros =",zero

In the entire set
ones = 4125
zeros = 4067

This seems ok. We can also check if the they are equally distributed in some arbitrary subset.

import os

with open('output_file', 'wb') as fout:
    fout.write(os.urandom(1024))

def bits(f):
    bytes = (ord(b) for b in f.read())
    for b in bytes:
        for i in xrange(8):
            yield (b >> i) & 1

one ,zero = 0,0
binaryList = []
for b in bits(open('output_file', 'r')):
    binaryList.append(b)
    if b == 1:
        one=one+1
    if b == 0:
        zero=zero+1

print "In the entire set"
print "ones =",one
print "zeros =",zero


one ,zero = 0,0
for b in binaryList[:len(binaryList)/2]:
    if b == 1:
        one=one+1
    if b == 0:
        zero=zero+1

print "In half of the entire set"
print "ones =",one
print "zeros =",zero

one ,zero = 0,0
for b in binaryList[:len(binaryList)/4]:
    if b == 1:
        one=one+1
    if b == 0:
        zero=zero+1

print "In a quarter of the entire set"
print "ones =",one
print "zeros =",zero

In the entire set
ones = 4125
zeros = 4067
In half of the entire set
ones = 2072
zeros = 2024
In a quarter of the entire set
ones = 1038
zeros = 1010

This still looks good. Now I would like to make decimal numbers out of these.

Standard