Monday, December 24, 2012

Perl 의 loop sample

루프 사용 예:
 #!/usr/bin/perl  
   
 @a = (0, 10, 20, 30, 40, 50);  
 foreach $i (@a)  
 {   
      # $i takes on each list item value in turn  
      printf("%d ", $i);  
 }  
 printf("\n", $i);  
   
 foreach $itm (reverse @a)  
 {   
      # reverse is a functiion that flips the list order  
      print $itm;  
      print " ";  
 }  
 print "\n";  
   
 $i = 0;  
 $item = 0;  
 while($i < 4)  
 {  
      $item = $a[$i];  
      print $item;  
      print " ";  
      $i++;  
 }  
 print "\n";  
   

결과 :
0 10 20 30 40 50
50 40 30 20 10 0
0 10 20 30

 for $i ( 1 .. 10 ) {  
   print($i);  
   print("\n");  
 }  

Perl 의 if, elsif, unless 문

 $age = ; # whatever ??  
 if ($age < 16)  
  {  
   print "Hi, Junior\n";  
  }  
 elsif ($age < 17)  
  {  
   print You can ????\n";  
  }  
 elsif ($age < 18)  
  {  
   print You can learn to drive\n";  
  }  
 else  
  { print "Go and Vote and then have a beer.\n";  
  }  
else if 가 아니라 elsif 임.
 $age = ... ;   
 unless ($age < 18)  
 {  
      print "Go and Vote and then have a beer.\n";  
 }  
if not 이 아니라 unless 임.
unless 에도 else 사용 가능.

If/Unless statement
키워드 : elseif

Perl 의 for 문

 for ($index = 0; $index <= 100; $index++) {  
   if ($index % 10 == 0) {  
     print("$index ");  
   }  
 }  
결과는 다음과 같음
0 10 20 30 40 50 60 70 80 90 100

The Binary Arithmetic Operators
The for statement

Perl 의 power operator

다음은 2의 3승 즉 8 을 계산.
$w = 2**3;
The Binary Arithmetic Operators

Perl의 chop() operator

이 함수는 맨 뒤의 한글자를 제거해준다.
chop('ABCD') -> 'ABC'
The String Operators

용도는 다음에 잘 설명되어 있다.
When a file is read using the diamond operator, the newline character that ends the line is kept as part of the input string. Frequently ,you'll see the chop() function used to remove the newline. For instance, chop($inputLine = );. This statement reads a line from the input file, assigns its value to $inputLine and then removes that last character from $inputLine - which is almost guaranteed to be a newline character. If you fear that the last character is not a newline, use the chomp() function instead.
출처 : http://affy.blogspot.kr/p5be/ch09.htm

Perl 의 chomp() 함수

Using the Perl chomp() function
참고 : Perl의 chop() operator

perl의 -w 옵션

다음과 같이 실행하면 warning 을 표시해준다.
perl -w
Using the -w Command-Line Option

Sunday, December 23, 2012

html에서 쓸수 있는 tab character

Q. html에서 쓸수 있는 tab character는 없는가?
A. 없다. table을 사용하는 것이 근본적인 해결책이다.
폭이 넓은 스페이스를 원한다면 &emsp 로 em-space 를 쓰는 것으로 대신할 수 있다.
HTML: Tab space instead of multiple “nbsp”?

Saturday, December 22, 2012

Script Objects

Script Objects
A script object is a user-defined object that can combine data (in the form of properties) and actions (in the form of handlers and additional script objects).

윈도우7 시작프로그램 관리하는 법

시작 > 검색창 > msconfig 실행
시스템 구성 화면에서 시작프로그램 탭으로 들어감
Step by Step: Windows 7에서 시작프로그램 제어

AppleScript Tutorial 모음

AppleScript Tutorials

There are over 100 tutorials and articles in unScripted and almost all of them are listed below.

General Information
Tutorial: Non-Scripter's Guide to Using Downloaded AppleScripts by Adam Bell

Tutorials about AppleScript Studio
AppleScript Studio Tutorial - Getting Started by Ben Waldie
AppleScript Studio Tutorial: Getting Started Using Tab Views by Ben Waldie
AppleScript Studio Tutorial - Getting Started - Displaying Progress by Ben Waldie
AppleScript Studio Tutorial - Getting Started with Table Views by Ben Waldie
AppleScript Studio Tutorial - Getting Started with Buttons (Part 1) by Ben Waldie
AppleScript Studio Tutorial - Getting Started with Buttons (Part 2) by Ben Waldie
Tutorial: Variable Scope in Applescript and Applescript Studio by Kevin Bradley
Applescript Studio Tutorial: Polishing Your Application by Kevin Bradley
Applescript Tutorial: Polishing an App 2 - Secrets Not In The Manual by Kevin Bradley
Applescript Studio: About the About Box by T.J. Mahaffey
Applescript Studio FAQ 1 by T.J. Mahaffey

Tutorials for Beginning Scripters
AppleScript Tutorial for Beginners I - Get Started & Script Editor by Craig Smith
AppleScript Tutorial for Beginners II - Variables and Dictionaries by Craig Smith
AppleScript Tutorial for Beginners III - The Power of Lists by Craig Smith
AppleScript Tutorial for Beginners IV - Records & Repeats by Craig Smith
AppleScript Tutorial for Beginners V - Testing & Shorthand by Craig Smith
AppleScript Tutorial for Beginners VI - User Interaction by Craig Smith
AppleScript Tutorial for Beginners VII - Errors by Craig Smith
AppleScript Tutorial for Beginners VIII - More on User Interaction by Adam Bell
AppleScript Tutorial for Beginners IX - Getting the Drop on Droplets by Craig Smith
AppleScript Tutorial for Beginners X - Math by Craig Smith
Applescript Tutorial: All AppleScript, All the Time by Craig Smith
Applescript Tutorial - Using Applescript Dictionaries by Kevin Bradley
AppleScript for Automators by Kevin Wolfe
Automator for AppleScripters by Kevin Wolfe
Tutorial on Building Automator Droplets by Craig Smith
Tutorial on Improving Your AppleScripts: Structured Programming by Kevin Bradley
Cooking with Data Types - Part 1 by T.J. Mahaffey
Cooking with Data Types - Part 2: Coercion by T.J. Mahaffey

AppleScripting Tools & Techniques
Subroutines - Part 1 by T.J. Mahaffey
Subroutines - Part 2 by T.J. Mahaffey
Getting Started with Handlers (Part 1 of 3-part Tutorial) by Ben Waldie
Getting Started with Handlers (Part 2 of 3-part Tutorial) by Ben Waldie
Getting Started with Handlers (Part 3 of 3-part Tutorial) by Ben Waldie
Applescript Tutorial - Using Applescript Dictionaries by Kevin Bradley
A Tutorial to Improve your Applescripts: Return to iTunes Scripting by Kevin Bradley
The Ins & Outs of File Read/Write in AppleScript by Nigel Garvey
Tutorial on Using Growl from your AppleScripts by Adam Bell
Tutorial: Some Lessons & Fun with "do shell script" in AppleScripts by Adam Bell
An AppleScript Tutorial on a Common Folder Action Problem by Kevin Bradley
Dates & Times in AppleScripts by Adam Bell
Tutorial for Using AppleScript's Text Item Delimiters by Adam Bell
A Tutorial on Parsing HTML from a Web Site by Adam Bell
Tutorial: a Beginner's Introduction to AppleScript Libraries by Adam Bell
A Tutorial to Improve your Applescripts: Return to iTunes Scripting by Kevin Bradley
Applescript Tutorial: Advanced iTunes Scripting with Libraries by Kevin Bradley
Applescript Tutorial: All Your Database Are Belong To Applescript by Kevin Bradley
Applescript Tutorial: Script Properties by Chris Moore
A "Quick 'n Dirty" Applescript Tutorial by Kevin Bradley
Tutorial on Improving Your AppleScripts: Structured Programming by Kevin Bradley
A Tutorial to Improve your Applescripts: Data Structures by Kevin Bradley
A Tutorial to Improve your Applescripts: Data Structures - Stacks by Kevin Bradley
AppleScript Tutorial on Range References with Text and Lists by Nigel Garvey
A Tutorial to Improve your Applescripts: Sorting - The Big "O" by Kevin Bradley
A Tutorial on Doing Structured Text Generation in AppleScript by chrys

Application Scripting
A Tutorial on AppleScripting Finder Search Windows by Adam Bell
A Tutorial for Using Spotlight in your AppleScripts by Adam Bell
A Tutorial on AppleScripting a mySQL Database by Craig Smith
Applescript Tutorial: Working With Images Using Image Events by Kevin Bradley
Automator Tutorial - Working With Images (Redux) by Kevin Bradley
Automating Mug Shots to Filemaker from iSight: AppleScript Tutorial by Diana Simonson
Applescript Tutorial: iCal Alarms! by Kevin Bradley
Applescript Tutorial: Appointments, Alarms & To Dos in iCal by Kevin Bradley
Applescript Tutorial: Talkin' The Talk with Apple's Speech Tools by Kevin Bradley
Tutorial & Review: Scripting Clickable Bliss' Billable by Adam Bell
A Tutorial Introduction to SQLite3 - a Simple Database Engine by Adam Bell
Synching iView to MySQL to update a website using Applescript by Diana Simonson
Using Applescript to Parse Data from one Filemaker format to Another by Diana Simonson
Automator for AppleScripters -- by Kevin Wolfe

Other Tips & Tricks in AppleScript
Applescript Tutorial: Building Script Applications by Kevin Bradley
Tutorial: A Single Dialog to Handle Multiple Entries by kai
An Introduction to Extracting Elements & Properties from Objects by kai
AppleScript Tutorial on Scripting System Preferences by kai
Automator Tutorial: Bindings by Kevin Wolfe
A Tutorial to Improve Your AppleScripts: Putting It All Together by Kevin Bradley
Protection for AppleScripts Compiled as Run-Only Applications by jj
Automate iWeb Uploads to Multiple Servers by Kevin Wolfe
Using launchd with AppleScript to Access a Flash Drive Automatically by Craig Smith
A Tutorial on Constructors & Handlers Containing Script Objects by jj
Object Pattern: the Object Switch -- by Chris Moore
Script Libraries -- by Chris Moore
Encrypting Messages (Pt 1) by Scott Lewis
Encrypting Messages (Pt 2) by Scott Lewis
Encrypting Messages (Pt 3) by Scott Lewis
Writing Cleaner Code by T.J. Mahaffey
Using Object Properties by Scott Lewis
Text Item Delimiters are De-limitless by T.J. Mahaffey
Idle Handlers by T.J. Mahaffey
AppleScript Toolbox Secrets: Dialog Alternatives by T.J. Mahaffey
UI Browser preview & MacOS X GUI Scripting by T.J. Mahaffey

Friday, December 21, 2012

맥에서 Perl 실행하는 법

1. 텍스트 편집기에서 다음과 같이 입력한다.
 #!/usr/bin/perl  
 use strict;  
 use warnings;  
 print "Hello World\n";  

2. Hello.pl 이라는 이름으로 저장한다. 저장 옵션은 다음과 같이 한다 (Text Wrangler 기준)
 Line breaks : Windows (CRLF) 또는 UNIX (LF)  
 Encoding : Unicode (UTF-8)  
저장할때 주의점 두가지는, with BOM 으로 저장하면 나중에 실행이 안되며
또한 저장 옵션에서 개행문자가 Line Feed 가 되는 옵션으로 저장해야 한다는 점이다.

3. 터미널에서 다음과 같이 실행한다.
 $ perl Hello.pl  
또는, chmod +x Hello.pl 로 실행파일로 만들어준 후 다음과 같이 그냥 실행할 수도 있다.
 $ ./Hello.pl  
코드 맨 첫줄의 #!/usr/bin/perl 가 바로 실행할 프로그램 패스를 지정해주는 역할을 한다.

4. 실행하면 터미널에 Hello World 라고 찍힌다.
만약 결과가 안 찍히면 2에서 설명한 저장 옵션이 잘못되어 있는 것이다.

레퍼런스 :
Mac Perl Primer for Mac OSX Users
Getting Started with Perl on Mac OS X

Daemon Tools 다운받는곳

http://www.daemon-tools.cc/kor/products/dtproAdv
키워드 : 버추얼데몬, 대몬

윈도우7 포맷 및 자체백업 방법

자체포맷 방법 : 부팅시 F8 누르고 컴퓨터 복구 모드에서 포맷 가능
자체 백업 등 관련 설명 : 윈도우 7 포맷.. 샀을때 CD같은걸 받지 않앗고 바로 윈도우7이였습니다
키워드 : 인스톨

FreeMind (마인드맵 소프트웨어) 간단 사용법

기본 기능 - 노드 생성하고 움직이는 법
현재 노드에서 tab을 누르면 child 노드가 생성된다
현재 노드에서 return 을 누르면 형제 노드가 생성된다
노드는 마우스로 끌어서 자유롭게 다른 노드 밑으로 넣어줄 수 있다
노드가 가지에 붙어 있는 부위에 마우스를 올리면 0 모양이 표시되는데 이걸 끌어 옮기면 노드 위치를 자유자재로 움직일 수 있다.

기본 기능 - 현재 노드 선택 및 에디트
(마우스를 올리면 회색으로 변하는 노드가 바로 현재 노드임)
화살표 키를 누르면 상하좌우로 현재 노드를 이동할 수 있다
F2를 누르면 edit 모드로 들어간다 (말단 노드의 경우 그냥 클릭하면 edit 모드로 들어감)

기본기능 - 줌인/줌아웃
Option + Up / Down 하면 마인드맵을 Zoom In / Zoom Out 한다
또는 Option + 마우스 스윕으로 Zoom In / Zoom Out 가능

알면 편리한 기능 - 노드 위치 변경
Command + Up / Down 하면 현재 노드의 위치를 하나 올리고 내린다
Command + Left / Right 하면 현재 노드의 위치를 좌우로 바꿔준다
(노드의 위치에 따라 단계를 하나 올리고 내리거나 노드 위치가 좌우로 바뀌게 된다)

알면 편리한 기능 - 노드 접기
Option + 상하스크롤(혹은 좌우스크롤) 하면 노드들이 단계별로 접힌다
현재 노드를 클릭하거나 space를 누르면 하위 노드들이 접힌다

알면 편리한 기능 - 노드 에디트
Alt + return 하면 edit 창이 별도로 떠서 폰트 속성 등을 줄수도 있다
Alt + return 해서 뜬 edit 창을 닫으려면 다시 Alt + return 하면 된다
노드의 텍스트를 여러 라인으로 써주려면 Alt + return 을 사용하는 것이 필수.

알면 편리한 기능 - Hyperlink 넣기
하이퍼링크를 넣는 핫키는 Command + K 이다.

몰라도 상관없지만 알면 좋은 기능
현재 노드에서 shift + return 을 누르면 위쪽에 형제 노드가 생성된다
현재 노드에서 shift + tab 을 누르면 parent 노드가 생성된다
두 노드를 차례로 선택하고 Command + L 누르면 화살표가 둘을 연결해준다.

기능 파악하기
프리마인드는 워낙 직관적이라 별도의 Help가 필요없는 어플리케이션이다
위에서 소개한 핫키들은 현재 노드에서 오른클릭을 하면 메뉴에서 쉽게 확인할 수 있다
위에서 소개한 기능 일부는 메뉴의 Navigate 메뉴항목에서도 확인할 수 있다

관련링크 : 마인드맵 소프트웨어

Thursday, December 20, 2012

Conduit 제거하는 법

Conduit.search.com 은 주로 google chrome 과 safari 를 공격해서 디폴트 페이지를 바꿔버리는 바이러스이다.
REMOVING the Conduit default page
디폴트페이지를 바꾸려면
chrome://chrome/settings/
으로 들어가서 On Startup 에서 Open a specific page or set of pages 에 설정돼있는 Conduit 을 없애주면 된다.

Wednesday, December 19, 2012

마인드맵 소프트웨어

대표적인 마인드맵 소프트웨어들
  • FreeMind ... 매우 직관적. 마인드맵이 자동으로 정리가 잘되어 큰 맵을 만드는데도 무리가 없다. 여기서 쓰이는 mm 포맷은 마인드맵 소프트웨어계의 업계 표준. 오픈소스 소프트웨어이다.
  • 알마인드 ... 매우 직관적이어서 첫 사용자에게 편하고 프로그램이 가벼운 것이 장점. 로딩속도가 빠르다. 첫 사용시에는 좋으나 쓰다보면 Freemind보다는 다소 맵 관리가 불편함을 발견하게 됨. 윈도우 only.
  • Mindjet ... 이전 버전은 MindManager 라는 이름이었다. FreeMind와 함께 마인드맵 소프트웨어의 양대산맥이었으나 2012년 이후로는 마인드맵 중심에서 벗어나 Collaborated Work Management 쪽으로 진화하고 있다. 
  • XMind ... 사용자는 꽤 있는듯 하나 마인드맵 소프트웨어의 취지에 걸맞지 않게 상당히 불편하다.
  • Visio ... MS 제품. 마인드맵 용만으로 쓰기에는 다소 무거운 느낌.
마인드맵 소프트웨어를 사용하는데는 마우스의 상하좌우 스크롤이 모두 되는 것이 편리하다. 그런 점에서 윈도우보다는 맥이 편하다. 실제 써본 결과 맥에서 Freemind를 사용하는 것이 가장 편하다는 느낌이다.

간단 사용법 :
  • FreeMind : tab 으로 child 노드를 만들고 return 키로 sibling 노드를 생성한다. 이것만 알아도 이 프로그램을 사용할 수 있다.
  • 알마인드 : space 로 child 노드를 만들고 return 키로 sibling 노드를 생성한다. child node 생성은 마우스로 드래그해도 된다.
키워드 : mind mapping
링크 :
FreeMind (마인드맵 소프트웨어) 간단 사용법
List of concept- and mind-mapping software
15 Great Mindmapping Tools and Apps

Tuesday, December 18, 2012

bash 스크립트 내에서 스크립트 자신의 폴더 알아내는 법

다음과 같이 하면 된다.

DIR=$( cd "$( dirname "$0" )" && pwd )
echo $DIR

출처 : Can a Bash script tell what directory it's stored in?
키워드 : Perl, 디렉토리, folder