Tuesday, September 6, 2016

BACK UP AND RESTORE DATABASE USING COMMAND LINE IN PHP SCRIPT

Filled under:

1. BACK UP DATABASE
This line bellow is used to back up database existing in MySQL database engine. This standart coding is using XAMPP Server and running in Windows Operating System. Before executing this line in browser, you have to try it in the Windows Command Prompt with your own system privileges.
a. Go to cmd.exe as an Administrator and run this command line:
C:\xampp\mysql\bin>mysqldump –h[hostname] –u[username] –p[password] [databasename] > [database back up file].[extension]
This is the example of the real code:
C:\ xampp\mysql\bin\mysqldump -u root spisy_kpe > spisy_kpe.sql
Never use –p if you don’t use password to encrypt the database. The above example is not using password, so there is no –p command.
b. Executing the command line with PHP Script:
Try to make program with php extension saved in the folder  in the htdocs and type this code bellow:
<?php
$command = "c:/xampp/mysql/bin/mysqldump -u root spisy_kpe > spisy_kpe3.sql";
exec($command);
echo "finished to backup database";
?>

Run the script using browser and find the backup file in the folder used to save this script program file.
2. CREATE DATABASE
a. Go to cmd.exe as an Administrator and run this command line:
C:\xampp\mysql\bin>mysql –h[hostname] –u[username] –p[password] –e “create database spisy;”

This is the example of the real code:
C:\ xampp\mysql\bin\mysql –h localhost -u root –e “create database spisy;”
Never use –p if you don’t use password to encrypt the database. The above example is not using password, so there is no –p command.
b. Executing the command line with PHP Script:
Try to make program with php extension saved in the folder  in the htdocs and type this code bellow:
<?php
$command = "c:/xampp/mysql/bin/mysql –h localhost -u root -e "create database spisy;";
exec($command);
echo "finished to create database";
?>

Try to open phpmyadmin through the browser and look at the database collection. The database you created will exist there.
3. RESTORE DATABASE
a. Go to cmd.exe as an Administrator and run this command line:
C:\xampp\mysql\bin>mysql –h [hostname] -u root –p [password] [restored database name] < [database file name].[extension]”

This is the example of the real code:
C:\xampp\mysql\bin>mysql –h localhost -u root spisy < spisy-kpe3.sql”
Never use –p if you don’t use password to encrypt the database. The above example is not using password, so there is no –p command.
b. Executing the command line with PHP Script:
Try to make program with php extension saved in the folder  in the htdocs and type this code bellow:
<?php
$command = "c:/xampp/mysql/bin/mysql –h localhost -u root spisy < spisy-kpe3.sql";
exec($command);
echo "finished to restore database";
?>

4. MERGING THE PROGRAM
Now, we can use all of program to back up, create and restore database in same time. The program look like bellow:
<?php
$command = "c:/xampp/mysql/bin/mysqldump -u root spisy-kpe > spisy-kpe3.sql";

exec($command);

echo "finished to backup database";

exec('c:/xampp/mysql/bin/mysql -u root -e "create database spisy;"');

exec('c:/xampp/mysql/bin/mysql -u root spisy < spisy-kpe3.sql');

echo "finished to restore database";
exec(exit);
?>

Posted By Novida2:36 PM

BACK UP AND RESTORE DATABASE USING COMMAND LINE IN PHP SCRIPT

Filled under:

1. BACK UP DATABASE
This line bellow is used to back up database existing in MySQL database engine. This standart coding is using XAMPP Server and running in Windows Operating System. Before executing this line in browser, you have to try it in the Windows Command Prompt with your own system privileges.
a. Go to cmd.exe as an Administrator and run this command line:
C:\xampp\mysql\bin>mysqldump –h[hostname] –u[username] –p[password] [databasename] > [database back up file].[extension]
This is the example of the real code:
C:\ xampp\mysql\bin\mysqldump -u root spisy_kpe > spisy_kpe.sql
Never use –p if you don’t use password to encrypt the database. The above example is not using password, so there is no –p command.
b. Executing the command line with PHP Script:
Try to make program with php extension saved in the folder  in the htdocs and type this code bellow:
<?php
$command = "c:/xampp/mysql/bin/mysqldump -u root spisy_kpe > spisy_kpe3.sql";
exec($command);
echo "finished to backup database";
?>

Run the script using browser and find the backup file in the folder used to save this script program file.
2. CREATE DATABASE
a. Go to cmd.exe as an Administrator and run this command line:
C:\xampp\mysql\bin>mysql –h[hostname] –u[username] –p[password] –e “create database spisy;”

This is the example of the real code:
C:\ xampp\mysql\bin\mysql –h localhost -u root –e “create database spisy;”
Never use –p if you don’t use password to encrypt the database. The above example is not using password, so there is no –p command.
b. Executing the command line with PHP Script:
Try to make program with php extension saved in the folder  in the htdocs and type this code bellow:
<?php
$command = "c:/xampp/mysql/bin/mysql –h localhost -u root -e "create database spisy;";
exec($command);
echo "finished to create database";
?>

Try to open phpmyadmin through the browser and look at the database collection. The database you created will exist there.
3. RESTORE DATABASE
a. Go to cmd.exe as an Administrator and run this command line:
C:\xampp\mysql\bin>mysql –h [hostname] -u root –p [password] [restored database name] < [database file name].[extension]”

This is the example of the real code:
C:\xampp\mysql\bin>mysql –h localhost -u root spisy < spisy-kpe3.sql”
Never use –p if you don’t use password to encrypt the database. The above example is not using password, so there is no –p command.
b. Executing the command line with PHP Script:
Try to make program with php extension saved in the folder  in the htdocs and type this code bellow:
<?php
$command = "c:/xampp/mysql/bin/mysql –h localhost -u root spisy < spisy-kpe3.sql";
exec($command);
echo "finished to restore database";
?>

4. MERGING THE PROGRAM
Now, we can use all of program to back up, create and restore database in same time. The program look like bellow:
<?php
$command = "c:/xampp/mysql/bin/mysqldump -u root spisy-kpe > spisy-kpe3.sql";

exec($command);

echo "finished to backup database";

exec('c:/xampp/mysql/bin/mysql -u root -e "create database spisy;"');

exec('c:/xampp/mysql/bin/mysql -u root spisy < spisy-kpe3.sql');

echo "finished to restore database";
exec(exit);
?>

Posted By Novida2:36 PM

Sunday, August 21, 2016

Python - Inconsistent use of tabs and spaces in indentation - Notepad++

Filled under:

I am trying to making Python 3.4 application using Notepad++ and windows command prompt.
I want to make main() function code block and call it in the __name__.
The line is looking like bellow:
#!\Python34\python
import os;

def main():
 bahasa = ['Python','Perl'];
 for b in bahasa:
  print(b);
 os.system("pause");

if __name__ == "__main__":
 main();
I saved syntax above in D:\PythonProject and named hello.py when I run the script using windows command prompt by typing
D:\PythonProject>python hello.py
I get error warning : TabError: inconsistent use of tabs and spaces in indentation I set Notepad++ tabs configuration by going to Setting --> Preference --> Language Menu then I choose Python, and I go to Tab Settings then I choose Python. It will automatically change the setting of our text editor from tabs into tab-space. It runs successfully.

Posted By Novida7:48 PM

Tuesday, July 19, 2016

Install Redmine using XAMPP, MySQL, Ruby on Rails

Filled under:

bellow are the requirement that we use to install redmine.

  • XAMPP v3.2.1
  • Ruby 2.2.4
  • Redmine 3.0.4
  • DevKit 4.7.2

1.        XAMPP Bitnami Installation

1.1.       Install XAMPP Bitnami dengan menggunakan xampp-win32-1.8.2-1-VC9-installer.exe. Before run the application, please turn off the antivirus which is running on PC.
1.2.       Please ignore the warning and continue the installation by clicking OK

Figure 1 Bitnami Installation warning

1.3.       Follow the instruction by only clicking Next tombol
1.4.       Make sure that the application path is already exist in the system drive by going to C:/xampp/htdocs
1.5.       Create folder dev-ruby inside htdocs
1.6.       Put redmine folder from bundle inside dev-ruby folder and just use the simple name for redmine folder by removing version number

Figure 2 Redmine folder in the xampp application

1.7.       After the installation completed, please open XAMPP Control Panel and you will see the following layout

Figure 3 XAMPP Control Panel v3.2.1
1.8.       Before start Apache and MySQL Service, please open the configuration file by clicking Config and choose Apache (http.conf)
1.9.       Please find Listen 80 line in the file and add Listen 3000 as the Ruby and Rails port.

Figure 4 Port Listening



1.10.   Add the following syntax at the end of file to create Virtual Host for Ruby and Rails
<VirtualHost *:3000>
   ServerName localhost
   DocumentRoot “C:/xampp/htdocs/dev-ruby/redmine/public”
<Directory “C:/xampp/htdocs/dev-ruby/redmine/”>
     Option Indexes FollowSymLinks Includes ExecCGI
     AllowOverride none
     Require all granted
<Directory>
</VirtualHost>

Use path which is defined in step 1.5 and step 1.6 to replace ~/dev-ruby/redmine

1.11.   Open Xampp control panel and Start Apache and MySql by clicking Start tombol and make sure that port 3000 is listed between Apache and Start tombol, and port 3306 is listed between MySQL and Start tombol

Figure 5 Starting Apache and MySQL


1.12.   Create redmine database in phpmyadmin by going to localhost/xampp (in this case I use port 90 for phpmyadmin, so I use localhost:90/xampp)

Figure 6 Creating Redmine Database

1.13.   Please go to the browser and go to URL : localhost:3000. Make sure that the redmine file will be listed in the homepage.

Figure 7 Listen localhost:3000
1.14.   if you get the above result, it means that the virtual host for Ruby and rails is ready to be used.


2.        Ruby on Rails Installation

2.1.       Install ruby installer using rubyinstaller-2.2.4-x64.exe in the bundle. Please follow the instruction and make sure you check Add Ruby executables to your PATH such the following picture and click Install

Figure 8 Installing Ruby
2.2.       Make sure that Ruby is already installed in the System, then put DevKit folder from bundle to the System parallel with installed Ruby22-64 folder

Figure 9 DevKit Folder

2.3.       Copy libmysqld.lib from C:\xampp\mysql\lib into C:\Ruby22-x64\lib\ruby\gems\2.2.0\gems\mysql2-0.4.4-x64-mingw32\vendor
2.4.       Open DevKit folder and run msys.bat
2.5.       On msys.bat run the following command:
cd C:/DevKit
ruby db.rk init
ruby db.rk install
2.6.       Close the msys.bat and open command prompt as administrator
2.7.       Check Ruby version
ruby -v
expected result:

Figure 10 Checking Ruby Version
2.8.       Check Gem version
gem -v

Figure 11 Checking Gem Version
2.9.       Install Ruby on rails in the folder which is defined in Step 1.5, in this case we use dev-ruby folder with the following syntax:
cd C:/xampp/htdocs/dev-ruby
gem install bundler
gem install rake
gem install rails -v=4.2.6
gem install mongrel -v 1.2.0.pre2 -- --with-cflags=\"-02 -pipe -march=native -w\"
gem install mongrel --pre
gem install mysql2
2.10.   If there is at least one line couldn’t be run, please type bundle install --without rmagick
2.11.   Open redmine folder C:\xampp\htdocs\dev-ruby\redmine\config, and Copy-paste database.yml.example, rename it tobe database.yml and then open it by using text editor such notepad.
2.12.   Only use the following code in the database.yml file:
development:
  adapter: mysql2
  database: redmine
  host: localhost
  username: root
  password: ""
  encoding: utf8
port: 3306


Figure 12 Configuring database.yml in redmine

2.13.   Open the command prompt again and go to redmine folder, then migrate the database into phpmyadmin by typing rake db:migrate
2.14.   Open the command prompt again and go to redmine folder, then type rails server

Figure 13 Start Redmine Service


2.15.   Go to URL: localhost:3000 from your local computer, but if you want to make this redmine readable from another computer, just simply type rails s -b 192.168.1.74 -p 3000 and Go to URL: 192.168.1.74:3000 and Enjoy Redmine!

Posted By Novida12:30 PM

Thursday, April 14, 2016

Mudahnya Mengurus Visa Kunjungan Bisnis Jepang

Filled under:

Assalamualaykum warrahmatullah wabarakatuh.
Konbanwa, minna san!
Alhamdulillah, sebulan yang lalu, tepat tanggal 22 Maret 2016, saya bisa berangkat ke Jepang untuk tujuan bisnis. Namun bukannya dengan tanpa halangan, pengurusan persiapannya benar-benar sangat panjang dan menelan sedikit emosi. Maklum, karena ini merupakan pengurusan passport dan visa untuk pertama kalinya.
Sebelum dapat mengajukan Visa kepada komjen Jepang, kita terlebih dahulu harus memiliki Passport. Kebetulan di tahun 2016, sudah terbit e-Passport atau electorin-Passport. Seperti yang kita tahu bahwa passport merupakan surat penyimpan informasi biometrik yang mengautentikasikan identitas seseorang. Jika di dalam negri, kita menggunakan KTP, maka identitas untuk di luar negri adalah passport. Hanya saja bedanya, e-passport telah dilengkapi dengan microprocessor chip (computer chip) dan antenna. Karena itulah kover buku passport dari e-passport lebih tebal dan menggunakan logo biometrik. Salah satu fungsi e-passport bagi kita yang sering sekali pergi ke Jepang adalah kita tidak perlu berulang kali mendaftarkan visa (Single Entry) jika bolak-balik pergi dan meninggalkan Jepang. Kemudian kita juga tidak perlu membayar biasa pembuatan visa alias gratis. Untuk passport biasa kita perlu merogoh koceh sebesar Rp 335 ribu, namun untuk sekali pengajuan visa Kunjungan sementara Jepang, kita perlu merogoh koceh sebesar Rp 330 ribu. Sedangkan untuk e-passport kita perlu merogoh koceh sebesar Rp 655 ribu, dan tidak perlu membayar biaya pengajuan visa. Untuk bagaimana mengajukan passport baik biasa dan elektronik, anda bisa kesini. Saya perlu mengingatkan bahwa bagi anda yang alamat KTP di luar Kantor Imigrasi pembuatan passport, anda perlu mencantumkan Surat Rekomendasi yang menjamin anda bahwa anda tidak akan menyalahgunakan data-data yang dipercayakan kantor imigrasi dan digunakan sebagaimana mestinya. Kebetulan saya beralamat KTP di Lumajang, Jawa Timur. Dan membuat passport di Kantor Imigrasi Kelas I - Jakarta Timur. Oleh karena tujuan saya ke Jepang kali ini untuk kunjungan bisnis, maka surat rekomendasi bisa dibuat oleh kantor tempat saya bekerja. Setelah semua surat lengkap dan beres, kemudian ada wawancara sedikit oleh pihak registrasi, anda hanya perlu mengikuti prosedur di Kantor Imigrasi dengan urut dan antri. Prosesnya hanya memakan waktu sehari. Namun, harus anda tahu bahwa pembuatan passport harus perlu mendaftar nomor antrian terlebih dahulu. Dan nomor antrian akan otomatis di-close oleh sistem terintegrasi yang ada di dalam Kanim pada pukul 09:00. Jadi saya sarankan agar anda sudah berada di Kanim sebelum jam tersebut. Karena untuk satu hari, jumlah pendaftar bisa mencapai ratusan orang dengan jumlah pengurus hanya sekitar 10 bilik saja.

Nah bagaimana dengan pengajuan visa Jepang?
Untuk proses sendiri sebenarnya tidak serumit dan selama pengurusan passport. Namun pengurusan visa tidak bisa sefleksibel passport. Pengurusan visa dilakukan di komjen atau kantor kedutaan Jepang, dan setiap daerah di Indonesia sudah dibagi kepada beberapa yurisdiksi. Jadi, tidak bisa sembarang kantor kedutaan bisa kita masuki untuk pengajuan visa.
Berikut adalah daftar yurisdiksi Konsulat Jendral Jepang di Indonesia:

  1. Bagian Konsuler Kedutaan Jepang di Jakarta memiliki wilayah yurisdiksi Jakarta, Banten, Jawa Barat, Jawa Tengah, Yogyakarta, Kalimantan Tengah, Kalimantan Barat, Sumatera Selatan, Bangka Belitung, Bengkulu, Lampung.
  2. Bagian Konsuler Kedutaan Jepang di Makasar memiliki wilayah yurisdiksi Sulawesi Utara, Gorontalo, Sulawesi Tengah, Sulawesi Tenggara, Sulawesi Selatan, Sulawesi Barat, Maluku Utara, Maluku, Papua (Irian Jaya), Papua Barat
  3. Bagian Konsuler Kedutaan Jepang di Surabaya memiliki wilayah yurisdiksi Jawa Timur, Kalimantan Timur, Kalimantan Utara, Kalimantan Selatan
  4. Bagian Konsuler Kedutaan Jepang di Denpasar memiliki wilayah yurisdiksi Bali, Nusa Tenggara Barat, Nusa Tenggara Timur 
  5. Bagian Konsuler Kedutaan Jepang di Medan memiliki wilayah yurisdiksi Aceh Nangroe Darusalam, Sumatera Utara, Sumatera Barat, Jambi, Riau, Kepulauan Riau
Jadi bagi kita yang kebetulan beralamat KTP di Surabaya kemudian berdomisili di Jakarta dan mengurus passport di Jakarta, tetap saja harus kembali ke tempat asal yurisdiksi untuk dapat mengajukan visa Jepang. Saya sendiri beralamat KTP di Lumajang (Jawa Timur), walaupun telah membuat passport di Kanim Kelas I Jakarta Timur, saya tetap harus pergi ke Kantor Konsulat Jendral Jepang yang berada di Surabaya. Jika penasaran anda boleh mencoba untuk tetap mengajuakan dengan alamat berbeda dari yurisdiksi yang sudah ditentukan, karena sampai kapanpun mereka tidak akan menerima permohonan anda. FYI saja bahwa Konjen Jepang sangat anti dengan penyogokan atau segala bentuk suap. Karena sepengalaman saya bahwa pengajuan visa bisa saja di tolak. Sistem pengajuan visa memang sedikit membingungkan, namun menurut saya ini sudah tidak se-membingungkan jaman dulu. Jika alamat KTP dan alamat Passport berbeda, maka sebelum dapat mengajukan visa, alamat passport harus dimutasi terlebih dahulu sesuai dengan alamat KTP, atau sebaliknya. Namun kita tidak perlu khawatir jika kita sangat kesusahan untuk mengurus visa di luar kota/provinsi/pulau, karena pengurusan visa dapat diwakilkan oleh orang lain, dengan syarat menyertakan surat kuasa atau Surat Tugas (jika keperluan bisnis). Pada kasus saya ini, saya meminta bantuan teman saya yang berdomisili di Surabaya untuk mengurus visa tersebut.
Adapun syarat untuk mengajukan visa kunjungan sementara untuk bisnis dapat dilihat disini. Dan lama pembuatan hanya memakan waktu 4 hari kerja.
Catatan lainnya yaitu jika anda ingin mengunjungi Jepang atau bahkan luar negri yang lain, anda harus telah benar-benar matang dalam perencanaan apa yang akan dilakukan disana dan dimana anda akan tinggal, karena pemerintah Jepang sangat teliti dan detil akan data yang kita ajukan. Namun tidak perlu khawatir, untuk template dokumen tambahan seperti jadwal perjalanan, surat undangan, mereka sangat fleksibel. Anda dapat mencari template-template yang sudah valid dan lolos di internet. Bagi anda yang dijamin segala biaya oleh perusahaan tempat anda bekerja, maka anda tidak perlu memberikan keterangan jumlah tabungan yang anda miliki, dan cukup meminta perusahaan tempat anda bekerja untuk membuatkan surat jaminan yang disertai dengan materai. Tetapi walau bagaimana, setelah anda sampai di terminal Bandara tempat pertama kali anda memasuki Jepang, anda akan tetap ditanya berapa banyak uang yang anda bawa. Pada saat itu saya hanya membawa sedikit uang dalam mata uang JPY sebesar 30.000 Y, sisanya saya membawa uang dalam mata uang IDR.

Posted By Unknown12:11 PM

Thursday, September 3, 2015

Knowing Islam from the lowest glasses

Filled under:

Assalamualaykum warahmatullah. . .

Peace and Allah's blessing be on you guys. This is for the first time I write down an article studying in religious viewpoint. This is the only a little bit of Islam comprehension. It has no purpose to influence whoever reading this.
Wish Shalawat and Salam are always to Prophet Muhammad Salallahu 'alaihi wassalam. This desire just begins by studying about The difference between Islam with other religion. The reason to compare is coming from the daily occurrences. I am an employee in the foreign company that has no Religious method to make a decision. So, you could imagine that my life has no reason to study about religion everyday. But, above 2 months ago, I got a new partner for my job. She is actually an Christian. The big surprise is she told me that she actually wanna be a Moslem since she has studied her current religion. The big reason then, She has read all of parts Bible and Al-Quran.
What kind of topic that make me so interested?
Indonesia has a larger Moslem population in the world (Read: "Region: Asia-Pacific". The Future of the Global Muslim Population. Pew Research Center. Retrieved 22 December 2011.). Most of us are Moslem religious by not choosing it self, but ancestry. We do ibadah (pray) by emulating what our ancestor has been done. We read Al-Quran by emulating what our ancestor has been read. They (the ancestor) just give us many explanations about what and how. What Moslem is and How a Moslem is. What Islam is and How Islam is. What Allah is (God) and How to believe Allah. There are many people can't explain, what the reason and Why should Moslem, Why should Islam and Why should Allah.

Please imagine that a people like my friend who was born to be Christian, hopes that she can choose her own religion. Then, when I asked her about the reason, she answer with good explanation. The explanations will be shown later.

If you are an Atheist, then you ask me, is God exist? Then I would say YES. God is exist. Allah is exit. I would describe them with this explanations bellow:
  • Creation or Evolution?
I learned that it takes far more “faith” to believe in the intellectually chic and fashionable evolutionary myth than it does to believe in the existence of God. In fact, I learned that evolution is based entirely on faith because no facts or proof have ever been found to support it! 
  • The Milky Way Galactic System.
  • Reproductive System
  • The Most Perfect Clock
You probably have a watch. Without it, you would be lost in a world that demands that people “be on time.”
Some watches are more accurate than others. How accurate is yours? How long before it loses a second? When this happens, you adjust it by reckoning from a more accurate source. That source, whatever it is, is also imperfect and has to be regularly updated, though not as often, to be in accord with the Master Clock of the United States at the Naval Observatory in Washington, D.C.
For many years, until 1967, Naval Observatory astronomers “observed” the motion of the earth, in relation to the heavens, to accurately measure time. All clocks in this country were set in relation to these very precise measurements. It was God who made this Master Clock of the Universe! He set the heavens in motion and mankind learned how to use its wonderful accuracy. As marvelous as this Master Clock is, the story does not end here.
In 1967, scientists built an “Atomic Clock.” It uses Cesium 133 atoms because they oscillate (vibrate) at the rate of 9,192,631,770 times per second. This produces accuracy within one second every 30 million years! Wouldn’t you love a watch that accurate? Cesium 133 atoms never vary a single vibration. They are steady—constant—reliable—and cannot be an accident of nature that just “happens” to always turn out exactly the same. God had to design the complexity and reliability of these atoms. No honest mind can believe otherwise. Men merely learned how to capture what God designed, for use in time measurement. Again, the story continues.
  • First Law of Thermodynamics
  • Second Law of Thermodynamics
  • Theory Debunked
  • Complexity of Life

Source Library :  AL-Quran, Ustd. Felix Y. Siaw, (My lovely sister) Jeannete C. W., The Existence of God, Logically proven!, and my own logic.
To be continued . . .

Posted By Unknown10:31 PM

Tuesday, October 21, 2014

Dynamic Ribbon Button Using Javascript

Filled under:

I tried to create dynamic ribbon button using jquery when I joined in the big project in the work. I will share this for everyone and practice my English. But I didn't use a css for styling the page. It just the hard code.

for demo, try it by your self!

Posted By Unknown3:40 PM