Programming and Exciting Things

Use forked git projects in composer

Published on 27.04.2015

Problem:
We want to use your fixed version before project owner accept your pull request.
Solution:
Open your

composer.json
file and in "repositories" array add:
  "repositories" : [ {
    "type" : "git",
    "url" : "https://github.com/yuksbg/guzzle"
  } ]
after that go to "require" section and use your branch/version like this:
  "require" : {
    "guzzlehttp/guzzle" : "dev-bugfix"
  },
Remember: Do not change original user in require section.
After that just
 composer update
and tada :) You will use your fork.

RabbitMQ & docker

Published on 24.04.2015

I just publish Dockerfile for RabbitMQ which use Ubuntu 14.04 as base image
Usage and details can be viewed at https://bitbucket.org/yuks/rabbitmmq

Android swipe/pull to refresh

Published on 08.03.2015

In this post I will describe how to use SwipeRefreshLayout which is part from support library too.
Using this new layout is pretty easy and this is a standard way to implement common Pull to refresh pattern.
We must know: SwipeRefreshLayout is a ViewGroup layout which can hold only one scrollable view as children.
Example layout file with Swipe Refresh

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:card="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <android.support.v4.widget.SwipeRefreshLayout
        android:id="@+id/swipe"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent" >

        <ScrollView
            android:layout_width="match_parent"
            android:layout_height="match_parent">
			
		
			..............................................
	
	
		</ScrollView>
    </android.support.v4.widget.SwipeRefreshLayout>
</RelativeLayout>

We can set OnRefreshListener to listen when user wants to refresh content
mSwipeLayout = (SwipeRefreshLayout) view.findViewById(R.id.swipe);

mSwipeLayout.setOnRefreshListener( new SwipeRefreshLayout.OnRefreshListener() {
            @Override
            public void onRefresh() {
				System.out.println("Updated");
				mSwipeLayout.setRefreshing(false);
			}
        });

If we want we can use it to display refreshing content before user iteract. For this we can use setRefreshing method
        mSwipeLayout = (SwipeRefreshLayout) view.findViewById(R.id.swipe);
        mSwipeLayout.post(new Runnable() {
            @Override
            public void run() {
                mSwipeLayout.setRefreshing(true);
            }
        });

Replace ubuntu default apt urls with Digital ocean mirros

Published on 24.02.2015

I'm using DigitalOcean for my VPS's, they provide local mirror for ubuntu.
With this simple command we can replace default ubuntu apt urls with their mirror. It's usefull for docker images.

sudo sed -i "s/archive\.ubuntu/mirrors.digitalocean/g" /etc/apt/sources.list

Installation of Docker on Ubuntu 14.04

Published on 24.02.2015

According to documentation installation process of docker on Ubuntu/Debian based OS's is pretty easy. We can install it with apt-get:

sudo apt-get update && apt-get install docker.io

After that we can just pull some image from repo and play with it. For example
docker pull ubuntu
or if you want only last ubuntu version
docker pull ubuntu:14.04
We can check downloaded images with
docker images
Result will be like:
root@atom:~# docker images
REPOSITORY          TAG                 IMAGE ID            CREATED             VIRTUAL SIZE
ubuntu              14.04               2d24f826cb16        3 days ago          188.3 MB
And after that we can create some ubuntu container with
docker run -i -t ubuntu /bin/bash