Check if nVidia is running (linux-optimus-bumblebee)


I recently downloaded 0AD to check it out and the first time I started it my experience was dreadful. I immediately knew what has happened (My Dell XPS laptop has an nVidia card with Optimus). I have not started the game via “optirun”. This fact actually spiked my curiosity as to how to check if the optirun is actually using the nVidia card and not the built in Intel one?

When you actually do a search on the subject you may find a lot of stuff about glxgears. This however is not a test at all and in my case it actually shows the same frame speed irrespective of whether optirun is used or not.

Having said that I’ve stumbled upon a great solution, use inxi: (I had to install it on Ubuntu, however according to the post I have found it is already installed on Linux Mint)

So how do you check?

$ inxi -Gx
$ optirun inxi -Gx

Outputs should be different, in the first case you should see Intel and the second one should provide you with info about your nVidia card.

Take care.

Source: FunTechTips

Crontab’s predefined definitions


While working on my “guestnet” bash script I run into one significant issue “nmcli” has to be run either by root or with sudo.

There were two options I was aware of to solve this issue:

  • grant password-less sudo access to this command to my user
  • have root execute the script on every boot

As I did not feel comfortable with option 1, I started looking for possible ways to execute the second one.

This was not hard at all, although it took me a bit of time to find out. Cron has predefined definitions, that one can use, see wikipedia. I suppose, if I read man pages for cron I would know that too :)

Anyway, this is much better than my initial idea of having cron running every 5 minutes to check if network is up and if not to bring it up.

Use @reboot for anything that you want to execute at reboot!
Having said that, if you don’t need sudo, you may as well use .desktop files in ~/.config/autostart/

Take care.

Ubuntu connection sharing as access point (guestnet bash)


Recently, I was working on my guest network (my router broadcasts at 5GHz, my media server rebroadcasts at 2.4GHz), which I need so that some of my legacy devices can have access to the internet and for any visitors I might have, so that they can use wifi, but not receive access to my proper network and its shares. It also is important that the new network is in access point (ap) mode as that is a requirement for most mobile devices.

Most, if not all tutorials for Ubuntu (mine is 14.04) you find will tell you to install KDE GUI network manager. That’s the last thing I wanted to do.

Once you create a hotspot (if you don’t know how to, please do a search) it will most likely be ad-hoc. To change it open your hotspot file in the text editor:

vim /etc/NetworkManager/system-connections/Hotspot

You will find a list of config items, but one of major importance is “mode”. Make sure it says:


on top of that, if you would rather have WPA2 encryption add the following (remember to change password):


Feel free to change “ssid” and “id” and rename the connection file to whatever you want and reboot your pc.
After reboot go to your network list and select “create new wifi network”
You should see “connection” dropdown where your “hotspot” should be listed, select that, and click create.

Voila! You now (should) have a hotspot in access point mode providing internet connection to all your android and other mobile devices.

Take care.

P.S. It will need adjustment, as every network has a different uuid, however I have written a bash script that is executed via cron on every reboot to automatically create the guest network. You can find it at github

Mystery of disappearing crontab


I have upgraded my media server to ubuntu 14.04 (from 12.04) and as such I had to edit my backup script.
Shortly after that I have noticed that my cron is emptied every now and then. I traced this back to the reboot. My cron disappears on reboot – shock!

I have an SSD drive and I followed one of many ‘limit wear and tear’ posts, where the author recommends to put /var/spool on tmpfs. Problem with that is that crontab is stored in var/spool/cron/crontabs an tmpfs is memory.

Easy fix!

Take care.

Ubuntu 14.04 unresponsive password prompt


I seem to have a fairly obscure issue with my Ubuntu (running on Dell XPS17 L702x with nVidia GT555M). The problem is that every once in a while, when the screen turns off and it locks the system. I’m unable to enter the password. There is no caret in password field. The first time it happened I turned the pc off, but this time I decided to fight ;)

In my case tty was still available so I logged on an tried startx. This gave me a desktop and a working mouse, but not the full unity, nor were there any open windows from the programs running in my session. Back to terminal I tried unity. This at first was disappointing as nothing happened. Programme was running in the terminal, but that’s about it (contrary to startx which immediately gave me gui). I tried to run it again, but this time, after I started it, I moved back to gui (Ctrl+Alt+F7).

Another potential loss of work/data has been averted. I had to enter the keyring password and was back in, with all my open programmes still running and unsaved data intact.

Take care.

Ubuntu 12.04 to 14.04 upgrade (‘Failed to start session’ error)


I have recently upgraded on of my computers from Ubuntu 12.04 to 14.04 and was confronted by the ‘Failed to start session’ error.

I could log in from the terminal, but going back to gui I was still presented with the log in screen
(Ctrl+Alt+F1 => terminal, Ctrl+Alt+F7 => gui)

In my case there have been a bunch of unmet, read not installed, dependancies for ubuntu-desktop, and solution was provided after the list of them.

To verify that’s the case try sudo apt-get install ubuntu-desktop
and then go with sudo apt-get -f install

Take care.

use rsync to back up local files


As I was keeping various parts of my backups on different hard drives and different computers/network drives I thought it’s time to unify this and I bought a pair of 2TB hard drives. I copied all the files, duplicated on the other drive and sat down to readup on the available back up solutions. In the end I chose the simplest one: RSYNC run via cron on a daily basis.

Below are the contents of my shell script, which is run by cron at 3 am every day.

all flags used here are explained in the rsync --help and manpages, backup directory is a current day of the month, so it get’s removed if it exists, giving me a one month’s backup facility. All output of this script is sent to a log file in a crotab, but it could be done in this script as well.

Take care.

UPDATE: One thing that is important to note are the final slashes in the $SYNCFROM and $SYNCTO. What will be transferred depends on them. If $SYNCFROM was to be “/media/Ext1″ (note missing final slash) then Ext1 would be considered a directory to be transferred and after transfer you would end up with /media/Ext2/Ext1, wherease in the code example above contents of /media/Ext1 directory are matched against contents of /media/Ext2 directory.

Loop through and lint php files via cli


This is a quick way to use php native linter to check files in your project.

for i in find path/to/your/project -name "*.php"; do php -l $i >> ./lint; done

What it does is it loops through every php file it finds in the given path and runs it through php linter, outputting path and status to the file “lint”.
Unfortunatelly, it will break on any file with errors, so you will have to fix the errors and run it again.

If you have any suggestions as to how to prevent this let me know via Twitter

Take care.

Using Vagrant


I’m not going to give you a tutorial on how to use vagrant, there have been plenty of people before me who have done a great job. I will share my bash scripts on github soon though.
The most important thing I was going to say is that you don’t need to learn Ansible, Chef or Puppet to make the most out of Vagrant. Yes, it is nice to learn basics of at least one of them and I have that on my schedule, but basic bash knowledge will take you far enough in no time.

Take care.

Jolla – after 2 months


I’ve had the privilege to own Jolla since 16th of December, here is my review of the phone after using it for two months.

Good things:

Swipe based UI – you probably have read reviews from various sources (techcrunch and the likes) saying how hard the navigation is, the matter of fact is that one has to be well, retarded to consider the UI hard to use. After a day or two you will be trying to use the gestures on other touch enabled devices and it will actually be quite annoying that they don’t support them.

Battery life – ever since the firmware upgrade the battery life is so freaking awesome that I doubt you will find a better one on the market. I tend to charge it every 3 days (maximum was 99hrs) and there are people reporting 4+ days of usage.

Mallit based keyboard – Jolla’s virtual keyboard is gorgeous and really nice to use. I admit I got used to swype on Samsung, but this is the second best thing.

Developer mode – No other device gives you access to the built in console. You can ssh to the device too.

True multitasking – every application you open and do not close (yes, you can close an application on Jolla) is running in the background. What’s more, you get up to 9 active tiles, which display changes to the apps, but also allow you to perform most common functions without going back into the app itself (example would be pause or play next song, update mailboxes, or refresh weather tile)

CLI based tools – I did not have time to play with the mer distro too much, but I did notice that Jolla comes with git and sqlite installed. You can get ruby, postgresql, midnight commander, emacs and many more from Possibilities are endless.

Software – There is enough applications in the Harbour (Jolla Store) at the moment, yes, you won’t count millions, not even thousands, but the matter of fact is that pretty much every person uses the same 50 apps, so why would you need the other million of the rubbish ones?
If you do need rubbish there is always Android VM, which allows you to run most of the Android apps. Yandex store is installed and if you are adventurous and feel the need for google store there are tutorials with instructions of how to install Play store.

TOHs (The Other Halfs) – This is a brilliant concept of replaceable, nfc enabled back-covers which are capable of additional functionality. People have already built a wireless charging one and there is a “home made” qwerty keyboard one as well. Other concepts where better camera, external battery, etc.

Negative side of SailfishOS:

Sailfish has only one issue – It’s young, it’s still in beta and there are things that will annoy.
1. Occasionally, emails accessed from notification screen will display white screen (you have to swipe back to email list an enter again)
2. Calendar does not have every x weekday of the month repeat setting
3. WiFi to mobile network change is not as smooth as one would expect (or is used to from other devices)
4. No distinction between contacts home/work/other phone number in the recent connections list (which may be costly if your friends home number is in another country)

There is probably more, but these are the things I’ve found annoying.

The beauty of Jolla comes to light with those issues though. The company has set up a service where users can voice their concerns, propose new features, ask for changes and help one another. And what’s even more important, Jolla listens. Try that with Google, Apple or Microsoft.

In conclusion:

It’s a mobile device like no other. Any linux fan should get one, any open source fan should get one, any developer should get one.
Should a casual user get one too? Well, if one only cares about shitty bird games and giving away all your personal information to the likes of google, facebook and apple then you might be served better by other companies (I personally would say no to such a person, however most of the apps required to satisfy such person are available via Android VM on Jolla and more devices sold means more devices in the future). Having said that, a person I just described might feel annoyed by SailfishOS in it’s current state.

In the end I feel that it’s better to support a company built on a trust between customer and vendor rather than give away all your private information to the spying machine of the government and/or the hypocrites from Mountain View, Cupertino or Redmond.

and because of that I bought another Jolla for my wife :)

Remove x number of files with name y


I’m playing with my vagrant setup script and learning new command line ‘tricks’. Here is one of many ways in which you could remove x number of files with a certain name:

ls -f | grep | head - | xargs rm

So if we want to remove 1 file named test, we would do:

ls -f | grep test | head -1 | xargs rm

Take care.

Date of the first ‘such’ day of the month


I’ve been doing a little tidy on my drive and I came across a little method I wrote some 2 years ago. It returns the first ‘such’ day of the month (meaning, date of the first Monday, Tuesday, Wednsday, etc). I thought it might come in handy to someone. If memory serves me right this code has been ‘battle tested’, but I don’t guarantee it being bugless. Give me a shout on twitter if you find something.

Take care.

Change colour of twitter header


Some of you probably have noticed that twitter refreshed their design. For those who, dislike it I have a simple greasemonkey script to edit top header to whatever colour you like.


Multiboot is a… challange


I always thought multibooting was easy. One partition for windows, one for linux. Over the weekend I thougth I will install a third OS and I had to shuffle things about. I ended up messing up both of them. No problem I thought, I will clear up some space, install, reinstall all will be good. It ain’t so. First I thought I will get rid of windows – in the end I no longer have time to play games, what’s more, with the advent of steam on Linux, my only reason to keep that OS is silly. So it’s gone :)
That, however did not end my troubles, cfdisk keeps complaining about overlapping partitions, it does so even though I have removed those partitions (unless it complained about swap starting on the begining of the extended partition [something to check tomorrow]). Having said all that I don’t think I will be wasting my time though.

My advice is -

If you have more than one OS and your partitions are not in the best configuration to add a third one, do yourself a favour and do one of the following:
a) install the third OS on a new hard drive
b) backup important data, wipe the drive and reinstall all of the OSes

In the end you will either save yourself a lot of time to start with or you will save yourself a lot of headaches in the long run.

Take care.

Create a bootable pendrive with dd


I’ve decided to jump into the deep water and switch from Ubuntu to ArchLinux
I will tell you more about it once I actually have it on my pc (see my Recipe for a (not so) kick ass weekend in 10 steps). Anyway, in case you ever wonder how to create a bootable pendrive here is how:

1. first, plug in the pendrive and check device number

(sudo) fdisk -l

2. second, make sure the drive is empty (let’s assume your pendrive is /dev/sdc)

(sudo) dd if=/dev/zero of=/dev/sdc

3. copy the .iso file to the pendrive (let’s assume you have it in ~/Downloads)

(sudo) dd if=~/Downloads/file.iso of=/dev/sdc

P.S. Please note that there is no digit after the sdc. (Most common reason for “missing or corrupt isolinux.bin” error.
Also, I’ve read that To do so for Ubuntu you first need to convert the .iso to .img

Take care.

Recipe for a (not so) kick ass weekend in 10 steps


The following recipe might shorten your life by more than the time you spend executing it if you have any data you do not want to loose, so think twice ;)

1. Make sure you installed Ubuntu with encrypted home folder.
2. Realise your OS is taking waaaaay too much space, just when you need it to install new distro.
3. Decide to keep /home as a separate partion shared by all linux distros you use.
4. Realise that it is the encryption, which doubles up the space needed by Ubuntu and decrypt it.
5. While moving files about, accidently mess up ownership and permissions on random selection of files.
6. Consider this a minor ‘issue’, install clean version of the distro, move (don’t COPY) important stuff there (rather than to any other drive), as if that new distro on that new partition was invincible to any further cockups.
7. Move along to installing your awesome distro over the broken one, but before you do make sure you have been setting up that new shiny partition with a nice GUI tool and ensure you set it so that it overlaps with another, don’t worry, you will not be told about this until it’s too late.
8. Look at the partition table (which by now is all out of order). Fix it reordering eveything. Reboot.
9. Be greeted by GRUB Rescue… Panic… Do not think… waste an hour trying various bullshit how-to’s
10. Go to bed. Wake up the next day, calmly approach the pc and fix it.

P.S. Remeber to always move your important data off the disk you will be messing up with. Loosing data ain’t funny.

Take care.

Magento: Get value of order item attribute


You can use the following code to access Magento order item attribute in the order grid view or in any other order view.

Take Care,

Git: Stage deleted files


As usual, I forgot how to stage deleted files in git and since I had about 100 of them I had to hunt for the solution again…

One option in to use

git add -u .

This however, will stage all files, including the ones that were modified, so it may not be suitable if you do atomic commits.

To do that I’ve found two options:
- First option comes from Agile Adam

git ls-files -d -z | xargs -0 git rm --cached --quiet

- Second one is from ComandLineFu

for x in git status | grep deleted | awk '{print $3}'; do git rm $x; done

Take care,

Case for Scottish independence.

I always thought of writing a long and elaborate explanation why a Scot (and anyone who lives in Scotland and is eligible) should vote YES. In the end it’s a fairly simple matter. Vote YES because you are Scottish. Other nations – large and small alike – can govern themselves, so can you.

In case you need more reasons, read on.

First thing you should ask yourself when considering the two sides ask yourself, why does the ‘Better Together’ side wants Scotland to stay part of UK, do they have your best interest at heart, or their own? Considering the past 5 years, can you say that Scotland has really been ‘better together’?

Second, Scotland will have to aplly for EU and Spain will block it. This is a position that so many Tories would love to be in, that I am seriously at a loss as to why they don’t support the YES campaign. But honestly, why would you even care if Scotland is in the EU? Countries like Norway or Switzerland are not and are doing just fine. Countries from the former eastern block did enjoy a lot of development money pouring in from the EU, but Scotland has not had that, so there is nothing to lose. There were other benefits, but those hardly apply to Scotland. On top of that, there is enough benefits to not being in the EU to render this topic absolutely pointless, but what is more important it should be a European Union’s role to welcome independent Scotland back and prevent Spain from blocking the accession. Oh, and by the way, you do remember the first point? Spain has a lot to gain by insisting on and vocalising their intent on making it hard for Scotland to join, they have a strong separatist movements in their country, so they have to put on a show. Will they ever do what they say does not matter much. European Union should be afraid of the fact that when Scotland becomes independent, is successful and is not part of the EU, other countries might want to leave.

Third, with the exception of very few countries, everyone else had to fight and die for the privilege of independence and if you look through out history, every nation had to fight for their independence, all that is asked for you is to go and formally state your will.

Fourth, Poland (country I’m from) in the late 18th century had an equivalent of the ‘better together’ team, although for them together meant ‘with Russia, Prussia and Austria’. Over the course of 23 years Poland was no more, our lands appropriated by the aformentioned countries. Nowadays we call the people who started it all as they should be called – traitors. It’s cowardly for a Scot to vote NO.

Fifth, ‘Better Together’ campaigners are happy to look past 2040, SNP is not. Believe me, no politician of today who supports ‘Better Together’ will be around in politics after 2040, so they don’t care. They can promise you 5 kg (~10lb) of gold or an elephant in 2050 if you vote NO and it won’t matter to them, they will be enjoing their retirement at your cost (literally).

Sixth, when oil runs out Scotland is ‘f£%£$ed’ – is it, do you really believe this or has someon told you that? There is a lot of small countries that have no oil in Europe and they are doing just fine, actually most of them are doing great. Need examples? Slovenia, Czech Republic, Austria, Estonia, Finland, Belgium, Holland, Switzerland. Scotland has plenty of natural resources to tap on when independent. What is more, future wars will not be fought over oil, but water. And Scotland has plenty of it; renewable technology potential – loads; Academic acumen – plenty; tourist potential – (subjective) more than the South.

Seven, SNP wants to open doors to more immigrants – that’s bad. No, that is actually good. As long as the health and benefit system is not prone to abuse, more skilled people create more opportunities, and thus economic growth which benefits themselves and the less skilled people. More growth leads to more employment and training opportunities moving people out of the low paid jobs to the ones with higher salaries. And if you are on benefits and proud of it (I’ve met such people, so there is no point pretending they don’t exist, although it’s doubtful they will ever read this) you should be open to an influx of more people willing to work, otherwise there won’t be enough taxes to pay for your benefit and you might end up with none.

Eight, Westminster politics is antagonistic; it’s a farce to watch them shouting at each other. But, dubious amusement aside, it’s a government people in Scotland did not vote for and yet ended up with, this is not democracy. I would even go as far as saying that the government in Westminster has no mandate in Scotland and as such it’s decisions are “unlawful” (they are lawful, but you do get what I mean, right?).

In the end I can only hope that everyone who has Scotland’s best interest at heart will go and vote YES in the referendum in 2014 as it is better to try and fail than not to try at all.


I’m Polish, I lived in Scotland for over 8 years now, which is about a third of my life (or almost a half of it if you discount all my international travels). I support the right of every nation to be independent (as long as it’s not an ethnic minority that settled on a land in a tight-knit community, refused to integrate with their hosts and claims the land is theirs). I favour open, free market based economy (no not the pseudo-capitalistic version that developed over the last 30-50 years). I don’t believe politicians they are like drug addicts – will say and do anything to make sure they get another fix.

And I will vote YES in 2014.

Vodafone prevents copy and paste of passwords


After a long time of not logging into my vodafone account, I’ve done so last night. The problem was that I did not remember what my password was, so I jumped in to my keepass and generated a nice, long password. Pasted that in the ‘password change’ form. And tried to log in. To my surprise Vodafone does not allow pasting into password field. So I asked them why, well, I did not really ask and I was not very pleasant. Nevertheless, Vodafone’s decision (as it is with any decision of developer to limit actions of users) was very annoying.
(Below you have an image of the conversation from twitter.)

So my question, to all the people more knowledgable in the subject of security, is whether it preventing paste on the password field has any benefits, or is it simply an annoying idiocy dreamt up by some “wannabe a star” corporate halfwit (something like the email disclaimer)?

My own take on this is that it promotes use of the same password throughout many websites or alternatively use of weak passwords.

For everyone interested, here is a piece of code that unbinds vodafone’s bullshit: (I have it running in my greasmonkey, so FU Vodafone)

And here is the code that they have in their js that is a culprit:

Copy of the aforementioned chat with Vodafone’s Help account maintainers:

chat with vodafone

If you do care to comment, please do so via twitter. Thanks!