Skip to main content

Posts

Showing posts from 2014

How to keep objects when activity is configured

When activity is reconfigured(e.g. rotating the screen), by default whole activity with its objects will be destoyed and recreated, because Android may need alternative resources to match current screen size. Related explanation on developer.android.com site: Caution: Your activity will be destroyed and recreated each time the user rotates the screen. When the screen changes orientation, the system destroys and recreates the foreground activity because the screen configuration has changed and your activity might need to load alternative resources (such as the layout).

Why shouldn't static variables be used as global variables in Android development

For mobile devices with small memories, memory usage and care of applications is essential. If an application uses images, it can easily result a memory leak if they cannot be collected by garbage collector. A reason why GB couldn't collect unused objects is that those objects refers to a static variable. So, if you are setting a property of a local variable with a static one, you need to be double careful.

Pressing ActionBarDrawerToggle doesn't Open Navigation Drawer Menu

I am implementing an application with fragments + main activity.  The extended activity class is android.app.Activity . I have aimed to use ActionBarSherlock to specialize the action bar. So, I have changed the inherited classes of main activity and fragment classes. Old Version: Main Activity -extends- Activity Fragments -extends- Fragment New Version: Main Activity -extends- SherlockFragmentActivity Fragments -extends- SherlockFragment

My First Mobile Game: Bazaar

I have published my first mobile game today. Its name is Bazaar. As may be seen from the name, it has a mediterranean style. Its game music too :) . It is a simple game. But I think it is a good start. Bazaar has basic aspects of knapsack problem. It is that you have a limited size of bag and lots of items. Each item has different size and value. You need to pick items up and fill the basket, such that these items shouldn't space much but value much in contrast. In other words, ratio of should be as high as possible.  As fruits fall down, the user swipes the basket and picks them by following the way explained above. Google Play Services is integrated to it. So, users will be able to compete with other players in the world. They will also be able to gain achievements as they play. Have fun!

Integration of MuPDF Project as a Library into an Android Studio Project

I have needed to use MuPDF library in my android project. After some research, I have seen that there are many integration tutorials but, but integrated projects are developed on Eclipse. For projects on AndroidStudio+Gradle, there is no example. I mean there is no specific example which exactly refers to this issue. So, after achieving my goal, I want to share the steps publicly so that it can be reused by others.

A Way To Monetize Your Kivy Game

While I am building my game, I look for a way to monetize it. This will be my first game, so it is also the first to attempt earning money with an App. I am also not familiar to monetization companies. So, I have done a search to find an appropriate ads network which can be easily integrated with kivy . The first and only company who provides a sdk for kivy is RevMob . I integrated RevMob sdk and tested it. Unfortunately, it doesn't have a good performance and FullScreen Ads crashes. Just links will work. Therefore, RevMob option is not really preferable since ads need to be visually effective. You can also integrate android sdk of any ads network by using pyjnius . In this post, I will show how to use Adbuddiz sdk with kivy.

How to analyse nova logs via logstash

In Elasticsearch family, there is a three that collects, analyses and plots logs, which I found quite beneficial. The three is  Logstash + Elasticsearch + Kibana. Logstash collects logs with various formats and parses them by using a given recipe. then parsed logs are stored into elasticsearch or another selected back-end. After all, using indexes in elasticsearch, Kibana will let you analyse logs in various ways with great visuality. In this post, I will quickly show how to work on openstack-nova logs on an already set up environment.

Change Default Editor in Debian

My favourite editor is vim in Linux. I am very comfortable with it. But when I need to do some come some configuration(e.g. crontab -e ), operating system opens it with default editor which is generally nano . This is annoying to me. Therefore, I generally change default editor with the following very simple step to vim :

Experiment with Python Ceilometer API

I will give a brief and quick introduction to Ceilometer API with python. Just noticed that there is no such example on Internet. Although it is quite easy, I thought that it may be helpful for some. Just create a python file where you store constants. By this way, it will be easy to manage them: OS_USERNAME="admin" OS_PASSWORD="PASS" OS_TENANT_NAME="admin" OS_AUTH_URL="http://controller:5000/v2.0/" CEILOMETER_ENDPOINT="http://controller:8777"

Find max positive product of three integer in an array

In careercup.com, I have seen a problem. It basically asks to get an integer array(includes positives and negatives) and return maximum positive product of three distinct element in it. Sorting is not allowed. For example: arr = [9, 10, -12, 4, 7, -8, -13, 4, -8, 12] elements = (-13, -12, 12) There are two cases: either P1*P2*P3 or N1*N2*P1(Pi stands for ith biggest and Ni stands for ith smalltest number.). So, the algorithm finds 2 elements in the array by partitioning. One is the 2nd smallest  and the other is 3rd biggest number. Then, among biggest 2 element, it finds the maximum. The latest form of array is as follows: N1,N2,...........,P3,P2,P1 It compares N1*N2 ith. P3*P2. It returns elements of bigger one with P1.

Openstack-compute on virtual machine - Unable to create an instance

I have built an openstack(icehouse) platform with three virtual machines; controller, compute and network nodes. I aim to use qemu instead of kvm for virtualization. So I have inserted the following lines into /etc/nova/nova.conf in compute node: [default] compute_driver=libvirt.LibvirtDriver [libvirt] virt_type=qemu But if an instance is tried to be created, it immediately gets into error state: Error: internal error: no supported architecture for os type 'hvm' After some research, I have found the golden information: Qemu hypervisor only supports RAW, QCOW2, VMDK virtual disk formats. Mine is VDI. I have converted the disk image into VMDK format. qemu-img convert input.vdi -O vmdk output.vmdk After running compute-vm on vmdk image, I become able to create an instance without any error.

"dpkg 'ldconfig' not found ..." error on Debian

When I tried to bootsrap a server into Chef, I faced with following error: dpkg: warning: 'ldconfig' not found in PATH or not executable. After a quick research, I found the exact answer. Sudoers file was defected. Following lines were missing: Defaults env_reset Defaults secure_path="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin" After adding these lines into the file, the problem has been solved.

Migration from Proxmox to Openstack

I needed to migrate virtual machines in proxmox to openstack. VMs are in raw format. I needed to take some actions for a succesfull migration. I have perform all actions on Ubuntu 12.04 with virt-manager. qemu-kvm is installed. Here is the list of actions that I took: First, close the machine and copy the image file into your Ubuntu. Convert raw image to qcow2 format: qemu-img convert -O qcow2 image1.raw image1.qcow2 You need the image in qcow2 format for compatibility with openstack platform.  Open the converted image in virt-manager. Before opening, edit disk options. Under ' advanced options ' section, select ' qcow2 ' as ' storage forma t '. Start the virtual machine. You should see the login screen soon. (If you don't set storage format, vm will not find a bootable device. )   If everything is ok so far, close the vm. Take qcow2 image and upload it into glance. It may take time depending on size of it. After this process is completed, open a

Host-only-network error in OS X Mavericks 10.9

After upgrading OS X to latest version (10.9.3), I have faced with a problem that virtual box was not able to create host only networks anymore. This is the error log printed if a host-only-network is tried to be created: Failed to create the host-only network interface. VBoxNetAdpCtl: Error while adding new interface: failed to open /dev/vboxnetctl: No such file or directory. After some research, I saw that this is a virtualbox bug. The reason is that StartupItems no longer exist in Mac OS 10.9 Mavericks. It is depraceated 8 years ago. Until this bug is solved, a temporary solution is: sudo /Library/StartupItems/VirtualBox/VirtualBox stop sudo /Library/StartupItems/VirtualBox/VirtualBox start Then, you can open Virtualbox application. In network tab, all host only networks will be listed. You can also check it via 'ifconfig' command. You can see the related virtualbox ticket on this link .

How to set markerOptions of a chart in primefacess

Primefaces uses jqplot to draw charts, but all configuration options of charts are not provided by primefaces. For example, you have a LineChartSeries object and you will draw it on a LineChartModel . There are only two configuration parameters( style and show ) for marker (this option presents in LineChartSeries class) although there are more in jqplot API. What will you do if you want to set size of a marker? What about the color?

OpenSSL - HeartBleed Vulnerability

Since HeartBleed vulnerability has been announced on April 7, almost all projects have rush to check how much their system is affected by it. Since it is a major vulnerability for OpenSSL, more or less some fallacies in each project exist.  This means that systems and data of their big amount of customers are in danger. That is why all users are waiting for a patch or a new release to avoid any attack related to this bug. What is this vulnerability? What does it cause?

How to install Graylog v0.20.0

There are three major dependencies of graylog: java, mongodb and elasticsearch. Either install openjdk-7-jdk or oracle java-7 (In this guide, oracle-java is installed.): echo "deb http://ppa.launchpad.net/webupd8team/java/ubuntu precise main" | tee -a /etc/apt/sources.list echo "deb-src http://ppa.launchpad.net/webupd8team/java/ubuntu precise main" | tee -a /etc/apt/sources.list apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys EEA14886 apt-get update apt-get install oracle-java7-installer Then, install elasticsearch: wget https://download.elasticsearch.org/elasticsearch/elasticsearch/elasticsearch-0.90.10.deb sudo dpkg -i elasticsearch-0.90.10.deb

How to prevent directory listing in Apache Server

When you type a path in the browser to reach your website, if your files are listed on the screen; you should avoid this behavior. It is obviously very insecure. Disabling directory listing in apache is very easy. You just need to know where to edit. Go to file " /etc/apache2/sites-enabled/000-default ". Open it with your favorite text editor as root user. Go to /var/www directory block. You will see following lines: <Directory /var/www/> Options Indexes FollowSymLinks MultiViews AllowOverride None Order allow,deny allow from all </Directory> In the line which starts with ' Options ', realize ' Indexes ' keywords. It causes directory listing. Remove it. Then, save and quit the file. Restart apache server ( sudo service apache2 restart ). And that's it.

How to handle 'SunCertPathBuilderException: unable to find valid certification path to requested target'

I have set up Atlassian Jira and set e-mail address for it. When I tried to sent test e-mail, I have faced with an error : SunCertPathBuilderException: unable to find valid certification path to requested target . After some search on Internet, I have found the following solution: To retrieve an SSL certificate from remote server, use InstallCert.java . After compiling the file, run the command: java InstallCert mta.xxx.gov.tr:465 . The run will fetch ssl certificate from specified port on the host:

Solve MYSQL Error 1045 (28000): Access denied

Most of mysql users will face with a login error, when they try to login with another user name into mysql db on localhost. I am one of them. Typically, these commands are run: > GRANT ALL ON *.* TO 'fatih'@'%' IDENTIFIED BY 'istanbul'; > quit; Then, we try ' mysql -u fatih -p ' . This ends with an error : ' ERROR 1045 (28000): Access denied for user 'fatih'@'localhost' (using password: YES) '   It doesn't seem reasonable at first look and to figure what is going on out, passwords and grants are usually checked as first action. However, both will not work, because granted from '%' behaves unexpectedly if you try to login a mysql db in your computer. Since localhost is resolved to 127.0.0.1 in /etc/hosts file, mysql interprets the login attempt from user 'fatih' as fatih@localhost which doesn't have permission to authenticate. There are two ways to handle this issue. Specify another ip ad