Samsung SCX-3405 as network scanner

To access a Samsung SCX3405 as scanner in your local network modify /etc/ :

#Samsung SCX-3400 Series
usb 0x04e8 0x344f

Sorting arrays by column

With argsort, you get the index of the sorted array, which you can use to access the original array in sorted order. By selecting a single column for the sort algorithmn you can sort the array by the different columns

Assume an array with 3 columns and N rows

arr_org = np.random.rand((20,3))

idx=arr_org[:,3].argsort() arr_sort =arr_org[idx]

USB stick gets mounted readonly

When plug in an USB stick it happens with Ubuntu that it gets mounted read-only. Even with rw mount option it is not possible to write. Often the mount point directoy is not writeable (or even accessible) to the user. This could be solved by setting the ACLs.

To see the actual access rights

$ ls -ld /media/<username>
drwxrwx---+ 2 <username> <username> 4096 Mar 4 18:32 /media/<username>

where the + charcter indicates the use of ACL. These ACL can be shown as followed

$ getfacl /media/<username>

# file: <username>/
# owner: <username>
# group: <username>

In this example, the user is read only. This can be easily changed to read-write (rw)

setfacl -m u:<username>:rwx /media/<username>

Eventually you have to reset the dirty-bit of the FAT filesystem of your USB stick.

dosfsck /dev/sdc1

Multiple conditions with numpy.where

Using numpy and the numpy.where function is very powerfull. If you want to use several conditions with np.where you have to use the bitwise-AND-operator to combine to different conditions in one query. Of course you can also use the bitwise OR-operator too.

daten = np.random.rand(50,5)
sel = np.where((daten[:,0]==5) & (daten[:,1]< 17))[0]
plt.scatter(daten[sel,3], daten[sel,4])
← Older Posts Home