Custom UIAlertView for iOS apps

You are wondering how to create a custom AlertView for your iOS app, default AlertView is awful and cannot be customized as we might want to.

Even though is very easy to use it, you only need to write this code:

[[[UIAlertView alloc] 
    message:@"This is default UIAlertView" delegate:self 
    cancelButtonTitle:@"Cancel" otherButtonTitles:nil] show];

The result is simple too

UIAlertView default

We’ll what about doing something like this with your UIAlertView



It’s also very easy and you only need to use pods, add this line to your pod file:

    pod "TAlertView"

Run “pod install” and you’re good to go.  Start playing with TAlertView adding this simple line:

[[[TAlertView alloc] 
    initWithTitle:@"Great!" andMessage:@"This is a basic alert"] 


On Github:

Mysql crash problems on EC2 AWS micro instance

If you have the default mysql config probably you’ll have some crash problems after a while running the instance.

I’m running a micro instance, with Ubuntu 12.04 and default mysql installation.

I’ve this logs reports:

[Note] Plugin 'FEDERATED' is disabled.
InnoDB: The InnoDB memory heap is disabled
InnoDB: Mutexes and rw_locks use GCC atomic builtins
InnoDB: Compressed tables use zlib 1.2.7
InnoDB: Using Linux native AIO
InnoDB: Initializing buffer pool, size = 128.0M
InnoDB: mmap(137363456 bytes) failed; errno 12
InnoDB: Completed initialization of buffer pool
InnoDB: Fatal error: cannot allocate memory for the buffer pool
[ERROR] Plugin 'InnoDB' init function returned error.
[ERROR] Plugin 'InnoDB' registration as a STORAGE ENGINE failed.
[ERROR] Unknown/unsupported storage engine: InnoDB
[ERROR] Aborting

[Note] /usr/sbin/mysqld: Shutdown complete


To solve it you need to add some lines on the /etc/mysql/my.cnf file after the [mysql] line:

innodb_buffer_pool_size = 40M

Also it’s recommended to run a repair table on each of your databases after changing the mysql settings and restart the mysqld service.

Git keep asking for my username and password on GitHub

If you’re experiencing this problem maybe you’ve made the checkout with the http or https url, that means that you dont have an authentication method.

For linux or Mac you can solve it with a simple way.


    git config --global credential.helper osxkeychain


    git config credential.helper cache

Reference for cache options on this link

If you’re on windows and you’re trying to use cache the cache helper you might have the next message:

    git: 'credential-cache' is not a git command. See 'git --help'.

So in that case you need to setup the ssh connection and change your remote protocol connection from http to ssh. To do that you need run:

    git remote set-url origin

You also need to setup your ssl-key you can do it from the GitHub config . If you don’t know how to generate ssh keys just follow these steps .

How to use Dropbox as a GIT repository

Don’t you ever setup another version control server, Mercurial, SVN, CVS, or any other you may know.

What is GIT?

“In software development, Git /ɡɪt/ is a distributed version control and source code management (SCM) system with an emphasis on speed. Initially designed and developed by Linus Torvalds for Linux kernel development, Git has since been adopted by many other projects.”

Git on Wikipedia

What is Dropbox

“Dropbox is a file hosting service operated by Dropbox, Inc., that offers cloud storage, file synchronization, and client software. Dropbox allows users to create a special folder on each of their computers, which Dropbox then synchronizes so that it appears to be the same folder (with the same contents) regardless of which computer is used to view it. Files placed in this folder also are accessible through a website and mobile phone applications.”

Dropbox on Wikipedia

How to setup a GIT repo into your Dropbox account

Of course most of you already know what is GIT or Dropbox, so let’s start with the cool part of the post. Obiously you need to have Drobox and GIT installed on you PC or laptop.

1. First you need to create an empty folder on your Dropbox.

:~$ cd Dropbox
:Dropbox$ mkdir project_name

2. Init the remote folder into your local Dropbox

:Dropbox$ cd project_name/
:project_name$ git init --bare
Initialized empty Git repository in /Users/zantez/Dropbox/project_name/

Perform an ls command and you’ll see some folders

[BARE:master]:project_name$ ls
HEAD config description hooks info objects refs

3. Now lets clone the current GIT repository to a destination on your PC or laptop

:git$ git clone ~/Dropbox/project_name project_name_local
Cloning into 'project_name_local'...
warning: You appear to have cloned an empty repository.
:git$ cd project_name_local/ [master]:project_name_local$

4. Let’s perform an initial commit and push it into the origin

[master]:project_name_local$ ls test.txt
[master]:project_name_local$ git add -A
[master]:project_name_local$ git ci -m "initial commit"
[master (root-commit) 6916e97] initial commit 1 file changed, 0 insertions(+), 0 deletions(-) create mode
    100644 test.txt
[master]:project_name_local$ git push origin master Counting objects: 3, done.
Writing objects: 100% (3/3),
219 bytes, done. Total 3 (delta 0), reused 0 (delta 0)
To /Users/zantez/Dropbox/project_name * [new branch] master -> master

Now you’re all set, start working on your GIT project ;)


or maybe you need to….

Clone your local GIT repo into your Dropbox account

Thanks to @httpdss for this contribution.

Go to your dropbox folder and clone your local repo with the –bare option

git clone --bare ~/local_repo local_repo.git

Go to your local_repo folder and add dropbox git repo you’ve just cloned as a remote

git remote add dropbox ~/Dropbox/git/woow/sooprise_site.git

It’s done! but remember to push your local changes into dropbox remote.

git push dropbox master


How to create infinite scroll with ajax on jQuery

Nowadays almost every page with dynamic news use infinite scroll, Twitter, Facebook and Pinterest are the main references for this.

It’s very practical when you have unstructured information, timed and loaded dynamically. Gives the sensation to the user that the information never ends, but also you can have some troubles if the user wants to have indented information, so be careful not always is the best choice for your user experience.

You can use some jQuery plugins, like paulrish / infinite scroll plugin ( ) or jScroll ( ). If you are those who want to do it themselves, just follow these steps to start from scratch your own jQuery infinite scroll piece of work.

If you want to make it yourself here you’ve a starting point, create a function to check if the last element of your list is on the current scroll position:

function element_in_scroll(elem)
    var docViewTop = $(window).scrollTop();
    var docViewBottom = docViewTop + $(window).height();

    var elemTop = $(elem).offset().top;
    var elemBottom = elemTop + $(elem).height();

    return ((elemBottom <= docViewBottom) && (elemTop >= docViewTop));

Now we need to setup the scroll event ( ) and check if the element we want to trigger the ajax request is visible to the user:


Inside of this event, call the element_in_scroll function and use the selector ( ) you want, in this case I’m using an html table

<table class="errors">
            <td><span class="label label-error" >ERROR</span></td>
            <td class="collapse"><span class="label label-warning" >Warning</span></td>
            <td class="collapse">example error</td>
            <td class="date collapse">2013-05-26 23:54:19</td>

So for this html you need to use this jQuery selector:

	if (element_in_scroll(".errors tbody tr:last")) {
			//Here you must do what you need to achieve the infinite scroll effect...

I’ve used an ajax request to perform the infinite scroll completion, here’s the complete scroll event call with the ajax request:

	if (element_in_scroll(".errors tbody tr:last")) {
				type: "POST",
				url: document.location.href,
				data: { text_filter:  $('#text_filter').attr('value'), index_count:$('#index_count').attr('value'),json: "true" }
			}).done(function( msg ) {
				$(".errors tbody ").append(msg.html);
				if (msg.count != 0) {
						//callback to the method to check if the user scrolled to the last element of your list/feed 

The data attributes are the references to know what page is needed, you can also use a timestamp depending on how are you saving your information. When msg.count is equal to zero, the scroll event is disabled.

Related links:

How to backup MySQL in diferent formats

The best way to have mysql backed up in different formats is to use PhpMyAdmin, you need to go to a database and the tab Export.

You can setup a Quick backup in different formats such as:

  • CodeGen
  • CSV
  • CSV for Excel
  • Microsoft Word 2000
  • JSON
  • Latex
  • MediaWiki Table
  • Open Document Spreadsheet
  • Open Document Text
  • PDF
  • PHP Array
  • SQL
  • Texty! text
  • XML
  • YAML

The best way to backup and be sure you can restore it fully functional is to use SQL backup, also you can backup your store procedures, trigger, useras and any other particular configuration of the database.


Screenshot for PhpMyAdmin:

13 09_51

Simple PHP Code Igniter class to show the error log

Sometimes we need to acces the php log, but is not available on the document root, so yo need to access by console or create a symlink to some part inside the public folder of your website. Also you need to add some credentials in order to protect your logs. This is a simple and safer way to access your php error log, you can add this controller inside your protected controllers using the php session or maybe a cookie generated by you with some encrypted data.

So here is the controller class to show the php log really easy for code igniter.

 * Php Log class
 * Display the php log
 * @category	Log
 * @author		Nicolás Bistolfi
 * @link
class Log extends Controller{

	private $logPath; //path to the php log
	*	Class constructor
	function __construct(){
		$this->logPath = ini_get('error_log');

	 * index: Shows the php error log
	 * @access public
	public function index(){
		if (@is_file($this->logPath)) {
			echo nl2br(@file_get_contents($this->logPath));
		} else {
			echo 'The log cannot be found in the specified route '.$this->logPath;

	 * delete: Deletes the php error log
	 * @access public
	public function delete(){
		if (@is_file($this->logPath)) {
			if (@unlink($this->logPath)) {
				echo 'PHP Error Log deleted';
			} else {
				echo 'There has been an error trying to delete the PHP Error log '.$this->logPath;
		} else {
			echo 'The log cannot be found in the specified route  '.$this->logPath.'.';


You can download the code by clicking here

How to backup MySQL database from the command line

Backup your MySQL database to an sql file with your command line. Using native mysql client and tools you can perform all the backup and restore operations you need.

First you need to have installed the command line tools, in this case mysqldump.

$ mysqldump --opt -u [uname] -p [dbname] > [backupfile.sql]
  • [uname] Your database username
  • [pass] The password for your database (note there is no space between -p and the password)
  • [dbname] The name of your database
  • [backupfile.sql] The filename for your database backup
  • [–opt] The mysqldump option

Example if you have a database called wordpress_blog you only have to do this:

$ mysqldump --opt -u root -p wordpress_blog > wordpress_blog_bk.sql

If you want to backup all the databases in only one sql file you can use –all-databases option

$ mysqldump -u root -p --all-databases > alldb_backup.sql