Sabtu, 11 Juli 2015

The package management system on Ubuntu makes it extremely simple to install and remove packages, but sometimes it’s important to figure out what version of a particular package that you actually have installed.
The apt-get utilities are simply a front-end to the debian dpkg utility, which actually does the real work. You can use this utility to figure out what version is installed.
dpkg -s <packagename>
Here’s an example, where I was trying to figure out what version of Ruby I had installed on my system:
geek@ubuntuServ:~$ dpkg -s ruby1.8
Package: ruby1.8
Status: install ok installed
Priority: optional
Section: interpreters
Installed-Size: 272
Maintainer: Ubuntu Core Developers <ubuntu-devel@lists.ubuntu.com>
Architecture: i386
Version: 1.8.4-5ubuntu1.2
Depends: libc6 (>= 2.4-1), libruby1.8 (>= 1.8.4)
Suggests: ruby1.8-examples, rdoc1.8, ri1.8
Description: Interpreter of object-oriented scripting language Ruby 1.8
Ruby is the interpreted scripting language for quick and easy
object-oriented programming. It has many features to process text
files and to do system management tasks (as in perl). It is simple,
straight-forward, and extensible.
.
This package provides version 1.8 series of Ruby.
.
On Debian, Ruby 1.8 is provided as separate packages. You can get
full Ruby 1.8 distribution by installing following packages.
.
ruby1.8 ruby1.8-dev ri1.8 rdoc1.8 irb1.8 ruby1.8-elisp
ruby1.8-examples libdbm-ruby1.8 libgdbm-ruby1.8 libtcltk-ruby1.8
libopenssl-ruby1.8 libreadline-ruby1.8
Original-Maintainer: akira yamada <akira@debian.org>
You can see that I’ve got version 1.8.4 installed.
apt-get
You can run a simulation to see what would happen if you upgrade/install a package:
apt-get -s install <package>
To see all possible upgrades, run a upgrade in verbose mode and (to be safe) with simulation, press n to cancel:
apt-get -V -s upgrade
apt-cache
The option policy can show the installed and the remote version (install candidate) of a package.
apt-cache policy <package>
apt-show-versions
If installed, shows version information about one or more packages:
apt-show-versions <package>
Passing the -u switch with or without a package name will only show upgradeable packages.
aptitude
The console GUI of aptitude can display upgradeable packages with new versions. Open the menu 'Upgradable Packages'. Pressing v on a package will show more detailed version information.
Or on the command-line:
aptitude versions <package>
Passing -V will show detailed information about versions, again to be safe with the simulation switch:
aptitude -V -s install <package>
Substituting install <package> with upgrade will show the versions from all upgradeable packages.

Jumat, 10 Juli 2015

Become a better programmer

Programmers nowadays should all know these 3 very important rules:
  1. Don’t use floating points for money
  2. Store date/time in “UTC” timezone
  3. Always use the “UTF8″ character set
Tom Scott brilliantly explains the above 3 topics in videos that roughly last 10 minutes each. He explains them clearly, with depth and in a passionate way. They are listed below. Start the video’s by clicking on them.

1. Don’t use floating points for money

…never ever…
utf8_video

2. Store date/time in “UTC” timezone

…yes, always…
timezone_video

3. Always use the “UTF8″ character set

…no exceptions…
floating_points_video
IMHO every programmer should watch these videos, because they are very educational. And “Yes”, it will takes you 30 valuable minutes of your precious time. But “No”, you will not regret it, because they teach you some valuable and elementary lessons. Lessons that apply on any software project, written in any programming language.

real_programmers
To convert your Ubuntu 14.04 into a powerhouse for software development for PHP, you need to install some developer tools from the rich set of available software packages. I have made a top 10 of my favorite developer tools.

1) Install Eclipse 3.8 as a complete IDE

Altough everybody I know prefers the JetBrains IDE’s, I am still a sucker for free (as in speech) software. I think Eclipse and the various distributions of Eclipse you can download are just as good, when properly configured.
1
sudo apt-get install eclipse

2) Install Geany 1.23 as a lightweight IDE

I also often find myself using a lightweight IDE. After using way too much “gedit” I have recently (re)discovered “Geany” and I feel it is perfect. With the following commands you install it with a good set of plugins.
1
sudo apt-get install geany geany-plugins
You can find some Geany color schemes on Github that are worth installing as well.
1
2
3
4
5
wget https://github.com/downloads/codebrainz/geany-themes/geany-themes-1.22.2.tar.bz2
tar -xvf geany-themes-1.22.2.tar.bz2
mkdir -p ~/.config/geany/colorschemes/
cp geany-themes-1.22.2/colorschemes/* ~/.config/geany/colorschemes/
rm -Rf geany-themes-1.22.2 geany-themes-1.22.2.tar.bz2

3) Install MariaDB 5.5

MariaDB is the replacement for MySQL now that Oracle has acquired it. This is comparable to the replacement of OpenOffice with LibreOffice after Oracle got their hands on it.
1
sudo apt-get install mariadb-server

4) Install PostgreSQL 9.3

PostgreSQL may be the most powerful database around.
With PostgreSQL 9.2, query results can be returned as JSON data types. Combined with the new PL/V8 Javascript and PL/Coffee database programming extensions, and the optional HStore key-value store, users can now utilize PostgreSQL like a “NoSQL” document database, while retaining PostgreSQL’s reliability, flexibility and performance. (source)
I feel you should always consider using it before choosing any “NoSQL” or “documents-based” database.
1
sudo apt-get install postgresql pgadmin3
Do not forget to set the root (postgres) password.
1
2
3
sudo -u postgres psql postgres
ALTER USER postgres WITH PASSWORD '<password>';
\q

5) Install Apache 2.4 + PHP 5.5 + modules

Install Apache and the default method (mod_php) to serve the new PHP 5.5.
1
sudo apt-get install apache2 libapache2-mod-php5
Install PHP 5 support for MariaDB and PostgreSQL.
1
sudo apt-get install php5-mysql php5-pgsql
Some PHP packages for Symfony development.
1
sudo apt-get install php5-intl php5-sqlite
PHP packages for cURL and XDebug.
1
sudo apt-get install php5-curl php5-xdebug
Optional PHP packages for creating images (GD), doing geolocalization on IP address (GeoIP), encryption and Redis/Memcache caches.
1
sudo apt-get install php5-gd php5-geoip php5-mcrypt php5-redis php5-memcache php5-memcached
Now enable mod_rewrite and restart Apache to make sure everything is loaded.
1
2
sudo a2enmod rewrite
sudo service apache2 restart

6) Install Adminer 4

PhpMyAdmin is a very popular web-based database management tool. Adminer is a drop in replacement that beats it on almost all points. You can install the latest version of Adminer using:
1
2
3
4
5
6
sudo mkdir /usr/share/adminer
sudo wget -O /usr/share/adminer/latest.php "http://www.adminer.org/latest.php"
sudo ln -s /usr/share/adminer/latest.php /usr/share/adminer/adminer.php
echo "Alias /adminer.php /usr/share/adminer/adminer.php" | sudo tee /etc/apache2/conf-available/adminer.conf
sudo a2enconf adminer
sudo service apache2 reload
Now go here to run it: http://localhost/adminer.php
In the future you can easily update Adminer using:
1
sudo wget -O /usr/share/adminer/latest.php "http://www.adminer.org/latest.php"

7) Install Git

Install the Git source code versioning system:
1
sudo apt-get install git
Check out this great Git cheat sheet.

8) Install some compilers and build tools

With the following commands you get most common compilers and build tools.
1
sudo apt-get install gcc build-essential libc6-dev autoconf automake

9) Install the Microsoft fonts

There are always people that rely on the standard Microsoft fonts (like Arial). Although this is bad practice and HTML5 allows you to embed fonts, still it may solve some problems to just install these:
1
sudo apt-get install ttf-mscorefonts-installer

10) Upgrade your Office experience

A developer also needs to read or write some documentation or specifications. Libreoffice Writer is IMHO better than the real thing (Microsoft Word).
1
2
sudo apt-get purge gnumeric abiword
sudo apt-get install libreoffice

Feedback?