Uncategorized

Updating Android SDK

Recently I am facing a problem when I create an Android application with Cordova platform. It happend when I execute $ cordova platform add android. The error line showing like this;

at /home/admin/.cordova/lib/android/cordova/3.3.0/bin/lib/check_reqs.js:87:29

This error message clear to me because when I opened check_reqs.js file, I found an information what I must do. Yeah, updating Android SDK or configuring Android SDK Path. But on this post, I will show you how to update The Android SDK;


$ cd android-sdk-linux/tools
$ ./android update sdk --no-ui

For further discussion, take a look at this

Advertisements

Laravel 4.x setting in production and development

Surely, in production use you don’t want to show any error to the user. In simple way, you can set debug to false:
/app/config/app.php

return array (

'debug' => false,

[...]

)

For complete setting for development and production, you can try;
/app/bootstrap/start.php

$env = $app->detectEnvironment(array(
	'local' => array('localURL.com'),
	'production' => array('productionURL.com')
));

Define your file/folder configuration for every situation (development/production):

app
app/config
app/config/local
app/config/local/app.php
app/config/local/database.php
app/config/production
app/config/production/app.php
app/config/production/database.php

Easiest way to write library in Laravel

Sometimes you have change a lot in your Laravel configuration and folder. This will avoiding running composer again.

First, just open your /app/start/global.php. Add a folder libraries (whatever you want):

app_path().'/commands',
app_path().'/controllers',
app_path().'/models',
app_path().'/database/seeds',
app_path().'/libraries',

And now you can add any file in your libraries folder.

Example:

<?php

/* File: Bantu.php */

class Bantu {

    public static function write( $message ) {

        echo $message;

    }

}

Non Alpha Numeric Regex with Javascript

Using javascript regular expressions to stop users from entering non-aphanumeric characters or white spaces

Say you want to stop users from entering non-aphanumeric characters or white spaces.

Using regular expressions would be the easiest method:

Here is my javascript code:

<script language="Javascript">
function alphaNumericCheck(){
    var regex=/^[0-9A-Za-z]+$/; //^[a-zA-z]+$/
    if(regex.test(document.add_data.password.value)){
        alert("Good")
        return true;
    } 
    else {
        alert("Please fix: password")
        return false;
    }
}
</script>

For numbers only use /^[0-9]+$/

For mixed text and numbers, with spaces /^[0-9a-zA-Zs]+$/

Here are more useful regular expressions:

[a-zA-Z] any letter
d any number; same as [0-9]
D any NOT number; same as [^0-9]
w any alphanumeric character; same as [a-zA-Z-0-9_]
W any NON-alphanumeric character; same as [^a-zA-Z0-9_]
s any whitespace (tab, space, newline, etc...)
S any NON-whitespace
n newline
t tab

To view a full html sample of the above code click the links below using regular expressions in JavaScript

Restarting Mysql and Apache Using Cron Job

Have you notice that your RAM usage on your server is very close to your memory installed? It’s possible because of memory leaking and resource hogging web application. You can free your RAM by restarting Apache and MySQL.

I will give you step by step adding cron jobs into your system:

  1. Login to your server with SSH
  2. Type crontab -l to display list of cron jobs,
  3. Type crontab -e to edit your crontab,
  4. Add * 4 * * * /etc/init.d/mysqld restart to restart Mysql everyday at 4 AM,
  5. Add * 5 * * * /etc/init.d/httpd restart to restart Apache everyday at 5 AM,
  6. Save your file,
  7. Recheck with crontab -l

Step by Step Installing Composer

Since Composer works with the current working directory it is possible to install it in a system wide way.

  1. Change into a directory in your path like cd /usr/local/bin
  2. Get Composer curl -sS https://getcomposer.org/installer | php
  3. Make the phar executable chmod a+x composer.phar
  4. Change into a project directory cd /path/to/my/project
  5. Use Composer as you normally would composer.phar install

Original Source: http://stackoverflow.com/questions/11333230/how-to-run-composer-from-anywhere