VMWare Workstation start on boot CentOS

FFMPEG CentOS 7 installation instructions

FFMPEG CentOS 7 installation instructions


  1. install the atrpms repository
  2. Install ffmpeg


install the atrpms repository

Add the GPG-Key using:

rpm –import http://packages.atrpms.net/RPM-GPG-KEY.atrpms

and then create a file name atrpms.repo inside /etc/yum.repos.d and fill it with:

name=Fedora Core $releasever – $basearch – ATrpms

FFMPEG CentOS 7 – Install ffmpeg

Now, run:

yum install ffmpeg

And you have ffmpeg installed on your CentOS 7.0 machine.

That’s it.


Apache Kafka logo

Kafka CentOS Installation Instructions

Kafka CentOS Installation Instructions

If you’re here, you’re probably knows what `Kafka` is and what it should be used for.

If not, visit Apache Kafka page to learn more


  • wget (yum install wget)
  • tar (yum install tar)


First thing, lets go over to Kafka Download page to download kafka into our machine:

# choose a directory to download kafka into. it could be really anywhere:
# /home, /var, /usr, /opt or even /tmp if you just wanna play with it.
cd /opt
wget http://apache.mivzakim.net/kafka/
tar -zxvf kafka_2.10-
rm kafka_2.10- -y
cd kafka_2.10-

Well.. and that’s preety it. you have Kafka CentOS installation on your machine. Now, lets play with it a little:

Start quick-and-dirty server

from Kafka QuickStart:

Kafka uses ZooKeeper so you need to first start a ZooKeeper server if you don’t already have one. You can use the convenience script packaged with kafka to get a quick-and-dirty single-node ZooKeeper instance.

so just run now at your console:

bin/zookeeper-server-start.sh config/zookeeper.properties

after, you’ll see the BEAUTIFUL output telling you everything is fine and zookeeper is running on

Kafka CentOS

Kafka CentOS

Now, we’re gonna be more dirtier and just for now, we’ll move the zookeeper server into background so we could start the kafka server. This can be done by pressing: CTRL+Z which outputs:

[1]+ Stopped bin/zookeeper-server-start.sh config/zookeeper.properties

Then run the command:

> [1]+ bin/zookeeper-server-start.sh config/zookeeper.properties &

# you can check that zookeeper is running at background by use the jobs command:
> [1]+ Running bin/zookeeper-server-start.sh config/zookeeper.properties &

Now start the Kafka server:

bin/kafka-server-start.sh config/server.properties

And look as the PRETTY lines are printing and loading your Kafka server instance.



FATAL Fatal error during KafkaServerStartable startup. Prepare to shutdown (kafka.server.KafkaServerStartable)

If you get this error, you need to add your hostname to /etc/hosts: localhost myhostname


What’s now?

That’s it, you have Kafka CentOS installation! Go from STEP 3 in the quickstart to learn the basics of Kafka..


Good Luck!

VMWare Workstation start on boot CentOS

EPEL CentOS 7 – Add Fedora EPEL repository


EPEL CentOS 7 – In the next tutorial I will show you how to add the fedora EPEL repository to your CentOS 7 installation


Applicable to

  • Centos 7.x, but also to CentOS 6.x (and probably earlier)



In order to install CentOS EPEL Repository you need:

  • root access
  • wget:
yum install wget -y



check here for latest version of epel-release-x-x.noarch.rpm

wget http://mirror.nonstop.co.il/epel/7/x86_64/e/epel-release-7-5.noarch.rpm
rpm -Uvh epel-release-7-5.noarch.rpm
rm epel-release-7-5.noarch.rpm -f

or in short:

rpm -Uvh http://mirror.nonstop.co.il/epel/7/x86_64/e/epel-release-7-5.noarch.rpm



yum repolist

to check that the repo installed correctly.


That’s it! You’ve added CentOS EPEL repository to your centos installation.


How to use?

yum --enablerepo=epel install [package]

for example:

yum --enablerepo=epel install zabbix

Note: The epel configuration file is located under /etc/yum.repos.d/epel.repo.


That’s it

VMWare Workstation start on boot CentOS

CentOS Automatic Updates

CentOS Automatic Updates

CentOS Automatic Updates tutorial.

This tutorial apply to Centos 5.x, 6.x and 7.x.


CentOS 5.x

The yum package supplied with CentOS 5.0 includes scripts to perform full system updates every day. To activate automatic daily updates, enter this command:

su -c '/sbin/chkconfig --level 345 yum on; /sbin/service yum start'

At the prompt, enter the password for the root account.

There is no separate yum service that runs on your system. The command given above enables the control script /etc/rc.d/init.d/yum. This control script activates the script /etc/cron.daily/yum.cron, which causes the cron service to perform the system update automatically at 4am each day.

CentOS 6.x

To get started, install yum-cron:

yum -y install yum-cron

By default, it’s configured to download all of the available updates and apply them immediately after downloading. Reports will be emailed to the root user on the system. To change these settings, just open /etc/sysconfig/yum-cron in your favorite text editor and adjust wherever setting you need to change:

The important settings to mention are:

# Don't install, just check (valid: yes|no)

# Don't install, just check and download (valid: yes|no)
# Implies CHECK_ONLY=yes (gotta check first to see what to download)

# if MAILTO is set and the mail command is available, the mail command is used to deliver yum output
# by default MAILTO is unset, so crond mails the output by itself
# example: MAILTO=root

# you may set DAYS_OF_WEEK to the days of the week you want to run
# default is every day

If you want to exclude some packages only from the automatic update you can edit the file /etc/sysconfig/yum-cron and set the option YUM_PARAMETER with -x packagename, you have to repeat the -x for every package that you want to exclude, such as:

YUM_PARAMETER="-x kernel* -x php*"

The cron jobs from the yum-cron package are active immediately after installing the package and there’s no extra configuration necessary. The job will be run when your normal daily cron jobs are set to run.

chkconig yum-cron on
service yum-cron start

CentOS 7.x

Although CentOS 6.x Instructions will work for CentOS 7.0, you could upgrade the installation process to be completely CentOS 7.0 compatible:

yum install yum-cron
systemctl enable yum-cron.service
systemctl start yum-cron.service

.conf file (Configuration) located at: /etc/yum/yum-cron.conf AND /etc/yum/yum-cron-hourly.conf.

Note that in contrast to CentOS 6.x, by default yum-cron only download updates once a day and doesn’t apply them. change to:

apply_updates = yes

In /etc/yum/yum-cron.conf if you wish to. make note that you can now define hourly updates in the /etc/yum/yum-cron-hourly.conf file.

That’s it.

VMWare Workstation start on boot CentOS

CentOS 7 VirtualBox Guest Additions Installation

CentOS 7 VirtualBox Guest Additions Installation Tutorial

In the following tutorial, I’ll demonstrate how to install Guest Additions on your VirtualBox hosted CentOS 7 Minimal machine.

Although this tutorial is intended for CentOS 7 minimal, it’s will probably also work on other CentOS releases.

Update your VirtualBox

VirtualBox 4.3.12 or later is required for support in CentOS 7.x, So if you’re using older version of VirtualBox – it’s time for you to upgrade.

Update and Reboot system

After successful installation of your new and shining CentOS box, CentOS-7-installation-VirtualBox

Important Before anything!, I’d advice you to update your CentOS & reboot:

yum update

After, also try to update your kernel and reboot:

yum update kernel

You will need to be the root user for the following routine or “su -”


In order to compile the guest additions you have to install make, gcc, kernel-devel in order to Install VirtualBox Guest Additions installation script.

yum install gcc make kernel-devel

OR, I’ll recommend installing the entire “Developer tools” group which will help you to avoid a lot of trouble later:

yum groupinstall "Development tools"
yum install kernel-devel

Install VirtualBox Guest Additions

Mount your guest additions:


Type at command::

cd /mnt
mkdir cdrom && mount /dev/cdrom /mnt/cdrom
cd cdrom && ./VBoxLinuxAdditions.run


If everything “OK” – You have Guest Additions properly installed on your Centos (Minimal) machine. now Reboot:



That’s it!



Change BlueStacks App Player Resolution


BlueStacks App Player for Windows is a great Android emulator that supports most of the common apps and games from Google Play.
In this tutorial I will show you how to Change BlueStacks App Player Resolution in Windows.

Download and Install BlueStacks App Player

  1. Go to http://www.bluestacks.com/ and download BlueStacks App Player
  2. Open BlueStacks App Player and register your GMail Account details
  3. Close BlueStacks

Change BlueStacks App Player Resolution

There are several values ‘GuestHeight/GuestWidth’, and ‘WindowHeight/WindowWidth’.
The ‘Guest’ values sets the Androids resolution and the ‘Window’ values sets the window resolution.

  1. Open ‘regedit’: Start->Run->regedit
  2. Navigate to: ‘HKEY_LOCAL_MACHINE/SOFTWARE/BlueStacks/Guests/Android/FrameBuffer/0/’
  3. Double click the value ‘GuestHeight’
  4. Change Base to Decimal
  5. Input your desired Height resolution
  6. Double click the value ‘GuestWidth’
  7. Change Base to Decimal
  8. Input your desired Height resolution

Repeat the process for the ‘WindowHeight’ and ‘WindowWidth’ values.
Change BlueStacks App Player Resolution



Template engine – Why it’s better to use two of them at once?

Template engine

In the following post I’ll try to show and explain how and why I am using two template engines in every application I’m working on. Also, why and how I am choosing my template engine(s) I’m working with.


Intro (about me)

Developing in: .NET / Python / Java / Go / PHP and more,

  • New exciting and better tools are important to me!
  • Performance (server & client) are very important to me!
  • The ability to arrange and split the code smartly exact as I want is very important to me!
  • The ability to comment as I like inside the code and the client not to receive it is very important to me! (especially in web HTML/JS)

Who using Template engine

Probably every web developer is using a template engine. You can find it as integral part of most decent modern web development frameworks and environments. Many exist standalone and not as part of any framework. although, Templates Engines are not sole exist for Web development and are used in large variety of tasks. This post is dedicated to web development Template Engines which are called specifically – “Web Template System”

If you’re a web developer and you don’t know or use any Template Engine: You better run some self-tests(!). If you don’t know what is template engine and how to use it, you better read before you continue…

Note about PHP. as I call PHP a bad language but a great Template engine by itself, so in many cases Template engine doesn’t needed or not used (although there are many PHP templates engines).


So, Why one template engine? Why not 2?

All configurations of template engine I saw are using one template engine per application. The scenario is simple; The web developer creates a template for an HTML page.. process it on the server and send the results to the browser. for example:


In the above example, the server will fill the $title variable as needed and result with the following to the client:

   <title>Using My Template Engine</title>


Now.. for my suggestion.

I’ve changed the way I am using template engine in my development. I am using two separate template engines in the app. One for creating minified html files with embedded JS and CSS, the other for filling the variables and send to the client.

I call the first TE(Template Engine) – The ‘First layer’, and second ‘Second layer’.


Example of 2-Layers-TE

Maybe It’s the best to show an example of how I am using my Templates engines together.

In this example I am rendering at first HTML using Tenjin (Python) and the second template engine as the web server is the basic Golang Template engine.

First Template Engine

<!-- all comments will be removed at the minify process -->
   <style><?py include('index.css') ?></style>
   <script type="text/javascript"><?py include('index.js') ?></script>
   <title>{{ .Title }}</title>

In the above example with Tenjin, you can see it includes two files: index.css and index.js which I I’ll show below. Also note the {{ .Title }} annotation which is NOT tenjin syntax but it’s golang template engine syntax, which means the first template engine (Tenjin) will just output this into the final html result.

The Styles are saved in another file (index.css):

// All comments will be removed at the minify process
body { background-color: blue }

Actually, I am using SCSS (SASS) for my CSS development, and then I compile and minify them (in the same script as part of the whole website compile) into index.min.css file. then, the above Tenjin imports index.min.css and not index.css. Also, I’m adding one more global.css which is embedded into all htmls.

And the JS are saved in another file (index.js):

$(function () {
 // also, those comments will be removed on minify

As with the CSS, sometimes I use CoffeeScript or IcedCoffeeScript and then compile it into JS.
Also, as part of the compile process, I am minifying the JS to index.min.js and Tenjin imports the minified file and not the source. If I use JS (and not CS or ICS) I minifyjs it before too, and in the process doing a syntax check.

Then, Using script I made – I minify all the templates (with inline CSS and JS) onto:

<html><head><style>body{background-color:blue}</style><script type="text/javascript">$(function(){});</script><title>{{ .Title }}</title></head><body></body></html>

You can see that the {{ .Title }}, which is Golang template engine syntax is still here. The first template engine (which in our case is Tenjin) isn’t processing the variables and just minify them with everything else.

Now, its ready to use from the Golang environment Template Engine. comment-less, minified and as one document, even if it’s built from 10 CSS files, 10 JS files and hierarchical templating.

In this way the actual logic designing of the hierarchy of the templates are done in the first layer and the second layer is only responsible to fill in the variables and pass to the client.

How I choose the templates engines?

The equation I use is simple:

FOR THE FIRST LAYER I use for the strongest template engine I can find. I like features like inheritance, raw, import, widgets …… ! I need everything! Performance isn’t needed at all at the first layer. It’s compiled after work has done in the code and then that’s it!. I want to be able to arrange my website htmls into preety smart structure. To split the JS files into many logic files… same with CSS. After it will be rendered for the second layer it will be fully minified as one document. then the performance matters…

FOR THE SECOND LAYER I use the fastest template engine I can find. Caching of templates is a must feature! Here the performance matters!. The template engine could be Logic-Free or not, It’s design decision, but no need here for hierarchy or any other expert feature in the TE as it using the full minified htmls. only to read the html from file into memory and then fill it now and then with data and pass to client.

REMEMBER You need to choose two TE with different syntax(!). You can’t use two of them that has the same snytax (like {{ var }}). Tenjing is using <% %> and Golang is using {{ }}.

If you’ll later use client side TE you better take that into account. AngularJS is using {{}}. Angular Syntax must be changed or another TE must be chosen for the second layer.


So, Why it’s good for?

So, Why I am doing this complex structure? Those are the advantages of this method:

  • Performance – Golang caches into memory the minified html with css, js embedded. it’s better for server side and for client side performance!!. It’s PRO! and minification doesn’t need to be done in real time!
  • You can create a complex inheritance for your files in the first layer WHILE you preserve performance in the second layer. You get to write and split code (html, css and js) in many files as you like. you know it will be all be merged and minified later….
  • You can put comments wherever you want freely!! (in the html as well as in the css/js) and they will be removed later by the minify process.
  • You can use Placeholders as usual in the webserver template engine (second layer), as well in the first layer.  application name, for example will be suited for the first layer as It doesn’t supposed to be changed but user name can be filled as usually in the second layer.
  • JS files are verified in the process!!. you will know about bad syntax before you’ll even open the browser!
  • If you use SASS you’ll find it’s so sweet… at last! you can manage your CSS as you’ve always dreamed of!


I made an example @ Github (https://github.com/ET-CS/2TE). I used Cheetah(Python) as the first layer, as it have lot more features then Tenjin, and I’ve used Golang as the webserver (second layer). although Golang is not the fastest TE I know, it’s fast enough and I really like Golang as a web server.

I made another example @ https://github.com/ET-CS/2TE-Bootstrap which is essentially the same idea as 2TE, but it is ready packed with Bootstrap HTML on either Jinja2 or Cheetah as the First layer. Great boilerplate for amazing fast web application!!


Always think performance…… and always MInified is better!!!


Android Context in non-activity Class – The Secret of ContextWrapper

Android Context in non-activity Class – The Secret of ContextWrapper

Android Context in non-activity Class

One of most frustrating issues I had to figure out when I’ve started to develop for Android was the Context.

Why there are several kind of Context? and more important – How can I call to system API method from a Class when all the important functions are available only from a Context class??

The problem

Let’s take this function inside activity for example (test for AirPlane Mode),
Where isAirPlaneModeOn() is using the getContentResolver() which is Context.method:

public class MyActivity extends Activity {
   public boolean isAirplaneModeOn() {
      return Settings.System.getInt(getContentResolver(),
         Settings.System.AIRPLANE_MODE_ON, 0) != 0;

Or inside a service:

public class MyService extends Service {
   public boolean isAirplaneModeOn() {
      return Settings.System.getInt(getContentResolver(),
         Settings.System.AIRPLANE_MODE_ON, 0) != 0;

P.S: The isAirplaneModeOn() function is using depreceated method (pre API 17) just for the purpose of simple example and backward compatibility.

Now… lets say you want to create some other class, and move the function to that class:

import android.provider.Settings;

public class MyOtherClass {
   public boolean isAirplaneModeOn() {
      return Settings.System.getInt(<span style="text-decoration: underline;">getContentResolver</span>(),
         Settings.System.AIRPLANE_MODE_ON, 0) != 0;

HEY?!!? Why Eclipse telling me: The method getContentResolver() is undefined for the type MyOtherClass

????? ….. Because getContentResolver() is a context method – Soon you realize you must have access to Context.. so What the solution?


Some solutions

I’ve read a lot about context(s). Maybe, most of the valuable stuff out there in the internet…

Some are saying to pass the context to the class and save a reference to that context like:

class YourNonContextClass {
   private Context context;

   public YourNonContextClass(Context context){

   public boolean isAirplaneModeOn() {
      return Settings.System.getInt(context.getContentResolver(),
         Settings.System.AIRPLANE_MODE_ON, 0) != 0;

Some are saying to pass the context to your static function like:

public class MyOtherClass { 
   public static boolean isAirplaneModeOn(Context context) {
      return Settings.System.getInt(context.getContentResolver(),
         Settings.System.AIRPLANE_MODE_ON, 0) != 0;

Both solutions works. Both have their Pros and Cons. both require you to alter the code inside the function.


Solution – The Secret of ContextWrapper

Finally … After a fashion… With lot of experimentation, I’ve found a great solution that I really like! :


So What is ContextWrapper?

Proxying implementation of Context that simply delegates all of its calls to another Context. Can be subclassed to modify behavior without changing the original Context.

In other simple words: It’s a class that inherits another Context.


So, How to use the ContextWrapper?

Let’s talk about the function we discussed above and create a ContextWrapper class for it:

public class MyContextWrapper extends ContextWrapper {

    public MyContextWrapper(Context base) {

   public boolean isAirplaneModeOn() {
      return Settings.System.getInt(getContentResolver(),
         Settings.System.AIRPLANE_MODE_ON, 0) != 0;

Note that nothing need to be changed in the isAirplaneModeOn() function as the class itself inherits the wrapper you’ve called from (Activity, Service, IntentService, etc).

To call the function just use:

boolean isAir = (new MyContextWrapper(this)).isAirplaneModeOn();

Where ‘this’ could be any context you’d like to. applicationContext, Service or Activity.


That’s it.  Easy haa!

And choose what fits you best…



Android Get Mobile IP Address code example

Android Get Mobile IP Address

Android Get Mobile IP Address Code Example

Android Get Mobile IP Address :

Getting the android IP address for Wi-Fi connection using the API is very simple:

 * Get the IP of current Wi-Fi connection
 * @return IP as string
private String getIP() {
 try {
   WifiManager wifiManager = (WifiManager) getSystemService(WIFI_SERVICE);
   WifiInfo wifiInfo = wifiManager.getConnectionInfo();
   int ipAddress = wifiInfo.getIpAddress();
   return String.format(Locale.getDefault(), "%d.%d.%d.%d",
   (ipAddress & 0xff), (ipAddress >> 8 & 0xff),
   (ipAddress >> 16 & 0xff), (ipAddress >> 24 & 0xff));
 } catch (Exception ex) {
   Log.e(TAG, ex.getMessage());
   return null;

But what if you need to get the Mobile connection IP?

The answer is to check the NetWorkInterface like this:

/** Get IP For mobile */
public static String getMobileIP() {
  try {
    for (Enumeration<NetworkInterface> en = NetworkInterface
    .getNetworkInterfaces(); en.hasMoreElements();) {
       NetworkInterface intf = (NetworkInterface) en.nextElement();
       for (Enumeration<InetAddress> enumIpAddr = intf
          .getInetAddresses(); enumIpAddr.hasMoreElements();) {
          InetAddress inetAddress = enumIpAddr.nextElement();
          if (!inetAddress.isLoopbackAddress()) {
             String ipaddress = inetAddress .getHostAddress().toString();
             return ipaddress;
  } catch (SocketException ex) {
     Log.e(TAG, "Exception in Get IP Address: " + ex.toString());
  return null;

And if you want to get the IP as IPV4 just replace the line:

          if (!inetAddress.isLoopbackAddress()) {


 if (!inetAddress.isLoopbackAddress() && InetAddressUtils.isIPv4Address(inetAddress.getHostAddress())) {

Optimize BlueStacks App Player for Windows


BlueStacks App Player for Windows is a great Android emulator that supports most of the common games on Google Play.
In this tutorial I will give you a few tips how to optimize BlueStacks App Player for Windows.

Download and Install BlueStacks App Player

  1. Go to http://www.bluestacks.com/ and download BlueStacks App Player
  2. Open BlueStacks App Player and register your GMail Account details
  3. Close BlueStacks

Adjust BlueStacks RAM (Memory)

BlueStacks App Player comes with a default of 768MB RAM.

  1. Open ‘regedit’: Start->Run->regedit
  2. Navigate to: ‘HKEY_LOCAL_MACHINE/SOFTWARE/BlueStacks/Guests/Android’
  3. Double click the value ‘Memory’
  4. Change Base to Decimal
  5. Input your desired RAM amount
    For example: If you have 4GB of RAM input 2GB: ‘2048’
  6. optimize BlueStacks RAM

Flickering Issue with NVidia Display Adapter

Sometimes with NVidia GPUs there is an issue that causes the screen to flicker.

  1. Open NVidia Control Panel and navigate to ‘Manage 3D Settings’
  2. Select tab ‘Program Settings’
  3. Click Add and Select ‘BlueStacks Frontend’
  4. Scroll down to ‘Threaded optimization’ and change it to ‘Off’
  5. optimize BlueStacks NVidia GPU

BlueStacks Process priority

Increase BlueStacks Process priorities in Task Manager:

  1. Open Task Manager and go to Details tab
  2. Right-Click ‘HD-Frontend’ and change priority to Above-Normal
  3. optimize BlueStacks NVidia CPU