Showing posts from May, 2010

PHP로 Short URL API 사용하기

Short URL 서비스의 API를 이용하여 URL 줄이기는 AJAX/JQuery 를 사용하는 예제였는데, 아래와 같이 PHP로 간단하게 사용가능합니다. :)

<?php function getShortURL($longUrl) { $url = ""; $url .= urlencode($longUrl); $data = file_get_contents($url); $json = json_decode($data, true); return "".$json['shorturl']; } echo getShortUrl(""); ?>

Chrome Extension 개발하기 - Getting Started (Hello, World!)

1. Create a folder somewhere on your computer to contain your extension's code.

컴퓨터 어딘가에 extension code개발할 폴더를 하나 만듭니다.

2. Inside your extension's folder, create a text file called manifest.json, and put this in it:

JSON 포맷의 manifest 파일을 하나 생성합니다. 파일인코딩은 반드시 UTF-8 로 해야 한글이 안깨집니다. ㅋ

* 개발자들은 많이 봤겠지만 manifest는 양키들도 일상에서는 잘 안쓰는 말인데, 사전적의미로는 "명백한, 분명한, 일목요연한" 으로 나오나 한국의 뉘앙스로는 "택배에 배송지/연락처 등등이 잘 정리되어 붙은 스티커" 같은 의미정도 되는것 같네요.

내용은 모두 직관적이라 생략합니다.

{ "name": "Hello World Extension", "version": "1.0", "description": "The first extension that I made.", "browser_action": { "default_icon": "icon.png", }, "permissions": [ "" ] }
3. Copy this icon to the same folder:

"default_icon": "icon.png" 부분에 선언된 바와 같이, extension 폴더 내에 icon.png 를 생성해서 넣어줍니다. 이 icon은 Chrome 에 출력될 버튼의 icon입니다.

4. Load the extension…

Ubuntu eclipse + subclipse 에서의 Failed to load JavaHL Library

- Ubuntu Desktop에서 Eclipse를 활용한 개발환경 구성하기(3)


$ sudo apt-get install libsvn-java

PageRank Implementation Using the BSP

In this post, I'm showing how to implement the PageRank using BSP.
P.S. Apache Hama's BSP framework is not ready yet.

And P.S. again, The pseudo code is developed, based on Java multi-threaded programming. As I introduced before (Hama BSP), the BSP programming is very similar to multi-threaded programming (See BSP serialize printing example). So, the BSP brings a familiar programming model to developers for implementing distributed applications. :-)

Anyway, let's assume that the web-graph G is stored in row sparse format as below:

Vertex: 1 2 3 4 5 6
Index: 0 1 3 4 6 8 10
IncomingEdgeList: 3 1 3 1 5 6 3 4 4 5

– Vertices V are web pages.
– Vertex index[] points to list of incoming edges's vertex.
The PageRank Algorithm is as below:

1) If vi links to vk…

– User equally likely to follow any link on page. – Probability of moving from vi to vk = 1/out_degree(vi).
2) If vi has no outlinks…

– User equally likely to jump to any state. – Probability = 1 / |V|
3) Weighted moves …

VirtualBox Kernel Errors on Ubuntu

솔직히 은행일만 아니면 깔고싶지 않은 것들인데.. 어쨌거나 설치하면서 만난 에러:

root@edward-desktop:/home/edward# sudo /etc/init.d/vboxdrv setup WARNING: All config files need .conf: /etc/modprobe.d/bttv.modprobe, it will be ignored in a future release. * Stopping VirtualBox kernel module * done. * Recompiling VirtualBox kernel module * Look at /var/log/vbox-install.log to find out what went wrong root@edward-desktop:/home/edward# cat /var/log/vbox-install.log Attempting to install using DKMS removing old DKMS module vboxdrv version 3.1.6 ------------------------------ Deleting module version: 3.1.6 completely from the DKMS tree. ------------------------------ Done. Creating symlink /var/lib/dkms/vboxdrv/3.1.6/source -> /usr/src/vboxdrv-3.1.6 DKMS: add Completed. Error! Your kernel source for kernel 2.6.3…

How to Install VirtualBox Guest Additions in Fedora 12

First, in the VM menu (not the Guest but the chrome around it) go to Devices > Install Guest Additions. It will mount a new disc image. Then fire up terminal.

$ su # yum install kernel-headers kernel-devel gcc # export KERN_DIR=/usr/src/kernels/ # cd /media/VBOXADDITIONS_3.1.2_56127 # ./
This time the kernel modules should compile. Then restart the system.

Update for 32-bit Guests:

A few possible changes if this doesn’t work for you with a 32-bit guest. (It didn’t for me, so I had to play around/research a bit more.)

# uname -rIf you see the letters PAE, then you’ll need to follow the rest of these steps. If you don’t see PAE, you should be fine.
If so, make sure your kernel is up to date with
# yum update kernel-PAE. After this, restart.
Instead of the kernel-devel package, you’ll need to install kernel-PAE-devel. That makes the second line of the example above:
# yum install kernel-headers kernel-PAE-devel gccIf you’d already …

The error message "An unknown error occured" of WordPress MU

It sometimes occur when the folder permissions or group ownership is not allowing the files to transfer over. However, In my case, php configuration was reason. The allow_url_fopen should be ON in PHP configuration (php.ini).

How to enable PHP JSON on Gentoo server?

URL shortener API를 php에서 사용해보려고 하다가 만난 삽질들인데...

CentOS 에서는
pecl install JSON해주면 되지만, gentoo에서는 뭔가 에러가 잔뜩 나온다. 이때,
USE="json exif" emerge dev-lang/php명령어로 설치해주면 되더군.

<?php $url = "".urlencode(""); echo $url; $response = str_replace(");","", str_replace("null(","",file_get_contents($url))); $json = json_decode($response, true); echo $json['shorturl']; ?>
Plus, file_get_contents() 함수에서 에러나면,

allow_url_fopen should be ON in PHP configuration (php.ini). Probably, you don’t have access to edit this file and it could also be that your hosting company has restricted changing the allow_url_fopen value. In this case, you should refer to them and ask them to set the value of allow_url_fopen to ON.

P.S. 프로그래밍 언어 중 내가 제일 싫어하는 것들: c, c++, php, sh…