Category Archives: howto’s

lftp and source: Is a directory error

I was running lftp with the -f switch to launch the usual mirror command, working fine with a few ftp servers at first, but when I added another sync with a pure-ftpd server something stopped working as intended: the message

source: Is a directory

appeared and nothing more happened, only after I pressed Enter the script went on with the execution.

What helped me was this discussion.

so I changed my script, and instead of having

open host
user username password
mirror blahblah

I used

open -u username,password host
mirror blahblah

and everything was magically fine!

Why? NO IDEA. Who cares. Works now.

Windows 10 bluetooth not working on Asus UX51VZ and Centrino Advanced-N 6235

Long story short, my bluetooth mouse, a Logitech Mx Master 2S, disconnected out of the blue, first times I just had to turn off and on bluetooth on windows, once the bluetooth device was automatically disabled because “it caused problems” and I had to restart, finally it stopped working altogether, always telling me “try connecting your device again”. I tested it with every other bluetooth device I had handy, to no avail.

Wasted maybe half an hour, on my almost nonexisting free time schedule (AAARGH)

So finally I had the nice thought of checking, from device manager, if there were updated drivers for the chipset responsible for wireless (WiFI and Bluetooth), a Centrino Advanced-N 6235. I updated it since it automatically downloaded new drivers, restarted as I was asked, and even if wifi kept being shitty, the bluetooth mouse finally connected, as did my android phone.

Change user of transmission-daemon under Debian and Raspbian

I have a raspi3 running transmission daemon downloading to an external USB drive shared via Samba. I don’t want to keep using debian-transmission user with the daemon since just switching to my user account having the access rights to the external USB is much simpler.

I had it already nice and running before, but updating the daemon with apt-get messed everything (and lost all the running torrents as well) so I had to rediscover the procedure once again, and for posterity (and myself for future occasions) I’m writing it down here.

By the way all the missing torrents appeared again after I solved the issue.

So, here are the things you need to do:

  1. run sudo service transmission-daemon stop just in case
  2. edit /etc/init.d/transmission-daemon to have USER=username
  3. edit /lib/systemd/system/transmission-daemon.service to the same effect
  4. run sudo chown -R user:user /etc/transmission-daemon/
  5. run sudo chown -R user:user /var/lib/transmission-daemon/

Done.

fix Android gallery timestamp from video image filename

If you copied the files from another phone, you will notice the new gallery will have all files to the same date of the copy operation.

Install BusyBox, and from terminal or better yet JuiceSSH onto local device, go to /sdcard/DCIM/Camera and do

for i in VID*.mp4; do busybox touch -t ${i:4:8}${i:13:4}.${i:17:2} $i; done;

for i in IMG*.jpg; do busybox touch -t ${i:4:8}${i:13:4}.${i:17:2} $i; done;

Supposing the filename is in the format

IMG_YYYYMMDD_HHMMSS.jpg VID_YYYYMMDD_HHMMSS.mp4

 

Firefox not firing onReadyStateChange with two AJAX requests and a confirm dialogue

There are many discussions like this on the internet, but I am confident I am now examining a very specific problem of Firefox, with a very specific AJAX routine.

Symptoms: there are other AJAX requests in the background, and there is a request initiated by the user, which requires confirmation (your average “are you sure you want to delete?” dialogue). The AJAX request to delete the entry never fired. Every AJAX request was in the default, asynchronous mode.

No matter what, I couldn’t for the life of me make that request work, everything else did. Only the “delete” functions didn’t (in Firefox, as Chome and Internet Explorer worked no problem).

I used console.log messages as crumbs along the way, to follow the flow, and it stopped right at onReadyStateChange, as anything after it wouldn’t show zip in the console. Which meant the onReadyStateChange wasn’t being triggered.

I even thought it was something off with the function name (maybe the delete inside it borked something, silly me thought).

I also tried switching to synchronous mode the incriminated requests… and welp, they worked! For a short while I thought about leaving them be synchronous, but I didn’t want those pesky warnings in the console about synchronous requests ruining the user esperience.

Only by chance an epifany happened, and the obvious came forth (I KNEW there had to be a reasonable explanation which I had yet to grasp).

Well, my configuration went like this (it’s an internal web application we are talking about): an AJAX request triggered each second to a PHP to check the user credentials and inactivity time, and an AJAX request by user intervention was launched to delete an entry… after a confirm dialogue requested, well, user confirmation for the delete (duh).

Everything worked flawlessly before, the problem started appearing after I added the background AJAX request each second (which I didn’t want to get rid of anyway).

As you may or may not know, the window.confirm dialogue is a synchronous structure, which means the page execution is frozen until the user presses either OK or CANCEL in the dialogue (same thing happens with the window.alert function).

So, imagine the background AJAX request being queued behind the confirm dialogue, and obviously taking precedence over anything else that had to come after, and the new AJAX request being formed right after the press on the OK button of the confirm dialogue, to delete the entry that the confirmation was for.

Well, these two requests were launched at the very same time, in a manner that Firefox (not the other browsers though) probably overlapped the onReadyStateChange and never triggered the one for the secondary AJAX request.

In fact getting rid of the confirmation dialogue solved the problem.

Either that, or I will have to come up with an asynchronous method of requesting user confirmation.

Import QR vCard with multiple words name and surname in Android

First of all: YOU CAN’T.

Now for real, there’s a workaround, just buid your vCard text to be rendered as QR Code by removing the spaces between the first name words, and the last name words (surname that you may like).

Example:

N:Johns Phillips;John Philip;;; (Last Name;First Name;;;)

becomes:

N:JohnsPhillips;JohnPhilip;;;

and then, in the address book editing form that appears in Android you just tap in the middle of the joined words and press space.

It will be MUCH faster than moving around in the fields the misplaced name components.

 

There is NO WAY to actually have a vcard data correctly formatted to be correctly rendered by a QR Code scanner and correctly passed to the address book.
If you used a correctly formatted vCard file to directly import it in Android address book, it will work (for example, first export a vCard file for a contact, and then reverse engineer it… but to actually copy the VCF to the phone for each contact and manually importing it would be time consuming and bothersome); but if you use a generated QR code from the vCard code, each and every QR scanner out there will pass the full name data to the address book as a single unformatted string, IGNORING the name components of the N field, leaving the address book parser to decypher which is which.

So, depending on how you go about hacking your way into the vCard format, you might get

John (first name) Philip Johns (middle name) Phillips (last name)

or any other weird combination, BUT the one you were looking for.

Believe me, I tried, and chances are, if you ended up here, you did, too.

In my case I spend on it much more time than I care to admit. More than I needed to actually code from scratch the PHP to generate the relevant QR code into my management software.

So just embrace this workaround, but if you find a solution, please Please PLEASE share in the comments.

Create STL from DICOM with 3D Slicer

Pretty much a self reference post, based on Slicer v. 4.6.

  1. Open the relevant DICOM set.
  2. Open the Crop Volume module
  3. In “Input ROI” dropdown select Create new AnnotationROI
  4. In the slices view adjust the selection so only the interesting area is covered (if you cannot see the delimiters of the crop rectangle, then zoom out the slice view -dragging with right mouse button- until it’s visibile, then move/resize it panning the slice view -dragging with middle mouse button- and then finally rezoom until you are satisfied adjusting the selection)
  5. Click on the Crop! button and see how the slices are cropped to the set area
  6. Open the Editor module (you can select the GenericAnatomyColors palette)
  7. Click on the coloured rectangle on the Label: row, and choose your relevant structure (if you’re here you probably want bone)
  8. Click on ThresholdEffect button (third from last from the effect buttons)
  9. In the Threshold Range input area that just appeared set a starting value of 300 HU (Hounsfield Units) which usually is a good starting density value for bone
  10. You will see the relevant areas blinking in the slices images, and you can adjust the density range by using the small arrow buttons on the side of the lower value of the range
  11. When satisfied, click Apply
  12. Click on the MakeModelEffect button, first from last, and right after click Apply
  13. After a while (depengin on how large is the ROI and how complex is your structure) the rendered model will appear in the 3D view
  14. Click on the SAVE button in the top tools bar, and deselect every entity except the last one (usually named bone if you followed this tutorial), and then choose the STL format in the dropdown on the side (VTK format is selected by default), plus change to your needs the saving folder, and press the Save button
  15. Profit!

Share mysql and apache folders from windows XAMPP to linux XAMPP

This is a replica of the article by jultech from 2007 for posterity and data-replication purposes.

When dualbooting between windows (first OS installed) and linux, do this:

~ # mv /opt/lampp/var/mysql /opt/lampp/var/mysql.BACKUP
 ~ # ln -s /mnt/windisk/path/to/XAMPP/mysql/data/ /opt/lampp/var/mysql
 ~ # mv /opt/lampp/htdocs /opt/lampp/htdocs.BACKUP
 ~ # ln -s /mnt/windisk/path/to/XAMPP/htdocs /opt/lampp/htdocs

This creates a backup of the original XAMPP folders in linux, and them symlinks them to the windows disk mounts.

Restart XAMPP to have th configuration running.

Thank you jultech.

Fix mount: unknown filesystem type ‘isw_raid_member’

You may also get ‘linux_raid_member‘ instead of ‘isw_raid_member‘, usually it’s the same.

So you probably have run through other tutorials telling you not to mount directly but to mount the raid instead…. but you have no raid!

Maybe though, you HAD a raid back in time, and you removed it leaving the disks as separate storage, and in that case there would be “rogue” raid metadata on the disk that makes linux (mint in my case) think it is a raid, and get confused.

Thanks to Chris_F I finally solved it, you need to use dmraid (install it if it’s not on the system, via apt-get) to remove those orphan tags:

sudo dmraid -rE /dev/sdb

In my case, this instantly showed the disk in file manager.

SQ8 mini camera DVR, enable loop recording

Connect the SQ8 camera to a USB charger. It cannot be a PC, otherwise it will work as an external drive and show you the contents of the SD, it just needs to receive power.
As soon as you connect the camera you will notice the rear led turning on and cycling through different colors, after which it will turn off: at that moment, the recording will have started.
I still haven’t tested the cyclic recording functionality, but this is supposed to record max 5 minutes chunks of video until the memory runs out, after which it deletes the oldest recordings.

BTW, the correct orientation of the camera is so that the flat side opposite to the buttons side is down, position it elsewhere will give you a rotated video.

On a side note, this camera has a really bad space usage; I put a 32gb card in it, and the file size of the 5 minutes video chunks is 400MB! There is virtually no compression on the video, and the maximum recording time before the oldest files are deleted is less than 6 hours.
90mbs per minute is a really bad stat, in comparison a naruto episode should be 2.4GB if it had the same time/size ratio, it is instead one tenth of that…