Selasa, 18 Desember 2012



Contoh penggunaan Memcache untuk  menyimpan data.
<?php
$memcache = new Memcache;
$memcache->connect('localhost', 11211) or die ("Could not connect");

$key = "Test"; // Nama unique key yang akan disimpan (cache) di cluster memory
$cache_result = array();
$cache_result = $memcache->get($key); // nama object Memcached

if($cache_result){
    // Jika request kedua (sudah di cache di awal)
    $result=$cache_result;
}else{
    // Jika request pertama ambil data dari database lalu distribusikan di memory server
    $con = ocilogon("scott","tiger","orcl");
    $sql ="SELECT * FROM EMP";
    $sql = ociparse($con,$sql);
    ociexecute($sql);
   
    while(ocifetch($sql))
    $result[]=ociresult($sql,"EMPNO"); // penyimpanan hasil query didalam array
    $memcache->set($key, $result, MEMCACHE_COMPRESSED, 600); // disimpan 600 detik atau 10 menit dengan nama key $key
}

//Menampilkan data
foreach($result as $r){
    echo "$r<br/>";
}

?>

Hasil dari file diatas, maka empno akan disimpan selama 10 menit.


Needed Files
·         memcached.exe Direct Link
·         MSVCP71.DLL Windows DLL Files
·         msvcr71.dll
·         php_memcache.dll Working memcache for PHP 5.3.4
Steps
1.     Copy MSVCP71.DLL, msvcr71.dll to C:\windows\system32
2.     Copy memcached.exe into C:\memcached
3.     Run Command Prompt as Administrator
4.     type: C:\memcached\memcached.exe -d install
5.     type: C:\memcached\memcached.exe -d start
6.     Copy php_memcache.dll to C:\wamp\bin\php\php5.3.4\ext
7.     Restart Apache using Wamp controls
8.     Enable WAMP -> PHP -> PHP Extensios -> php_memcache
9.     Run this code to test the installation: 

<?php
    $memcache = new Memcache;
    $memcache->connect("localhost",11211); # You might need to set "localhost" to "127.0.0.1"

    echo "Server's version: " . $memcache->getVersion() . "<br />\n";

    $tmp_object = new stdClass;
    $tmp_object->str_attr = "test";
    $tmp_object->int_attr = 123;

    $memcache->set("key",$tmp_object,false,3600);
    echo "Store data in the cache (data will expire in 3600 seconds)<br />\n";

    echo "Data from the cache:<br />\n";
    var_dump($memcache->get("key"));
?>

If you see anything but errors, you are now using memcache!


Memcached, by default, loads with 64mb of memory for it’s use which is low for most applications. To change this to something else, navigate to HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\memcached Server in your registry, find the ImagePath entry and change it to look something like this:
“C:\memcached\memcached.exe” -d runservice -m 512
Now when you start the service via net start “memcached Server”, it will run with 512mb of memory at it’s disposal.







Kamis, 06 September 2012

Untuk merubah input type pada html dengan jquery hanya membutuhkan satu baris script yaitu :
$('element').get(0).type = 'input type';
sebagai contoh untuk merubah input bertype text menjadi password kita hanya cukup menambahkan 

$('#text').get(0).type = 'password';

sekian terima kasih atas kunjunganya

Senin, 14 Mei 2012


Sebelum memulai langkah-langkah instalasi Eclipse dan Android SDK pastikan komputer Anda telah terinstal Java SE Development Kit (JDK) yang bisa diunduh di alamat http://www.oracle.com/technetwork/java/javase/downloads/index.html. Ukuran file installer JDK tersebut kurang lebih 78 MB.
Jangan terburu-buru melaksanakan langkah demi langkah pada tutorial berikut, tetapi pahami dan baca dulu keseluruhan langkah agar tidak bingung.
Langkah-langkah instalasi Eclipse :
  1. Download file Eclipse Classic (ukuran kurang lebih 171 MB) di alamat  http://www.eclipse.org/downloads/
  2. File hasil download berbentuk .zip, kemudian uncompress file tersebut dengan tools-tools seperti WinRar
  3. Setelah diekstrak, maka akan dihasilkan folder eclipse, kemudian pindahkan folder tersebut di hardrive/lokasi yang mudah diakses
  4. Eclipse tidak memerlukan instalasi. Dalam folder eclipse akan ditemukan file eclipse.exe. Untuk membuka program eclipse tersebut cukup dilakukan eksekusi file eclipse.exe tersebut.
  5. Tampilan halaman awal eclipse akan tampak sebagai berikut :
  6. Selanjutnya yaitu melakukan instalasi plugin ADT Eclipse. Pastikan komputer telah terkoneksi dengan internet. Klik menu Help -> Install New Software. Klik Add pada sudut kanan atas dialog. Pada dialog Add repository, masukkan name "ADT Plugin", lalu  masukkan URL https://dl-ssl.google.com/android/eclipse/. Klik OK.
  7. Pada dialog Available Software, pilih checkbox Developer Tools, kemudian klik Next dan Next. Tunggu hingga selesai dan klik button Finish.
  8. Restart Eclipse Anda.
Langkah-langkah instalasi Android SDK :
  1. Download file Android SDK (ukuran kurang lebih 32 MB) di alamat http://developer.android.com/sdk/index.html
  2. Pada halaman tersebut akan ada dua pilihan installer. Jika Anda pilih yang .zip maka tidak perlu melakukan instalasi (cukup di-uncompress). Sedangkan jika Anda pilih yang recommended dalam bentuk .exe, maka nantinya Anda akan melakukan instalasi dengan mengeksekusi file .exe tersebut. Keduanya memiliki isi/file yang sama, tidak ada perbedaan.
  3. Untuk tutorial ini akan lebih mudah jika Anda mendownload versi Android SDK yang berekstensi .zip. Dengan demikian Anda hanya tinggal meng-uncompress file .zip tersebut.
  4. Hasil uncompress file .zip tersebut adalah sebuah folder dengan nama android-sdk-windows. Letakkan/pindahkan folder tersebut dimanapun agar mudah diakses. Misalnya di dalam folder eclipse yang sudah ada sebelumnya.
  5. Pastikan Anda terhubung ke internet. Eksekusi file  SDK Manager.exe, kemudian klik button Update All untuk melakukan update library secara otomatis hingga selesai. Proses ini akan memakan waktu lama apabila Anda ingin memasang semua library untuk berbagai jenis tipe Android OS, karena jika semuanya terinstal kurang lebih akan memakan 2GB harddrive Anda. Sebenarnya ada cara lain agar Anda tidak perlu melakukan update via online, yaitu secara offline. Caranya yaitu dengan melakukan copy paste seluruh folder dan file android-sdk-windows milik orang lain yang sudah berhasil terinstal.
Langkah menghubungkan Eclipse dengan Android SDK :
  1. Buka Eclipse, kemudian masuk ke menu Window -> Preferences, lalu klik Tab Android
  2. Pada dialog tersebut klik button Browse, kemudian arahkan ke path/lokasi folder android-sdk-windows Anda.
  3. Klik Apply, maka akan muncul beberapa macam library yang siap digunakan, seperti tampak pada gambar berikut.
  4. Klik OK, selamat, sekarang Anda sudah siap melakukan uji coba membuat aplikasi Android menggunakan Eclipse.
sumber: http://www.adityarizki.net/2011/05/tutorial-instalasi-eclipse-dan-android-sdk-windows/

Senin, 07 Mei 2012

Contoh pemakaian javascript confirm() pada jquery:
button:
<input type=\"button\" id=\"btndel\" class=\"delete\" value=\"Delete\" name=\"delete\" alt=\"aku\"> 
jquery script:

<script>
$(document).ready(function(){
$(".delete").click(function(){
    var nama = $(this).attr('alt').toUpperCase();
    var x = confirm("Menghapus User " + nama)
    if(x){
     alert("Lanjutkan")
    }
})
})
</script>
Jika pada confirm box dijawab yes maka akan ada alert "Lanjutkan"

contoh hasil Simple Confirm

Selasa, 17 April 2012

Here are my notes how I managed to get HTTPS working on Wamp5 in my test environment, meaning my laptop. The credits go to the guys at [www.apache-ssl.org].


OPENSSL_CONF ENVIRONMENT VARIABLE 

Go to Control Panel – System – Advanced – Environment Variables 

Add a new system variable OPENSSL_CONF: 

Variable name: OPENSSL_CONF 
Variable value: c:\wamp\Apache2\conf\openssl.cnf 

Log out and log back in. 

Go to the command prompt and type in: 

set | more 

Make sure you see the following line among the environment variables: 
OPENSSL_CONF=c:\wamp\Apache2\conf\openssl.cnf 


GENERATE KEY 

Again in the command prompt, go to C:\wamp\Apache2\bin and run the following command: 

openssl req -new > webserver.csr 

The command runs and prompts you to enter a PEM pass phrase and verify it. Write down the phrase because you will need it later. 

It will then ask you to enter information that will be incorporated into your certificate request. When the command finishes, it has created several files, including privkey.pem, in c:\wamp\apache2\bin. 

REMOVE PASSPHRASE 

Run the following command: 

openssl rsa -in privkey.pem -out webserver.key 

You will be prompted for the pass phrase from the previous step. The RSA key is written and the file webserver.key is now available in the folder. 

CONVERT INTO SIGNED CERTIFICATE 

Run the following command to create a certificate which expires after one year: 

openssl x509 -in webserver.csr -out webserver.cert -req -signkey webserver.key -days 365 


STORE CERTIFICATE FILES 

Create a folder c:\wamp\OpenSSL with the following subfolders: 

certs 
crl 
newcerts 
private 

Copy the following files to certs: 

webserver.cert 
webserver.csr 
webserver.key 

Copy the following files to private: 

.rnd 
privkey.pem 
cacert.pem (same as above, just a wild guess) 


MODIFY HTTPD-SSL.CONF 

Change the following lines, adjusting the email address and the paths to your settings: 

SSLSessionCache "shmcb:C:/wamp/Apache2/logs/ssl_scache(512000)" 

SSLMutex default 

# General setup for the virtual host 
DocumentRoot "C:/www/mysecuresite" 
ServerName localhost:443 
ServerAdmin myemail@example.com 
ErrorLog "C:/wamp/logs/mysecuresite_error_log" 
TransferLog "C:/wamp/logs/mysecuresite_access_log" 

SSLCertificateFile "C:/wamp/OpenSSL/certs/webserver.cert" 

SSLCertificateKeyFile "C:/wamp/OpenSSL/certs/webserver.key" 

SSLCARevocationPath "C:/wamp/OpenSSL/crl" 

<Directory "C:/wamp/Apache2/cgi-bin"> 

CustomLog "C:/wamp/logs/ssl_request_log" \ 
"%t %h %{SSL_PROTOCOL}x %{SSL_CIPHER}x \"%r\" %b" 



MODIFY OPENSSL.CNF 

There is a file openssl.cnf in c:\wamp\Apache2\conf even though no extension is shown in Windows Explorer. Go to the DOS command prompt and run DIR to see the file extension. Make a backup copy of this file first and rename it in DOS to openssl.cnf.txt so that you can edit it. 

Modify the base directory: 

dir = c:/wamp/OpenSSL # Where everything is kept 

Go to the DOS prompt and change the name of the file back to openssl.cnf. 


MODIFY HTTPD.CONF 


Change
#LoadModule ssl_module modules/mod_ssl.so
to
LoadModule ssl_module modules/mod_ssl.so

Last, but not least, make sure your secure site is part of the virtual hosts in Apache: 

# Secure (SSL/TLS) connections 
#Include conf/extra/httpd-ssl.conf 
Include conf/extra/httpd-ssl.conf 


TEST HTTPS 

Run httpd –t and make sure the syntax is OK. 

Restart Apache. 

Check that port 443 is open by running the following in the command prompt: 

netstat -an | more 


Test the https connection from your browser and hopefully it works :-) 



CLIENT CERTIFICATES 

For details on how to generate a client certificate see the instructions at [www.apache-ssl.org

Senin, 09 April 2012

Langkah pertama download versi phpMyAdmin versi terbaru di http://www.phpmyadmin.net/home_page/downloads.php.
saya menggunakan phpMyAdmin-3.4.5-all-languages.7z
Setelah download selesai , extract file tersebut. Lalu buat database : phpmyadmin .
Lalu import file create_tables.sql dan upgrade_tables_mysql_4_1_2+.sql dari folder script.
Replace phpmyadmin yang lama dengan yang baru , buka file config.default.php dari folder libraries.
kemudian ubah seperti dibawah ini :
/* Storage database and tables */
$cfg['Servers'][$i]['pmadb'] = 'phpmyadmin';
$cfg['Servers'][$i]['bookmarktable'] = 'pma_bookmark';
$cfg['Servers'][$i]['relation'] = 'pma_relation';
$cfg['Servers'][$i]['table_info'] = 'pma_table_info';
$cfg['Servers'][$i]['table_coords'] = 'pma_table_coords';
$cfg['Servers'][$i]['pdf_pages'] = 'pma_pdf_pages';
$cfg['Servers'][$i]['column_info'] = 'pma_column_info';
$cfg['Servers'][$i]['history'] = 'pma_history';
$cfg['Servers'][$i]['tracking'] = 'pma_tracking';
$cfg['Servers'][$i]['designer_coords'] = 'pma_designer_coords';
$cfg['Servers'][$i]['userconfig'] = 'pma_userconfig';

Simpan dan jalankan http://localhost/phpmyadmin/

Selamat mencoba...
Contoh:
Jika pada apache

RewriteEngine On
RewriteRule ^index\.html$ ./index.php?mdrw=on
RewriteRule ^manual\.html$ ./index.php?action=manual&mdrw=on
RewriteRule ^([0-9]+)_([-0-9]+)\.html$ ./index.php?action=vtopic&forum=$1&page=$2&mdrw=on

Maka pada Nginx
rewrite ^index\.html$ index.php?mdrw=on last;
rewrite ^manual\.html$ index.php?action=manual&mdrw=on last;
rewrite ^([0-9]+)_([0-9]+)\.html$ index.php?action=vthread&forum=$1&page=$2&mdrw=on last;

Semoga bermanfaat
Nginx (baca: engine x) adalah server HTTP dan Proxy dengan kode sumber terbuka yang bisa juga berfungsi sebagai proxy IMAP/POP3. Kode sumber nginx ditlis oleh seorang warga negara Rusia yang bernama Igor Sysoev pada tahun 2002 dan dirilis ke publik pada tahun 2004. Nginx terkenal karena stabil, memiliki tingkat performansi tinggi dan minim mengonsumsi sumber daya(sumber: wikipedia).

untuk download Nginx+Php+MySql dapat menuju langsung ke http://code.google.com/p/wemp/downloads/list 


Senin, 02 April 2012

Using a CREATE TABLE statement

The syntax for creating a primary key using a CREATE TABLE statement is:

CREATE TABLE table_name
(column1 datatype null/not null,
column2 datatype null/not null,
...
CONSTRAINT constraint_name PRIMARY KEY (column1, column2, . column_n)
);

For Example:

CREATE TABLE supplier
(supplier_idnumeric(10)not null,
supplier_namevarchar2(50)not null,
contact_namevarchar2(50),
CONSTRAINT supplier_pk PRIMARY KEY (supplier_id)
);
In this example, we've created a primary key on the supplier table called supplier_pk. It consists of only one field - the supplier_id field.

We could also create a primary key with more than one field as in the example below:
CREATE TABLE supplier
(supplier_idnumeric(10)not null,
supplier_namevarchar2(50)not null,
contact_namevarchar2(50),
CONSTRAINT supplier_pk PRIMARY KEY (supplier_id, supplier_name)
);

Using an ALTER TABLE statement

The syntax for creating a primary key in an ALTER TABLE statement is:

ALTER TABLE table_name
add CONSTRAINT constraint_name PRIMARY KEY (column1, column2, ... column_n);

For Example:


ALTER TABLE supplier
add CONSTRAINT supplier_pk PRIMARY KEY (supplier_id);
In this example, we've created a primary key on the existing supplier table called supplier_pk. It consists of the field called supplier_id.

We could also create a primary key with more than one field as in the example below:

ALTER TABLE supplier
add CONSTRAINT supplier_pk PRIMARY KEY (supplier_id, supplier_name);

Drop a Primary Key

The syntax for dropping a primary key is:

ALTER TABLE table_name
drop CONSTRAINT constraint_name;

For Example:


ALTER TABLE supplier
drop CONSTRAINT supplier_pk;
In this example, we're dropping a primary key on the supplier table called supplier_pk.

Disable a Primary Key

The syntax for disabling a primary key is:

ALTER TABLE table_name
disable CONSTRAINT constraint_name;

For Example:


ALTER TABLE supplier
disable CONSTRAINT supplier_pk;
In this example, we're disabling a primary key on the supplier table called supplier_pk.

Enable a Primary Key

The syntax for enabling a primary key is:

ALTER TABLE table_name
enable CONSTRAINT constraint_name;

For Example:


ALTER TABLE supplier
enable CONSTRAINT supplier_pk;
In this example, we're enabling a primary key on the supplier table called supplier_pk.

Minggu, 01 April 2012

Buka file config.inc.php yang ada di folder phpMyadmin kemudian gantilah seperti dibawah ini
$cfg['blowfish_secret'] = ‘isidenganterserahanda’;
$cfg['Servers'][$i]['auth_type']     = 'cookie';    // Authentication method (config, http or cookie based)?]
$cfg['Servers'][$i]['user']          = 'root';      // MySQL user
$cfg['Servers'][$i]['password']      = '';          // MySQL password
Hasil:

Setting phpMyAdmin Dengan Cookie

Rabu, 28 Maret 2012

The ALTER TABLE statement allows you to rename an existing table. It can also be used to add, modify, or drop a column from an existing table.

Renaming a table

The basic syntax for renaming a table is:

ALTER TABLE table_name
 RENAME TO new_table_name;

For Example:


ALTER TABLE suppliers
 RENAME TO vendors;
This will rename the suppliers table to vendors.

Adding column(s) to a table

Syntax #1
To add a column to an existing table, the ALTER TABLE syntax is:

ALTER TABLE table_name
 ADD column_name column-definition;

For Example:


ALTER TABLE supplier
 ADD supplier_name  varchar2(50);
This will add a column called supplier_name to the supplier table.

Syntax #2
To add multiple columns to an existing table, the ALTER TABLE syntax is:
ALTER TABLE table_name
ADD (column_1column-definition,
column_2column-definition,
...
column_ncolumn_definition );

For Example:

ALTER TABLE supplier
ADD (supplier_namevarchar2(50),
cityvarchar2(45) );
This will add two columns (supplier_name and city) to the supplier table.

Modifying column(s) in a table

Syntax #1
To modify a column in an existing table, the ALTER TABLE syntax is:

ALTER TABLE table_name
 MODIFY column_name column_type;

For Example:


ALTER TABLE supplier
 MODIFY supplier_name   varchar2(100)     not null;
This will modify the column called supplier_name to be a data type of varchar2(100) and force the column to not allow null values.

Syntax #2
To modify multiple columns in an existing table, the ALTER TABLE syntax is:
ALTER TABLE table_name
MODIFY (column_1column_type,
column_2column_type,
...
column_ncolumn_type );

For Example:

ALTER TABLE supplier
MODIFY (supplier_namevarchar2(100)not null,
cityvarchar2(75));
This will modify both the supplier_name and city columns.

Drop column(s) in a table

Syntax #1
To drop a column in an existing table, the ALTER TABLE syntax is:

ALTER TABLE table_name
 DROP COLUMN column_name;

For Example:


ALTER TABLE supplier
 DROP COLUMN supplier_name;
This will drop the column called supplier_name from the table called supplier.

Rename column(s) in a table
(NEW in Oracle 9i Release 2)

Syntax #1
Starting in Oracle 9i Release 2, you can now rename a column.
To rename a column in an existing table, the ALTER TABLE syntax is:

ALTER TABLE table_name
 RENAME COLUMN old_name to new_name;

For Example:


ALTER TABLE supplier
 RENAME COLUMN supplier_name to sname;
This will rename the column called supplier_name to sname.
Acknowledgements: Thanks to Dave M., Craig A., and Susan W. for contributing to this solution!

Practice Exercise #1:
Based on the departments table below, rename the departments table to depts.
CREATE TABLE departments
(department_idnumber(10)not null,
department_namevarchar2(50)not null,
CONSTRAINT departments_pk PRIMARY KEY (department_id)
);
Solution:
The following ALTER TABLE statement would rename the departments table to depts:

ALTER TABLE departments
 RENAME TO depts;

Practice Exercise #2:
Based on the employees table below, add a column called salary that is a number(6) datatype.
CREATE TABLE employees
(employee_numbernumber(10)not null,
employee_namevarchar2(50)not null,
department_idnumber(10),
CONSTRAINT employees_pk PRIMARY KEY (employee_number)
);
Solution:
The following ALTER TABLE statement would add a salary column to the employees table:

ALTER TABLE employees
 ADD salary number(6);

Practice Exercise #3:
Based on the customers table below, add two columns - one column called contact_name that is a varchar2(50) datatype and one column called last_contacted that is a date datatype.
CREATE TABLE customers
(customer_idnumber(10)not null,
customer_namevarchar2(50)not null,
addressvarchar2(50),
cityvarchar2(50),
statevarchar2(25),
zip_codevarchar2(10),
CONSTRAINT customers_pk PRIMARY KEY (customer_id)
);
Solution:
The following ALTER TABLE statement would add the contact_name and last_contacted columns to the customers table:
ALTER TABLE customers
ADD (contact_namevarchar2(50),
last_contacteddate );

Practice Exercise #4:
Based on the employees table below, change the employee_name column to a varchar2(75) datatype.
CREATE TABLE employees
(employee_numbernumber(10)not null,
employee_namevarchar2(50)not null,
department_idnumber(10),
CONSTRAINT employees_pk PRIMARY KEY (employee_number)
);
Solution:
The following ALTER TABLE statement would change the datatype for the employee_name column to varchar2(75):

ALTER TABLE employees
 MODIFY employee_name varchar2(75);

Practice Exercise #5:
Based on the customers table below, change the customer_name column to NOT allow null values and change the state column to a varchar2(2) datatype.
CREATE TABLE customers
(customer_idnumber(10)not null,
customer_namevarchar2(50),
addressvarchar2(50),
cityvarchar2(50),
statevarchar2(25),
zip_codevarchar2(10),
CONSTRAINT customers_pk PRIMARY KEY (customer_id)
);
Solution:
The following ALTER TABLE statement would modify the customer_name and state columns accordingly in the customers table:
ALTER TABLE customers
MODIFY (customer_namevarchar2(50) not null,
statevarchar2(2) );

Practice Exercise #6:
Based on the employees table below, drop the salary column.
CREATE TABLE employees
(employee_numbernumber(10)not null,
employee_namevarchar2(50)not null,
department_idnumber(10),
salarynumber(6),
CONSTRAINT employees_pk PRIMARY KEY (employee_number)
);
Solution:
The following ALTER TABLE statement would drop the salary column from the employees table:

ALTER TABLE employees
 DROP COLUMN salary;

Practice Exercise #7:
Based on the departments table below, rename the department_name column to dept_name.
CREATE TABLE departments
(department_idnumber(10)not null,
department_namevarchar2(50)not null,
CONSTRAINT departments_pk PRIMARY KEY (department_id)
);
Solution:
The following ALTER TABLE statement would rename the department_name column to dept_name in the departments table:

ALTER TABLE departments
 RENAME COLUMN department_name to dept_name;
Subscribe to RSS Feed Follow me on Twitter!