Profile

Click to view full profile
Hi, I'm Veerapat Sriarunrungrueang, an expert in technology field, especially full stack web development and performance testing.This is my coding diary. I usually develop and keep code snippets or some tricks, and update to this diary when I have time. Nowadays, I've been giving counsel to many well-known firms in Thailand.
view more...
Showing posts with label Mac. Show all posts
Showing posts with label Mac. Show all posts

Monday, November 28, 2011

Run internet required commands behind a proxy server in Linux

Most of the time I need to run a terminal behind a proxy server at my office to run a batch job, and I failed to run it because I don't know how to add proxy server in the terminal. But, now, I just found the command to add a proxy server in Linux. It's very simple just only one line :)

Open terminl and type this command
# Changing username, password, proxyname, and port to be yours.
export http_proxy="http://username:password@proxyname:port"
# After that you can test to run behind your proxy server
# , simply as following.
wget http://www.google.com
# If the connection is successful, then you will get the 
# file from this Google page.

To remove the proxy server from your network run the following command:
# Just delete a proxy sever variable using unset 
unset http_proxy
# Or set http_proxy to blank
export http_proxy=""

The example above is how bind a proxy server in HTTP protocol.
For the other protocols, e.g. FTP, ... so on. Try to find its variable for binding with a proxy server.
Another protocol that I know is FTP.
FTP => ftp_proxy
If you want to remove it, do the same as the example above.

Good luck ^^.

How to restart Linux network service

Sometime you may need to update your network immediately, e.g. DHCP and IP under a virtualization software, ... so on. The fastest way is to restart the network service.

You need to login as root user before using the following commands!!!

RedHat Linux command to reload or restart network:
# To restart Linux network service:
$ service network restart
or
$ /etc/init.d/network restart

# To start Linux network service:
$ service network start

# To stop Linux network service:
$ service network stop
Debian Linux command to reload or restart network:
# To restart Linux network service:
$ /etc/init.d/networking restart

# To start Linux network service:
$ /etc/init.d/networking start

# To stop Linux network service:
$ /etc/init.d/networking stop
Ubuntu Linux user use sudo command with above Debian Linux command:
# To restart Linux network service:
$ sudo /etc/init.d/networking restart

# To start Linux network service:
$ sudo /etc/init.d/networking start

# To stop Linux network service:
$ sudo /etc/init.d/networking stop

Credit: http://theos.in/desktop-linux/tip-that-matters/how-do-i-restart-linux-network-service/

Monday, April 25, 2011

Cut Automator script for Mac with Automator

One thing that caused a lot of problems for me in Mac is there is no "cut" short key like "ctrl+x" in Windows. I had to dragged items, sometimes it's hard to do like that. So far, I tried to develop "Cut Script" with Automator. It can be used by using right clicking to the item, then select the path to move.

You can create it as following steps:
1. Open Automator from your Application.
2. Service receives selected change to "files or folders" and in to "Finder".
3. Drag "Get Selected Finder Items" to the Automator space.
4. Drag "Set Value of Variable", and change its name to "item".
5. Drag "Apple Script".
Step 3-5
6. Drag "Ask for Finder Items", and change type(Type:) to "Folders".
7. Drag "Set Value of Variable", and change its name to "path".
8. Drag "Apple Script".

Step 6-8
9. Drag "Get Value of Variable", and change its name to "item".
10. Drag "Move Finder Items", and change to(To:) to "path".

Step 9-10
Download

In addition, you can also download it, and then place it into your profile service folder (~/Users/[User]/Library/Services/).
Now, you can move your file faster with easy steps. Don't have to drag anymore!

Saturday, April 2, 2011

How to install Python Imaging Library (PIL)

Python Imaging Library is a library for doing image processing tasks just as its name. In Windows you can install it easily by downloading PIL windows installer, but in Linux and Mac are more harder. You have to compile and install it from a source package. PIL also need other libraries in order to install it completely as followings: JPG, Freetype, LittleCMS 1.19 NOT 2.0+.

In Linux, you may install those libraries via your command line. For example, sudo apt-get install (Ubuntu). Then, install PIL.

However, in Mac, you have to install Xcode and X11 to make your Mac can use "./configure" and "make" command. After that, installing MacPorts or Fink which allow you to get those required libraries and download them via command line (use "port install" or "fink install" respectively). Finally, install PIL after installing dependent libraries.


You can download PIL from here (all platforms): from http://www.pythonware.com/products/pil/

To install PIL from source package do steps follows:
1. Change current directory of your terminal under PIL source folder.
2. Type "sudo python setup.py build_ext i".
3. Run the test "python selftest.py".
4. If everything is fine, then install it by typing  "sudo python setup.py install".

Then, you should run PIL example code to make sure installation is complete. If not or in the case that you already installed PIL, you need to delete its package from site-package in python library. Then, you have to extract PIL source package from zip file again (do not use older extracted folder because it won't work for sure). Build it again, then install.

p.s. Required libraries: libjpeg, freetype, lcms

Sunday, March 20, 2011

How to show hidden files in Mac

It's very easy by do as following:
1. Open "Terminal"
2. type "defaults write com.apple.finder AppleShowAllFies TRUE"
3. Then type "killall Finder" to restart Finder

Note: If you want to change back to hidden files, just change TRUE into FALSE

Monday, February 28, 2011

LaTex Editor and Compiler

For Windows, we can use TeXnicCenter from http://www.texniccenter.org/ and use MikTex as a LaTex compiler from http://miktex.org/.

For Mac, you can just install MacTex package from  http://www.tug.org/mactex/ easily.

Friday, February 25, 2011

How to fix Boot Camp time offset

I have a problem with the time in Boot Camp. Everytime I use Windows and then comeback to use OSX, the current time will be changed all the time. It's very annoying. Now, I just found the solution from this blog: http://grupenet.com/2007/12/04/fix-boot-camp-time-offset/. It's very useful.

There are 3 steps:
1. Open your notepad.
2. Copy and paste the following:
@echo off
net time /setsntp:tick.usno.navy.mil
net stop w32time
net start w32time
3. Copy it into "Startup" folder in Startup menu

Now every time you start up Windows, it will fix the time offset automatically.
p.s. If it doesn't work, try to use automate sync time. If you can access internet, the time will be synchronized automatically.

Friday, February 18, 2011

Simple way to export files from iPods

There are many to export files from iPods but I just found this solution is very simple. After you install the program and then open it. It will show the contents from your iPods. Finally, you just drag and drop files into your location. This application is called DeTune.

Wednesday, February 16, 2011

How to copy fonts in Mac

There are 2 ways to do that.
1. Copy directly by copy fonts into /Library/Fonts/
2. Go to application -> open Font Book -> import fonts

p.s. If want to export text to other computer, can use .pdf. It can be read in any machine without fonts installation problem.

Thursday, February 10, 2011

Quick open terminal in Mac by using one click

In the past, I post about quick open terminal in Windows and Ubuntu. Now, it's a time for Mac.
You can do it by download one of them (they're very similar).
1. http://code.google.com/p/cdto/
2. http://homepage.mac.com/thomasw/OpenTerminal/

After download, you have to drag it icon into finder bar.


It's very easy to use by click at an icon or drag folder to an icon. Then, it will open terminal at the current or selected directory.

^^

For Windows: http://darkkung-blog.blogspot.com/2010/10/open-command-window-at-current-path-in.html
For Linux-Ubuntu: http://darkkung-blog.blogspot.com/2010/10/quick-open-teminal-in-ubuntu-by-using.html

p.s. You can create it by yourself by using "Automator" by looking at http://www.macworld.com/article/47793/2005/11/folderinterm.html for more details.

How to add restore session tabs feature to Mac Safari

Last week, I got MacBook Pro. It's the first time I used Apple product. I got new experience and satisfaction for using it. But I have many newcomer common problems. For example, Read and write in NTFS hard disk, Office software, Left menu tab, How to install software, New Keyboard and shortkey, and the most basic thing like web browser.

For me, restore the last open session tabs feature is very important. So, I have to use Safari plugin e.g. SafariStand that can restore tabs.
The installation guide is here:


Now, I can enjoy with Safari ^^.