2013-10-31

libcmt and msvcrt, cannot compile

Having trouble with libcmt and msvcrt?

Then certainly you are attempting to link multithreaded code to singlethreaded. The libcmt is multi threaded, msvcrt is single threaded. Switch to msvcmrt.lib, or change /MD to /LD, if you're creating dll-s.

2013-10-30

tryLock and NFS --> weird failure, lockfile created but IOException returned

Using tryLock() on a FileChannel, and you cannot get a lock, BUT the lockfile itself is created?

Your nfslock daemon is not running. Check for rpc.statd:
Bad: NFS Locking Daemon is NOT running
If you cannot start it, restart portmap first.

2013-10-29

MCC DAQ miniLAB 1008 (USB) under Linux

Most of the MCC DAQ's USB and PCI devices have 3rd party Linux kernel drivers. For details, see: http://www.mccdaq.com/daq-software/Linux-Support.aspx
  1. Fetch all stuff from here: ftp://lx10.tx.ncsu.edu/pub/Linux/drivers/USB/
  2. Read the README_mcc_usb file CAREFULLY. You have two options:
    1. hiddev
      1. + Easy, works unprivileged.
      2. - May not be present in linux kernel v3.0+, and is not working in 2.4 at all.
      3. - SLOW: max 200Hz (which is not enough for a big setup)
      4. - No documentation and examples exists.
    2. libhid/libusb
      1. + Uses libusb, works under all linux kernels
      2. + No theoretical ceiling for max throughput.
      3. + libusb is portable through Linux, Windows, Mac, etc
      4. - Needs to be run as root, or set the executable to suid.
      5. - Need USB programming knowledge.
      6. - Compiling libhid manually.
  3. I assure you, option 2 (libhid+libusb) will be better.
  4. Step 0: Deploy dependencies
    1. sudo apt-get install libusb-1.0-0 libusb-1.0-0-dev
  5. Step 1: Deploy libhid
    1. Fetch libhid from http://libhid.alioth.debian.org/
    2. tar -xzf libhid*.tar.gz
    3. cd libhid*
    4. ./configure --prefix=/usr --sysconfdir=/etc --disable-werror
    5. make
    6. sudo make install
  6. Step 2: Deploy the MCC-specific libhid-based usb library
    1. wget ftp://lx10.tx.ncsu.edu/pub/Linux/drivers/USB/60-mcc.rules
    2. sudo cp 60-mcc.rules /dev/.udev/rules.d/
    3. sudo udevadm control --reload-rules
    4. tar xzf MCCLIBHID*.tgz
    5. cd libhid (this is another directory!)
    6. Edit the Makefile
      1. Add " -lm" to the end of the line (after "-o $@") in the libmcchid.so target.
      2. Replace all occurence of "/usr/local/" to "/usr/" (there will be 33)
    7. make
    8. sudo make install
    9. run your device's test as root, like "sudo ./test-minilab1008"
      1. Good: "miniLAB 1008 Device is found!" and a menu-driven test interface
      2. Bad: 
        1. "hid_force_open failed" - you're not root
        2. Any other error message: well, hack :-)

2013-10-13

BCM43xx vs. (k)ubuntu 10.04+

  1. sudo bash
  2. apt-get purge bcmwl-kernel-source
  3. apt-get purge bcm-kernel-source
  4. apt-get install linux-firmware-nonfree
  5. reboot
  6. Make sure to turn ON the Wi-Fi button/latch/whatever
  7. Enjoy

2013-10-08

Perforce: Delete a client/workspace even if it does not exist anymore

So the user formatted/lost/whatever their computer and maybe even had opened files there?
Grab your admin account:

  1. p4 client WORKSPACE
    Delete the line starting with "Host:", to remove host restriction from that client workspace.
  2. p4 -u USER -c WORKSPACE revert -k -a
    Reverts all (no file glob specified) unchanged (-a) open files in that workspace (-c), and doesn't sync anything (-k).
  3. p4 client -f -d WORKSPACE
    Deletes (-d) the workspace, forced (-f).
Extras:
    • List user's client workspaces:
      p4 clients -u USER
    • Remove all managed files (just files! directory is just metadata in perforce) from the current workspace:
      p4 sync //...#none
      Then delete the directories manually -_-
    • Explicitly set a server:
      p4 -p perforce-otherone:1666 clients -u USER
    • (Moar to come)

    2013-10-07

    Selenium: Maximizing Chrome and Firefox through a RemoteWebDriver

    Having issues because your browsers driven by a RemoteWebDriver says "no such element"? Maybe other windows interfere.
    Nevertheless, you can try putting it in fullscreen.
    Chrome:
    DesiredCapabilities capability = DesiredCapabilities.chrome();
    LinkedList<String> switches = new LinkedList<>();
    switches.add("--start-maximized");
    capability.setCapability("webdriver.chrome.driver", ".\\chromedriver.exe");
    capability.setCapability("chrome.switches", switches);
    // ...
    RemoteWebDriver driver = new RemoteWebDriver(new URL(this.hub), capability);
    
    A list of chrome command line arguments: http://peter.sh/experiments/chromium-command-line-switches/
    Firefox:
    // ...
    driver.manage().window().maximize();
    

    2013-09-20

    Absolute musthave for vi(m)


    • "Get me out!!!": Esc Esc :q!
    • Save: Esc Esc :w
    • Save&Exit: Esc Esc :wq
    • Insert: Esc Esc i
    • Search for regex: Esc Esc /regex
    • Do search further: n
    • Delete line: Esc Esc dd
    • Delete n lines: Esc Esc ndd
    • Undo: u
    • Go to given line: Esc Esc :number
    • Go to beginning: g
    • Go to end: G

    2013-09-17

    Linux: IO things

    system activity
    sar -P ALL
    If %iowait is greater than 5%, something is DJ-ing with your disks.
    iostat w/ nfs
    iostat -mnh
    This shown which block devices are being read/write right now. If Blk_read/s or Blk_wrtn/s is greater than 50, you can start being suspicious.

    2013-09-16

    LabVIEW: LV By a Programmer

    Some thoughts I had while working in LabVIEW for a couple of years:
    1. Mathematics. Think before draw. "The less you plan, the more complex your VI will be."
    2. Pre-compute. Reuse. Pipeline. "Used twice? SubVI!"
    3. Avoid Express VI-s.
    4. Organize wires into a cluster if they are related, and are more than 3 of them.
    5. If and only if an input is required by the algorithm, set it to required. Not required inputs should have sane defaults. Otherwise, you’ll trash the block diagram with unnecessary constants.
    6. Customize the Clean-up Diagram button for your favourite style, and Use It.
    7. Always go from left to right. Do not make wires that go around from the right, rather extend the space on the left.

    2013-09-10

    Confluence: Search for things skipping the shipped "search engine"

    Using Atlassian Confluence, and have to report on exact things, like "How many, and which pages refer to a given phrase"?
    This searches through all the latest version of all the pages:
    SELECT DISTINCT
       'http://confluence.example.com/confluence/pages/viewpage.action?pageId=' || contentid AS URL
    FROM
       CONTENT
    INNER JOIN BODYCONTENT USING(contentid)
    WHERE
       prevver      IS NULL
       AND SPACEID  IS NOT NULL
       AND PARENTID IS NOT NULL
       AND REGEXP_LIKE(BODY, 'internal-webserver\d(\.example\.com)?\\public', 'i');