Thursday, March 22, 2018

link dump for triple boot of Windows, Linux and MacOS on Macbook

1. https://lifehacker.com/how-to-run-a-portable-version-of-windows-from-a-usb-dri-1565509124


https://medium.com/@manujarvinen/setting-up-a-multi-boot-of-5-linux-distributions-ca1fcf8d502

2. Brief notes: Using rEFInd, need to allow drive to spin up for it to be visible on refind.

usb drive not seen with refind.

Windows XP installer did not allow installation to partition which was created after the mac partition, so creating a new partition by moving the mac partition - 8 hours!

3. EFI fix - https://apple.stackexchange.com/questions/57597/how-to-fix-broken-efi-partition

https://www.kubuntuforums.net/showthread.php/43221-GRUB-2-A-Guide-for-Users/page15?p=379352#post379352

Tried gdisk -> Advanced -> H

Finally. Install Mint alongside other partitions.

4. https://www.tecmint.com/command-line-tools-to-monitor-linux-performance/

5. EFI - Created with Linux mint install graphical using 200 MB at beginning.

Edit: 7 Nov 2019 - https://www.intowindows.com/how-to-create-live-usbcddvd-of-vistaxp/


Edit: 2 Jan 2021 - Possibly a portable Win10 using WintoUSB may be the easiest option, for Windows 7 and higher versions of Windows - the Macbook is supposed to boot from CD if we press and hold the C keyhttps://en.wikipedia.org/wiki/WinBuilder#Actively_developed_projects


restoring to a different path

 A link dump on restoring a cloned disk to a different path - 



Wednesday, March 21, 2018

recovering after overwriting EFI partition

Tried to install Windows XP on the Macbook running OS X 10.6 and Linux Mint 18.1 dual boot. Though a new primary partition was created at the beginning of the drive, Windows XP refused to install on it, saying there are too many partitions.



In the process, the EFI boot partition was overwritten. So, the machine would not boot. Tried creating a refind boot USB drive - that showed up the Mac and Linux boot loaders, but did not boot either of them - the Linux boot ended in an emergency shell, and the Mac boot ended with the Mac apple turning into a cross, and not booting.

Googled various options, and thought the easiest way would be to do another Linux install. Made another Linux Mint installable USB drive by doing dd of the Mint 18.3 iso to a 16 GB drive, recreated an EFI partition using the installer's GUI partitioning tool, installed the 18.3 to another partition created in free space, and after install, the 18.3 and MacOS were successfully booting.

The original Linux Mint 18.1 was still not booting - dropping into emergency shell. 'Welcome to emergency mode! After logging in, type "journalctl -xb" to view system logs, "systemctl reboot" to reboot, "systemctl default" to try again to boot into default mode.'



journalctl -xb showed that the reason for not booting up was that it was not able to mount /boot/efi with UUID - the UUID had changed, of course, since the boot partition had been re-created. So, just booted into the new 18.3 Linux install, mounted the 18.1 volume, sudo nano edited the /etc/fstab with the UUID from the 18.3's /etc/fstab, and then rebooted - all OK.

Here are some of the things I googled and found - something like rough notes -

enabling bios mode
https://superuser.com/questions/1133040/unable-to-boot-into-windows-10-with-refind-solved/1133052
Ctrl R for safe boot into OS X
https://kb.wisc.edu/helpdesk/page.php?id=7197



Saturday, March 17, 2018

Unified Threat Management - UTM devices, proxies etc

In the context of an outage of our Cyberoam device, and the general decrepitness of the college proxies, I took a look at some available options, tuning etc.

https://www.quora.com/Which-is-the-best-Open-Source-Unified-Threat-Management-System-UTM-in-the-market

mentions ClearOS

http://jonmoore.duckdns.org/index.php/network-security/32-open-source-utm

reviews pfsense , untangle and sophos. He has an additional VPN requirement.

Comodo offers a free download.

https://www.google.co.in/search?q=set+up+a+unified+threat+management+appliance+with+open+source+software

For squid tuning, cache size etc,
https://forum.pfsense.org/index.php?topic=24429.0

where a user suggests, for an admin who has trouble with 70 users,

 I recommend use 10KB to 16KB(thumbnail picture size) for object size.
On restart COSS contents will be lost(developent still on progress for this issue)

for your memory issues:
squid/lusca would use 10MB per GB of total cache(when full).
http://wiki.squid-cache.org/SquidFaq/SquidMemory#How_much_memory_do_I_need_in_my_Squid_server.3F

If your system starts to use SWAP file(due to lack of RAM) then it will definitely slows your internet.
Squid/lusca starts to grow Page faults it also affects performance.

You might need to consider changing your cache_mem and give them to your OS.
This FAQ would help you.
http://wiki.squid-cache.org/SquidFaq


Tuesday, March 13, 2018

temporary router

PB sent me his configuration changes when he put in a temporary router -

1. Editing /etc/network/interfaces to give our mail server a public id (earlier it was in the DMZ)
2. Physically connecting the server with LAN cable to one of the ports of the router.
3. Going to NAT Access Control under Network Options on the router's config page, to disable NAT for the mail server. 

Sunday, March 11, 2018

lines seen on camera capture with new SDK

With QHYCCD's new SDK, lines were seen on captures. But on further study, found that the lines were seen when phone LED or LCD screen of computer is used as illumination, not otherwise.

So this is probably due to the effect of the rolling shutter + the repetition rate of the illumination.

We checked with sunlight - no lines - and with SLED illumination - no lines. So we are probably all good.

Tuesday, March 06, 2018

Windows executable slower

Found that an opencv cross-platform executable was running slower on Windows - compiling in Release mode instead of Debug mode did not improve this. Most probably due to the DFT algorithm, which might not be optimized on Windows. There were multiple DFTs called within the image refresh loop. The linux binary ran at 100 fps for 16 bit 320x240 images and 200 fps for 8 bit 320x240, but the windows exe was limited to 64 fps for both 16 bit as well as 8 bit. Linux was running on an i7 Macbook running Mint 18.1, Windows 8.1 was running on an i5 I believe.

Edit - my analysis above seems to be wrong - the code only had the Hilbert transform (and hence the DFT) on press of s key - and the fps was low even when no keys were being pressed. Some other bottleneck. Display driver?  

QHY SDK - Windows and Linux

Found the answer to my query to the QHYCCD helpdesk in November - the difference between the behaviour of Windows software which uses the Windows QHY SDK, and software built using the Linux SDK (and between different versions of the SDK!) are due to different implementations of the SDK.

My query was:

....my question is about frame to frame variations.

For example, I closed the lens cap and took two snapshots. Gain=5, Exposure time = 20 ms. I find that the pixel values are like:

Frame1: 3168   3216   3184   3184 etc
Frame2: 3232   3152   3248   3184  etc

So when i subtract Frame 2 - Frame 1, I get
64  -64  64 0 etc. with a max value of 256.

And this difference increases when there is light falling on the camera.

Is there any way to reduce this frame to frame difference? Any way to reach the 6e performance?

Also, when reducing gain, I find that the image gets saturated at a value below the full 16-bit max value of 65535. For example, with a gain of 5, the saturation happens at an intensity of 27776.

The reply was that the 6e error is the readout noise. The rest of the noise is probably shot noise

 The gain values are the numbers entered in Sharpcap (latest version). I have checked with two different QHY5Lii-M cameras. On both, if gain is reduced below 30, saturation occurs below 65535 (in 16bit mode - in 8bit mode, below 255).

For example, as mentioned before, with a gain of 5, whether the exposure is 5 millisec or 5 sec, the max value is only 27776.

But when I code my own capture, using the SDK at
https://github.com/qhyccd-lzr/QHYCCD_Linux
there is a difference - if I change the parameter CONTOL_GAIN
with SetQHYCCDParam(camhandle, CONTROL_GAIN, camgain);
even for value of camgain=1, I am able to see saturation at 255 for 8 bit mode. So, I could use this for my work. Maybe Sharpcap uses a different set of numbers? or a different parameter? as gain. 


The QHY team did not reply, but I found that the Windows and Linux SDKs have a different range for the Gain parameter, and probably for other parameters as well!  The Linux SDK (Software Development Kit) and the Windows SDK are developed by different teams. So, the same functions have different implementations! For example, gain goes from 1-100 in the Linux SDK we tested. But gain goes 1-480 in the latest Windows SDK.

Sunday, March 04, 2018

cross platform issues

In order to get the OpenCV code using the QHY camera SDK - originally written on Linux - running on Windows by compiling it with Visual Studio, the following items had to be done.

  1. Install the latest Visual Studio Community edition (v. 15, Visual Studio 2017). OpenCV's latest binaries only work with v14 and v15, and if we use some other version of VS, we would have to recompile opencv, which would be a pain.
  2. Install the latest QHY SDK from http://www.qhyccd.com/SWHIST_SDK.html - the latest version of the SDK has the lib files, h files and so on in addition to the dll binaries. Currently the latest version is at the bottom of the page!
  3. Install the latest version of OpenCV for Windows from sourceforge, following the instructions at https://docs.opencv.org/2.4/doc/tutorials/introduction/windows_install/windows_install.html
  4. The instructions on how to build an opencv application, https://docs.opencv.org/2.4/doc/tutorials/introduction/windows_visual_studio_Opencv/windows_visual_studio_Opencv.html#windows-visual-studio-how-to
    is reasonably similar to what we need to do, except for the fact that it would be better if we create a new property sheet called common and save it for future use as mentioned in the next point below - VS15 does not recommend .user property sheets.
  5. In a newly created property sheet (called common, for reuse), add the additional include directories, linker files etc as mentioned in the documentation on point 4 above. Here, we need to add the QHY SDK includes and dlls also. The opencv libraries are now distributed as a single file, opencv_world.lib and not the multiple lib files as in the documentation above. So, in short,
    VC++ directories -> Include
    Linker General -> Additional Library directories
    Linker Input -> names of the lib files in Additional Dependencies 
  6. The .cpp files need to have ifdefs for linux and windows standard headers separately. Code can be seen at https://github.com/hn-88/ASKlive/blob/master/ASKlive.cpp
  7. For the C function sprintf to work, the following pre-processor directive has to be added - C++ -> Preprocessor - > Preprocessor definitions -> add _CRT_SECURE_NO_WARNINGS
  8. In order to copy over the required DLLs, the following post build event has to be added -
    xcopy /y /d "D:\qhy\*.dll" "$(OutDir)"
    xcopy /y /d "$(OPENCV_DIR)\bin\*.dll" "$(OutDir)"

    It is safer to copy to the executable's directory, since there is quite a bit of confusion about copying to system folders - http://www.forceflow.be/2012/04/04/the-3264-bit-dll-confusion-on-windows-64-bit/
  9. Arrays have to be pre-assigned sizes - can't be assigned sizes at runtime as with GNU C compiler. 
Edit 3 June 2018 - 10. Added this line of code to prevent the "exe has stopped working" Windows dialog box on exit - 
SetErrorMode(SEM_FAILCRITICALERRORS | SEM_NOGPFAULTERRORBOX);
via stackoverflow, with additional documentation at msdn

Raspberry PI configuration link dump

  1. Impressive - The Raspberry Pi 3 boots up in 25 seconds to Desktop. 10 seconds to open Chromium browser. 25 seconds to load a google spreadsheet. Overall, faster than my AMD64 Windows XP laptop from 2009. :)

  2. Older version of RPi (Pi2?) - good for playing local videos - was pleasantly surprised to find that I could just put in the same micro-SD card which was running Raspbian 9 into a SD-card adapter and put it into the older Pi, and it booted and ran fine - did not need any reinstall.

    It is good for playing local videos. It could play 2 windows with 2 instances of VLC running local copies of 360p videos without any problems - 35% CPU for each instance, MP4 and DIVX respectively. But it could not play videos reliably over the network. Also, web browser Chromium takes a very very long time to open, web pages crawl to load. Probably because of the low RAM.

    But I can use it as a video player, with a status message at the bottom or something like that.

  3. lspci -vvnn | grep 802

    lsusb does not show it when driver is not installed.

  4. Cloning RPi with dd - https://www.raspberrypi.org/forums/viewtopic.php?t=46911
    sudo fdisk -l
    sudo dd bs=4M if=/dev/sdc | gzip > /home/your_username/image`date +%d%m%y`.gz
    sudo gzip -dc /home/your_username/image.gz | dd bs=4M of=/dev/sdc


  5. Enabling monitoring on RPi wifi - https://raspberrypi.stackexchange.com/questions/36747/enable-monitoring-mode-for-rtl8188cus-via-usb-on-raspbian

  6. How to loop in VLC - https://forum.videolan.org/viewtopic.php?t=78723 - and subtitles in vlc playlist maker.

  7. Adjusting Overscan on the RPi - https://retropie.org.uk/forum/topic/2371/using-composite-video-can-t-see-everything-on-the-screen/16

  8. Raspberry PI model comparison - http://socialcompare.com/en/comparison/raspberrypi-models-comparison

  9. Shortcut to edit text file -  Exec=leafpad %U /home/pi/file.txt

Saturday, March 03, 2018

securing lighttpd

Brief notes on securing lighttpd, the light-weight web-server - 

https://www.packtpub.com/mapt/book/networking_and_servers/9781847192103/7

# deny access to all files below a certain path
$HTTP["url"] =~ "/certain-path/" { url.access-deny = ("") }
# deny access on all jpeg images to the Google bot
$HTTP["useragent"] =~ "Google" { url.access-deny = (".jpg") }
# deny access by referrer
$HTTP["referrer"] !~ "^($|www.ourhost.com)" {
url.access-deny = ("")
}

under mod_access

and also passwd auth.

Friday, March 02, 2018

QHY camera glitch

After removing the new SDK files from Linux Macbook in order to test the camera again with the old SDK, the QHY5L-ii camera was not being recognized on the Linux machine at all. Both cameras, on both USB ports, LED does not light up, no dmesg messages either.

Tried on another Linux machine - Acer running Ubuntu 16 - without any drivers installed - again, no dmesg messages.

Tried changing the USB cable - then a dmesg message was seen, detecting on a 'slow port'. Tried on the Macbook again after reinstalling the new SDK, now it was showing dmesg messages as well as LED lighting up - detected OK. Changed back to the original USB cable - everything still OK.

So, probably a combination of hardware and firmware issues. 

Wednesday, February 28, 2018

excess CPU usage from Windows Update Agent

Noticed that an SVCHost process was taking up 50% CPU on my 2-core Windows XP machine. This behaviour started around a week back. Killed the process, ran Trend Micro's House call online anti-virus, did not detect anything. If I directly kill the SVCHost process itself, sometimes it disables audio - that thread is also on that process. Googling for solutions, got one way to do it using process explorer. 




Right-clicking the process and going to properties, in the threads tab, we see that Windows Update Agent is the culprit - killing or suspending it stops the high CPU usage.

There are some posts about solutions, like

but apparently this particular problem was fixed already,


"The problem that the "Symptoms" section describes was corrected in Windows Update Agent 3.0 and in update 927891. These updates were distributed through Microsoft Update in June and July, 2007. If you are still experiencing a problem that resembles the one that this article describes, it may be a different problem. To troubleshoot similar problems, please see the "Similar problems and resolutions" section later in this article."

So, currently I will just live with suspending the thread. 

Tuesday, February 27, 2018

Saturday, February 24, 2018

removing a recent audio file

Got a request to remove a recently played program from our downloadable content. So, deleted from local server ~/audio folder, also deleted from dl.radiosai.org so that old saved download links will not work, and have edited the remote database so that it shows - as description and does not show a download option. That seemed to be the easy way to delete the entry which is linked to a recently played file, without having to go into all the other linked tables. Similarly have edited local database, and have put "cannot play" flag on. 

Thursday, February 22, 2018

MAT types in OpenCV

From http://ninghang.blogspot.in/2012/11/list-of-mat-type-in-opencv.html

A Mapping of Type to Numbers in OpenCV

C1C2C3C4
CV_8U081624
CV_8S191725
CV_16U2101826
CV_16S3111927
CV_32S4122028
CV_32F5132129
CV_64F6142230

Wednesday, February 21, 2018

pause and exist

Matlab, Octave etc have these commands, which could be useful to do some action if a file exists - pause and exist. For example, to open a file in real time, use
exist
to check for file, and
pause
to wait for desired time.