… because I forget simple little things too soon …

12 Aug

I’m alive

Walking down the side of the same street
under the same glaring lights
over the same bridge
under which the same gentle warm water flows
reflecting the same sky
in embrace of the same quiet city

I am breathing
I am alive
I can smell life
and it’s growing in me
the proof that I can
and will walk this path again

So leave me an empty spot
right here for the next time
Leave me a pocket of air
to get high on
Leave me stray rays
to run after and catch
Leave me some autumn breeze
my skin yearns for a touch

7 Aug

Young and Dumb

I thought I had heard that song for the last time
I thought the echoes in my head could get me through the times

I thought I had figured it out and had won the game
I thought others never learnt and kept doing the same

Sometimes I wished that song played again
Sometimes I thought I heard it, but it was just the rain

In depth of silence I took shelter and it was fine
After a while I settled down and stopped looking for a sign

I found comfort in knowing that feeling numb
is a justified answer to the question for some

And then you came along and wrapped me in the warmth of that song
I saw that I had been wrong, wrong, wrong

10 Apr

Make USB Flash Write Fast Again

I have a 64GB SanDisk Extreme USB flash drive that I use for just about anything. It is a USB 3.0 drive and at the time of purchase, it had the best performance out of all drives in the market.

I can’t remember how fast it was exactly when I first bought it but I remember the read speed was above 200 MB/s and write was above 150 MB/s. But yesterday, a year or so after purchase, I had write speeds of 20 MB/s sometimes falling to 6 MB/s. I wasn’t surprised as I knew at some point all the blocks will be written to and due to lack of support for TRIM, things will get slow — didn’t think that slow!

How do I know it doesn’t support TRIM? If I format and mount an FS with discard mount option and subsequently run fstrim /mnt where /mnt is the mount point of the volume, I get this:

fstrim: /mnt: the discard operation is not supported

OK, but not all hope is lost. I knew about ATA Secure Erase command. What if that works? Turns out it does and it works oh so well. I followed the linked kernel guide but here is a summary of commands I ran (change /dev/X to appropriate dev) for the impatient. I strongly recommend reading the full guide.

14 Mar

Add hyperlinks to PDFs made by Inkscape

svglinkify demo PDF output
The final PDF generated by svglinkify which has clickable hyperlinks. See the source SVG file and the Inkscape exported PDF based on which the above is generated.

Inkscape despite being the most wonderful vector graphics editor program out there, has bummed me every time I tried to export something as PDF with hyperlinks in it. Inkscape does support adding links to arbitrary objects but in the conversion process to PDF, that metadata is lost. The reason for this loss (persumably) is that Cairo, a solely graphics rendering library used by Inkscape for outputting PDF, has no notion of object metadata. It just draws stuff to various types of canvas, like bitmaps, PDF, etc.

Being lazy (good thing) and not knowledgeable enough about Inkscape development, I set out to fix this problem quickly such that it can help me (and others) here and now, not in some unknown time in the future. This smells like it requires hackery and that’s exactly right. With less than 200 lines of python code, I made a very simple script that takes an SVG and a PDF of that SVG made by Inkscape, and creates a final PDF that has clickable hyperlinks. The SVG needs some simple treatment which is described in detail in the header comments of the python script. I have also made a demo SVG, and the PDF output of the script which can be seen on the right.

You can get svglinkify.py from github gists. You need python 2 or 3, qpdf and of course Inkscape to make everything work.

9 Mar

Automatic wake-up from suspend on SSH connection

My brother recently told me how he was planning to slave a Raspberry Pi to wake up his PC at home when he tries to remote SSH into it. We talked for a few minutes, throwing ideas around and we came up with the solution that follows.

He has a Netgear WNR3500Lv2 running Tomato by Shibby which is a custom open source firmware. I can’t praise it enough but suffice to say, once you go Shibby, everything else looks silly.

So why did I mention what router he uses? Because we picked the router to take the place of the Raspberry Pi. After all, it runs linux with all the unix niceties and it’s already there as part of the network. But it also has an advantage over Pi, and that is its knowledge of connections made from the outside world. Only if we could trigger a script every time a new connection was made to port 22 (SSH) of his PC. Turns out iptables lets us do just that. We can add a rule that logs every new connection to port 22 in the FORWARD table and watch kernel log at /proc/kmsg. Our script will then send a magic WOL packet to wake up the destination. Due to nature of TCP and the blazing speed of linux machines waking up from suspend, the client will only see a slight delay when connecting and everything else is transparent.

12 Feb

Crazy Town

Punk pirates listen to radio rage
Machine guns are born by the underage
A felon is let out of her corny cage
This town is maxed out on its crazy gauge

Bags of shuffled cards are dealt
Haze of every look is felt
A runaway not far away has knelt
’round his neck a firmly tightened belt

Laughter is heard at the sight of gore
Heavy grime washes off the shore
Bored is happy to pay plenty for more
Living souls are rotten to the core

Barbers are cutting limbs for cash
Sitters let kids on their hash
Curtain tops are now a trendy fash
White and fresh is sure to earn a bash

On radio a line is said
On this chaos a light is shed
To the savvy, a lie is fed
“Pain in this town, has long been dead”

8 Jan

Qualcomm Quick Charge 2.0 protocol specification and support

I got myself a PureGear Extreme USB Wall Charger few months ago. It’s Quick Charge 2.0 (QC2.0) enabled. But it didn’t live up to the claims made by Qualcomm to charge from 0% to 60% in 30 minutes. So I figured either the charger wasn’t doing what it promised to, or my phone was the culprit. Gotta find out which.

In a non-QC2.0 charger that conforms to USB Charging Specification, a certain resistance is connected across the USB data lines. When a phone is plugged in, the phone measures this resistance to find out how much current it’s allowed to draw from the charger. The voltage is always 5V. Lower the resistance means higher maximum current draw allowed. A resistance of 0Ohms means draw as much as you want.

In QC2.0 chargers, maximum current information is no longer communicated to the phone. Instead, there is an interface chip that takes commands from the phone over the USB data lines. The commands only tell the charger what voltage to supply. Choices are 5V, 9V, 12V and 20V. The protocol is simple. After the phone is plugged in, it asserts certain voltages on the USB data lines. The charger measures the voltage on the data pins and sets the output voltage accordingly. The details can be found in the datasheet of a QC2.0 charger IC (CHY100) that I found with a bit of googling. Note that a higher maximum current cannot damage a phone (a phone only draws what it needs), but a higher input voltage regardless of maximum current can damage the phone.

Now the fun part. I striped a mid section of a USB cable and hooked up probes to each lead to measure voltages on all lines. Then I plugged my HTC One M8 with initial charge of 5%. I then ran adb connect followed by adb shell to open a terminal session to the phone. The IBAT(uA) line in /sys/devices/platform/htc_battery/power_supply/battery/batt_attr_text gives the current draw. At 5% charge, my phone was drawing 1400mA at 5V. Even if the charging process is 100% efficient and the current draw stays at 1400mA, charging a 2600mAh battery to 60% will take longer than an hour. Not the 30 minutes I was promised.

So I measured the voltage on the USB data lines to see if the phone was indeed talking to the charger block over QC2.0 protocol. Turns out it did. It was asking it for 5V, by pulling the D+ pin to 0.7V and D- to GND. I kind of wish it didn’t talk QC2.0 so that it could be enabled somewhere. Now the odds are: either the phone isn’t asking for more voltage because it can’t handle it or that the kernel is not configured to ask for more. I really hope it’s the latter.

I will update this post as I find more info about this.

Quick Charge 2.0 Specification Diagram
Simple table showing what voltages on data lines corresponds to what output voltage. Be sure to read the CHY100 datasheet in detail for the exact working.

2014-01-08: OK. I can confirm that the issue is the ROM I’m using (Cyanogenmod 11 Nightly). I just restored the stock recovery and plugged in the phone while in recovery and it now configures the charger for 9V output. Now I know where to dig.

2014-01-09: Upgraded to Cyanogenmod 12 Nightly. Issue still there. I noticed that sometimes the phone puts 3V on D+ but 0V on D-. I suspect cyanogenmod uses outdated device tree.

2014-01-13: Got it. The problem was that CM didn’t have a daemon called hvdcp which configures the DCP (Dedicated Charger Port) circuitry of the phone and requests 9V input. After some time of hacking, I managed to fix it all up and submitted a patch to CM for review. The battery now charges at 2500mA compared to 1400mA before the change. That means, 60% of the battery will be charged in 37 minutes which is pretty close to Qualcomm’s promise of 30 minutes.

12 Nov

Shock Stall

Shaking off the glory
Sitting you down for a quiet story
Drink up my buzzed and fuzzed honey
Dinner isn’t gonna be ready

Had a mishap today at the shop
Told the cashier that at aisle 24, someone threw up
Asked and told and ran and got shot
I was the one who did it on someone’s top

Had a long day, bit an apple rotten to the core
Yellow curtains of your half open door
Covered my drooling mouth as I entered the corridor
Saw the swinging cut out of our lord, land head on on the floor

Sore sailing the waves of this scenery
Taking nothing for granted, there is nothing to take
Bone to bone to the song of this mockery
Layers of irony start to flake and flake

Wave at and blow kisses to hard rock lovers
Long live the Napolean of fish fodders
Hats off to room bargers, and shirt tuckers
Cult of card cutting cowards and lucky lusters

Switched on, full on at the start of this robbery
Commence the countdown to the end of our misery
Load up your guns, it is customary
to off everyone cold and steal no money

1 Nov

Null Encounters

Lights are on
Curtains down
Corners of the room
Trenches for our doom

Cyanide in hand
Roll of nails on sand
Can of can’ts on the shelf
Sharp minds adrift

Second thoughts first
Tell and show oppressed
Yet agains yet again
Unknown, ruled a sin

Down lookers and hopers
Miles out of focus
A poke for a cheap laugh
made a hole in the raft

Perky form outlawed
Perfect deemed flawed
Backs bare to the waist
Shoes laced in a haste

Ill-endowed with time
Sulked but felt fine
Be-all end-all of doubt
Prepared but wants out

Misguided and unsure
Ruled under, beat and sore
Pour a heart in a lake
Rid the chest of the ache

Lights dimmed
Talks and walks trimmed
Corners curved
Poison served

31 Oct


I’m Kermit and I’m enjoying your heat
You’re hot as shit and I am terribly sweet
Your busts are banging, sight of them a treat
I rhyme like a motherfucker, it is pretty neat

I’m Kermit and that is how I greet
a hot mama on a train, on the street
Next to me or on my lap, please take a seat
I’ll offer you milk, like monsieur Lapadite

besides ranting, you may also find me asking silly questions, write code for the world or just plain showing off. Make sure you read the privacy policy.