Things I don't want to look for twice..

Apache disable reverse DNS lookups

So, I had this annoying problem with Apache logging reverse DNS instead of client IP. The only explanation I could find is this one:

So, when using IP based access lists, instead of:

Allow from # my IP address


# my IP address
Allow from

It took me a while to find..

Streaming PulseAudio on a Samsung SmartTV

So, recently I turned back to Linux and I was sick of Windows and NSA and all that crap. And my all time favourite for a desktop still remains Linux Mint. So I got myself a 64-bit Linux Mint 16 (Petra), installed ..and so far so good. Surely, I had some issues with ATI proprietary drivers, especially in Google Chrome which actually have solve by accessing chrome://flags and changing some stuff around. But today, as I own a Samsung Smart TV, I needed my desktop to stream my Rhythmbox to it. (I don’t use Banshee, the default player, ..well, just not a fan)

Anyways, so if you need to stream your output to a Samsung SmartTV, this is what you’ll have to do: (in the mean time, give the middle finger for Samsung, as they’re not planning on doing Samsung Link for Linux)

1. install the necessary packages:

sudo apt-get install rygel rygel-gst-launch wavpack paprefs pavucontrol

2. edit your own users’s rygel.conf:

vim ~/.config/rygel.conf

3. add something like this:

title=@REALNAME@'s media
title=@REALNAME@'s media
title=Audio/Video playback on @HOSTNAME@
myaudioflac-title=FLAC audio on @HOSTNAME@
myaudioflac-launch=pulsesrc device=upnp.monitor ! flacenc

This will transcode everything to FLAC and advertise this as “FLAC audio on @HOSTNAME@”. I did this because around half of my music collection is actually FLAC. To transcode to mp3, replace the following block:

myaudiompeg-title=MPEG audio on @HOSTNAME@
myaudiompeg-launch=pulsesrc device=upnp.monitor ! lamemp3enc target=quality quality=6

4. Run paprefs and check everything under Network Server:



5. (restart your computer – I sincerely think it’s optional step, but I’ve read is some place)

6. Start your music player, hit Play, then run pavucontrol and select the output to be “DLNA/UPnP Streaming”



7. Start rygel, preferably in the background, after you’ve seen you don’t have any errors.

8. Turn on your TV and hit the “Src” button on the remote and you should see something like “Network Gst Launch”. Select that, than “Music”, then click on “FLAC audio on hostname”

That’s it! It should automagically start playing..

NOTE: all commands should be run as your own user, not root.

Got inspired from:


Pig Latin (python)

pyg = 'ay'
original = raw_input('Enter a word: ')
word = original.lower()
first = word[0]

if len(original) > 0 and original.isalpha():

if first[0] == 'a' or first[0] == 'e' or first[0] == "i" or first[0] == "o" or first[0] == "u":
new_word = word + pyg
print new_word
new_word = word[1:] + first + pyg
print new_word

print 'empty or has numbers/special characters'

Sink my battleship (python)

from random import randint
board = []
for x in range(5):
 board.append(["O"] * 5)
def print_board(board):
 for row in board:
 print " ".join(row)
print "Let's play Battleship!"
def random_row(board):
 return randint(0, len(board) - 1)
def random_col(board):
 return randint(0, len(board[0]) - 1)
ship_row = random_row(board)
ship_col = random_col(board)
# print ship_row
# print ship_col
for turn in range(4):
 # print "You are on turn " + str(turn + 1) + "."
 # print "Turn #%i: " % (turn + 1)
 # Everything from here on should go in your for loop!
 # Be sure to indent four spaces!
 guess_row = int(raw_input("Guess Row:"))
 guess_col = int(raw_input("Guess Col:"))

 if guess_row == ship_row and guess_col == ship_col:
 print "Congratulations! You sunk my battleship!"
 if (guess_row < 0 or guess_row > 4) or (guess_col < 0 or guess_col > 4):
 print "Oops, that's not even in the ocean."
 elif(board[guess_row][guess_col] == "X"):
 print "You guessed that one already."
 print "You missed my battleship!"
 board[guess_row][guess_col] = "X"
 if turn == 3:
 print "Game Over"
 # Print (turn + 1) here!
 print str(turn + 1)

Host1Plus fake advertising (solved)

This morning I’ve ordered a level 1 VPS from Host1Plus. I’ve wanted to do that for a long time, but I wasn’t very impressed by CPU offer. Yesterday when I checked their offer, I’ve seen they’re offering 1 core for the entry-level plan, so I ordered a level 1 for 2 years. Paid with my VISA card this morning and I had my VPS by the time I woke up after my afternoon sleep – yeap, I sleep in the afternoon, so what?!

So, here is the offer:


That’s cool, 1 core just for me. So I created my account, paid for 2 years and wait quietly for them to set up my new VPS. After few hours, as their email didn’t come, I checked my client area page and saw that:


(yeap, I’ve deleted the IP Addresses field)

Anyway, I saw the 50% CPU and decided to dig deeper into it, and found out that:


So it seems that the web interface in client area was right. Instead of having full 3.4GHz core, I only have 1696MHz, which, you already guessed, is around 50%. Nice, so not one core, just a half of it. So I thought there’s an error in the template they’re deploying, so I entered a live chat with a support guy. Here are some parts of it. First, we talk about what the website says:

16:48 Host1Plus: Well you have 1 CPU core with 50% of it’s speed
16:48 Me: yeap
16:49 Me: shouldn’t I have 1 core with 100% speed?
16:49 Me:
16:50 Me: it clearly states 1 core, not half core
16:52 Host1Plus: Your server can use 50% of 1 CPU core, that is defined in service configuration
16:52 Me: Yes, but what I just bought is 1 full core, not half of it
16:53 Me: and VPS hosting level 1 means 1 full core, 256MB ram and 15GB of disk space
16:53 Me: if you need, I can send you a print screen of your website
16:54 Host1Plus: I am afraid it does not state in the plans that level 1 has 1 full core, it shows that it includes 1 core
16:54 Me: exactly, 1 core, not 0.5 core
16:56 Host1Plus: It seems there is misunderstanding in our communication, have you checked how much CPU speed it shows inside your server ?
16:56 Me: before buying a host1plus VPS I had a free one, which clearly stated I don’t have a full CPU core
16:56 Me: model name : Intel(R) Core(TM) i7-3770 CPU @ 3.40GHz
stepping : 9
cpu MHz : 1696.060
16:57 Me: exactly half of 1 core
16:57 Host1Plus: Half of it’s speed, not the core itself
16:58 Me: you can’t split a CPU core in 2
16:58 Host1Plus: That’s why it shows 50%
16:58 Me: so, I see 2 options: 1. you’re misguiding clients or 2. service configuration not updated with the specs from the site
16:59 Host1Plus: If it would be 100% then you could all 3.40GHz
16:59 Me: exactly!
16:59 Me: which currently, I don’t

So yes, they are showing 1 core, but you only get half. Wait, it’s getting better:

17:01 Host1Plus: As I can see level 1 comes with 50% priority, level 2 – 100%, level 3 – 150%, level 4 – 200% and level 5 with 350%
17:01 Host1Plus: Everything is all right with the plans
17:03 Me: well, thing is, from your website, you can understand: level1: 100%, level2: 100%, level3: 200%, level4: 200%, level5: 400%
17:03 Me: 100% meaning 1 full core

Everything alright with the plans, I’m sure, but not alright with the website. So, although on level3 and level4 it says you get 2 cores, you get 1.5 cores for level 3, 2 cores for level4 and 3.5 cores instead of 4 for level 5. Fucking marketing department!

This is funny:

17:16 Host1Plus: Unfortunately, I don’t see the reason why your server should have more CPU speed than it’s defined in the configuration, you have ordered level 1 even without asking about it’s specifications before ordering

Why not calling you anyways? And just have contact info on your website? That should avoid this kind of issues. But, as long as you’re writing something on your website, ..I would expect to pay for what I see, not for what you mean. Now, the refund option:

7:18 Me: ok, upgrading is not an option, but as it’s not even 1 day since I bought your product and not pleased because it’s not what it’s advertised, I can surely ask for a refund, right?
17:20 Host1Plus: You may get refund only if your request matches with Host1Plus refund policy

Here is their refund policy:

Terms that must be met in order to receive a refund:
– Refunds are only applicable for monthly hosting service fees;
– Refunds are only applicable if we have failed to provide 99% uptime of the service;
– Refund is provided only once for a single account of the customer;
– Refunds are only applicable for services paid using Credit Cards. If payments were done using 3rd party checkout services (PayPal, etc.) refunds are only provided to clients HOST1PLUS accounts credit balance.

So guess what? Not getting a refund, because it was not a monthly payment. Silly me! Final issue: payment recurrency. I tried to get them to disable it. But:

17:24 Me: how can I make sure it’s not recurring payment? and my card is not credited automatically in 2 years?
17:25 Me: should I contact braintree? is there some settings you’ll make to my account?
17:25 Me: I wish that in 2 years my card won’t be billed automatically by you
17:25 Me: how can I do that?
17:27 Host1Plus: If you will cancel the service before the due date, the outstanding invoice will be canceled and you won’t be charged
17:30 Me: and there’s no way you can disable recurring payment on this account?
17:31 Me: because I might forget the expiration date..
17:33 Host1Plus: I am afraid I don’t have permission to disable recurring payment, however, I can advice with the management whether such option could be disabled for you

So I’m left with half core for the next 2 years. Probably enough for what I’m needing this for, but still, someone should modify the website or increase the CPU percentage. In the mean time, don’t trust what’s on, get a live chat before trying to buy something from them first.



Yesterday, a Senior Administrator from Host1Plus contact me and asked me if there’s a way we can solve this, as they’re willing to increase my processing power to 1 full CPU, as stated on the webpage when I ordered the package. So, considering template custom changes were not a solution, I got upgraded to the Level 2 VPS for free for the rest of my billing period, which yes, gives me a full CPU, but also double memory (512MB instead of 256MB) and bigger swap. Also, noticed they changed their offer to clearly state 0.5CPU instead of 1. And I guess I’ll continue with level 2 after this, looks better for my tests.

So, after seeing they’re actually concerned about their customers, at least the ones that own a blog, I can recommed them to be quick and fast in processing orders and support tickets. Prices are more than ok, too!

convert squid unix timestamp

I needed this because I needed to calculate requests per minute from a squid log file:

perl -p -e 's/^\d+\.\d+/localtime $&/e' < /path/to/squid.log

unattended-upgrades – bug

So, trying to run unattended-upgrades, and with –dry-run and –debug it seems like it was blacklisting some packages. After some Google Search, I found this:

So it seems like after I allowed unauthenticated packages to get on the servers, it made unattended-upgrades to malfunction. So, to make them work again, I commented this line in apt:

// APT::Get::AllowUnauthenticated "true";

After that, unattended-upgrades started to work again.

unattended-upgrades not working on Debian Squeeze (6)

I had to debug a problem where unattended-upgrades didn’t work. All my log was full of:

2013-09-23 13:20:38,180 INFO Initial blacklisted packages: blacklisted-package
2013-09-23 13:20:38,180 INFO Starting unattended upgrades script
2013-09-23 13:20:38,180 INFO Allowed origins are: ["('Debian', 'stable')", "('Debian', 'squeeze-stable')", "('Debian', 'squeeze-security')", "('Debian', 'squeeze-updates')", "('', 'stable')"]
2013-09-23 13:20:39,507 INFO No packages found that can be upgraded unattended

I tried to run unattended-upgrades with “–dry-run” and “-d” but that didn’t help much. So, the issue here is that Wheezy is out. Wheezy being out, it will look for packages for Wheezy, instead of Squeeze. So this section:

Unattended-Upgrade::Allowed-Origins {
 "${distro_id} stable";
 " stable";

Will have to be replaced with:

Unattended-Upgrade::Allowed-Origins {
 "${distro_id} oldstable";
 " oldstable";

After that, dry-run worked perfectly, so probably the upgrades, too.

VMWare Workstation 10 “Failed to Lock the File”

I tried to copy all files from a VM running on VMWare Workstation 10 for Linux, to a Windows machine with the same software installed. When trying to power on the machine, I got an error that said “Failed to Lock the File” and something about not finding the vmdk file or one of the snapshots. I tried re-copying those files about 3 times with no success. After a short google search, you’ll have to remove the folders that have .lck at the end. After removing those, I powered on the machine, and up and running it is.

Cron: (*system*) WRONG INODE INFO (/etc/crontab)

So, I edited crontab because I wanted to reschedule cron.daily to a convenient time. After restarting cron, I noticed there’s an error in logs.  Not a worry, the service was running fine, but I didn’t want to see that error. Problem is that is world-wide writable:

ls -la crontab
-rw-rw-rw- 1 root root 724 Sep 17 09:20 crontab

Don’t know how this changed, but it’s now 666, Devil’s number. So after:

chmod 644 /etc/crontab

..everything is back to normal again.

Still trying to figure out why logrotate doesn’t rotate some logs while running from cron.daily, but works just fine while running from command-line.