Swap Ctrl and Super keys on Linux

For past year I was working only with Macbook Pro and got used to OS X keyboard shortcuts (Super + C / Super + V). Now at work I still using OS X and at home I have Linux (Elementary OS) machine, and switching between OSX and Linux shortcuts is a lot of pain. But Linux has wonderful tool called xmodmap with it you can remap (switch) these two keys.

I found this partial solution on AskUbuntu.com. To remap my keys I executed following commands:

xmodmap -e "remove mod4 = Super_L"
xmodmap -e "add control = Super_L"
xmodmap -e "remove control = Control_L"
xmodmap -e "add mod4 = Control_L"

To execute all these commands automatically on my login. I created .xmodmap (with dot) file on my home directory and added these commands (Gist):

remove mod4 = Super_L
add control = Super_L
remove control = Control_L
add mod4 = Control_L

EDIT: it looks like lightdm does not read ~/.xmodmap file on login. Quick workaround is to add code below to Startup applications in Ubuntu/Elementary OS:

xmodmap ~/.Xmodmap
Posted in Linux | Tagged , | Leave a comment

PHP development environment with Docker

Docker PHP

It was some time I wrote something in my blog. Since last my post I was wondering in various courses to learning about new web development technologies. Lastly I met Docker and it is awesome at least I image it is 🙂

So starting today I am going to start some blog series, how to setup PHP development environment based on Docker. In case you don’t know what Docker there is good post about it by Geoffrey Bachelet. He also has his own blog post of building PHP DE but I like to do things in my way, with little more details.

First things first, I am using Elementary OS, so any commands you would see in this series should work on any Ubuntu based OS, even on Boot2Docker thing. Installing Docker is quite easy just follow instructions for your system in official Docker documentation.

Now when all is set up we can start building our development environment. Now days in PHP composer is must go for every developer. I would be using composer Docker repository. To install just pull it like described with command:

$ docker pull composer/composer

Then use it like so:

$ docker run -t -i -v $(pwd):/app -u 1000 composer/composer init

Notice I added -u 1000, this tells Docker to set me as owner for composer generated/installed files.

If command was successful you should see generated composer.json file. If not write comment below what OS you are using, maybe we would find solution together. Congratulations now you got now you have working composer in even PHP less environment.

Posted in Linux, Programming | Tagged , , , | Leave a comment

Puppet install less compiler from wheezy backports

Recently I was building my Symfony development box with Vagrant and faced problem how to install less compiler. After some searches I decided that best(?) way to install lessc is from Debian backports. Now I had another problem, how to install package from backports? Solution wasn’t easy to find, however I used these steps:

Install apt puppet module, in Vagrantfile add these lines:

$script = <<EOF
mkdir -p /etc/puppet/modules
(puppet module list | grep puppetlabs-apt) ||
   puppet module install puppetlabs-apt --version 1.4.2
EOF

  config.vm.provision :shell, :inline => $script

Now in your puppet manifest file include apt, add backports source, and install package like any other:

include apt
class node-less {
	include apt::backports

	apt::source { 'debian_backports':
		location => 'http://ftp.lt.debian.org/debian',
		release => 'wheezy-backports',
		repos => 'main',
		include_src => false,
	}
	
	package { 'node-less':
		ensure => present,
                require => apt::source['debian_backports']
	}
}
Posted in Linux, Programming, Server | Tagged , , , | Leave a comment

[Note] How to fix php simple xml CDATA problem

Note for me how to fix simplexml_load_string or simplexml_load_file functions problem, when there is text in CDATA and its is skipped by parser. Fix can be found on Tech Thought blog article “How-To: Fix SimpleXML CDATA problem in php

Posted in Programming | Tagged , , , | Leave a comment

Silex autoload namespaces without Composer

Currently I am working on one of my projects. For this project I am using Silex micro PHP framework, because its small fast and has all tools required for my project and uses some great libraries from Symfony2 framework.

Anyway to have reusable code I wanted to create some code on my namespace. All examples on the Internet shows to use $app['autoloader']->registerNamespace... but this functionality is deprecated and suggestion is to use Composer (composer.json). But I really didn’t wanted to use it. In fact I think micro framework should be able to setup fast without additional stuff like Composer.

Some time spent on searching found a solution. What I needed is to change first file in my controllers file to this:

//before was 
//require_once __DIR__.'/../vendor/autoload.php';
$loader = require_once __DIR__.'/../vendor/autoload.php';

And then add some namespaces paths to loader itself:

$loader->add('Irmantas', __DIR__ . '/../src/');
$loader->add('OtherNamespace', __DIR__ . '/../libs/other/');

Thats it and I have fully working namespace autoloader.

Posted in Programming | Tagged , , , | 4 Comments

Symfony2 Vagrant setup

Recently I searched for good Symfony2 Vagrant setup and came up that Andreas Hucks work is most suitable for my needs. It has everything what I needed NFS setup, preinstalled phpMyAdmin, Xdebug and etc.
However I installed newest Vagrant version (1.0.3) and then I tried to vagrant up my project I got this error:

NFS shared folders requires that host only networking is enabled
with a static IP. Please enable host only network and assign a
static IP via `config.vm.network`.

After some experiments with configuration I managed to solve issue by changing Vagrantfile config.vm.network line to this code:

config.vm.network :hostonly, "33.33.33.100"

After this fix VM started with no more issues.

I forked Andreas Hucks repository and added my configuration changes.

Here is repository link: https://github.com/irmantas/sf2-vagrant

Posted in Linux, Programming, Server | Tagged , | 1 Comment

[Note] Generate NetBeans 7 getters and setters

To generate setters and getters in code just place your cursor after class parameter and hit Alt + Insert on keyboard and Generate dropdown with options will apear. Select Getter and setter.. and its done.

It is strange that this option is not under Source menu.

Posted in Applications, Programming | Tagged , | Leave a comment

[Note] Resize images with mogrify on Linux

I find my blog best place to store notes. Today’s my quick note is how to resize images with mogrify (this tool comes together with imagic) on Linux.

mogrify -resize 300x200 myfile.jpg

To batch resize in current directory just add asterisk instead of filename.

Posted in Linux | Tagged , , | Leave a comment

Flush memcached cached data

Just quick tip for me and for my readers how to flush cached data in memcached. Just call ‘flush_all’ command for running memcached service:

echo "flush_all" | nc 127.0.0.1 11211

There are more available commands like ‘get’, ‘set’ or ‘stats’ for memcached. All these commands can be found in here.

Posted in Server | Leave a comment

How to change FileZilla settings save path

By default FileZilla saves all its configuration files including Site Manager configuration somewhere in OS user home directory. This can be easily changed where ever you want all you have to do is to copy fzdefaults.xml.example form {FileZilla install directory}/docs and place it in:

  • for Windows users in same directory as filezilla.exe
  • for OSX user in Contents/SharedSupport/ subdirectory
  • for Linux or BSD users in ~/.filezilla or /etc/filezilla or share/filezilla subdirectory of the install prefix
Rename copied file to fzdefaults.xml open it and change Config Location property to location where you want to save your passwords.
Posted in Applications | Tagged , , | Leave a comment