Hacks (14)

MFA from command line

MFA, 2FA, 2 step validation, etc. are everywhere these days. And it’s a good thing.

Problem with using the phone to get the authentication code is that you need to have it handy at all times (when you want to login at least) and that you have to read the code then type it in (too many steps)

One possible alternative is to use the command line oathtool

Here’s my snippet, I added the following line in my .bashrc

function mfa () { oathtool --base32 --totp "$(cat ~/.mfa/$1.mfa)" | xclip -sel clip ;}

Some preparation work:

sudo apt install oathtool xclip
mkdir ~/.mfa

If you want to use the same account with both a phone based MFA generator and the shell, set them up at the same time. Simply use the generated string for setting up the account in the Google Authenticator (as an example) and the add it to the ~/.mfa/account_name.mfa

The use of xclip automatically copies the 6 digit authentication code to the clipboard. You can go ahead and paste it.

The above setup works in Ubuntu. Didn’t try it on other systems.

Similar Posts:

Exim mail queue cleanup

I wrote before about cleaning up the mail queue. I had a large queue today though and the exim tools “felt” slow. So I did it manually (which wasn’t much faster):
cd /var/spool/exim/input/
for d in *; do echo in $d; cd /var/spool/exim/input/$d; C=0; for x in *H; do grep -q example.com $x; if [ $? -eq 0 ]; then f=${x%H}; (( C++ )); rm ${f}{H,D}; fi; done; echo $C mails deleted; echo "remaining: "; ls -l | wc -l; echo ---; done

Similar Posts:

Email Tracking

Most email clients can request a return receipt. One way to set this up in Thunderbird for example is to go to “Preferences > Advanced > General > Return Receipts …” and check the “When sending messages, always request a return receipt”

The problem with this approach is that when the person you’re emailing has set his email client to reject that request (or does that manually every time), you will not get a receipt back. And honestly speaking there is no way to force that. Now there are some services out there that promise to track your mail when that’s read, and those rely on embedding a transparent gif that will call home when the message is opened. I tried a few of these services: the free ones did not deliver (or seemed too shady for my taste) and the paid ones did not look too good either. So I cooked up a quick solution that I can use when needed (like when I’m tracking my brother on his honeymoon trip *evil grin*)

The code is below, pretty self explanatory. You will need a transparent gif/png. That’s easy too 😉

Edit: Looks like some services are not so bad. Checkout bananatag and YesWare Email Tracking

Similar Posts:

The Hunt for Postal Codes in Beirut, Lebanon

A few weeks (months?) ago there was a (very low) buzz in the Lebanese social media (twitter, blogosphere) about someone (MP? MoT?) announcing that LibanPost will “finally” be using a post code system for Lebanon. That sounded like great news, in spite of the fact that (as many pointed out) a similar announcement was made almost 10 years before that and no one knew about it (especially at LibanPost!)

I am ordering a couple of nifty items for myself (a Pebble and a MYO). And I am actually considering delivering them home, since I live in Beirut now. So I called up LibanPost hotline (1577) and asked if they have a way to tell me what my postal code is. The very nice lady at the other end took a couple of minute and asked me the same question a few times before it dawned on her that I’m actually asking for my own address’ postal code. I’m not too good at explaining things on the phone (or verbally in general), so I’m not blaming her. But when she knew what I was asking for she was very kind to point me to the next step:

Call 01629629 and ask for Mr. Mouhammad Hashash

I am assuming that’s public information, so I’m posting here so people searching for the same info might have a trail to follow. I called the number and Mr. Hashash was indeed the person to call. But since it was (almost) 13:00PM, he was on his lunch break. No one was there to replace him unfortunately. But the good people (3) at his office were kind enough to take my phone numbers and my address (I thought they were going to give me the postal code finally, but it was only for the note they took). So now I wait for the call. Hopefully we’ll get a Postal Code soon (and that the delivery men at LibanPost would be able to use it!)

UPDATE: at ~15:30 the kind Mr Hashash called and simply gave me the Postal Code for my building. I’m going to test it out real soon.

Similar Posts:

    None Found

Burn-in Subtitles for Manga

I had to burn in the subtitles for Naruto while converting from MKV to MP4 so I can watch them on Apple TV 3. Here’s the HandBrake command I used:

 HandBrakeCLI -i NarutoShippuuden.311.[480p].mkv -s 1 --subtitle-burned -o 322.mp4

Similar Posts:

    None Found

NVidia Driver on Ubuntu 13.04

A quick recipe that worked like a charm
Download driver from http://www.nvidia.com/object/linux-display-amd64-313.30-driver.html
then run:

sudo service lightdm stop
sudo chmod a+x NVIDIA-Linux-x86_64-313.30.run
sudo ./NVIDIA-Linux-x86_64-313.30.run

You may need to run the last command twice (including a reboot) if you are already running Nouveau drivers. Follow the on-screen instructions.

Similar Posts:

Stop Apache VirtualHost Spoofing

There are many techniques to stop spoofing websites. One of the most straight forward is to create a default NameVirtualHost to capture and block all spoofs. Here’s a recipe I’m using:

ServerName stop.spam
DocumentRoot /var/www/stopspam
ErrorLog /dev/null

Deny from all

Similar Posts:

This and Lots of That

It’s been a while since I wrote anything here. We moved, then kept on moving until we could move no more. Or at least that’s how it felt. From the quiet fresh and mostly healthy environment in the mountains of Lebanon to the confinements of Beirut, it wasn’t really that much fun. It took a while to get settled, and I could honestly say that after 3 months of that we’re still not there yet. I don’t think we will be settled here in any case, so it’s not that big a deal.
The only problem is that the coping is not the same as enjoying. And the creative process needed for coping is pretty different.
I won’t go on a rant, I still have things to do. I just thought I would share a few things I’ve been doing in the last 3 months or so.

Bread making

We had been thinking about this Moulinex bread machine for a rather long time. Pia did the research and it seemed like the best one we could find in the Lebanese market. We didn’t shell out an extra 60$ for the “Baguette” version as it seemed very silly to pay that much for a simple insert!
Since then, we have been making our own bread. Played around with the recipes and indulged in some “pain au lait” and brioche the first week or so. Then we moved back to our regular whole wheat bread. That smells and tastes just great.
I am still looking for Rye flour, and not finding any. Maybe I’m just looking in the wrong places.
pics coming soon

Small hacks

Desk lamp

For some reason, I am not able to find anything these days. Or things are simply too expensive to be reasonable. We need a couple of desk lamps, but I couldn’t find anything below 100$. Now tell me this is not crazy! I found clip-on lamps at the Chinese store in Manara for 4000LBP(~3$). But their necks were too low. So I bought a microphone stand for 15$ and fixed the neck of the clip-on lamp on that. Pia was positively impressed and I felt pretty proud of myself. Compare this to prices on Amazon! *sigh*
pics coming soon

Internet TV

I did not hook the TV to the cable/antenna/sat receiver yet. For different reasons (mainly being lazy). I will probably do that soon, but meanwhile I am enjoying getting all the latest TV series and my favourite movies thru a combination of flexget, deluge and xbmc. Oh, and here’s a good howto to get you started.
I also use the official XBMC remote for android and Transdroid (not from market) from my phone to control those. It’s a good combination, pretty easy and I don’t have to think about it. The only problem I have is that the old Dell i6400 I’ve been using as HTPC is slowly dying of old age and I have yet to find a suitable replacement!

Cloud9 IDE

Almost all of the PCs/Laptops we have are in sync. Still using the IDE and re-syncing the files on the laptop after working all day on the desktop (even with the ease of git) is a bit annoying for the lazy programmer in me. And I have been looking for an IDE to use on the road even when I’m out of the house. Enter Cloud9 IDE. Sure it’s nice to work in the cloud, but it turns out they have a standalone version that doesn’t have all the bells and whistles (no problem here). You will need nodejs setup along with a few dependencies and modules. But it’s really worth it. I’ve been playing with a new personal app for the android (and perhaps iOS) to be released soon and doing all of the work (so far) inside c9.

Gadgets wishlist

Here’s my list for the coming months:

Similar Posts:

Building DNS Zone Files

The only way to get a full listing of a DNS zone is to use AXFR to request a zone transfer. But that’s usually locked and not available. So building the zone file for a domain is basically guesswork or manual labour at best.

For some background information check out these questions on SO
Here’s a script I wrote to try and automate that as much as possible. Still in beta. Suggestions welcome.

Note: I use DNSPython

Next on my list is using the RimuHosting/Zonomi API to create/import the DNS zone.

Similar Posts:

Gnome Shell Screenshot + Imgur

The old gnome-screenshot was a very useful app. Unfortunately it seems to have been dropped in the latest gnome shell. I found this extension that does a similar job though. It’s called  Area Screenshot and you can find the code via github

Looking at the Advanced Usage note it seems that the developer added a hook that allows users to run a program after the screenshot has been taken. I used that to upload screenshots automatically to imgur.com. You will need to download the Bash Script Uploader and save it somewhere accessible as an executable. Then create the following script in ~/bin/area-screenshot-post

url=`imgur "$1"`
notify-send --hint=int:transient:1 "Screenshot Uploaded" "Copied URL to clipboard:\n$url"

You will get the url in the notification area.

Similar Posts: