Programming and Exciting Things

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

Use rsync on non standart port

Published on 21.01.2015

I want to get out from my current hosting provider - Superhosting servers but I'm super lazy and instead of making tar.gz / zip archives and moving them via wget for example I prefer to use rsync. Everything is good until I realize that Superhosting is using non standard SSH port, fortunately I can still using rsync with setting "-e" parameter

rsync -avz -e "ssh -p 1022" user@server.net:~/www/ /tmp/copy
This will copy all content from account www directory to /tmp/copy on new machine.