폼에서 넘어온 변수값을 형태별로 재 정의

MongoDB 를 사용하면서 HTML Form 에서 넘어오는 데이터를 저장할 때, 별도로 datatype 을 선언하지 않으면 무조건 String 으로 저장되는 문제가 있어서, GET,POST,REQUEST 의 모든 변수를 재 정의하는 함수를 만들어, 페이지의 최 상단에서 처리하면 이 후에 해당 변수 처리 편하게 쓸 수 있다.

웹폰트 확장자(ttf,otf,woff)의 mimetype 지정 (nginx)

Chrome Console 을 보고 있자니 Errors 메시지를 보고 있자면 답답하다.

$ vi /etc/nginx/mime.types

맨 하단에 아래 3줄 추가 후 재시작

input[type="checkbox"] 의 폼전달의 문제 해결

코드를 작성할 때 어떠한 기능을 사용하는지 여부를 boolean 으로 기록하기 위하여 <input type="checkbox" name="foobar" value="true"> 와 같이 작성을 하여 체크를 한다. 사용자가 체크를 하게 되면 당연히 checked="checked" 속성이 지정되고 PHP에는 $_REQUEST['foobar'] = 'true'; 와 같이 전달이 되지만, 체크를 하지 않은 경우에는 해당 변수 자체를 선언을 하지 않고 보내게 된다. 즉 isset() 을 사용해도 false 가 떨어진다는 것이다.

당연한 이야기겠지만, 나는 $_REQUEST['foobar'] = ''; 와 같이 값은 비어있더라도, 변수가 선언이 되었는지 여부는 같이 와줘야 여러가지 복합상황에서의 코드 검열을 손쉽게 할 수 있지 않을까 한다는 생각이 들었다. 넘겨진 $_REQUEST 와 기존 데이터 변수와의 병합을 하기 위해서는 모든 변수를 다 isset() 로 체크할 수 없는 터라, input[type="checkbox"] 요소 앞에 같은 name input[type="hidden"] 을 삽입하여 해결을 했다.

간단히 요약하자면,

위와 같은 형태로 작성을 하면, $_REQUEST['foobar'] = 'false'; 와 같이 전달을 받을 수 있다.

귀차니즘용 for jQuery

php 5.3 에서 5.4 로 업데이트 시 알아둘 것

지금까지 php 5.3 대를 사용하면서 조만간 레거시로 넘어갈 조짐도 보이고, genghisapp.com 의 Mongo WebUI 매뉴얼에 php -S 옵션을 통해 단독 서버도 띄울 수 있는 기능이 있다고 하여 php 5.4 버전으로 업데이트를 하면서 문제가 생긴 부분을 기록한다.

my.cnf:old_password=1

이 말인 즉, php 의 MySQL Authenticate 에서 old password 에 대한 지원을 하지 않으므로, my.cnf 에서도 old_password 를 제거하고, MySQL 에서 모두 set password = password() 를 통해 암호를 업데이트 해줘야한다.

magic_quotes_gpc

역시 기본으로 제거가 되었다. SQL Injection 등을 위한 편의 옵션이었지만, 앞으로 코드 작성시 더 엄격하게 주의해야할 부분이다.

Thumbs.db 썸네일 캐싱 끄기

파일정리를 하다보면 수시로 보게 되는 창인데, 빈 폴더임에도 불구하고 썸네일 캐싱 짜내느라 분주하신 윈도우님 때문에 고생이 이만 저만이 아니다. XP때는 괜찮았는데, Vista, 7, 8 특히 심하게 나타난다.

캐싱을 끄는게 차후를 위해서 안좋을수도 있지만, 요새 컴퓨터 성능상 썸네일을 실시간으로 내는게 크게 힘든건 아니라 판단하기에, 과감하게 꺼버리도록 한다.

이전 7 까지는 탐색기 (Windows Explorer) 의 도구 > 옵션 > 고급에서 없앴지만, 역시나 Windows 8님은 특별하니까… gpedit.msc 에서 다음 이미지를 참고하여 해당항목을 Enable 하자

위의 경고창은 제발 다시는 보지마요. 윈도우님

참고링크 : http://social.technet.microsoft.com/Forums/en-US/W8ITProPreRel/thread/ed3a112e-df02-41b7-aace-09707113ae47/

php 5.3.9 이상의 버전에서 Access denied 가 뜬다면?

https://bugs.php.net/bug.php?id=60763

php 를 업데이트 이후 몇몇 페이지에서 access denied 라는 문구만 표시되는 문제가 있어서,
찾아보니 5.3.9 버전 이후부터, php-fpm.conf 에 다음과 같은 옵션이 추가 되었다고 한다.
php-fpm 을 backend 로 사용하는 대부분의 nginx, lighttpd 에서 발생한다.

만약 새로 설치를 하는 경우 security.limit_extension 항목이 존재하므로, .html 만 추가해주면 되지만,
기존 버전에서 업데이트 하는 경우에는 해당 옵션이 없으므로, 마지막 줄에 추가 해주면 된다.

security.limit_extension = .php .html

MagicMouse 가 느려질 때…

http://support.apple.com/kb/HT1365

요새 이상하게 마우스가 느려지는 현상이 발생하고 있다.

맥북프로를 2010년에 구입해서 지금까지 한번 그런적이 없다가.
사용패턴을 바꿔서 집에 외장모니터에 연결하고 데스크탑 대용으로 쓰기 시작하면서 느끼는 증상

CPU가 버벅 거리는 것도 아닌데, 이따금씩 트랙킹이 느려진다거나 멈춘다거나 하는 증상 때문에,
너무 불편해서 ‘아 Bluetooth 는 아직 주옥 같구나…’ 하며,
그냥 무선으로 쓰는것에 감사하자 하던 터에 검색을 해보니
Bluetooth 와 wifi 가 같은 주파수 대역 2.4GHz 을 사용한다는 것을 배우고,
‘Aㅏ 공유기 또 사야하나…’ 라는 좌절 중. 위의 URL을 찾았으니…

Certain external monitors and LCD displays: Certain displays may emit harmonic interference, especially in the 2.4GHz band between channels 11 and 14. This interference may be at its worst if you have a portable computer with the lid closed and an external monitor connected to it. Try changing your access point to use 5 Ghz or a lower 2.4 GHz channel.

특정 외장 모니터 및 LCD 디스플레이: 특정 디스플레이, 특히 채널 11~14의 2.4GHz 대역에서 고조파 간섭이 생길 수 있습니다. 이러한 간섭은 휴대용 컴퓨터의 뚜껑이 닫혀 있고 외장 모니터가 연결되어 있는 경우 가장 심해질 수 있습니다. 5Ghz 또는 하위 2.4GHz 채널을 사용하도록 액세스 포인트를 변경하십시오.

딱 내가 이런 환경. MBP Lid 를 닫아둔 상태에서 외장 LCD모니터를 쓰고 있고, 2.4GHz 대역의 무선 공유기를 사용하고 있으니 말이다.
그래서 사용하는 wifi 를 2.4 하위 채널을 1번으로 무작정 바꾸고나니, Delay 도 거의 사라지고 버벅임도 없다.

“공유기 안사도 됨”

slice_host

CentOS – Installing Nginx via yum

Nginx is a popular lightweight server for those who do not need the bulk and extra services that Apache may offer.

This article will look at installing Nginx on a CentOS Slice using the ‘yum’ package manager.


Yum

Using the inbuilt package manager to install packages is a great idea as it solves dependency issues and you are assured of any security updates if, and when, they occur.

However, one drawback can be that it is rare for a version upgrade to be placed into the repositories. As such, it is possible for a newer version of an application to be released and not be placed into the repository.

EPEL

To install Nginx using yum we will need to include the EPEL (Extra Packages for Enterprise Linux) repository. This repository was developed by the Fedora community to provide extra add-on packages for Fedora-based Redhat Enterprise Linux and it’s other compatible offspring such as CentOS.

One thing to keep in mind when adding extra repositories is that many include newer versions of packages that are readily available through the standard channels. This can cause problems as packages can be automatically upgraded and cease to function as expected.

I want to make it clear that the EPEL repository is purely complimentary and only provides additional packages that are otherwise unavailable through the default repositories.

Versions

Using yum in conjunction with the EPEL repository, CentOS will install Nginx version 0.6.33.

However, at the time of writing, the latest stable version of Nginx is 0.6.34. You can check the latest versions and change logs at the main nginx site.

Which one you choose is, of course, entirely up to you.

If you decide you would rather have a later version of Nginx than the one the EPEL repository provides, then please refer to the sister article (link on the way) which will take you through the process of installing Nginx from source.

Installation and Dependencies

Let’s begin by installing the EPEL repository:

Installing nginx using Yum is now incredibly simple, thanks to EPEL, as it involves one command:

As this will be the first package we install using EPEL, we will be asked to import the EPEL gpg-key.

This key is used to sign all packages that are associated with the EPEL repository to verify their validity.

Once the gpg-key has been imported, the installation should proceed as expected.

This will install any dependencies that Nginx requires and actually incorporates the experimental Perl module. You can read more documentation about this feature as well as many others at Nginx’s English Wiki.

Start

One odd thing is that Nginx is not started automatically:

Done

Navigate

Now simply navigate to your IP address:

and you will see the following welcome screen:

Nginx Welcome Screen

Init Scripts

As you would imagine when installing an application with the yum package manager, all init scripts have been created.

However, we need to set up Nginx to start automatically if the slice is rebooted:

Controlling nginx is done with these commands:

You can also check the current status as well as the configuration syntax by using the following commands:

The configtest option is particularly useful for testing your Nginx configuration before actually implementing it with a reload or restart.

That’s it.

Summary

Using the yum package manager along with the EPEL repository makes the installation of Nginx and associated dependencies very simple indeed.

The only thing to consider is the version disparity between the one offered by yum and the one available via source code.

Mark

source : http://articles.slicehost.com/2008/12/17/centos-installing-nginx-via-yum

Linux Find SCSI Hard Disk Model, Serial Number, Size, and Total Sectors Information

Simply use utility called sdparm to fetch SCSI / SATA device information. Inquiry data including Vital Product Data (VPD) pages can also be displayed. Commands associated with starting and stopping the medium; loading and unloading the medium; and other housekeeping functions may also be performed by this utility.

In short you can get or set SCSI hard disk parameters. If you are using ATA ( IDE ) hard disk use hdparm utility

Install sdparm utility

Type the following command at shell prompt:
# apt-get install sdparm
Red Hat / CentOS user can grab sdparm rpm package here.

sdparm examples

To list common mode parameters of a disk, enter:
# sdparm /dev/sda

To list the designators within the device identification VPD page of a disk:
# sdparm --inquiry /dev/sdb

To see all parameters for the caching mode page:
# sdparm --page=ca /dev/sdc

To set the “Writeback Cache Enable” bit in the current values page:
# sdparm --set=WCE /dev/sda

cufonLarge

Cufon 으로 한글폰트 생성시 사용할 Subset

Cufon 에서 한글 TTF를 이용하여 Cufon.JS 폰트를 생성시에, Subset 선택에서 All 을 선택하게 되면, 실제 TTF용량과 비슷하거나, 혹은 이보다 더 커질 수 있다. 일반적으로 사용하는 완성형 한글 외에 특수 확장 한글까지 전부 포함이 되어서 생기는 문제가 발생하는 것이다.

해결방안은 과거 WEFT를 이용하여 웹폰트(EOT)를 만들때 사용된 Subset 에 포함된 내용을 이용하면 용량이 절반이상 줄일 수 있다.
이를 이용하기 위해서는 Cufon Generate 페이지 일부를 수정하여 적용이 가능하다.
첨부된 Subset 의 내용을 입력하기 위해서는 기존 Input 태그에서는 256 글자로 제한되어있으므로, 이를 Textarea 태그로 변경하여 Subset 을 복사, 붙여넣기 하면 된다. 그리고 기본적으로 선택된 Basic 은 Uncheck 해도 무방하다.

* 페이지의 Include the following glyphs (if available) 의 하단에 Also include these single characters 의 <input 을 <textarea 로 변경.

링크 : Subset.txt