Friday, June 14, 2024

Updating battery date on an ancient UPS(like APC Back-UPS NS600, etc)

This may be one of the reasons your UPS can shutdown prematurely even if the battery has been replaced recently and is in a good shape. It's projecting time based on the original battery date. Below are the simple commands to update it. These are for OpenWrt, adjust accordingly if you are on systemd system.

# /etc/init.d/apcupsd stop
# apctest
...
You are using a USB cable type, so I'm entering USB test mode
Hello, this is the apcupsd Cable Test program.
Getting UPS capabilities...SUCCESS

Please select the function you want to perform.

1)  Test kill UPS power
..
4)  View/Change battery date
...
12) View/Change self-test interval
 Q) Quit

Select function number: 4

Current battery date: 04/03/2011
Enter new battery date (MM/DD/YYYY), blank to quit: 03/28/2023

#/etc/init.d/apcupsd start

Tuesday, May 30, 2023

cartesian joins

Julia:

sample_vv = [[1, 2], [2, 3, 4], [5, 1], [7, 9]]
product(vv)=foldl((v1, v2)->vec(hcat.(v1, v2')), vv)
product(sample_vv)

Sunday, August 7, 2022

Ubuntu keyboard switch to be inline with windows

gsettings set org.gnome.desktop.wm.keybindings switch-input-source "['<Shift>Alt_L']"
gsettings set org.gnome.desktop.wm.keybindings switch-input-source-backward "['<Alt>Shift_L']"

Monday, December 23, 2019

Bloomberg API from Linux using standard terminal.


I switched my PC to linux recently (lubuntu) and so far everything is running smoothly, but there are some windows-only software lacking. One such thing is Bloomberg.

The company does offer Bloomberg Anywhere, which runs Terminal app and Excel in data centers and displays them remotely via Citrix on your PC. This covers the basic usage, but gives no way to access their APIs, which are often used to download data for analysis with python or java extensive toolbox. They also do offer server gateways(b-pipe?), but the cost and complexity can only be afforded by big companies.

Here is not quite easy or elegant, but a working solution to this.
  1. You need to run Windows on virtual machine(VM). I use VirtualBox, but VMware probably works as well. Bloomberg software is installed there.
  2. You need a dual port forward, both in VM and Windows. Here is the dataflow: HostOS/localhost:8194->GuestOS/ip:8194->GuestOS/localhost:8194
Step 1 is time consuming, but straightforward.

Step 2 is more involved. Firstly you need a port forward in VBox to be able to access guest VM from host via TCP/IP. This can be done via VBox dynamically( don't need to reboot VM):
The tricky part is you need to run another port forward in windows and built-in one, netsh, won't work with loopback interface bbcomm runs on, but I got PortMapper from AnalogX (http://www.analogx.com/contents/download/Network/pmapper/Freeware.htm) to work. Again this is configured via UI:
Install Linux API packages, login to the terminal, start PortMapper (in this order!) and all should work:
$ cd
$ cd blpapi_cpp_3.13.1.1/Linux

$ LD_LIBRARY_PATH=. ./SimpleBlockingRequestExample_32
SimpleBlockingRequestExample
Connecting to localhost:8194
Subscribing to IBM US Equity
Requesting reference data IBM US Equity
ReferenceDataResponse = {
    securityData[] = {
        securityData = {
            security = "IBM US Equity"

...