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 REPOSITORY_PATH > FILE_NAME

# 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,

../repos/zend

../repos/symfony

../repos/ci

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)

[General]

anon-access = read

auth-access = write

password-db = passwd

and setup password

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

[user]

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 0.0.0.0:3690                0.0.0.0:*                   LISTEN

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

– setup for SVN_EDITOR

# vi ~./bash_profile

SVN_EDITOR=/usr/bin/vim

export SVN_EDITOR

*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://repos.test.com/zend/trunk (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://repos.test.com/zend/branches (symfony and ci)

(( same to above))

– Generate Tags

# svn mkdir svn://repos.test.com/zend/tags (symfony and ci)

(( same to above ))

– Check directories

# svn list svn://repos.test.com/zend

output :

branches/

tags/

trunk/

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

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

vhosts# svn import zend svn://repos.test.com/zend/trunk

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://repos.test.com/zend/trunk 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

http://uniapple.net/usaddress/

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

Ex) http://uniapple.net/usaddress/address.php?address1=3913+21st&address2=&city=long+island+city&state=ny&zipcode=11101&country=US&returntype=json

* 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)

http://uniapple.net/geoip/

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 http://uniapple.net/geoip/

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

EX ) http://uniapple.net/geoip/?ip=24.24.24.24

Return :
{“country”:”US”,”region”:”NY”,”city”:”Binghamton”,”postal_code”:”NULL”,”latitude”:”42.1393″,”longitude”:”-75.8798″,”metro_code”:”502″,”area_code”:”607″}

Default return type is json type, also you can select the type in ‘country’,’region’,’city’,’postalCode’,’json’
EX ) http://uniapple.net/geoip/?ip=24.24.24.24&type=country

Return :
US

The location database is from MaxMind.
and database server is PostgreSQL
If you have any question, please email me at ilovekanon@gmail.com
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.

http://code.google.com/intl/ko-KR/apis/youtube/2.0/developers_guide_php.html#Getting_Started

1. Firstly, download PHP Client Library

http://framework.zend.com/download/gdata/

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

include_path="/home/content/a/b/html/youtube/library"

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

echo $_SERVER['DOCUMENT_ROOT'];

more info, check this : http://code.google.com/intl/ko-KR/apis/gdata/articles/php_client_lib.html#appendix_phpini

For testing your setting, try to run this script.

http://framework.zend.com/svn/framework/standard/trunk/demos/Zend/Gdata/InstallationChecker.php

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

(http://code.google.com/intl/ko-KR/apis/youtube/2.0/developers_guide_php.html#Getting_Started , 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 ‘http://www.youtube.com/watch?v=wst4zG_BNUg&feature=youtube_gdata_player

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

<?PHP

require_once 'Zend/Loader.php'; // the Zend dir must be in your include_path
Zend_Loader::loadClass('Zend_Gdata_YouTube');

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

?>

We need to get VIDEO_ID for getVideoEntry parameter.

How we get? the url contain the VIDEO_ID.

http://www.youtube.com/watch?v=wst4zG_BNUg&feature=youtube_gdata_player

Now we know the VIDEO_ID.

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

<?php

require_once 'Zend/Loader.php'; // the Zend dir must be in your include_path
Zend_Loader::loadClass('Zend_Gdata_YouTube');

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

$videoThumbnails = $videoEntry->getVideoThumbnails();
print_r($videoThumbnails);

?>



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 :

http://code.google.com/intl/ko-KR/apis/youtube/2.0/developers_guide_php.html#Getting_Started

============================================================================================
============================================================================================
My Youtube Class
============================================================================================

<?php
require_once 'Zend/Loader.php'; // the Zend dir must be in your include_path
Zend_Loader::loadClass('Zend_Gdata_YouTube');

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

public function __construct($video_codes){
if(!isset($video_codes)){
throw new Exception('Video_codes are required!');
}
if(!is_array($video_codes)){
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();
$yt->setMajorProtocolVersion(2);
$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(){
$this->set_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('http://www.youtube.com/embed/{$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 을 보면,

http://us2.admin.mailchimp.com/campaigns/show?id=724557

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

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

그럼 어디에 있느냐!

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

커다란 제목 밑에,

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

URL에 http://us2.campaign-archive.com/?u=a5fbac57cdc61a4fc3a6a263d&id=1b03ae32ff

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

Posted in Tools | Leave a comment

Eclipse SVN

http://subclipse.tigris.org/svn/subclipse/
http://blog.jidolstar.com/552

Posted in Tools | Leave a comment