09 March 2015

Seesu.me, dwb & vk.com

Rather a useless post, but it was fun for me to find all these out.

The story

seesu.me is an awesome online media player or radio or whatever you call it. Just give it try.
dwb is a minimalistic vim-imsnpired browser.
And vk.com is popular (at least in xUSSR countries) social network.

What brings them all here is that there is large music collection available on vk.com which can be very nicely listened to with seesu.me. But me problem was that vk login button wasn't working in dwb browser.

The solution

In short i needed to do the following:
  1. open dev console (dwb is based in webkit, so there is on) to find the login button
  2. check if clicking on it programatically would work
  3. if yes, all done - i'll login to vk, login will be remembered and nothing to worry about
Pressing standard Ctrl+Shift+I didn't worked. With google on my hands i found man 1 dwb which states that enable-developer-extras need to be enabled. I had no idea what it was, playing with command completion in dwb itself didn't helped as well. Again googling i found that option in ~/.config/dwb/settings (close dwb, then edit and save the file, then run browser again).

After that dev console popped up on :wi command, but unfortunately each time it shows up it crashes the whole browser.

I had to pick firefox to check if triggering click programmatically would do the trick and it really did. Invoking $('.sign-in-to-vk').click() in dev console was at least triggering popup blocker and then i was able to reach the popup (BTW popup blocker was veeery important here).

Back to dwb i needed a way to execute arbitrary JS on a page which was quickly and easily found in already opened man page. So on seesu page i typed :js $('.sign-in-to-vk').click() and nothing happened again. Here i remembered about popup blocker and (quickly again) found and option javascript-can-open-windows-automatically which was set to true with ss javascript-can-open-windows-automatically true

After that repeating JS snipped worked like a charm.

12 January 2015

Adventures with Asus P8H61-M LE/USB3 and UEFI boot

On Friday i've broken my boot loader tying to migrate to UEFI and today i was looking forward to fix and get UEFI working! But that wasn't the case.
My PC booted in UEFI mode from Achlinux USB pendrive i've brought from home, but i rejected to boot from HDD.
I don't know how much time would i spent with this, but fortunately our sysadmin guys passed through and noticed me messing about BIOS. That appeared to be a know issue of my motherboard. The version i had was 0306.

I won't provide you with detailed instruction on how to upgrade you BIOS! The only hint i may give you - prior to doing this do reset all setting to defaults.

Now all works for me :)

27 February 2014

ReviewBoard: RandomPool has no attribute 'new'

ReviewBoard 1.7.21 is installed from packages on CentOS6.4

Error message from post title is shown when I add a BitBucket repository. Inspecting sources of ReviewBoard it appeared that it performs a workaroung in case an old version on pycrypto lib is installed. And the workaround doesn't work quite well.

My distro had 2.0.1 version installed, so I had to find a newer version manually and install it with rpm -Uvh. After restarting apache everything worked fine.

10 February 2014

MalformedUrlException o_O

Caused by:
        at java.net.URL.(URL.java:601)
        at java.net.URL.(URL.java:464)
        at java.net.URL.(URL.java:413)
        at org.apache.xerces.impl.XMLEntityManager.setupCurrentEntity(Unknown Source)
        at org.apache.xerces.impl.XMLVersionDetector.determineDocVersion(Unknown Source)
        at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
        at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
        at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
        at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source)
        at org.apache.xerces.jaxp.SAXParserImpl$JAXPSAXParser.parse(Unknown Source)
        at org.apache.xalan.templates.StylesheetRootProxy.(Unknown Source)
 at java.net.URL.(URL.java:601)
 at java.net.URL.(URL.java:464)
 at java.net.URL.(URL.java:413)
 at com.sun.org.apache.xerces.internal.impl.XMLEntityManager.setupCurrentEntity(XMLEntityManager.java:649)
 at com.sun.org.apache.xerces.internal.impl.XMLVersionDetector.determineDocVersion(XMLVersionDetector.java:186)
 at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:772)
 at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:737)
 at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(XMLParser.java:119)
 at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(AbstractSAXParser.java:1205)
 at com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl$JAXPSAXParser.parse(SAXParserImpl.java:522)
 at javax.xml.parsers.SAXParser.parse(SAXParser.java:395)

...may just mean that you pushed a null InputSteam into parser.

For example this piece of code would produce such exception trace:

SAXParserFactory factory = SAXParserFactory.newInstance();
SAXParser parser = factory.newSAXParser();
parser.parse(new InputSource((InputStream) null), new DefaultHandler());

It also may be done in less explicit way, for example with an XSLT parser being given XSLT source with null InputSteam inside (which actually was the issue I originally faced).

06 January 2013

LXDM PostLogout script to shutdown user's apps

LXDM is a bit strange in it's behaviour to not to kill your apps running when you log out. After logging out my deadbeef continues to play music and conky is still drawn on top of LXDM greeter. Look funny heh :)
I don't really like this, but I wanted DM to show list of users instead of simple prompt. Arch wiki suggests just to killall --user $USER which would also kill all your background processes they may be running (torrent, screen, etc).
Enough words - here goes the script:
$ cat /etc/lxdm/PostLogout 
# Note: this is a sample and will not be run as is.

current_windows=`xlsclients -al | grep Window | cut -d' ' -f2 | sed -e 's/:$//'`
for wid in $current_windows
        pid=`xprop -id ${wid} _NET_WM_PID | awk -F ' = ' '{ print $2 }'`
        wmname=`xprop -id ${wid} WM_CLASS | cut -d= -f2 | cut -d, -f2 | sed -e 's/[ "]//g'`
        if [ "p${pid}" != "p" ]
                echo "Killing ${wmname} (${pid})"
                kill ${pid}
                echo "No PID found for ${wmname}"

# for some reason PID for conky cannot be determined
killall --user $USER conky
It requires xlsclients and xprop. Some apps (like conky) are special case and they don't show their PID in X11 properties of a window, so they are killed separately.