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
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.
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.
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.
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.
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”
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
10.1.1.216:5555 followed by
adb shell to open a terminal session to
the phone. The
IBAT(uA) line in
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.
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
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.
A while back I had to make a decision that could affect my life in a significant way, forever! This decision depended entirely on odds — whether it was worth the risk. In search for some hard numbers, I realized that such statistics is very difficult to come by and when you do find it, the useful bits are buried among pages and pages of text and formulas in some research paper. I read 1000 page manuals every other week and even I don’t usually make it to the end of these papers.
The previous paragraph is perhaps a little abstract. A concrete but a silly example is if you were thinking of spending some big buck on a lottery ticket. What chance are you taking? Finding the numbers for this particular example is not that difficult. Any lottery organization must provide the odds of each game to players before they purchase their tickets. However, what you get is always a number, something like 1:4132766. But what does that mean? It literally means the odds of a single ticket hitting the jackpot is 1 to 4132766. OK, but how big is 4 million. Without fail, you are inclined to ask: “what’s something with similar odds?”
And so the idea to compare probabilities was born. It’d be much more helpful to be told that you are as likely to hit the jackpot as you are to be eaten by a white shark (this is an example, I don’t know the odds of either). I figured one person (me for now) should suffer once and from then on, everyone should benefit. I put together a simple site in two weeks with some initial data. Statsic was the most creative name I could come up with. As I’m not a statistician and frankly hated statistics back in college, I may have made a lot of boo boos in my analysis of the data on the site. However, I am intending to learn as I go and provide a high quality original source that is reliable and comprehensive.
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
Lights are on
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
Talks and walks trimmed
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
Up my game
Down-level an amount worthy of my fame
Disengage from the roaring torque of your engine
Disparage my opponents, call them names
Up my game
Reid this empty house, rape it with an emptier flame
Deceive me with your age old finest deceit
Revel as I break and fall to my knees
Up my game
Deplete the building desire to dismiss it as vain
Exert a microscopic effort to advance me
An extra breath for you, means the world to me
Up my game
Bear the burden that what you do is lame
Agitate your friends, and save me the calm you
Wholeheartedly laugh when pain is flowing through you
Up my game
Train me until I’m clean and tame
Play me, whisper to me “who knows whom to blame?”
Frame me with good intentions, a noble aim
Up my game
But quash the thought of me doing you the same
Bet on your life that for the rest of it you will regret
spending a single moment, upping my game
Up my game
I dare you
Are you game?