December 2011
18 posts
2 tags
Checking the javascript type
Enter in console…
typeof object
Object can be any variable, objects, functions, strings, whatever…just play around with it.
2 tags
Open file in NetBeans from Mac Terminal
alias nb='/Applications/NetBeans/NetBeans\ 7.0.1.app/Contents/MacOS/netbeans --open'
Insert above code to ~/.profile
You can open file from terminal with nb index.php
4 tags
Syntax Highlighting for Mac Vi
Run
sudo vi /usr/share/vim/vimrc
Insert.. syntax on "turns on highlighting
set ai "turns on auto indent
set nu "turns on line numbers
I am not setting syntax on and set nu as auto in the rc file.
Perfer to turn them on as needed.
3 tags
Multiple windows in vi
:sp (horizontal)
:vs (vertical)
CTRL+W hjkl or up, down, left right to move around.
2 tags
Quit Vi easy mode
Found myself stuck in Vi easy mode.
CTRL+L
:qa!
Quit without saving
3 tags
Open Terminal from Finder
Settings -> Keyboard -> Services -> New Terminal at Folder
(restart Finder with killall Finder if it doesn’t work)
3 tags
Setting Virtual domain with XAMPP for mac
Sudo Edit the file /Applications/XAMPP/etc/extra/httpd-vhosts.conf
Refer to the examples in the file.
Insert Include conf/extra/httpd-vhosts.conf into
/Applications/XAMPP/etc/httpd.conf
Edit /etc/hosts and insert an entry for your doman that points to 127.0.0.1
Edit: For Lion users, add ::1 for every localhost domain that you have. This will speed things up a lot!
source:...
4 tags
Git fetch, push and merge
Lets say you created a new branch called “testbranch” on remote.
git fetch orgin
To fetch data from remote to local.
git merge origin/testbranch
To merge new “testbranch” branch.
git push origin testbranch OR git push origin
testbranch:testbranch
Former is a shorthand, latter is simply saying to push local
testbranch to remote testbranch.
2 tags
Git Diff
git diff
Shows changes between unstaged files and last commit
git diff head
Similiar to git diff
git diff --cached
Shows changes between staged files and last commit
2 tags
Vsphere Client
Download vSphere Client from the vSphere Server:
http://{your-server-ip}
source: http://www.thegeekstuff.com/2010/06/vmware-vsphere-client-install/
4 tags
Installing Windows 7 with Virtual Box in Mac OS X...
Here I’m trying to run Windows 7 with Virtual Box on my Mac.
Normal installation works fine,
Creating the drives,
Installing the OS
Well, problem came when I tried to share folders with my Mac.
Have to install Virtual Box Guest addition add on to do that.
Well, nothing happens when I clicked “Install Guest Additions…”
under Devices of VB menu. (You have to be running...
1 tag
Installing Kohana 3.2
If you’re getting this error:
HTTP_Exception_404 [ 404 ]: Unable to
find a route to match the URI: kohana-3.2 Check that your base_url is set eg:
Kohana::init(array( 'base_url' => '/kohana-3.2/', ));
3 tags
Installing xdebug with XAMPP on Mac
Follow instructions from http://xdebug.org/find-binary.php
to get the correct version of xdebug.
However, compile it with 32bit else you will find yourself trapped
with wrong architecture error.
./configure --enable-xdebug --with-php-config=/Applications/XAMPP/xamppfiles/bin/php-config CFLAGS="-arch i386 $CFLAGS" CCFLAGS="-arch i386 $CCFLAGS" CXXFLAGS="-arch i386 $CXXFLAGS" LDFLAGS="-arch i386...
1 tag
My new .profile
A shorter and more colorful prompt
#the prompt
#export PS1="\u@\h\w--\d--\t$"
alias gitbs="git branch | grep '^* ' | awk '{print \$2}'"
alias gitprompt="git status -s 2>/dev/null >&2 && echo \"(\`gitbs\`) \""
colorlightblue="\[\033[0;34m\]"
colorlightgreen="\[\033[0;32m\]"
colorred="\[\033[0;31m\]"
endcolor="\[\033[m\]"
export PS1="${colorlightgreen}\w${endcolor}"
PS1="$PS1...
5 tags
Common ports
HTTP
Port 80
FTP
Port 21
SSH
Port 22
5 tags
Install swftools Mac / Linux
Mac
Use Macports to install on Mac
However, use sudo port install foo configure.compiler=llvm-gcc-4.2
to install if you’re on lion os.
Check out the problemhotlist if you still encounter problems.
source: https://trac.macports.org/wiki/ProblemHotlist Linux
source:
http://www.betaquest.com/2010/08/how-to-install-swftools-0-9-1-on-centos-5-5/
Follow the steps and pray that it works.
2 tags
Listing all installed packages in Mac
source: http://forums.macrumors.com/showthread.php?t=817008 pkgutil --pkgs
3 tags
Setting up proftpd with mysql authentication
source:
http://heker86.wordpress.com/2008/10/21/how-to-install-and-configure-proftpd-with-integrate-the-mysql/ http://en.gentoo-wiki.com/wiki/ProFTPD/MySQL#Use_flag
The second link is secondary. Basically just to add a log file for sql
logs.
Most steps in link 1 is valid. Except for # create a user's home directory on demand if it doesn't exist SQLHomedirOnDemand on
Use # create a user's home...
November 2011
23 posts
5 tags
User management in Unix/Linux/OS X
source: http://www.linuxquestions.org/questions/linux-newbie-8/how-to-list-user-in-linux-box-add-an-user-to-a-group-386387/ http://www.cyberciti.biz/faq/howto-linux-add-user-to-group/
Listing Groups cat /etc/group | cut -d":" -f1
Adding Groups groupadd developers
Listing Users cat /etc/passwd | cut -d":" -f1
Adding Users useradd -G developers tom
Add User Password passwd vivek
3 tags
Setting up proftpd in Centos →
3 tags
How to clone virtual machines in VMware ESXi →
3 tags
Getting back Mouse control in Vsphere Client...
CTRL + ALT
5 tags
Chrome http poster alternative
Advanced REST client
https://chrome.google.com/webstore/detail/hgmloofddffdnphfgcellkdfbfbjeloo
3 tags
My new .profile
My new .profile
The previous post on .profile has errors cause the formatting ran.
#the prompt
#export PS1="\u@\h\w--\d--\t$"
alias gitbs="git branch | grep '^* ' | awk '{print \$2}'"
alias gitprompt="git status -s 2>/dev/null >&2 && echo \"(\`gitbs\`)...
4 tags
Some Useful apps for mac
Paragon NTFS reader
Stuffit
Adium
Sizeup
AppCleaner
TotalFinder
3 tags
Default Mac key binding →
2 tags
Check if apache is running and start it Centos
I had this problem where i could ssh and ping the centos server,
however, was not able to connect to it with the browser.
Check if DNS is configured correctly:
source: http://www.centos.org/modules/newbb/viewtopic.php?viewmode=flat&order=DESC&topic_id=11989&forum=40&move=next&topic_time=1199523861 cat /etc/resolv.conf
/bin/netstat -r
Check Apache is running:
source:...
3 tags
Push new branch to Github
source: http://gitready.com/beginner/2009/02/02/push-and-delete-branches.html
Pushing to remote
git push origin newfeature
add -u for tracking
Two steps involve to remove a branch
1. Remove remote
git push origin :newfeature
2. Remove local
git branch -d newfeature
4 tags
Transfer files with terminal
source: http://hintsforums.macworld.com/archive/index.php/t-29244.html
copy from a remote machine to my machine: scp
user@192.168.1.100:/home/remote_user/Desktop/file.txt
/home/me/Desktop/file.txt
copy from my machine to a remote machine: scp /home/me/Desktop/file.txt
user@192.168.1.100:/home/remote_user/Desktop/file.txt
copy all file*.txt from a remote machine to my machine...
3 tags
Installing Git in Centos5
Update: yum install git
It works like a charm
No configurations needed. So can ignore all the below.
Basically I followed the routines as stated on this site: http://kb.liquidweb.com/install-git-on-centos-5/ yum -y install zlib-devel openssl-devel cpio expat-devel
gettext-devel
cd /usr/local/src
wget http://kernel.org/pub/software/scm/git/git-1.6.4.tar.gz
tar xvzf git-1.6.4.tar.gz
cd...
5 tags
Changing IP address for Centos
In the command prompt, enter “setup” Go Network Configurations -> Edit Devices->eth0
Scroll to DHCP, press space to unselect.
Enter your static IP, and the Netmask (if applicable).
Save everything the type “reboot” to restart server.
3 tags
Cloning virtual machine from VM vsphere client
Select the main host
Under Summary Right click on database and Browse Datastore
Select the .vmk and .vmdk files from which you want to clone
Create a new folder as target
Copy the files into target folder
Right click on .vmk file and add to inventory
You’re done!
Can proceed to start up in vSphere client
Note: Need to stop or suspend the source machine in order to copy the
files.
4 tags
Changing Configure lion terminal color
Just changed my terminal colors based on the theme installed from http://blog.toddwerth.com/entries/13
After running the terminal script go to terminal settings to make it
the default theme. I changed the font size to 10 and the background to dark grey.
The colors didn’t show at first, had to include this line in .profile
“export CLICOLOR=1”; Its mentioned in the comments below...
3 tags
Download Drupal with drush
This downloads fresh copy of latest drupal site to the current directory in its designated folder.
Eg drupal-7.9 drush dl --debug
I had to use sudo command to do that. Probably because XAMPP is installed outside of user home directory at /Application/XAMPP
6 tags
Change ownership and group mac
You can change the owner and group of a file or a directory with the chown command. Please, keep in mind you can do this only if you are the root user or the owner of the file.
chown -R username directory
-v for verbose eg -Rv
-R for recursive, eg for directory
chgrp -R usergroup directory
-R, -v same as chown
3 tags
Show hidden files in Finder
defaults write com.apple.Finder AppleShowAllFiles YES
Relaunch Finder by holding option key and open context menu of finder in the dock.
Choose Relaunch
3 tags
Mac filename with spaces
Either specify in quotes “hello world” or hello\ world.
The 2nd method escapes the space character.
2 tags
Helpful Mac Shortcut
Control-Eject
Show shutdown dialog
Option-Command-Eject
Put the computer to sleep
Control-Command-Eject
Quit all applications (after giving you a chance to save changes to open documents), then restart the computer
Control Option-Command-Eject
Quit all applications (after giving you a chance to save changes to open documents), then shut down the computer
Mac Terminal...
4 tags
Listing ls only directories in Linux
$ ls -l | grep “^d”
http://embraceubuntu.com/2005/10/19/list-only-the-directories/
Linux directory switching changing behaviour →
6 tags
Installing Pear and Drush on Mac Lion
Getting installation file from pear
sudo curl http://pear.php.net/go-pear.phar > go-pear.php
Start installation
sudo php -q go-pear.php
Change Installation Base
/usr/local
Proceed Install
Duplicate php.ini.default to php.ini
sudo cp /etc/php.ini.default /etc/php.ini
Edit /etc/php.ini
include_path=”.:/usr/local/share/pear”
Add /usr/local/bin to path in .profile (create the...
October 2011
1 post
3 tags
My .profile
alias ki=’open -a “Komodo Edit”’
alias gitbs=”git branch | grep ‘^* ’ | awk ‘{print \$2}’”
alias gitprompt=”git status -s 2>/dev/null >&2 && echo "(`gitbs`) "”
colorblue=”\[\033[0;34m\]”
colorred=”\[\033[0;31m\]”
endcolor=”\[\033[m\]”
...
September 2011
2 posts
4 tags
Switching Tab in Mac Terminal
You can also cycle tabs left and right in Terminal.app with ⌘{ and ⌘} (listed in the Window menu), or (my preference) ⌘⇧← and ⌘⇧→.
(http://ciaranwal.sh/2007/12/10/tab-switching-in-terminal)
1 tag
Firefox addon
JSON view
Poster
August 2011
2 posts
4 tags
Codeigniter Coding Style Guide
File Format/Encoding: UTF-8, with no BOM
Line Endings: Unix LF
PHP Closing:
Do no use ?>
Use: /* End of myfile.php */ /* Location: ./system/modules/mymodule/myfile.php */
Class and Method Naming
eg: class Super_class eg: function get_properties()
Class names starts with Uppercase. Class method all in lower case. Every word separated by underscores.
Variable Name
...
2 tags
CodeIgniter Routes and URI segment
$route[‘promotion/(:num)/(:num)/share’] = “promotion_detail/share/$1/$2”;
$this->uri->segment(2) = $1
$this->uri->segment(3) = $2