Welcome to the first part of the book project series. Without further ado, let’s get started
Undoubtedly, there are many books about
I picked it a few weeks before the company I work at decided to move from the SVN to GIT, making what’s supposed to be a huge step forward. It turned out it really was.
Through the first 100 pages, Ben explains the concept of git, which is a decentralized versioning system and underlines what distinguishes it from other versions systems i.e. SVN, CVS, and Mercurial. Additionally, the author covers a number of topics: git customization, setting up a git server, or repository migration, which may help you during git initial setup. Chapters are well structured, precise and thrift. Concepts are explained in a clear manner and easy to understand. The book helps newcomers with getting to grips with the concept of distributed work using branches and provides several user stories, which cover most of the daily usages of the versioning system.
It’s a great chunk to start with in order to build a solid base of knowledge. Even readers who are already familiar with the git mechanics may find something interesting and non-trivial like chapters covering the git internals. After reading Pro Git I felt comfortable enough to navigate toward the git official documentation with a lot more courage.
Personally, the most important takeaway was the function called bisect, which I didn’t know existed before reading this book. It got into my mind so deep I decided to immediately put it into action. In case you are not familiar with it, here’s a short explanation from the official documentation:
This command uses a binary search algorithm to find which commit in your project’s history introduced a bug. You use it by first telling it a “bad” commit that is known to contain the bug, and a “good” commit that is known to be before the bug was introduced. Thenhttps://git-scm.com/docs/git-bisect
git bisectpicks a commit between those two endpoints and asks you whether the selected commit is “good” or “bad”. It continues narrowing down the range until it finds the exact commit that introduced the change.
Using it along automated tests allows to quickly locate the commit that broke it, which may really speed up your work.
Would I recommend the book? Definitely, just bear in mind you can really skip half of it, if you are not interested in the migration, server picking, choosing a communication protocol, or the git internals. Otherwise it’s well worth your time.
I must admit being busy with my new position as C# developer I haven’t spend much time on my blog lately. It’s a high time to change it. I decided to challenge myself with a task of reading and reviewing 12 books (+ extras) that are more or less related to programming. Based on the most recommended books for programmers, I’ve prepared a list and decided to see for myself if they’re worth reading. Except for reviews I’m going to work through a few examples from each book that I find the most significant.
Here’s the list:
- Clean Code – Robert C. Martin
- Pro Git – Scott Chacon, Ben Straub
- Head First Design Patterns – Eric Freeman
- 97 Things Every Programmer Should Know – Kevin Henney
- Introduction to Algorithms (parts)
- Cracking the Code Interview – Kitoyana
- How to Create a Mind – Ray Kurzweil
- The Shallow – Nicolas G. Carr
- Thinking, Fast and Slow – Daniel Kahneman
- Code Complete – Steve McConnell
- Clean Architecture – Robert C. Martin
- Refactoring – Martin Fowler
Welcome to the second part of the tutorial, in which I’ll show you how to deploy a LAMP stack on your droid smartphone. Here’s the link to the previous part.
Rule of three
As far as I’m concerned there are three ways to launch a web server on the android device.
First and the most challenging is to install Linux natively. This would require native drivers for your smartphone, as the android layer would be wiped out totally. I’ve seen some examples of such ports of HTC devices, however, I was unable to find any materials for my Xperia or other brands. If you’ve heard about such projects, don’t hesitate and let me know.
Alternatively, you can install one of the web server apps, that emulate the environment and let you use the AMP stack such as PAW Server, KSWeb, BIT Web Server or any other. The advantage of this solution is that you don’t need to root your device. You can have a preconfigured environment waiting for deployment in a blink of an eye. The downside is that you don’t have the flexibility of Linux machine, ability to install any additional software, get the latest version of PHP, Apache2, SQL. Also, it lacks configuration options.
The third option and the one I went for is to use rooted device along with Linux Deploy, Busy Box (you’ll have this one already installed if you followed the first part of this tutorial) and Remote VNC for streaming the Linux desktop. Basically, it lets you create a virtual machine running a distribution of Linux of your choice. It seems to be the best of two worlds: you can use everything Linux has to offer and don’t have to worry about the drivers. Surely it won’t run so smoothly as a native installation would, but the performance is ok for most of the needs.
Deploying a distribution of Linux of your choice
First install BusyBox – it gives your phone access to the Linux commands required by the Linux Deploy virtual machine. Once you install it, you do not have to worry about it.
Open Linux Deploy and make sure it has administrator privileges. Now press the small download button in the top or bottom corner of the screen. This will take you to the options menu. Most of the settings here can be left as they are, you can choose the Linux distribution. Everything is here – from Debian and Ubuntu to Kali Linux, Gentoo, Fedora and others. Each distribution has its own quirks and fans. One difference worth noticing is that there are two packages standards – DEB and YUM. In most cases it’s not a huge difference, however unless you own a Snapdragon 835 or newer, your software packages will be limited to the ones based on x64 libraries. For the sake of this tutorial, I went for Ubuntu which uses apt manager for DEB packages.
Next you should choose an installation directory and set the size of virtual machine image. This is important because by default the image size is set to 2GB, while the system files can take up to 1.6GB, leaving you with 400MB for your experiments. In case you use fat32 file system on your device/sdcard the max size you can use is roughly 4GB. If you’re lucky and your device is able to read ext4 cards, then you’ll be limited to 16TB per image or rather the card capacity.
Next under the GUI category tick enable under GUI to ensure you have a graphical interface to work with and check out the GUI Settings. Choosing the resolution is up to you. I’d suggest to set it to either your smartphone default resolution in case you’ll display it on a smartphone or to the native resolution of any external screen you want to use. Set your username to ‘root’ to give yourself privileged access and make a note of the password.
Now click the menu that looks like three dots and click ‘Install’. This will take a little while but will install the entire Linux distro on your device. Click the ‘Start’ button to run it in ‘chroot’ – essentially a small sub-compartment on your device. Finally, you’ll use VNC Viewer in order to actually view the GUI. Load it up and set the address to ‘localhost:5900’. Then enter the password that you set earlier. You can either install VNC on your smartphone or desktop just as you’d use any remote desktop. In case you’d want to stream the Linux desktop to your smartphone directly, you need a USB to MicroUSB OTG cable and a set of keyboard and mouse for convenience.
First, make sure you’re logged as root. If you set the user to root in the previous step, most likely you would. If not, elevate user privileges by adding ‘sudo’ word before all commands from this chapter. Next, ensure your system and apt package lists are fully up-to-date by running the following:
apt-get update -y && apt-get upgrade -y
-y flag tells apt to go ahead and update the system without prompting you. Next you’ll need some kind of text editor. Personally I used nano, but actually any is going, to be fine. It’s up to your preference.
apt-get install nano -y
apt-get install gedit -y
apt-get install python-software-properties
apt-get purge php5-fpm
apt-get install php7.0-cli php7.0-common libapache2-mod-php7.0 php7.0 php7.0-mysql php7.0-fpm php7.0-mysql
apt-get install php7.0-cgi php7.0-dbg php7.0-dev php7.0-curl php7.0-gd
apt-get install php7.0-mcrypt php7.0-xsl php7.0-intl
After the installation is complete, restart Apache2:
service apache2 restart
And verify if the PHP7 installed correctly:
Please run for the standard Apache installation
apt-get install apache2
or in case you don’t want to use the php-fpm package:
apt-get install apache2 libapache2-mod-php -y
Check if the Apache is running:
service apache2 status
If not, try to start it manually:
service apache2 start
Apache2 enable mod_rewrite
sudo a2enmod rewrite
sudo service apache2 restart
Then open the configuration file:
AllowOverride None to AllowOverride All
Options Indexes FollowSymLinks
Require all granted
sudo service apache2 restart
apt-get install mysql-server -y
Follow the prompts as below:
- Would you like to setup VALIDATE PASSWORD plugin? press Enter here for No
- Please set the password for root here. New password: Type a secure password here then press Enter
- Re-enter new password: Re-type the secure password here then press Enter
- Remove anonymous users? (Press y|Y for Yes, any other key for No) : press y and then Enter here
- Disallow root login remotely? (Press y|Y for Yes, any other key for No) : press y and then Enter here
- Remove test database and access to it? (Press y|Y for Yes, any other key for No) : press y and then Enter here
- Reload privilege tables now? (Press y|Y for Yes, any other key for No) : press y and then Enter here
Then try to start mysql service:
service mysql start
You log into the client by running:
mysql -u root -p
To find port mysql is listening at just log into the client the type:
SHOW GLOBAL VARIABLES LIKE ‘PORT’;
If it works, well done! If not, check the error log in console or at /var/log/mysql/error.log. Some of the most frequent issues are:
- Cannot touch ‘/var/log/mysql/error.log’: Permission denied
This means the MySQL process cannot access logs directory, you can fix it by running:
chown -R mysql /var/log/mysql
…or any other mentioned catalog in the log. If that doesn’t help, try setting the access rights by running CHMOD -R 777 for given directory and gradually decrease the rights.
- ERROR: The partition with /var/lib/mysql is too full!
Check if you have any free space on the partition, if you do and the error persists, try changing the owner of the catalog recursively as in the previous example.
- ERROR 2002 (HY000): Can’t connect to local MySQL server through socket ‘/var/run/mysqld/mysqld.sock’ (111)
Firstly, you can try going to /etc/mysql/my.cnf and change ‘bind-address’ parameter to ‘localhost’ or ‘127.0.0.1’. Sometimes the Android kernel can be compiled with CONFIG_ANDROID_PARANOID_NETWORK setting. This allows only certain users to use the device network i.e. users that belong to hardcoded groups –
To fix it add mysql user to one of the groups:
usermod -a -G aid_inet,aid_net_raw mysql
Well done, you have a working web server! 🙂 Just put your project in the var/www/html catalog or define your own in the etc/apache2/sites-enabled configuration file. To find your IP address, to which you can connect from outside devices, run the following command:
ifconfig | grep inet
Wait but Why?
My journey with the Coderslab coding boot camp is coming to an end. For the final project, I’ve decided to design an online film database parser, implementing RESTful API and turn it into a simple website. If you’re interested, please follow this link to Github, where you’ll find both project source files and detailed description. It should offer only a single functionality – option to select a random movie matching chosen criteria (been ever wondering what to watch this evening?). To spice it up slightly and make myself an opportunity to implement some SQL performance tuning, I decided to deploy the website on an experimental architecture.
My first thought went to Raspberry Pi due to its incredible fan base and an immense amount of high-quality tutorials. Then I remembered that I have a glossy orange Sony Xperia Z3 Compact in my drawer, which works perfectly fine despite screen issues. Android system is based on Linux, so I thought while being more challenging, turning the phone into mobile, waterproof (almost!), the battery-powered web server would be also more satisfying.
In this piece, I’d like to have a quick look at the book-based learning in 2017 and why it’s a good idea to always reach out for the original pieces rather than localizations, even if it does require a bit of a stretch.
I’ve spent several years working on technical translations in various fields, including IT. In general, the content is sent to translation/localization for one main reason. The idea of expanding and reaching the new audience. However, the situation with the handbooks, especially in IT doesn’t quite fall into this category. In a few steps, I’ll try to convince you why it’s much better to reach for the books written originally in English.
- Time complexity: O(n2)
Hi, in the second episode of the algorithms series I’d like to take a closer look at yet another simple sorting technique called selection sort. Similarly to bubble sort, it consists of two dependent loops, therefore it’s time complexity also equals to O(n2). It goes like this:
- While sorting the array in ascending order we set the first loop and the first element in the array as a minimum.
- We set up a second loop with a range of the second till the last element, as it doesn’t make much sense to compare the first element with itself.
- If any of the remaining elements in the array is lower than the first, we set it as a minimum.
- As a final step, the lowest value is swapped with the first value (at 0 index).
- The loop continues with j+1 element as a minimum and j+1+1 as the remaining range.
Here’s the presentation (credits to http://www.xybernetics.com):
- Time complexity: O(n2)
Bubble sort is one of the easiest sorting algorithms to implement. The name is derived from the process of sorting based on gradually “bubbling” (or rising) values to their proper location in the array. The bubble sort repeatedly compares adjacent elements of an array as in the following picture:
The first and second elements (4 and 2) are compared and swapped if out of order. Then the second and third elements (4 and 5) are compared and swapped if out of order and so on. The algorithm consists of two loops. In each iteration a single value is set in the right place. This sorting process continues until the last two elements of the array are compared and swapped if out of order (the last iteration doesn’t swap any values).
I’d like to share my thought regarding the developers’ boot camps and help you answer the question: “should I sign up for a coding bootcamp?” from a camper perspective. According to all indications coding boot camps still seem to gain momentum. Though it’s not a new term worldwide, it was not until 2016 when the industry stopped being locally sterile. When new opportunities appeared in Cracow, I was a skeptic at first. I started self-studying by following the freecodecamp front-end path, accompanied by Pluralsight and Udemy video courses. Almost all of these are free or cost next to nothing compared to any boot camp. The price is one of the main no-go factors, but we’ll talk about it in a second.
There are many critical reviews, but most share the four common denominators: high price, the uniqueness of programming, the shallowness of knowledge and the notion that you can learn everything yourself. Let’s have a look at the four horsemen…
Every blog has its first post, this is the one. I’d like to begin with a short introduction. I’m 28, based in Cracow, working full time as a translator and trying to dive into the ocean of programming. The idea of software development has been circling around my mind for several years. Although I gave it a try few times, it yielded no success. I bet started in a similar fashion as many of you, dear readers – looking around and trying to figure out what the hell should I begin with.
Does “Thinking in Java” rings a bell? Few years ago I thought it was a great idea to grab it pair with some online course. The choice fell on “Java for complete beginners” by John Purcell. The knowledge was substantial yet somehow, lacking IT background, I couldn’t wrap my mind around it and… no offence John, I must admit to something. The mix of low tone voice accompanied by a classical intro took stronger effect than a sleeping pill. This phenomena still astonishes me – I started fresh just to feel drowsy after 6 minutes, and after the 12 minute mark I could fall asleep anywhere, anytime, literally.
It all seemed too detached, abstract, illusory and made as little sense as the Python’s death bridge keeper’s question of the airspeed velocity of an unladen swallow (it’s 42 btw). Before I saw any potential real world application, I found myself surrounded by polymorphism, abstract classes and static methods…