Saturday, June 22, 2013

Simple Validation rule in CodeIgniter




now, i can share about validation rule in CodeIgniter. if you using validation default in CodeIgniter, you must follow rule module Library, Helper, etc in CodeIgniter.

if you not expert using JavaScript, ajax, or jQuery for validation in CodeIgniter you can try using validation in CodeIgniter this is rule validation in CodeIgniter :

Rule Reference

The following is a list of all the native rules that are available to use:
Rule Parameter Description Example
required No Returns FALSE if the form element is empty.
matches Yes Returns FALSE if the form element does not match the one in the parameter. matches[form_item]
is_unique Yes Returns FALSE if the form element is not unique to the table and field name in the parameter. is_unique[table.field]
min_length Yes Returns FALSE if the form element is shorter then the parameter value. min_length[6]
max_length Yes Returns FALSE if the form element is longer then the parameter value. max_length[12]
exact_length Yes Returns FALSE if the form element is not exactly the parameter value. exact_length[8]
greater_than Yes Returns FALSE if the form element is less than the parameter value or not numeric. greater_than[8]
less_than Yes Returns FALSE if the form element is greater than the parameter value or not numeric. less_than[8]
alpha No Returns FALSE if the form element contains anything other than alphabetical characters.
alpha_numeric No Returns FALSE if the form element contains anything other than alpha-numeric characters.
alpha_dash No Returns FALSE if the form element contains anything other than alpha-numeric characters, underscores or dashes.
numeric No Returns FALSE if the form element contains anything other than numeric characters.
integer No Returns FALSE if the form element contains anything other than an integer.
decimal Yes Returns FALSE if the form element is not exactly the parameter value.
is_natural No Returns FALSE if the form element contains anything other than a natural number: 0, 1, 2, 3, etc.
is_natural_no_zero No Returns FALSE if the form element contains anything other than a natural number, but not zero: 1, 2, 3, etc.
valid_email No Returns FALSE if the form element does not contain a valid email address.
valid_emails No Returns FALSE if any value provided in a comma separated list is not a valid email.
valid_ip No Returns FALSE if the supplied IP is not valid. Accepts an optional parameter of "IPv4" or "IPv6" to specify an IP format.
valid_base64 No Returns FALSE if the supplied string contains anything other than valid Base64 characters.

 
if you confused for using rule, you can read manual book or you can change and custom rule validation in class module.
for modify rule validation in CodeIgniter, you can open file in system/library/form_validation.php

for example in rule alpha..

public function alpha($str)
{
        return ( ! preg_match("/^([a-z])+$/i", $str)) ? FALSE : TRUE;
}

and using rule :

$this->form_validation->set_rules('name','Name Message','alpha');

alpha only make validation for if you input in form using space rule alpha make not valid you input form. because space not alphabetical characters. if you want using rule alpha and make space is valid in alpha rule, you just modify function alpha :

public function alpha($str)
{
        return ( ! preg_match("/^([a-z ])+$/i", $str)) ? FALSE : TRUE;
}

i just add space in [a-z] to [a-z ] very simple.
not modify? just make a new function in class form_validation.

finish, and sorry if my english not good.


Sunday, June 16, 2013

failed running MOCP




hai guys, i want to share a solution in MOCP.
when you running a MOCP, you find this problem

Running the server...
Trying OSS...

FATAL_ERROR: No valid sound driver!


FATAL_ERROR: Server exited!

first, you can try check your problem in ALSA

# alsa_out

and you will find :
Cannot connect to server socket err = No such file or directory
Cannot connect to server request channel
jackdmp 1.9.9.5
Copyright 2001-2005 Paul Davis and others.
Copyright 2004-2012 Grame.
jackdmp comes with ABSOLUTELY NO WARRANTY
This is free software, and you are welcome to redistribute it
under certain conditions; see the file COPYING for details
no message buffer overruns
no message buffer overruns
no message buffer overruns
JACK server starting in realtime mode with priority 20
audio_reservation_init
Acquire audio card Audio0
creating alsa driver ... hw:0|hw:0|1024|2|48000|0|0|nomon|swmeter|-|32bit
lsof: WARNING: can't stat() fuse.gvfsd-fuse file system /run/user/1000/gvfs
      Output information may be incomplete.
Cannot connect to server socket err = No such file or directory
Cannot connect to server request channel


ATTENTION: The playback device "hw:0" is already in use. The following applications  are using your soundcard(s) so you should  check them and stop them as necessary before  trying to start JACK again:

pulseaudio (process ID 1663)

JackTemporaryException : now quits...
Cannot initialize driver
JackServer::Open failed with -1
Failed to open server
Cannot connect to server socket err = No such file or directory
Cannot connect to server request channel
Cannot connect to server socket err = No such file or directory
Cannot connect to server request channel
Cannot connect to server socket err = No such file or directory
Cannot connect to server request channel
Cannot connect to server socket err = No such file or directory
Cannot connect to server request channel
jack server is not running or cannot be started
jack server not running?

so you have problem in jack driver.

this is solution for it :

i find this problem in my fedora 18. I try install

1. # yum install jaaa.x86_64 japa.x86_64 ambdec.x86_64 pulseaudio-module-jack.x86_64 bio2jack.x86_64

2. # yum install jack-audio-connection-kit.x86_64 jack-audio-connection-kit-devel.x86_64 bio2jack-devel.x86_64

3. # yum install python-alsa.x86_64 alsa-tools-firmware.x86_64 alsa-oss.x86_64

after install you run this CLI

$ aoss mocp

if you reboot and will start using MOCP and find problem again about this, you just run

$ aoss mocp

have fun, and good luck.

Sunday, June 2, 2013

Aku tidak pernah MEMBENCI Indonesia !!!




MERAH PUTIH..!!!

negeri ini adalah negeri yang diberikan oleh Alloh SWT sebagai negeri untuk memimpin DUNIA.. yah.. itulah yang aku saya rasakan.

Bahasa persatuan ini haruslah menjadi bahasa persatuan di DUNIA..!!
karena bahasa Indonesia begitu kaya bahkan bahasa yang begitu Indah jika kita merangkainya. kemana saya harus katakan keinginan saya? haruskah saya meretas semua website di dunia ini, memberi tahu kepada mereka bahwa INDONESIA ADALAH NEGARA PEMIMPIN DUNIA.

setiap detik negeri ini semakin hancur dan semakin tak bermoral. tidak bisa mempertahankan apa yang di miliki, pemuda negeri semakin parah, seakan mereka bukan berasal dari negara Indonesia. sekolah di negeri inipun lambat laun semakin tidak beradab.. mereka membuang sedikit demi sedikit kutur Indonesia. andai pemuda di negeri ini tahu betapa hebatnya Indonesia. andai mereka sadar betapa kayanya Indonesia. 1 : 1.000.000 pemuda di negeri ini yang sadar akan hal itu. pemerintah yang selalu membeberkan kalau pemudah Indonesia harus menjadi penerus bangsa. aahhh tapi mana... yang mereka ucapkan itu hanyalah sampah.. pembogong.. tidak bisa dipercaya.

pemerintah negeri ini seakan tidak punya sedikit pun itikat untuk mewujudkan kata pencitraan itu. negeri ini payah, mereka yang menjadi dewa di negeri ini adalah mereka yang beruang.. bukan mereka yang sadar akan kata MERAH PUTIH. bahkan negeri ini put tak punya passion sama sekali. negeri ini sekarang sudah menjadi budak, menjadi pengikut, menjadi kacung...

tak peduli tulisan ini akan di cerca, dihina atau bahkan aku harus dibui karena menghina pemerintah negeri ini. biarkan mereka tau, biarkan aku yang mewakili hati pemuda negeri ini yang faham akan kata MERAH PUTIH.

semenjak aku mulai meminjakan kaki ku di ruangan kelas SD sampai sekarang.. hati selalu bertekad kalau negeri ini harus menjadi Juara dan memimpin dunia, kekayaan negeri ini harus terjaga. mereka yang bukan berasal dari Indonesia haruslah menjadi budak, bukan menjadi raja. pemimpin negeri ini haruslah menjadi pedoman bukan menjadi bahan cemoohan.... dan negeri ini harus MERDEKA sampai kapan pun. tidak butuh pemuda yang pintar.. negeri ini butuh pemuda yang peduli.. karena rasa peduli yang akan membuat pemuda negeri ini menjadi PINTAR..!!!!