Category Archives: Tools

How to migrate SVN repository?

Now my repository locate in /var/www/vhosts/repository/zend

and I need to migrate the repository to /var/svn/repository/zend

1. Dump repository


# svnadmin dump /var/www/vhosts/repository/zend > zendProjectRepo.dump

2. Move the dump file to new path.

# mv /var/www/vhosts/repository/zend/zendProjectRepo /var/svn/repository/

3. Create new repository and load the dump file

# cd /var/svn/repository/

# svnadmin create zend

# svnadmin load zend < zendProjectRepo.dump

Done!, now we just migrate svn repository to new location :)

Posted in Tech Note, Tools | Tagged , , | Leave a comment

[SVN] Sync repository and working copy when committing

I have Developing server and Live server separately. and update source after commiting to working copy is kind of annoying job. (For Live server, I strongly recommend to update source one by one)

# ls /repos_path/hooks

There are some hooks for SVN events.

Now we need to hook SVN update action to post-commit (when committing)

# cp post-commit.tmpl post-commit

# chown svn:svn post-commit

# chmod +x post-commit

# vi post-commit

and Add this line,

svn update [working_copy_path]

ex) svn update /var/www/vhosts/zend

Finish setting post-commit hook. try committing source, the working copy source will be changed automatically.

If it does not working, try to restart SVN service.

Posted in Tech Note, Tools | Tagged , , | Leave a comment

[SVN] How to manage multiple project with SVN

Let’s suppose I have 3 projects.

1. Zend Project (path : var/www/vhosts/zend)

2. Symfony Project (path : var/www/vhosts/symfony)

3. Ci Porject (path : var/www/vhosts/ci)

Now I need to manage the 3 project with SVN. And I want to have each repository for each project, because the version (for version control) must be seperated.

Firstly, prepare SVN.

* Install SVN

# yum install -y subversion

* Add user for SVN

# adduser svnuser
# passwd svnuser

1. Create folder which will contain repositories.

(The repository location is not very important so wherever we can create)

I named the folder as repos and located in /var/www/vhosts/repos .

2. Create each folders for each repositories.

it should be like this,




3. Create repository for each project.

# svnadmin create --fs-type fsfs /var/www/vhosts/repos/zend (symfony and ci)

4. Check ownership for repository folder

# chown -R svnuser/svnuser /var/www/vhosts/repos/zend (symfony and ci)

5. Setup SVN setting file

# vi /var/www/vhosts/repos/zend/conf/svnserve.conf (symfony and ci)


anon-access = read

auth-access = write

password-db = passwd

and setup password

# vi /var/www/vhosts/repos/zend/conf/passwd (symfony and ci)


svnuesr = 1234567890

6. Run SVN (Daemon)

# svnserve -d -r /var/www/vhosts/repos (*repos -> repository container folder)

(-d : daemon, -r : repository)

– Check svn running,

# ps -aux | grep svnserv

root     11160  0.0  0.0  10284   896 ?        Ss   14:08   0:00 svnserve -d -r /var/www/vhosts/repos

# netstat -ant | grep 3690

tcp        0      0      *                   LISTEN

7. Generate directories for SVN (trunk, branches and tags)

– setup for SVN_EDITOR

# vi ~./bash_profile



*svn: None of the environment variables SVN_EDITOR, VISUAL or EDITOR are set,
and no ‘editor-cmd’ run-time configuration option was found

If you get like this error message, please check SVN_EDITOR setting

– Generate Trunk

# svn mkdir svn:// (symfony and ci)

Editor will be opened automatically then

:q (close)

c (to continue)

then, it might ask you root password. then type root password.

– Generate Branches

# svn mkdir svn:// (symfony and ci)

(( same to above))

– Generate Tags

# svn mkdir svn:// (symfony and ci)

(( same to above ))

– Check directories

# svn list svn://

output :




8. Import project files into trunk if there is already.

# svn import (project dirctory) svn://(repository_url)/trunk

vhosts# svn import zend svn://

9. Check out

# svn checkout svn://(repository_url)/trunk (project directory)

– If there is project file already, delete it (make sure import all the files into trunk before delete!)

vhosts# svn checkout svn:// zend

For client (like your desktop), do checkout same way above.


Posted in Tech Note, Tools | Tagged , , , , | Leave a comment

Verify US address and figure out residential or commercial address

For Json type output, put the returntype=json into the url


* It uses UPS address validation street level

Sample Code Download : Download Sample Code

Note : If you care about commercial and residential shipping address, you could save around 20% shipping fee.

Posted in Tech Note, Tools | Tagged , , , | 6 Comments

Exponential Moving Avg

Posted in Tech Note, Tools | Tagged , , , | Leave a comment

Get location From IP Address (Json Type or Text)

I had a little free time, so I made getting location from IP address.

The main purpose was I want to test PostgreSql performance. and I get a satisfied result. :) and it use Maxmind Free GeoIp Database.

try this

To get the location using IP Address, please put the IP into ip parameter.

EX )

Return :

Default return type is json type, also you can select the type in ‘country’,’region’,’city’,’postalCode’,’json’
EX )

Return :

The location database is from MaxMind.
and database server is PostgreSQL
If you have any question, please email me at
Thank you, and have a great day!

Posted in Tech Note, Tools | Tagged , , , , , | Leave a comment

Browser Shortcut keys

Reduce wrist pain tip^^, Browser shortcut keys

Ctrl+N Open a new window
Ctrl+T Open a new tab
Ctrl+W Close the current window/tab
Ctrl+R Refresh
Esc Stop
Alt+ Back
Alt+ Forward
Alt+Home Go to your homepage
Alt+D Move focus to the address bar to type in a URL
Ctrl+Enter Add “http://www.” and “.com” around an address
MiddleClick Middle-clicking a tab will close it, even if it’s not the active tab
Posted in Tech Note, Tools | Tagged , | 4 Comments

How to get youtube thumbnail and video information. (Using GAPI)

I got a order from my supervisor making youtube video gallery today.

So that, I need to get youtube thumbnail image for listing.

I just test my code and I confirmed it works well. So, I’d like to show you how to get youtube thumbnail.

My envirment is WAMP. So I refered this api manual.

1. Firstly, download PHP Client Library

and extract to the folder you want.

2. GAPI run based on Zend Framework. So we need to install Zend Framework first.

(* You don’t have to download Zend Framework, because the Google Client Library already has it.)

Now, we need to tell to our PHP ‘Hey, I gonna use Zend Framework ,so make it ready!’

In my case, I’m using windows (This is my test server)

I add a command line into php.ini file.

# include_path = “c:\your_library_path”

# In my case

include_path = "c:\wamp\www\youtube\library"

If you are using Linux,

# include_path = [DOCUMENT_ROOT]/library


* If you do not know your DOCUMENT ROOT path, then try to print out


more info, check this :

For testing your setting, try to run this script.

If you got the same result as above, then it’s installed successfully.

If not, check your php.ini file again.

Now we are all ready to surfing youtube API ioi

( , all these functions are yours!)

Let’s get a thumb nail for a youtube video.

I choose this movie ‘Miley Cyrus is Justin Bieber – PARODY – SNL / Saturday Night Live 2011’

The url is ‘

Create test.php file, and typing code like this,


require_once 'Zend/Loader.php'; // the Zend dir must be in your include_path

$yt = new Zend_Gdata_YouTube();
$videoEntry = $yt->getVideoEntry(VIDEO_ID);


We need to get VIDEO_ID for getVideoEntry parameter.

How we get? the url contain the VIDEO_ID.

Now we know the VIDEO_ID.

Finally! let’s get the thumbnail url using getVideoThumbnails() function.


require_once 'Zend/Loader.php'; // the Zend dir must be in your include_path

$yt = new Zend_Gdata_YouTube();
$videoEntry = $yt->getVideoEntry('wst4zG_BNUg');

$videoThumbnails = $videoEntry->getVideoThumbnails();


Output :

It show various thumbnail, but I need only first one.

If you curious the other thumbnails, try to output:

$thumbSize = sizeof($videoThumbnails);
for($i=0; $i<$thumbSize; $i++){
echo "<img src='{$videoThumbnails[$i]['url']}' /><br />";

For first one ::

echo "<img src='{$videoThumbnails[0]['url']}' />";

output :

Ok, we got the thumb nail now.

Let’s make url link the image to youtube.

echo 'Flash Player Url: ' . $videoEntry->getFlashPlayerUrl() . "<br />";
echo "<a href='". $videoEntry->getFlashPlayerUrl() ."'><img src='{$videoThumbnails[0]['url']}' /></a>";

The other useful functions,

function printVideoEntry($videoEntry)
// the videoEntry object contains many helper functions
// that access the underlying mediaGroup object
echo 'Video: ' . $videoEntry->getVideoTitle() . "<br />";
echo 'Video ID: ' . $videoEntry->getVideoId() . "<br />";
echo 'Updated: ' . $videoEntry->getUpdated() . "<br />";
echo 'Description: ' . $videoEntry->getVideoDescription() . "<br />";
echo 'Category: ' . $videoEntry->getVideoCategory() . "<br />";
echo 'Tags: ' . implode(", ", $videoEntry->getVideoTags()) . "<br />";
echo 'Watch page: ' . $videoEntry->getVideoWatchPageUrl() . "<br />";
echo 'Flash Player Url: ' . $videoEntry->getFlashPlayerUrl() . "<br />";
echo 'Duration: ' . $videoEntry->getVideoDuration() . "<br />";
echo 'View count: ' . $videoEntry->getVideoViewCount() . "<br />";
echo 'Rating: ' . $videoEntry->getVideoRatingInfo() . "<br />";
echo 'Geo Location: ' . $videoEntry->getVideoGeoLocation() . "<br />";
echo 'Recorded on: ' . $videoEntry->getVideoRecorded() . "<br />";

// see the paragraph above this function for more information on the
// 'mediaGroup' object. in the following code, we use the mediaGroup
// object directly to retrieve its 'Mobile RSTP link' child
foreach ($videoEntry->mediaGroup->content as $content) {
if ($content->type === "video/3gpp") {
echo 'Mobile RTSP link: ' . $content->url . "<br />";

echo "Thumbnails:<br />";
$videoThumbnails = $videoEntry->getVideoThumbnails();

foreach($videoThumbnails as $videoThumbnail) {
echo $videoThumbnail['time'] . ' - ' . $videoThumbnail['url'];
echo ' height=' . $videoThumbnail['height'];
echo ' width=' . $videoThumbnail['width'] . "<br />";

More functions,

Please check Google API Manual :

My Youtube Class

require_once 'Zend/Loader.php'; // the Zend dir must be in your include_path

class Get_youtube_thumb {
protected $_video_codes;
protected $_thumbs = array();

public function __construct($video_codes){
throw new Exception('Video_codes are required!');
throw new Exception('Video_codes should be an array!');

$this->_video_codes = $video_codes;

protected function set_thumbs(){
$code_size = sizeof($this->_video_codes);

for($i=0; $i<$code_size; $i++){
$yt = new Zend_Gdata_YouTube();
$videoEntry = $yt->getVideoEntry($this->_video_codes[$i]);
$videoThumbnails = $videoEntry->getVideoThumbnails();

$this->_thumbs[$i]['code'] = $this->_video_codes[$i];
$this->_thumbs[$i]['thumb'] = $videoThumbnails[0]['url'];

public function get_thumbs(){
return $this->_thumbs;

$test_array = array('zwJef-hQ4Pk','9jArUdIQ9kw','8uUzvBhCMKQ','liHKFvMJ0p4','UfcvO2t8Ntg');
$yt = new Get_youtube_thumb($test_array);
$tm = $yt -> get_thumbs();
echo "<ul>";
for($i=0,$tm_size=sizeof($tm); $i < $tm_size; $i++){
echo "<li><a href=\"javascript:get_video('{$tm[$i]['code']}')\"><img src='{$tm[$i]['thumb']}' /></a></li>";
echo "</ul>";

Posted in PHP, Tech Note, Tools, Works | Tagged , , , , , , | 8 Comments

Get mailchimp campaign ID

Campaign 페이지의 URL 을 보면,

이런식으로 뒤에 id=하고 숫자가 있는데 이게 절대 Campaign ID가 아니다. 이걸

API에 물리면 아무런 결과값을 얻을수 없을것이다.

그럼 어디에 있느냐!

Campaign List에서 원하는 Campaign을 클릭한다.

커다란 제목 밑에,

campaign archive 라고 있다, 클릭해보면


와 같이 id= 하고 campaign Id를 볼수 있다.

Posted in Tools | Leave a comment

Eclipse SVN

Posted in Tools | Leave a comment