Skip to main content

Posts

Showing posts from 2015

Proxy Configuration for Git, NPM, and Bower

If you are in a suck place with proxy, you need to configure proxy setting for your repository and package manager tools such as git, npm, or bower. Git You can use this command to set configuration globally git config --global http.proxy http://username:password@proxy.server.com:8080 git config --global https.proxy https://username:password@proxy.server.com:8080 Command to unset git config --global --unset http.proxy git config --global --unset https.proxy Command to check the value git config --global --get http.proxy git config --global --get https.proxy NPM Command format npm config set <key> <value> npm config get <key> npm config delete <key> npm config list npm config edit Command to set (don't forget to include quote and trailing slash) npm config set proxy "http : //username:password@proxy.server.com:8080/" npm config set https - proxy "http : //username:password@proxy.server.com:8080/" Bo

Configure Display Resolution in Raspberry Pi

Raspberry Pi 2 supports its HDMI display for 1080p resolution. But, when you want a smaller resolution whether it is in a large display panel, you can configure it manually from terminal. 1) Get the lists of supported resolutions and modes of your monitor tvservice -d edid edidparser edid 2) Edit the configuration file nano /boot/config.txt 3) Find configuration for HDMI group and HDMI mode. The mode is the code shown in the result of first step. DMT group is 2 and CEA group is 1. For example, hdmi_group=2 #(DMT) hdmi_mode=85 #(code 85) 4) Restart your Raspberri Pi More References:  http://www.cpmspectrepi.webspace.virginmedia.com/raspberry_pi/MoinMoinExport/OptimisedDisplaySettings.html

Sends Email in The Background in PHP

If you send email in PHP with any library through SMTP server, the process will take a while (2 seconds or more). The process isn't necessary to be sequential. Clients don't need to wait and know the sending process had finished or not. So, the sending process is better to be run as background process. If you use Linux, you can use exec method. If you're in Windows environment, you can use popen method. Then you send the result to the background. In Linux, you can use wget command to be executed to access email sending application script. The message contents can be setup and maintain in database before this action is run. exec("wget -qO- http://domain.com/send.php &> /dev/null &"); Or you can pass the contents directly as parameters for PHP arguments which is executed. exec("php /path/to/your/mailer/script \"arg1\" \"arg2\" > /dev/null 2> /dev/null &"); If you are in Windows pclose(popen(

Custom Error Messages Location with jQuery Validation

jQuery Validation is a simple tools to validate a form with jQuery. We can custom error message location using this library. If you just want to set a box to gather all error messages, you can use this scheme. Javascript $ ( '#form' ). validate ({ rules : { first : { required : true }, second : { required : true } }, messages : {}, errorElement : 'div' , errorLabelContainer : '.errorTxt' }); HTML <form id = "form" method = "post" action = "" > <input type = "text" name = "first" /> <input type = "text" name = "second" /> <div class = "errorTxt" ></div> <input type = "submit" class = "button" value = "Submit" /> </form> But if you want to put error messages in different places for each fields, you c

Running Wordpress Behind Proxy

For latest version of Wordpress you can add this code in wp-config.php. define('WP_PROXY_HOST', 'your.proxy.com');  define('WP_PROXY_PORT', '8080');  define('WP_PROXY_USERNAME', 'my_user_name');  define('WP_PROXY_PASSWORD', 'my_password');  define('WP_PROXY_BYPASS_HOSTS', 'localhost, www.example.com');

Chicken and Pig

A chicken and a pig are walking down the road. Then conversation begins. Chicken: "Do you want to open a restaurant with me?" The pig considers the question and replies Pig: "Yes, I'd like that. What do you want to call the restaurant?" Chicken: "Ham and Eggs!" The pig stops, pauses, and replies. Pig: "On second thought, I don't think I want to open a restaurant with you. I'd be committed, but you'd only be involved." In a project, there will be people who have committed to the project. Other might be interested in the project, but they aren't on the hook. Those who are responsible for the project have the authority to do what is necessary for its success. Those who aren't responsible can't interfere unnecesarily. from "Agile Project Management with Scrum by Ken Schwaber"

Generate SSH Keys in Ubuntu

An SSH key allows you to establish a secure connection between your computer and a remote server. This type of connection run by generating an SSH key in your local computer (or remote computer, keep private and public key in local computer, then store the public key in remote server. In Ubuntu, you can use this command: $ ssh-keygen -t rsa -C "lukibsubekti@gmail.com"

How To Use Git in Netbeans

Git is a popular version control application nowadays. Recently I have created a note about its differences with SVN and how to use it in Eclipse . There are many Git client tools. But I just want to show how to use Netbeans built-in Git tools. It makes the development process easier because it has been integrated with the IDE. Create Remote Git Repository We need a remote Git repository so everyone can store or receive any revision or updated files through the networks. We can set up our own Git server or use a public Git server like Github . In this note, I use Github. 1. Create an account in Github and create an empty Git repository Create an empty public repository in Github 2. Get the remote repository link Your Github Repository URL Create a New Project in Netbeans and Create Local Git Repository After we have a remote Git repository, we can create a project stored in the remote repository. We also need to create a local repository before we can push

Creating a Self-Signed SSL Certificate

A self-signed SSL Certificate can be used if you want to make a secure connection to a server by encrypting the data like the HTTPS connection. We can utilize OpenSSL to generate the key and certificate. We can run  $ sudo openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout /path/to/yourkey.key -out /path/to/yourcert.crt to generate the key and certificate files.  Some important parameters are as follows: req : This specifies a subcommand for X.509 certificate signing request (CSR) management. X.509 is a public key infrastructure standard that SSL adheres to for its key and certificate management. Since we are wanting to create a new X.509 certificate, this is what we want. -x509 : This option specifies that we want to make a self-signed certificate file instead of generating a certificate request. -nodes : This option tells OpenSSL that we do not wish to secure our key file with a passphrase. Having a password-protected key file would get in the way of Apache

Install PostgreSQL in Ubuntu 14.04

In Ubuntu 14.04, PostgreSQL repository isn't listed by default. We must add the record first. Run $ nano /etc/apt/sources.list.d/pgdg.list to add repository list file Add deb http://apt.postgresql.org/pub/repos/apt/ trusty -pgdg main in the file Run $ wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | \ sudo apt-key add - Run $ sudo apt-get update then $ sudo apt-get install postgresql-9.4 For administrator we can install pgadmin3 $ sudo apt-get install pgadmin3 For client tools we can install postgresql-client $ sudo apt-get install postgresql-client

Check integrity of a file using MD5 sum and verify authenticity via GPG

When you download a file from a website, sometime the website also provide some codes of MD5 sum result to check file integrity after downloading. MD5 sum result can be generated using this command. $ md5sum download.file Then you can compare your result with code provided by the website. Next, to verify authenticity via GPG, use this following steps. - download the public key - download the authenticity key - run: $ gpg --import publickey.asc - run: $ gpg --verify authkey.asc downloaded.file

Tunneling SSH over HTTP Proxy

Many offices and campuses implement proxy server in their networks. This situation is frustating by most developer who maintain any server outside the office or campus networks. So tunneling SSH over HTTP proxy is a best deal for them. Some apps and methods can be used to do that. But, I found this following method is easy. Download corkscrew from http://www.agroman.net/corkscrew/ Extract the downloaded file $ tar -xzvf corkscrew.tar.gz Go into corkscrews extracted directory, configure, and install it $ cd corkscrew $ ./configure $ make install   Corkscrew is now installed in /usr/local/bin Add SSH configuration file on $HOME/.ssh/config Write these lines: Host *      ProxyCommand corkscrew proxy.example.com 8080 %h %p If your proxy use username and password, you can use this code: Host *      ProxyCommand corkscrew proxy.example.com 8080 %h %p ~/.ssh/proxyauth In ~/.ssh/proxyauth , put your credentials: <username>:<password> Now you can try $ ssh

Securely Files Transfer with Remote Server using SFTP

Recently I have post a note about how to transfer files among linux servers using terminal . Now I note some commands while using SFTP. Like SSH, we can start to establish connection with remote server using following command. $ sftp user@remote.server and some command that we'll like to use pwd : check current remote directory location ls : list all files in current remote directory cd : move to other remote directory lpwd : check current local directory location lls : list all files in current local directory lcd : move to other local directory get remoteFile localFile : download remoteFile to locaFile get -r someDirectory : download files recursively from a remote directory, -P or -p to maintain appropriate permission put localFile or put -r localDirectory to send files to remote server df -h to check directory space ! to go to local shell and exit to return to SFTP session Complete commands on Ubuntu manuals: http://manpages.ubuntu.com/manpages/utopic/m

How to Use SVN Command Line Tools in Ubuntu

Prerequisites You have SVN (Subversion) server where your project files will be stored. It also can be installed on same computer where you make your project. You have installed Subversion on local computer where your project is saved. These are some steps you can do. Checkout .  You must set a directory (your project directory) in local computer which files will be stored in SVN repository. $ svn checkout http://yoursvnserver.com/svn/path/to/repo/myproject /home/user/myproject It will create a ".svn" directory inside "/home/user/myproject/" and make "/home/user/myproject" as working copy. Import . This step will copy files from your local project directory to SVN repository. $ svn import /home/user/myproject http://yoursvnserver.com/svn/path/to/repo/myproject   Update or Commit . Update will download changes from SVN repository. Commit will upload files to SVN repository. Update will sync updated files to working copy. For more advance use, yo

Transfer File Among Linux Servers Using Terminal (Command Line)

When you operate some servers, sometime you need to transfer or copy some files from one server to another. There is command line tool that you can use like SCP. $ scp <file> <username>@<IP address or hostname>:<Destination> for example: $ scp "file.txt" user1@itb.ac.id:/home/user1/files If you want to copy file from remote server to local server just change the command. $ scp <username>@<IP address or hostname>:<Source> <LocalDestination> "LocalDestination" can be set to ' . ' to assign the file to current working directory. ' -r ' parameter can be set to copy directory recursively. Another tool you can use is SFTP. It maintain session so you can move files interactively between servers. $ sftp luki@myserver.com