달력

4

« 2024/4 »

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
2018. 6. 20. 09:28

호이안 밥집 리스트 Enjoy/etc2018. 6. 20. 09:28

호이안



포슈아

오전 10 ~ 오후 9

길찾기

반세오 분짜, 깨끗



미쓰리 (Miss Ly Cafe 22)

오전 11 ~ 22시 브레이크 15-17

길찾기

프라이드완탄, 새우볶음밥, 깨끗



모닝글로리

길찾기

분짜 등등. 에어컨자리 요청, 깨끗



포비엣46

오전10 ~ 오후 10

길찾기

쌀국수, 한국인많음 에어컨 깨끗, 아기의자



반미프엉

오전 6.5 ~ 오후 9.5

길찾기

반미, 소고기 질김, 돼지 비계많고, 꼭 닭으로...



비스마켓 (vy's market)

오전 8 ~ 오후 10, 브레이크 오후3~5

길찾기

넓고 깨끗한편, 반쎄오 등등



라이스 드럼

오전 8 ~ 오후 11

길찾기

완탕튀김... 2층 뷰 좋음, 깨끗



블루드래곤

오전 8 ~ 오후 10

길찾기

쌀국수 스프링롤



베일웰 (베일우물)

오전 10 ~ 오후 10

길찾기

라이스페이퍼 반쎄오



cong 분짜

오전 10.5 ~ 오후 9.5

길찾기

분짜



홈호이안 

오후 1 ~ 오후 11

길찾기

두부요리, 에어컨 깨끗.



피반미

오전 8 ~ 오후 8

길찾기

반미



콩카폐

오전 7 ~ 오후 11.5

길찾기

코코넛커피



에스프레소 스테이션

오전7.5 ~ 오후 5

길찾기

코코넛커피






:
Posted by 라면스프
2016. 5. 20. 16:30

Visual Basic 6 명령줄에서 빌드하기 Enjoy/etc2016. 5. 20. 16:30


Visual Basic 6 컴파일 하기!!!!!

비주얼베이직6  외부에서 컴파일 할때 사용하기.

CMD 창에서 실행할때 사용되는 명령어 확인

까먹지말고 정리정리!!!



참고사이트 : https://msdn.microsoft.com/en-us/library/aa231236(v=vs.60).aspx



=============================================================================


[컴파일 명령어 및 옵션]


도움말보기




vb6.exe [[{/run | /r}] | [/runexit] | [{/make | /m}] 프로젝트이름] [/out 로그파일명] [/outdir 로그파일경로] [/d 상수=값{[:constN=valueN]}][/mdi | /sdi][{/cmd 인수 | /c 인수}]


[옵션]


/run 또는 /r 프로젝트

:[프로젝트 속성] 대화상자의 [만들기] 탭의 [명령줄 인수] 필드에 저장된 인수를 사용하여, VisualBasic이 프로젝트 이름을 컴파일하고 실행합니다.


/runexit 프로젝트이름

:VisualBasic이 프로젝트 이름을 컴파일하고 실행합니다. 프로젝트가 디자인모드로 되돌아 오면 VisualBasic이 종료됩니다.


/make 또는 /m 프로젝트

:프로젝트 파일 안에 저장된 기존 설정을 사용하여, VisualBasic이 프로젝트 이름을 컴파일하고 실행 가능한 파일을 만듭니다.


/out 파일이름

:/m 또는 /runexit로 만들 때 오류를 파일로 받아들일 수 있게 지정합니다. /out을 사용하지 않으면 오류가 메시지 상자에 표시됩니다.


/outdir 경로

:/make를 사용할 때 만들어지는 모든 출력파일이 놓여질 디렉토리경로를 지정합니다.


/d 또는 /D 상수=값...

:VisualBasic이 /make로 EXE나 ActiveX 구성 요소를 만들 때 조건부 컴파일 상수로 사용할 값을 지정합니다. 상수가 여러 개일 때는 콜론으로 구분하십시오.


/cmd 또는 /c 인수

:[프로젝트 속성] 대화 상자의 [만들기] 탭의 [명령줄 인수]필드에 인수를 지정합니다. 이 때 이 옵션은 명령줄 맨끝에 위치해야 합니다.


/mdi 또는 /sdi

:VisualBasic 환경을 단일 문서 인터페이스(SDI)나 다중 문서 인터페이스(MDI)로 전환합니다. 이 설정을 바꾸기 전까지는 현재의 모드를 유지합니다.


* 위의 스위치에서 프로젝트 이름 위치에 그룹 이름을 사용할 수 있습니다.



EX) TEST.vbp 프로젝트를 make 하는 명령어. out 메시지는 test_out.log 로 출력할 때


     "C:\Program Files (x86)\Microsoft Visual Studio\VB98\vb6.exe" /make "D:\VBProject\TEST\TEST.vbp" /out "D:\VBProject\TEST\outlog\test_out.log"

     



=============================================================================




Working with Command Line Switches


Command line switches provide a way to control how Visual Basic executes. Using command line switches, you can start an instance of Visual Basic and run a specified project, make an executable file or dynamic-link library, or specify a string to be passed to the Command$ function.

For example, to run the project MyProj.vbp and then automatically exit, start Visual Basic with the following command line:


c:\Program Files\Microsoft Visual Studio\VB\vb6.exe /runexit MyProj.vbp


The following table summarizes the Visual Basic command line switches.


Switch Description


/cmd cmdstring Specifies a command string to be passed to the Command$ function. When used, it must be the last switch on the command line.

/d compileconst Specifies one or more conditional compilation constants to use with the /make or /makedll switch.

/make projectname Makes the specified project into an executable file.

/makedll projectname Makes the specified project into a dynamic-link library.

/mdi Starts Visual Basic using the multiple document interface (MDI) programming environment.

/out filename Outputs errors to a file when used with the /make or /makedll switch.

/run projectname Runs the specified project.

/runexit projectname Runs the specified project and then automatically exits.

/sdi Starts Visual Basic using the single document interface (SDI) programming environment.

/? Displays a list of valid command line switches.


For More Information   See "Command Line Arguments."




:
Posted by 라면스프
2015. 11. 5. 15:09

Convert JSON string to Map – Jackson Enjoy/JSP2015. 11. 5. 15:09

출처 : http://www.mkyong.com/java/how-to-convert-java-map-to-from-json-jackson/


In this tutorial, we will show you few Jackson examples to convert JSON string to/from a Map.

P.S All examples are tested with Jackson 2.6.3

1. JSON string to Map

JsonMapExample.java
package com.mkyong.json;

import java.io.IOException;
import java.util.HashMap;
import java.util.Map;

import com.fasterxml.jackson.core.JsonGenerationException;
import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.JsonMappingException;
import com.fasterxml.jackson.databind.ObjectMapper;

public class JsonMapExample {

	public static void main(String[] args) {

		try {

			ObjectMapper mapper = new ObjectMapper();
			String json = "{\"name\":\"mkyong\", \"age\":29}";

			Map<String, Object> map = new HashMap<String, Object>();

			// convert JSON string to Map
			map = mapper.readValue(json, new TypeReference<Map<String, String>>(){});

			System.out.println(map);

		} catch (JsonGenerationException e) {
			e.printStackTrace();
		} catch (JsonMappingException e) {
			e.printStackTrace();
		} catch (IOException e) {
			e.printStackTrace();
		}
	}

}

Output

{name=mkyong, age=29}

2. Map to JSON string

Example to convert the Map to JSON string.

MapJsonExample.java
package com.mkyong.json;

import java.io.IOException;
import java.util.HashMap;
import java.util.Map;

import com.fasterxml.jackson.core.JsonGenerationException;
import com.fasterxml.jackson.databind.JsonMappingException;
import com.fasterxml.jackson.databind.ObjectMapper;

public class MapJsonExample{

	public static void main(String[] args) {

		try {

			ObjectMapper mapper = new ObjectMapper();
			String json = "";

			Map<String, Object> map = new HashMap<String, Object>();
			map.put("name", "mkyong");
			map.put("age", 29);

			// convert map to JSON string
			json = mapper.writeValueAsString(map);

			System.out.println(json);

			json = mapper.writerWithDefaultPrettyPrinter().writeValueAsString(map);

			// pretty print
			System.out.println(json);

		} catch (JsonGenerationException e) {
			e.printStackTrace();
		} catch (JsonMappingException e) {
			e.printStackTrace();
		} catch (IOException e) {
			e.printStackTrace();
		}
	}

}

Output

{"name":"mkyong","age":29}
{
  "name" : "mkyong",
  "age" : 29
}

3. Map to JSON File

JsonMapFileExample.java
package com.mkyong.json;

import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.fasterxml.jackson.core.JsonGenerationException;
import com.fasterxml.jackson.databind.JsonMappingException;
import com.fasterxml.jackson.databind.ObjectMapper;

public class JsonMapFileExample {

	public static void main(String[] args) {

		try {

			ObjectMapper mapper = new ObjectMapper();

			Map<String, Object> map = new HashMap<String, Object>();
			map.put("name", "mkyong");
			map.put("age", 29);

			List<Object> list = new ArrayList<>();
			list.add("msg 1");
			list.add("msg 2");
			list.add("msg 3");

			map.put("messages", list);

			// write JSON to a file
			mapper.writeValue(new File("c:\\user.json"), map);

		} catch (JsonGenerationException e) {
			e.printStackTrace();
		} catch (JsonMappingException e) {
			e.printStackTrace();
		} catch (IOException e) {
			e.printStackTrace();
		}
	}

}
c:\\user.json
{"name":"mkyong","messages":["msg 1","msg 2","msg 3"],"age":29}

4. JSON file to Map

JsonFileMapExample.java
package com.mkyong.json;

import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Map;

import com.fasterxml.jackson.core.JsonGenerationException;
import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.JsonMappingException;
import com.fasterxml.jackson.databind.ObjectMapper;

public class Jackson2Example {

	public static void main(String[] args) {

		try {

			ObjectMapper mapper = new ObjectMapper();

			// read JSON from a file
			Map<String, Object> map = mapper.readValue(
					new File("c:\\user.json"), 
					new TypeReference<Map<String, Object>>() {
			});

			System.out.println(map.get("name"));
			System.out.println(map.get("age"));

			@SuppressWarnings("unchecked")
			ArrayList<String> list = (ArrayList<String>) map.get("messages");

			for (String msg : list) {
				System.out.println(msg);
			}

		} catch (JsonGenerationException e) {
			e.printStackTrace();
		} catch (JsonMappingException e) {
			e.printStackTrace();
		} catch (IOException e) {
			e.printStackTrace();
		}
	}

}

Output

mkyong
29
msg 1
msg 2
msg 3

References

  1. Wikipedia : JSON
  2. Jackson – High-performance JSON processor
  3. Jackson 2 – Object to / from JSON


:
Posted by 라면스프
2015. 11. 5. 14:28

ObjectMapper (FasterXML/jackson) Enjoy/JSP2015. 11. 5. 14:28

출처 : http://noritersand.tistory.com/240


라이브러리 다운로드

http://wiki.fasterxml.com/JacksonDownload


 jackson-annotations-2.2.3.jar

 jackson-core-2.2.3.jar

 jackson-databind-2.2.3.jar


Map - JSON 변환



writeValueAsString( value )

  • value: String 타입으로 변환할 대상


readValue( arg, type )

  • arg: 지정된 타입으로 변환할 대상
  • type: 대상을 어떤 타입으로 변환할것인지 클래스를 명시한다. Class객체, TypeReference객체가 올 수 있다.

ex)

mapper.readValue(arg, ArrayList.class);

mapper.readValue(argnew ArrayList<HashMap<String, String>>().getClass());

mapper.readValue(arg, new TypeReference<ArrayList<HashMap<String, String>>>(){});


● Map

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
import com.fasterxml.jackson.databind.ObjectMapper;
 
public class Test2 {
    public static void main(String[] args) throws Exception {
 
        ObjectMapper mapper = new ObjectMapper();
 
        HashMap<StringString> map = new HashMap<StringString>();
        map.put("name""steave");
        map.put("age""32");
        map.put("job""baker");
 
        System.out.println(map);
        System.out.println(mapper.writeValueAsString(map));
    }
}
 
// {age=32, name=steave, job=baker}
// {"age":"32","name":"steave","job":"baker"}
cs

맵 타입이 JSON 형식의 String 타입으로 변환된다. 자바스크립트에 JSON을 넘겨줄 때 유용하다. 


이와 반대로 JSON을 맵 타입으로 변환하려면 다음처럼 작성한다:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.ObjectMapper;
 
public class Test2 {
    public static void main(String[] args) throws Exception {
 
        ObjectMapper mapper = new ObjectMapper();
        HashMap<StringString> map = new HashMap<StringString>();
 
        String jsn = "{\"age\":\"32\",\"name\":\"steave\",\"job\":\"baker\"}";
        
        map = mapper.readValue(jsn, 
                new TypeReference<HashMap<StringString>>() {});        
        
        System.out.println(map);
    }
}
 
// {name=steave, age=32, job=baker}
cs


● List<Map>

다음은 view에 전달할 model이 List<map<?, ?>> 타입일 때 이를 JSON으로 변환하는 방법이다.

사용방법은 크게 다르지 않고 writeValueAsString, readValue 메서드를 사용하되 타입 명시만 달리한다.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.ObjectMapper;
 
public class Test2 {
    public static void main(String[] args) throws Exception {
 
        ObjectMapper mapper = new ObjectMapper();
 
        // map -> json
        ArrayList<HashMap<StringString>> list 
                = new ArrayList<HashMap<String,String>>(); 
        
        HashMap<StringString> map = new HashMap<StringString>();
        map.put("name""steave");
        map.put("age""32");
        map.put("job""baker");
        list.add(map);
        
        map = new HashMap<StringString>();
        map.put("name""matt");
        map.put("age""25");
        map.put("job""soldier");
        list.add(map);
        
        System.out.println(mapper.writeValueAsString(list));
 
        
        // json -> map
        String jsn = "[{\"age\":\"32\",\"name\":\"steave\",\"job\":\"baker\"},"
                + "{\"age\":\"25\",\"name\":\"matt\",\"job\":\"soldier\"}]";
        list = mapper.readValue(jsn, 
                new TypeReference<ArrayList<HashMap<StringString>>>() {});        
        
        System.out.println(list);
    }
}
 
 
// [{"age":"32","name":"steave","job":"baker"},{"age":"25","name":"matt","job":"soldier"}]
// [{name=steave, age=32, job=baker}, {name=matt, age=25, job=soldier}]
cs






:
Posted by 라면스프
2015. 3. 2. 23:32

그리드 헤더 체크박스 Enjoy/FLEX2015. 3. 2. 23:32

3 state checkbox for headerrenderer in datagrid




출처 : https://srinichekuri.wordpress.com/2011/05/20/3-state-checkbox-for-headerrenderer-in-datagrid/


Today I made by first contribution to Adobe Cook by posting about this topic. The idea on this topic started by showing my earlier post on gmail header to my colleague who also happens to be the owner of post in adobe cookbook that talks about 3State checkbox for TreeRenderer. He pointed out that the checkbox in the header can be threeState. Well thats a common problem but suprisingly this was not addressed in the online opensource community for Datagrid. I saw an opportunity and coded it.

Note:
There is a bug in my colleague’s post that it doesn’t take care of the initial state, I have taken care of that bug in my code.My code itself is inspired by my colleagues post.

The checkbox in headerRenderer will have three states:

  • All the rows in the datagrid are selected (‘select’ State).
  • None of the rows in the datagrid are selected(‘unselected’ State)
  • One or more rows (but not all) are selected(‘undecided’ State).

ScreenShots:
Change of state from ‘unselect’ state to ‘select’ state:

Change of state from ‘select’ state to ‘undecided’ state:

Code:

Here is the code for Main.mxml:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
<?xml version="1.0" encoding="utf-8"?>
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
                xmlns:s="library://ns.adobe.com/flex/spark"
                xmlns:mx="library://ns.adobe.com/flex/mx"
                creationComplete="creationCompleteHandler(event)">
 
    <fx:Script>
        <![CDATA[
            import mx.collections.ArrayCollection;
            import mx.controls.Alert;
            import mx.events.FlexEvent;
 
            private var _dataProvider:ArrayCollection;
            [Bindable]
            public function set dataProvider(value:Object):void{
                _dataProvider=value as ArrayCollection
            }
            public function get dataProvider():Object{
                return _dataProvider;
            }
 
            protected function creationCompleteHandler(event:FlexEvent):void
            {
                dataProvider = new ArrayCollection([
                    {checked:true, name:'Jim Smith'},
                    {checked:false, name:'Yancy Williams'}]);
            }
 
        ]]>
    </fx:Script>
 
    <mx:DataGrid id="myDataGrid" left="10" top="10" dataProvider="@{dataProvider}">
        <mx:columns>
            <mx:DataGridColumn textAlign="center" dataField="checked"
                                       width="90"
                                       rendererIsEditor="true"
                                       sortable="false"
                                       itemRenderer="renderer.CheckboxItemRenderer"
                                       headerRenderer="renderer.ThreeStateCheckBoxHeaderRenderer"
                                       />
            <mx:DataGridColumn headerText="Name" dataField="name" width="110"/>
        </mx:columns>
    </mx:DataGrid>
 
</s:Application>

Code for headerRenderer

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
package renderer
{
    import flash.events.MouseEvent;
 
    import mx.collections.ArrayCollection;
    import mx.controls.DataGrid;
    import mx.controls.Image;
    import mx.controls.dataGridClasses.DataGridListData;
    import mx.controls.dataGridClasses.MXDataGridItemRenderer;
 
    import spark.components.CheckBox;
 
    /**
     * HeaderRender with a Three State Checkbox.
     * <p>Functionality:<br>
     *    <li>Selecting the checkbox will select all the rows in the datagrid</li>
     *    <li>Unselecting the checkbox will unselect all the rows in the datagrid</li>
     *
     * <p>The checkbox can be three states at any point:<br>
     *    <li>select: This would mean that all the rows are selected</li>
     *    <li>unselect: This would mean that none of the rows are selected</li>
     *    <li>undecided: This would mean that one or more (but not all) of the rows are selected</li>
     *
     * @author Srinivas Chekuri
     *
     */
    public class ThreeStateCheckBoxHeaderRenderer extends MXDataGridItemRenderer
    {
        protected var myCheckBox:CheckBox;
        protected var myImage:Image;
        private var imageWidth:Number   = 9.5;
        private var imageHeight:Number  = 9.5;
        private var inner:String    = "assets/inner.png";
 
        private const SELECT_STATE:String="select";
        private const UNSELECT_STATE:String="unselect";
        private const UNDECIDED_STATE:String="undecided";
 
        private var STATE:String = UNSELECT_STATE;
 
        /**
         * Constuctor
         *
         */
        public function ThreeStateCheckBoxHeaderRenderer()
        {
            super();
        }
 
        /**
         * overides the function <code>createChildren</code> in the component lifecyle. This instantiates
         * <code>myCheckBox</code> and <code>myImage</code>.
         *
         */
        override protected function createChildren():void{
            super.createChildren();
            myCheckBox = new CheckBox();
            myCheckBox.setStyle("horizontalCenter", "0");
            myCheckBox.setStyle("verticalCenter", "0");
            myCheckBox.addEventListener( MouseEvent.CLICK, checkBoxClickHandler );
            addElement(myCheckBox);
            myImage = new Image();
            myImage.source = inner;
            myImage.addEventListener( MouseEvent.CLICK, imageClickHandler );
            myImage.visible=false;
            addElement(myImage);
        }
 
        /**
         * overides the function <code>updateDisplayList</code> in the component lifecyle. This sets the
         * display settings of <code>myCheckBox</code> and <code>myImage</code>. This also updates the state
         * according to the selections made in the datagrid.
         *
         * @param unscaledWidth
         * @param unscaledHeight
         *
         */
        override protected function updateDisplayList(unscaledWidth:Number, unscaledHeight:Number):void{
            super.updateDisplayList(unscaledWidth,unscaledHeight);
 
            myImage.x=myCheckBox.x+1.5;
            myImage.y=myCheckBox.y+5.5;
 
            myImage.width=imageWidth;
            myImage.height=imageHeight;
 
            if(areAllSelected()){
                STATE=SELECT_STATE;
            }else if(isAnyColumnSelected()){
                STATE=UNDECIDED_STATE;
            }else if(!isAnyColumnSelected()){
                STATE=UNSELECT_STATE;
            }
            checkState();
        }
 
        /**
         * Makes adjustments to the <code>visible</code> property of <code>myImage</code> and
         * <code>selected</code> of <code>myCheckBox</code> according to the state.
         *
         * @private
         *
         */
        private function checkState():void{
            if(STATE==SELECT_STATE){
                myImage.visible=false;
                myCheckBox.selected=true;
            }else if(STATE==UNSELECT_STATE){
                myImage.visible=false;
                myCheckBox.selected=false;
            }else{
                myImage.visible=true;
                myCheckBox.selected=false;
            }
        }
 
        /**
         * Handler method for <code>MouseEvent.CLICK</code> event on <code>myImage</code>.
         *
         * @param event
         *
         */
        protected function imageClickHandler(event:MouseEvent):void{
            STATE=SELECT_STATE;
            checkState();
            selectAll();
        }
 
        /**
         * Handler method for <code>MouseEvent.CLICK</code> event on <code>myCheckBox</code>.
         *
         * @param event
         *
         */
        protected function checkBoxClickHandler(event:MouseEvent):void{
            selectAll();
        }
 
        /**
         * Selects all the rows in the datagrid.
         *
         */
        private function selectAll():void{
            var ac:ArrayCollection = DataGrid(DataGridListData(listData).owner).dataProvider as ArrayCollection;
            for each (var o:Object in ac){
                o.checked=myCheckBox.selected;
            }
            DataGrid(DataGridListData(listData).owner).dataProvider = ac;
        }
 
        /**
         * Checks if all the rows are selected in the datagrid.
         *
         * @return Boolean: returns <code>true</code> if all rows are selected else returns
         * <code>false</code>.
         *
         */
        private function areAllSelected():Boolean{
            var ac:ArrayCollection = DataGrid(DataGridListData(listData).owner).dataProvider as ArrayCollection;
            var b:Boolean=true;
            for each (var o:Object in ac){
                if(!o.checked){
                    b=false;
                    break;
                }
            }
            return b;
        }
 
        /**
         * Checks to see if any one of the rows are selected.
         *
         * @return Boolean: return <code>true</code> if any one the rows are selected.
         *
         */
        private function isAnyColumnSelected():Boolean{
            var ac:ArrayCollection = DataGrid(DataGridListData(listData).owner).dataProvider as ArrayCollection;
            var b:Boolean=false;
            for each (var o:Object in ac){
                if(o.checked){
                    b=true;
                    break;
                }
            }
            return b;
        }
    }
}

Code for itemRenderer:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
<!--?xml version="1.0" encoding="utf-8"?-->
 
        <![CDATA[
            import mx.collections.ArrayCollection;
            import mx.controls.DataGrid;
            import mx.controls.dataGridClasses.DataGridListData;
            import mx.events.FlexEvent;
 
            /**
             * Handler function for <code>MouseEvent.CLICK</code> on checkbox.
             *
             * @param event MouseEvent
             *
             */
            public function clickHandler(event:MouseEvent):void{
                var o:Object = DataGrid(DataGridListData(listData).owner).selectedItem;
                o.checked=cb.selected;
                ArrayCollection(DataGrid(DataGridListData(listData).owner).dataProvider).setItemAt(o,DataGrid(DataGridListData(listData).owner).selectedIndex);
            }
 
            /**
             * Overides <code>data</code> parameter to set the <code>selected</code> parameter of the
             * checkbox.
             *
             * @param value Object
             */
            override public function set data(value:Object):void{
                if(value!=null){
                    super.data=value;
                    cb.selected=value.checked;
                }
            }
        ]]>

You can download the code from my post in Adobe cook book.

:
Posted by 라면스프
2013. 11. 22. 15:26

[펌][BlazeDS] 메세징을 위한 폴링과 설정 Enjoy/FLEX2013. 11. 22. 15:26

원문출처 : http://jjaeko.tistory.com/115



[BlazeDS] 메세징을 위한 폴링과 설정



BlazeDS 에서는 rtmp 채널을 지원하지 않기 때문에, 디폴트로 폴링 방식으로 메세징을 지원 합니다.
이런 사실 때문에, real-time messaging을 지원하지 않을거라는 착각을 할 수 있는데 다양한 테크닉으로 real-time messaging을 구현할 수 있습니다. 하지만 앞으로 소개될 테크닉들은 http-based 이기 때문에 독자적인 socket을 사용하는 lcds에 비해 속도와 동시접속에 있어서 뒤쳐질 수 밖에 없습니다.


Simple Polling




이 방식은 real-time의 효과를 볼 수 없는 기본적인 polling 입니다. 일정한 간격으로 요청(poll)하고 응답(ack) 받습니다. 만약 요청 했을 때, 다른 client로 부터 메세지가 들어와 있지 않다면 비어 있는 응답을 받습니다.

설정 방법은 다음과 같습니다.

<channel-definition id="polling-amf" class="mx.messaging.channels.AMFChannel">
    <endpoint url="http://{server.name}:{server.port}/{context.root}/messagebroker/amfpolling" class="flex.messaging.endpoints.AMFEndpoint"/>
    <properties>
        <polling-enabled>true</polling-enabled>
        <polling-interval-seconds>4</polling-interval-seconds>
    </properties>
</channel-definition>




Piggybacking Polling
이 방식은 Simple Polling에서 일정한 간격에 의한 poll 이전에 다른 client의 메세지가 들어와 있을 경우, 다른 어떤 요청(Producer 또는 RemoteObject)을 보낸다면 그에 대한 결과와 더불어 메세지도 함께 응답 합니다.

설정 방법은 다음과 같습니다.

<channel-definition id="polling-amf" class="mx.messaging.channels.AMFChannel">
    <endpoint url="http://{server.name}:{server.port}/{context.root}/messagebroker/amfpolling" class="flex.messaging.endpoints.AMFEndpoint"/>
    <properties>
        <polling-enabled>true</polling-enabled>
        <polling-interval-seconds>4</polling-interval-seconds>
        <piggybacking-enabled >true</piggybacking-enabled >
    </properties>
</channel-definition>




Long Polling




이 방식은 polling 이지만 다른 client로 부터 메세지가 올 때까지(또는 설정한 기간 만큼) poll을 잡아 놓음으로써 real-time의 효과를 볼 수 있습니다.

설정 방법은 다음과 같습니다.
wait-interval-millis : (default 0) poll 의 대기시간 입니다. -1의 경우 다른 client의 메세지가 올 때까지 무한대로 기다립니다.
max-waiting-poll-requests : 대기하는 poll의 갯수입니다.

<channel-definition id="long-polling-amf" class="mx.messaging.channels.AMFChannel">
    <endpoint url="http://{server.name}:{server.port}/{context.root}/messagebroker/amfpolling" class="flex.messaging.endpoints.AMFEndpoint"/>
    <properties>
        <polling-enabled>true</polling-enabled>
        <wait-interval-millis>-1</wait-interval-millis>
        <polling-interval-millis>100</polling-interval-millis>
        <max-waiting-poll-requests>50</max-waiting-poll-requests>
    </properties>
</channel-definition>




Streaming




HTTP1.1 스펙의 open connection 기능을 이용함으로써, 서버 push를 구현하는 방법 입니다.
서버 push이기 때문에 real-time 그 자체라고 할 수 있습니다.

설정 방법은 다음과 같습니다.
max-streaming-clients : open connection의 갯수입니다.

<channel-definition id="streaming-amf" class="mx.messaging.channels.StreamingAMFChannel">
    <endpoint url="http://{server.name}:{server.port}/{context.root}/messagebroker/streamingamf" class="flex.messaging.endpoints.StreamingAMFEndpoint"/>
    <properties>
        <max-streaming-clients>10</max-streaming-clients>
    </properties>
</channel-definition>




퍼포먼스는 Stream -> long polling -> piggybacking polling -> simple polling 순으로 좋습니다.
설정 가능한 프로퍼티는 참고 문서를 참조 하세요.





참고 사이트. http://livedocs.adobe.com/blazeds/1/blazeds_devguide/help.html?content=lcconfig_3.html


Configuring channels with servlet-based endpoints


The servlet-based endpoints are part of both BlazeDS and LiveCycle Data Services ES.

Simple channels and endpoints

The AMFEndpoint and HTTPEndpoint are simple servlet-based endpoints. You generally use channels with these endpoints without client polling for RPC service components, which require simple call and response communication with a destination. When working with the Messaging Service, you can use these channels with client polling to constantly poll the destination on the server for new messages, or with long polling to provide near real-time messaging when using a streaming channel is not an option in your network environment.

Property

Description

polling-enabled

Optional channel property. Default value is false.

polling-interval-millis

Optional channel property. Default value is 3000. This parameter specifies the number of milliseconds the client waits before polling the server again. When polling-interval-millis is 0, the client polls as soon as it receives a response from the server with no delay.

wait-interval-millis

Optional endpoint property. Default value is 0. This parameter specifies the number of milliseconds the server poll response thread waits for new messages to arrive when the server has no messages for the client at the time of poll request handling. For this setting to take effect, you must use a nonzero value for the max-waiting-poll-requests property.

A value of 0 means that server does not wait for new messages for the client and returns an empty acknowledgment as usual. A value of-1 means that server waits indefinitely until new messages arrive for the client before responding to the client poll request.

The recommended value is 60000 milliseconds (one minute).

client-wait-interval-millis

Optional channel property. Default value is 0. Specifies the number of milliseconds the client will wait after it receives a poll response from the server that involved a server wait. A value of 0 means the client uses its configured polling-interval-millis value to determine the wait until its next poll. Otherwise, this value overrides the default polling interval of the client. Setting this value to 1 allows clients that poll the server with wait to poll immediately upon receiving a poll response, providing a real-time message stream from the server to the client. Any clients that poll the server and are not serviced with a server wait use the polling-interval-millis value.

max-waiting-poll-requests

Optional endpoint property. Default value is 0. Specifies the maximum number of server poll response threads that can be in wait state. When this limit is reached, the subsequent poll requests are treated as having zero wait-interval-millis.

piggybacking-enabled

Optional endpoint property. Default value is false. Enable to support piggybacking of queued messaging and data management subscription data along with responses to any messages the client sends to the server over this channel.

login-after-disconnect

Optional channel property. Default value is false. Setting to true causes clients to automatically attempt to reauthenticate themselves with the server when they send a message that fails because credentials have been reset due to server session timeout. The failed messages are resent after reauthentication, making the session timeout transparent to the client with respect to authentication.

flex-client-outbound-queue-processor

Optional channel property. Use to manage messaging quality of service for subscribers. Every client that subscribes to the server over this channel is assigned a unique instance of the specified outbound queue processor implementation that manages the flow of messages to the client. This can include message conflation, filtering, scheduled delivery and load shedding. You can define configuration properties, and if so, they are used to configure each new queue processor instance that is created. The following example shows how to provide a configuration property:

<flex-client-outbound-queue-processor class="my.company.QoSQueueProcessor"> <properties> <custom-property>5000</custom-property> </properties> </flex-client-outbound-queue-processor>
serialization

Optional serialization properties on endpoint. For more information, see Configuring AMF serialization on a channel.

connect-timeout-seconds

Optional channel property. Use to limit the client channel's connect attempt to the specified time interval.

invalidate-session-on-disconnect

Optional endpoint property. Disabled by default. If enabled, when a disconnect message is received from a client channel, the corresponding server session is invalidated. If the client is closed without first disconnecting its channel, no disconnect message is sent, and the server session is invalidated when its idle timeout elapses.

add-no-cache-headers

Optional endpoint property. Default value is true. HTTPS requests on some browsers do not work when pragma no-cache headers are set. By default, the server adds headers, including pragma no-cache headers to HTTP responses to stop caching by the browsers.

Non-polling AMF and HTTP channels

The simplest types of channels are AMF and HTTP channels in non-polling mode, which operate in a single request-reply pattern. The following example shows AMF and HTTP channel definitions configured for no polling:

<!-- Simple AMF -->
<channel-definition id="samples-amf"
    type="mx.messaging.channels.AMFChannel">
    <endpoint url="http://{server.name}:8400/myapp/messagebroker/amf"
        type="flex.messaging.endpoints.AmfEndpoint"/>
</channel-definition>
<!-- Simple secure AMF -->
<channel-definition id="my-secure-amf"
    class="mx.messaging.channels.SecureAMFChannel">
    <endpoint url="https://{server.name}:9100/dev/messagebroker/
        amfsecure" class="flex.messaging.endpoints.SecureAMFEndpoint"/>
</channel-definition>
<!-- Simple HTTP -->
<channel-definition id="my-http"
    class="mx.messaging.channels.HTTPChannel">
    <endpoint url="http://{server.name}:8400/dev/messagebroker/http"
        class="flex.messaging.endpoints.HTTPEndpoint"/>
</channel-definition>
<!-- Simple secure HTTP -->
<channel-definition id="my-secure-http" class="mx.messaging.channels.SecureHTTPChannel">
    <endpoint url=
        "https://{server.name}:9100/dev/messagebroker/
            httpsecure"
        class="flex.messaging.endpoints.SecureHTTPEndpoint"/>
</channel-definition>

Polling AMF and HTTP channels

You can use an AMF or HTTP channel in polling mode to repeatedly poll the endpoint to create client-pull message consumers. The interval at which the polling occurs is configurable on the channel. You can also manually poll by calling the poll() method of a channel for which polling is enabled; for example, you want set the polling interval to a high number so that the channel does not automatically poll, and call the poll() method to poll manually based on an event, such as a button click.

When you use a polling AMF or HTTP channel, you set the polling property to true in the channel definition. You can also configure the polling interval in the channel definition.

Note: You can also use AMF and HTTP channels in long polling mode to get pushed messages to the client when the other more efficient and real-time mechanisms are not suitable. For information about long polling, see Long polling AMF and HTTP channels.

The following example shows AMF and HTTP channel definitions configured for polling:

<!-- AMF with polling -->
<channel-definition id="samples-polling-amf"
    type="mx.messaging.channels.AMFChannel">
    <endpoint url="http://{server.name}:8700/dev/messagebroker/amfpolling"
        type="flex.messaging.endpoints.AMFEndpoint"/>
    <properties>
            <polling-enabled>true</polling-enabled>
            <polling-interval-seconds>8</polling-interval-seconds>
    </properties>
</channel-definition>
<!-- HTTP with polling -->
<channel-definition id="samples-polling-http"
    type="mx.messaging.channels.HTTPChannel">
    <endpoint url="http://{server.name}:8700/dev/messagebroker/httppolling"
        type="flex.messaging.endpoints.HTTPEndpoint"/>
    <properties>
            <polling-enabled>true</polling-enabled>
            <polling-interval-seconds>8</polling-interval-seconds>
    </properties>
</channel-definition>

Note: You can also use secure AMF or HTTP channels in polling mode.

Long polling AMF and HTTP channels

In the default configuration for a polling AMF or HTTP channel, the endpoint does not wait for messages on the server. When the poll request is received, it checks whether any messages are queued for the polling client and if so, those messages are delivered in the response to the HTTP request. You configure long polling in the same way as polling, but you also must set the wait-interval-millismax-waiting-poll-requests, and client-wait-interval-millis properties.

To achieve long polling, you set the following properties in the properties section of a channel definition in the services-config.xml file:

  • polling-enabled
  • polling-interval-millis
  • wait-interval-millis
  • max-waiting-poll-requests.
  • client-wait-interval-millis

Using different settings for these properties results in different behavior. For example, setting the wait-interval-millis property to 0 (zero) and setting thepolling-interval-millis property to a nonzero positive value results in normal polling. Setting the wait-interval-millis property to a high value reduces the number of poll messages that the server must process, but the number of request handling threads on the server limits the total number of parked poll requests.

The following example shows AMF and HTTP channel definitions configured for long polling:

<!-- Long polling AMF -->
<channel-definition id="my-amf-longpoll" class="mx.messaging.channels.AMFChannel">
    <endpoint
        url="http://servername:8700/contextroot/messagebroker/myamflongpoll" 
        class="flex.messaging.endpoints.AMFEndpoint"/>
    <properties>
        <polling-enabled>true</polling-enabled>
        <polling-interval-seconds>0</polling-interval-seconds>
        <wait-interval-millis>60000</wait-interval-millis>
        <client-wait-interval-millis>3000</client-wait-interval-millis>
        <max-waiting-poll-requests>100</max-waiting-poll-requests>
    </properties>
</channel-definition>

<!-- Long polling HTTP -->
<channel-definition id="my-http-longpoll" class="mx.messaging.channels.HTTPChannel">
    <endpoint
        url="http://servername:8700/contextroot/messagebroker/myhttplongpoll" 
        class="flex.messaging.endpoints.HTTPEndpoint"/>
    <properties>
        <polling-enabled>true</polling-enabled>
        <polling-interval-seconds>0</polling-interval-seconds>
        <wait-interval-millis>60000</wait-interval-millis>
        <client-wait-interval-millis>3000</client-wait-interval-millis>
        <max-waiting-poll-requests>100</max-waiting-poll-requests>
    </properties>
</channel-definition>

Note: You can also use secure AMF or HTTP channels in polling mode.

The caveat for using the wait-interval-millis BlazeDS is the utilization of available application server threads. Because this channel ties up one application server request handling thread for each parked poll request, this mechanism can have an impact on server resources and performance. Modern JVMs can typically support about 200 threads comfortably if given enough heap space. Check the maximum thread stack size (often 1 or 2 megabytes per thread) and make sure that you have enough memory and heap space for the number of application server threads you configure.

To ensure that Flex clients using channels with wait-interval-millis do not lock up your application server, BlazeDS requires that you set the max-waiting-poll-requests property, which specifies the maximum number of waiting connections that BlazeDS should manage. This number must be set to a number smaller than the number of HTTP request threads your application server is configured to use. For example, you configure the application server to have at most 200 threads and allow at most 170 waiting poll requests. This setting would ensure that you have at least 30 application server threads to use for handling other HTTP requests. Your free application server threads should be large enough to maximize parallel opportunities for computation. Applications that are I/O heavy can require a large number of threads to ensure all I/O channels are utilized completely. Multiple threads are useful for the following operations:

  • Simultaneously writing responses to clients behind slow network connections
  • Executing database queries or updates
  • Performing computation on behalf of user requests

Another consideration for using wait-interval-millis is that BlazeDS must avoid monopolizing the available connections that the browser allocates for communicating with a server. The HTTP 1.1 specification recommends that browsers allocate at most two connections to the same server when the server supports HTTP 1.1. To avoid using more that one connection from a single browser, BlazeDS allows only one waiting thread for a given application server session at a time. If more than one Flash Player instance within the same browser process attempts to interact with the server using long polling, the server forces them to poll on the default interval with no server wait to avoid busy polling.

Streaming AMF and HTTP channels

The streaming AMF and HTTP channels are HTTP-based streaming channels that the BlazeDS server can use to push updates to clients using a technique called HTTP streaming. These channels give you the option of using standard HTTP for real-time messaging. This capability is supported for HTTP 1.1, but is not available for HTTP 1.0. There are also a number of proxy servers still in use that are not compliant with HTTP 1.1. When using a streaming channel, make sure that the channel hasconnect-timeout-seconds defined and the channel set has a channel to fall back to, such as an AMF polling channel.

Using streaming AMF or HTTP channels/endpoints is like setting a long polling interval on a standard AMF or HTTP channel/endpoint, but the connection is never closed even after the server pushes the data to the client. By keeping a dedicated connection for server updates open, network latency is greatly reduced because the client and the server do not continuously open and close the connection. Unlike polling channels, because streaming channels keep a constant connection open, they can be adversely affected by HTTP connectors, proxies, reverse proxies or other network components that can buffer the response stream.

The following table describes the channel and endpoint configuration properties in the services-config.xml file that are specific to streaming AMF and HTTP channels/endpoints. The table includes the default property values as well as considerations for specific environments and applications.

Property

Description

connect-timeout-seconds

Using a streaming connection that passes through an HTTP 1.1 proxy server that incorrectly buffers the response sent back to the client hangs the connection. For this reason, you must set the connect-timeout-seconds property to a relatively short timeout period and specify a fallback channel such as an AMF polling channel.

idle-timeout-minutes

Optional channel property. Default value is 0. Specifies the number of minutes that a streaming channel is allowed to remain idle before it is closed. Setting the idle-timeout-minutes property to 0 disables the timeout completely, but it is a potential security concern.

max-streaming-clients

Optional endpoint property. Default value is 10. Limits the number of Flex clients that can open a streaming connection to the endpoint. To determine an appropriate value, consider the number of threads available on your application server because each streaming connection open between a FlexClient and the streaming endpoints uses a thread on the server. Use a value that is lower than the maximum number of threads available on the application server.

This value is for the number of Flex client application instances, which can each contain one or more MessageAgents (Producer or Consumer components).

server-to-client-heartbeat-millis

Optional endpoint property. Default value is 5000. Number of milliseconds that the server waits before writing a single byte to the streaming connection to make sure that the client is still available. This is important to determine when a client is no longer available so that its resources associated with the streaming connection can be cleaned up. Note that this functionality keeps the session alive. A non-positive value disables this functionality.

user-agent-settings

Optional endpoint property. Default values are as shown in the following example:

<user-agent-settings> <user-agent match-on="MSIE" kickstart-bytes= "2048" max-streaming-connections-per-session="1"/> <user-agent match-on="Firefox" kickstart-bytes="0" max-streaming-connections-per-session="1"/> </user-agent-settings>

User agents are used to customize the streaming endpoint for specific web browsers for the following reasons:

  • A certain number of bytes must be written before the endpoint can reliably use a streaming connection as specified by the kickstart-bytes attribute.
  • There is a browser-specific limit to the number of connections allowed per session. In Firefox, the limit is eight connections per session. In Internet Explorer, the limit is two connections allowed per session. Therefore, BlazeDS must limit the number of streaming connections per session on the server to stay below this limit.

By default, BlazeDS uses 1 as the value for max-streaming-connections-per-session. You can change the values for Internet Explorer and Firefox, and you can add other browser-specific limits by specifying a new user-agent element with a match-on value for a specific browser user agent.

The following example shows streaming AMF and HTTP channel definitions:

<!-- AMF with streaming -->
<channel-definition id="my-amf-stream"
    class="mx.messaging.channels.StreamingAMFChannel">
    <endpoint url="http://servername:2080/myapp/messagebroker/streamingamf" 
        class="flex.messaging.endpoints.StreamingAMFEndpoint"/>
</channel-definition>

<!-- Secure AMF with streaming -->
<channel-definition id="my-secure-amf-stream"
    class="mx.messaging.channels.SecureStreamingAMFChannel">
    <endpoint url="http://servername:2080/myapp/messagebroker/securestreamingamf" 
        class="flex.messaging.endpoints.SecureStreamingAMFEndpoint"/>
</channel-definition>

<!-- HTTP with streaming -->
<channel-definition id="my-http-stream"
    class="mx.messaging.channels.StreamingHTTPChannel">
    <endpoint url="http://servername:2080/myapp/messagebroker/streaminghttp" 
        class="flex.messaging.endpoints.StreamingHTTPEndpoint"/>
</channel-definition>

<!-- Secure HTTP with streaming -->
<channel-definition id="my-secure-http-stream"
    class="mx.messaging.channels.SecureStreamingHTTPChannel">
    <endpoint url="http://servername:2080/myapp/messagebroker/securestreaminghttp" 
        class="flex.messaging.endpoints.SecureStreamingHTTPEndpoint"/>
</channel-definition>


:
Posted by 라면스프
2013. 3. 22. 18:52

grep 옵션 Enjoy/etc2013. 3. 22. 18:52

출처 : http://radiocom.kunsan.ac.kr/lecture/unix_cmd/grep.html


grep


지정한 파일에서 정규 표현식으로 나타낸 단어를 찾아 그 단어가 있는 라인을 출력함


하나 또는 그 이상의 파일에서 찾고 싶은 어떤 문자들을 검색하여 그 문자를 포함하는 라인들을 찾고, 찾은 라인 모두를 인쇄한다. grep 명령의 기본 구문은 다음과 같다.

grep 문자열 파일명

grep 문자열 *

grep [-chinvw] 'pattern' file_name [file_names]

-ccount 옵션은 파일 이름 다음에 패턴이 들어 있는 라인의 수를 표시
-hhide 옵션은 파일이름을 출력하지 않음
-iignore옵션은 대소문자 구분하지 않고 찾음
-nline number 옵션은 출력하는 각 라인에 라인번호를 붙임
-vinverse 옵션은 패턴이 없는 라인만 출력
-wword 옵션은 패턴 자체가 완전한 단얼로 독립되었을 경우만 글자로 인식함

여기서 ‘문자열’는 사용자가 찾으려는 단어 또는 구를 나타내고 ‘파일명’은 검색 대상 파일이다. ‘문자열’은 하나 또는 여러 문자를 의미한다. 단일 문자도 단어나 문장과 같이 하나의 문자열이다. 문자열에는 “빈칸”, 구두점과 보이지 않는 (제어) 문자들이 포함될 수 있다.

파일명은 지정하면 해당 파일에서만 찾지만, 파일명을 *와 같은 메타문자를 사용하면 현재 디렉토리의 모든 파일을 대상으로 하므로 디렉토리내의 모든 파일내에서 해당 문자열을 찾게된다.

grep, egrep, fgrep의 차이를 간단히 요약하여 정리하면 다음과 같다.

fgrep정규 표현식을 사용하지 않음
grep정규 표현식을 사용함
egrep정규 표현식과 확장 표현식을 사용

【예제】
    % grep s01287 /etc/passwd
    s01287:x:1028:103:choi eun sook:/export/home0/class12/s01287:/bin/csh
    %
grep은 다른 명령어들과 함께 “필터”로 자주 사용된다. grep은 사용자가 명령의 수행결과에서 불필요한 정보를 제거할 수 있도록 한다. grep을 필터로 사용하려면, 반드시 명령의 수행 결과를 grep을 통해 파이프(|) 해야 한다. 다음 예제는 파일 이름이 “.ps”로 끝나는 파일 중에서 5월에 생성된 것들을 나타낸다.

ls -l *.ps ¦ grep May

또한 여러 단어로 구성된 패턴을 찾으려면, 단일(‘ ’) 또는 이중(“ ”) 인용부호를 사용하여 해당 문자열을 묶어 준다.

grep "JoonIk Joe" phonebook

grep을 사용하여 파일 그룹에서 특정 문자열을 찾을 수 있다. grep이 여러 파일에서 일치하는 패턴을 찾은 경우, 먼저 해당 파일 이름과 콜론을 인쇄한 후 그 패턴과 일치하는 줄을 인쇄한다.

grep ar *

파일에서 특정 문자열을 포함하고 있지 않은 모든 줄을 찾으려면, grep에서 -v 옵션을 사용한다. 다음 예제는 현 디랙토리에 있는 파일 중에서 문자 e를 포함되지 않은 줄을 찾는 방법이다.

grep -v e *

정규 표현식을 사용하여 패턴으로 정의된 대상을 찾을 때 grep 명령을 사용할 수도 있다. 정규 표현식은 문자 및 숫자들과 grep에 특수한 의미를 갖는 문자로 구성된다. 메타문자인 특수 문자들은 시스템에서도 특수한 의미를 가지므로 인용부호나 이스케이프 문자를 사용해야 한다. 명령어 프롬프트 상태에서 grep 정규 표현식을 사용할 때마다 인용부호 또는 백슬래시(\)로 메타문자들(& ! . * $ ? 및 \)을 묶어 주어야 한다.

    % grep '^b' list    ☜  파일 list에서 “b”로 시작하는 줄을 찾는다.
    % grep 'b$' list    ☜  파일 list에서 마지막 문자가 ‘b’로 끝나는 줄을 찾음
    % grep '^b$' list   ☜  파일 list에서 “b”만 있는 줄을 찾음
    % grep 'an. ' list  ☜  세 자리 문자 중 처음 두 문자가 “an”으로 시작되는 것
    % grep 'qu*‘ list  ☜ 문자 “qu”가 포함된 모든 단어를 찾음
    % grep 'nn*' list   ☜ 문자 “n”을 포함하는 모든 단어를 찾음
    % grep 'nnn*' list  ☜ 문자 “nn”을 포함하는 모든 단어를 찾음
    % grep .* list      ☜ 어떤 문자가 나타나지 않거나 여러 번 나타난 경우를 찾음

정규 표현식에서 메타문자(& ! . * ? $ 및 \) 앞에 백슬래시(\)를 나타내면 grep으로 하여금 그것의 특수 의미를 무시하도록 한다.

예를 들어

    % grep ^\.       ☜ 마침표로 시작되는 줄을 찾음 
    % grep '\$'      ☜ "$" 문자가 포함된 줄을 찾음 

다음은 grep 탐색 패턴을 만드는데 자주 쓰이는 정규 표현식 기호이다

1) 일반 정규 표현식

기호의미사용 예설명
^라인의 첫 글자^aa자로 시작하는 라인
$라인의 끝 글자a$a자로 끝나는 라인
.한 글자a...ba와 b 사이에 3 글자가 있는 단어
** 기호 바로 이전의 글자나 정규 표현식이 
0회 이상 반복
abc*c가 0번 이상 반복
ab, abc, abcc, abccc 등
[ ]한글자를 대체할 글자의 목록을 []에 나열, "¦"를 여러 개 쓴 것과 같은 의미

"-" 기호와 함께 쓰면 문자의 범위를 지정할 수 있음

[abc]dad, bd, cd를 뜻함, a,b,c 중 어떤 한 글자라도 반드시 있는 단어

"[a-z]"는 a부터 z까지 중 하나, "[1-9]"는 1부터 9까지 중의 하나를 뜻함

[^]한글자를 대체하지 못할 글자의 목록을 [^ ]에 나열

"-" 기호와 함께 쓰면 문자의 범위를 지정할 수 있음

[^abc]dad, bd, cd는 포함하지 않고 ed, fd 등을 포함

[^a-z]는 알파벳 소문자로 시작하지 않는 모든 문자를 나타냄

2) 확장 정규 표현식

기호의미사용 예설명
++ 기호 바로 이전의 글자나 정규 표현식이
1회 이상 반복
abc+c가 1회 이상 반복 : abc, abcc, abccc 등
?? 기호 바로 이전의 글자나 정규 표현식이
없거나 1회만 존재
abc?c가 없거나 한번만 존재 : ab, abc
()부분 정규 표현식의 시작과 끝을 표시a(bc)*
a(bc)+
a(bc)?
bc가 0회 이상 반복 : a, abc, abcbc 등
bc가 1회 이상 반복 : abc, abcbc 등
bc가 있거나 없거나 : a, abc
¦¦로 구분된 단어들 중 최소 하나가 존재a(b¦c)b 또는 c가 최소 하나 존재 : ab, ac, abc, acb
{m,n}{} 기호 바로 이전의 글자나 정규 표현식이
m개 이상 n개 이하 반복
a{1,3}b'ab', 'aab', 'aaab'를 포함하지만,
'b'나 'aaaab'는 포함하지 않음

효율적인 검색을 위해 grep 명령어를 변형한 2개의 명령어가 제공된다.

그중 하나는 fgrep(fixed grep 또는 fast grep) 명령어로 이 명령어는 정규 표현식이 아닌 단순한 문자열만을 인수로 사용한다.

또 하나의 명령어인 egrep(extended grep) 명령어는 fgrep와는 반대로 grep보다 더 다양한 정규 펴현식 연산자를 사용할 수 있다. 일반적으로 grep 명령어가 제일 사용하기 편리하다.

【예제】
    % cat aa
    jinpo	202.31.146.123
    radio	202.31.146.122
    knusun1	202.30.55.11
    knu2000	202.30.55.15
    % grep 11 aa
    radio	202.31.146.122
    knusun1	202.30.55.11

fgrep 명령은 grep와 비슷하지만, 다중 표적 탐색에 쓸 수 있으나, 패턴 탐색을 위한 정규 표현식은 허용되지 않고, grep보다 빠르다. fgrep에서 다중 표적을 줄 때는 각 표적이 분리된 라인으로 하여야 되고, 다중 표적 설정 시 인용부호로 묶어야 한다.

【예제】
    # fgrep "jinpo
    > knusun1" aa
    jinpo	202.31.146.123
    knusun1	202.30.55.11

egrep는 grep 명령 패밀리 중 가장 강력하다. fgrep처럼 다중 표적 탐색을 할 수 있고, 표적 설정에 정규 표현식을 쓸 수 있으며, 보다 완전하고 강력한 정규 표현식을 제공한다.

egrep 명령은 문자 반복에 +, 0이나 ?을 사용할 수 있고, egrep는 다중 표적을 fgrep처럼 분리된 라인에 넣거나, 수직 바나 파이프 기호(¦)로 구분한다. 파이프 기호와 표적 사이에는 빈칸이 없어야 한다.

【예제】
    # egrep "jinpo
    > radio" aa
    jinpo	202.31.146.123
    radio	202.31.146.122
    # egrep "jinpo¦radio" aa
    jinpo	202.31.146.123
    radio	202.31.146.122
    # 
현재 디렉토리 내의 모든 파일을 점검하여 지정한 문자열을 찾을 수 도 있다.

【예제】

grep abc * ☜ *은 모든 파일을 의미함
fgrep abc * ☜ *은 모든 파일을 의미함
【예제】
$ grep Adm /etc/group /etc/passwd
/etc/passwd:adm:x:4:4:Admin:/var/adm:
/etc/passwd:lp:x:71:8:Line Printer Admin:/usr/spool/lp:
/etc/passwd:uucp:x:5:5:uucp Admin:/usr/lib/uucp:
/etc/passwd:nuucp:x:9:9:uucp Admin:/var/spool/uucppublic:/usr/lib/uucp/uucico
/etc/passwd:listen:x:37:4:Network Admin:/usr/net/nls:

$ grep -n Adm /etc/group /etc/passwd  ☜  줄번호도 표기
/etc/passwd:5:adm:x:4:4:Admin:/var/adm:
/etc/passwd:6:lp:x:71:8:Line Printer Admin:/usr/spool/lp:
/etc/passwd:7:uucp:x:5:5:uucp Admin:/usr/lib/uucp:
/etc/passwd:8:nuucp:x:9:9:uucp Admin:/var/spool/uucppublic:/usr/lib/uucp/uucico
/etc/passwd:10:listen:x:37:4:Network Admin:/usr/net/nls:

$ grep -h Adm /etc/group /etc/passwd  ☜ 파일명을 출력하지 않음
adm:x:4:4:Admin:/var/adm:
lp:x:71:8:Line Printer Admin:/usr/spool/lp:
uucp:x:5:5:uucp Admin:/usr/lib/uucp:
nuucp:x:9:9:uucp Admin:/var/spool/uucppublic:/usr/lib/uucp/uucico
listen:x:37:4:Network Admin:/usr/net/nls:

$ grep -c Adm /etc/group /etc/passwd  ☜  검색어가 있는 라인의 개수를 출력
/etc/group:0
/etc/passwd:5

$ grep -i Adm /etc/group /etc/passwd  ☜ 대소문자 구분없이 검색어를 찾음
/etc/group:sys::3:root,bin,adm
/etc/group:adm::4:root,daemon
/etc/group:tty::7:root,adm
/etc/group:lp::8:root,adm
/etc/group:sysadmin::14:
/etc/passwd:adm:x:4:4:Admin:/var/adm:
/etc/passwd:lp:x:71:8:Line Printer Admin:/usr/spool/lp:
/etc/passwd:uucp:x:5:5:uucp Admin:/usr/lib/uucp:
/etc/passwd:nuucp:x:9:9:uucp Admin:/var/spool/uucppublic:/usr/lib/uucp/uucico
/etc/passwd:listen:x:37:4:Network Admin:/usr/net/nls:
$ 
【예제】
$ grep 'Network' /etc/passwd
listen:x:37:4:Network Admin:/usr/net/nls:

$ grep 'uucp' /etc/passwd
uucp:x:5:5:uucp Admin:/usr/lib/uucp:
nuucp:x:9:9:uucp Admin:/var/spool/uucppublic:/usr/lib/uucp/uucico

$ egrep '(Network¦uucp)' /etc/passwd
uucp:x:5:5:uucp Admin:/usr/lib/uucp:
nuucp:x:9:9:uucp Admin:/var/spool/uucppublic:/usr/lib/uucp/uucico             
listen:x:37:4:Network Admin:/usr/net/nls:
$
【예제】
$ grep '$' /etc/init.d/ufs_quota  ☜ $는 줄 끝을 의미

#!/sbin/sh
#
# Copyright (c) 1993, 1997 by Sun Microsystems, Inc.
# All rights reserved.
#
#ident  "@(#)ufs_quota  1.2     97/12/08 SMI"

case "$1" in
'start')
        /usr/sbin/quotacheck -a
        /usr/sbin/quotaon -a
        ;;

'stop')
        /usr/sbin/quotaoff -a
        ;;

*)
        echo "Usage: $0 { start ¦ stop }"
        exit 1
        ;;
esac
exit 0
$ fgrep '$' /etc/init.d/ufs_quota ☜ $은 문자 $을 의미함 case "$1" in echo "Usage: $0 { start ¦ stop }" $

grep정규 표현식을 사용하여 파일에서 문자열을 찾음
egrep정규 표현식과 확장 정규 표현식을 사용하여 파일에서 여러 개의 문자열을 찾을때 편리
fgrep정규 표현식을 사용하지 않기 때문에 메타문자 따위도 파일에서 찾을 수 있음
pgrep지정한 프로세스를 찾음 (cf: ps -A)

:
Posted by 라면스프


출처 : http://blog.daum.net/nyx21/7577691

 출처  - 자바 개발자를 위한 이클립스 바이블 제 2판 (피어슨에듀케이션코리아) p.287~288



목적확장점
오브젝트 레이블에 텍스트나 아이콘 장식 추가org.eclipse.ui.decorators
Window > Show View 메뉴 선택에 새로운 뷰 기여org.eclipse.ui.views
새로 만들기 마법사org.eclipse.ui.newWizards
표준 Export… 과 Import 메뉴 선택에 새로운 마법사 기여org.eclipse.ui.exportWizards
org.eclipse.ui.importWizards
표준 File > New 메뉴 선택에 새로운 마법사 기여org.eclipse.ui.newWizards
Window > Preferences 대화상자에 설정 페이지 기여org.eclipse.ui.preferencePages
오브젝트의 프로퍼티 대화상자에 페이지 기여org.eclipse.ui.propertyPages
리소스에 대한 새로운 편집기 정의
Open With 메뉴 분기에 선택으로 보인다.
org.eclipse.ui.editors
Window > Open Perspective 메뉴 선택에 대한 새로운 퍼스
펙티브 정의. 새로운 퍼스펙티브의 숏컷, 뷰 숏컷 그리고 기
존의 퍼스펙티브에 액션 집합 추가
org.eclipse.ui.perspectives
org.eclipse.ui.perspectiveExtentions
워크벤치 윈도우 메뉴 바 또는 툴바에 액션 기여org.eclipse.ui.actionSets
퍼스펙티브에서 지정된 뷰/편집기가 열려 있다면 웨크벤치
윈도우 메뉴 바 또는 툴바에 액션을 기여
org.eclipse.ui.actionSetPartAssociations
편집기의 툴바나 메뉴 선택에 액션 기여org.eclipse.ui.editorActions
편집기, 뷰 또는 객체의 콘텍스트 메뉴에 액션 기여org.eclipse.ui.popupMenus
뷰의 툴바나 풀다운 메뉴에 기여org.eclipse.ui.viewActions
Help > Help Contents 선택으로 활용 가능한 온라인 도움말
정의
org.eclipse.ui.help
org.eclipse.help.contentProducer
네비게이터 뷰의 Filter… 메뉴 선택에 대한 추가적인 필터
정의
org.eclipse.ui.ide.resourceFilters
기존의 리소스 또는 새로운 리소스 타입에 대해 자신만의
점진적인 빌드 과정 정의(Project > Rebuild Project).
프로젝트 기능을 향상
org.eclipse.core.resources.builders
org.eclipse.core.resources.natures
사용자 정보로 리소스에 태그를 붙임. 마커는 태스크 뷰나,
텍스트 편집기의 수직 표시자와 같은 뷰나 편집기와 아웃
라인 뷰에서 레이블 장식으로 표시될 수 있다.
org.eclipse.core.resources.markers
만들어져 있는 텍스트 편집기, JFace Text 는 사용자의 일관
된 편집 경험을 보장하기 위해 화장 가능하고 재사용 가능
한 텍스트 편집기를 제공한다. 그것을 알맞게 조정하여 표
시자에서 유일한 텍스트 주석에 대한 추가적인 요구, 라인
숫자, 구문 강조, 내용 돕기와 같은 추가적인 정보를 알려줄
수 있다.
org.eclipse.core.filebuffers.documentSetup
org.eclipse.ui.editors.templates
사용자의 행동에 기반하여 활용 가능한 옵션의 수 줄이기org.eclipse.ui.activities


:
Posted by 라면스프
2013. 1. 29. 15:43

SVN 권한 설정 Enjoy/etc2013. 1. 29. 15:43


출처 : http://ummae.tistory.com/197



SVN 권한 설정


svnserve.conf

[general]
anon-access=none
auth-access = write
password-db = passwd
authz-db = authz
realm = Kanji_Proj

요로코롬 짧아진다. 그럼 각각의 의미를 알아 보자.

[general]
anon-access=none           #인증되지않은(즉 계정이 없는) 사용자에 대해 접근을 거부한다.
auth-access = write          #인증된 사용자에 대해 쓰기 권한을 준다.
password-db = passwd     # 인증된 사용자에 대한 계정 정보(아이디/패스) 정보가 기록된 파일명을 의미한다.(기본값 passwd) 
authz-db = authz              # 인증된 사용자에 대해 저장소에 대한 권한 설정이 기록된 파일명(기본값)
#realm = Kanji_Proj             #현재 파일에 해당되는 저장소의 영역에 대해 설정하는 것인데 여기서는 주석처리로 하고 넘어가자.(ㅌㅌ)

즉, 인증된 사용자에게 저장소의 접근권한을 일체 주지 않고, 인증된 사용자에게만 접근을 허용하는 그런 의미를 갖는 svnserve.conf파일이 되겠다. 

다음으로 passwd 파일을 살펴보자.

passwd 

[users]
# harry = harryssecret
# sally = sallyssecret

aaa = a
bbb = b
ccc = c

= 를 기준으로 왼쪽이 아이디 오른족이 비밀번호가 된다. 
id: aaa, pw: a
id: bbb, pw: b 이런식이다.

마지막으로 authz

authz

[groups]
# harry_and_sally = harry,sally
gABC = aaa, bbb, ccc

# [/foo/bar]
# harry = rw
# * =

# [repository:/baz/fuz]
# @harry_and_sally = rw
# * = r

[/]
@gABC = r

[ABC:/]
* = r
@gABC  = rw

authz 파일의 의미를 살펴보자

[groups]
# harry_and_sally = harry,sally   # 사용자를 그룹단위로 묶을 수 있다.
gABC = aaa, bbb, ccc               # 즉, 사용자 aaa, bbb, ccc를 묶어서 gABC라는 그룹으로 관리.

# [/foo/bar]
# harry = rw
# * =

# [repository:/baz/fuz]             #repository저장소의 /baz/fuz위치에 대한 권한
# @harry_and_sally = rw            #@<-의 의미는 그룹을 뜻한다. harry_and_sally 그룹에 읽기/쓰기권한을 준다.
# * = r                                     # * 는 모든 사용자를 의미한다. 모든 사용자에게 읽기 권한을 준다.            

[ABC:/]                                 #ABC:/저장소
* = r                                       #모든 사용자에게 읽기 권한을 준다.
@gABC  = rw                          #gABC그룹에게 읽기/쓰기 권한을 준다.


주의 1. authz 파일에 보면 *(와일드카드)가 모든 사용자를 의미한다고 했는데, 만약 svnserve.conf 파일에 anon-access=none (인증된 사용자에 대한 권한접근을 거부) 설정이 안되 있으면 말 그대로 아이디가 있건 없고 모든 접속한 사용자에 대한 권한이 되 버린다. 하지만 anon-access=none 이 설정되 되어 있다면 아이디/비번을(계정) 을 갖고 있는 사용자들에 대한 권한 설정이 될 것이다.

:
Posted by 라면스프
2013. 1. 21. 11:06

SVN(Subversion) 명령어 사용 방법 Enjoy/etc2013. 1. 21. 11:06

출처 : http://blog.naver.com/sjh77ch/62179981



SVN(Subversion)은 형상관리를 위한 도구이다. 다시 말하면 소프트웨어 개발의 버전 관리 시스템이다.

 

SVN에서 많이 사용되는 명령어는 다음과 같다.

 

checkout 또는 co - 저장소(repository)에서 로컬 작업공간으로 소스를 받아오는 것.

$ svn checkout 저장소URL [PATH...]

: 지정된 로컬경로에 저장소의 소스가 복사된다. 경로가 지정안되면 저장소URL의 맨마지막 디렉토리명이 저장될 디렉토리로 사용되어진다. -r 옵션으로 리비전을 지정한 경우엔 해당 리비전의 소스를 가져온다.

예제) svn checkout -r 99 http://repository/src src

설명) 저장소에서 리비전 번호 99의 src경로내의 소스를 가져온다.

 

update 또는 up - 저장소(repository)의 최신 내용으로 로컬 소스를 갱신 한다.

$ svn update [PATH...]

: 기본적으로 최신 리비전을 반영한다. 그러나 -r 옵션으로 리비전을 지정한 경우엔 그 리비전으로 맞춘다.

 

commit 또는 ci - 로컬에서 수정된 내용을 저장소에 적용시킨다.

$ svn commit [PATH...]

: 기본적으로 이 명령을 내리면 수정 사항을 코멘트할 수 있게 로그 편집기가 실행된다. lock된 파일이나 디렉토리는 commit성공후 자동적으로 unlock된다.

 

lock - 저장소의 파일이나 디렉토리를 잠근다.

$ svn lock TARGET

: lock이 걸린 파일이나 디렉토리는 다른 사용자가 변경하여 commit할 수 없다. 해당 경로의 작업이 너무 방대하여 그 동안 다른 사용자가 수정하지 못하도록 할때 유용.

 

unlock - 저장소의 잠근 파일이나 디렉토리를 풀어준다.

$ svn unlock TARGET

: lock의 반대. 기본적으로 lock을 건 사용자가 풀어줘야 한다.

 

add - 새 파일이나 디렉토리를 추가한다.

$ svn add PATH...

: add 명령은 지정된 PATH의 새로운 파일이나 디렉토리를 버전관리 대상에 등록할 뿐이므로, add후 commit 명령을 수행해야만 실제로 저장소에 해당 파일이 추가된다.

 

delete 또는 del, remove, rm - 파일이나 디렉토리를 제거한다.

$ svn delete PATH...(URL)

: delete 명령은 add와 반대로 해당 PATH의 파일이나 디렉토리을 버전관리 대상에서 삭제한다. 역시 commit 명령을 수행해야만 실제로 저장소에서 해당 목록이 제거된다. URL로 지정했을 경우 해당 목록은 즉시 저장소에서 제거된다.

 

 

copy 또는 cp - 로컬 사본이나 저장소 내용을 복사한다. 브랜치(branch)를 만들기 위해 사용.

$ svn copy SRC  DST

: SRC가 로컬경로이고 DST도 로컬경로일 경우, 로컬복사되고 commit시 저장소에 복사 목록이 추가 저장된다. SRC가 로컬경로이고 DST가 저장소URL일 경우, URL에 복사되고 즉시 commit됨. SRC가 저장소URL이고 DST가 로컬경로일 경우, 로컬로 checkout하고 commit시 저장소에 해당 사본이 추가.

SRC가 저장소URL이고 DST도 저장소URL일 경우, 저장소 내에 브랜치(branch)를 만듬.

 

move 또는 mv, rename, ren - 파일이나 디렉토리의 이름을 바꾸거나 이동시킨다. 이 명령은 copy후 delete와 같다.

$ svn move SRC  DST

: SRC가 로컬경로이고 DST도 로컬경로일 경우, 로컬로 rename 또는 move되고 commit시 저장소에 반영된다. SRC가 저장소URL이고 DST도 저장소URL일 경우, 저장소에서 rename,move가 바로 commit됨.

 

info - 해당 파일에 대한 정보를 출력한다.

$ svn info TARGET

: TARGET의 저장소 URL경로나 마지막 수정 일자등에 대한 정보를 보여준다.

 

log - 해당 경로나 파일의 로그( 리비전에 따라 변경된 내역)를 볼수 있다.

$ svn log [PATH]

: 지정된 로컬 PATH에 대한 로그를 출력한다. -r 옵션을 지정하면 출력할 리비젼 범위등을 정할 수 있다.

예제) svn log -r 30:100 test.c

설명) 리비전 번호 30~100 내에서 test.c에 대한 로그를 출력한다.

 

status 또는 stat, st - 로컬 경로의 파일이나 디렉토리의 상태를 보여준다.

$ svn status [PATH]

: 해당 파일이 수정, 추가되었는지 등의 정보를 보여준다. -u 옵션을 주면 저장소의 최신 리비젼이 얼마인지 알려준다.

 

diff 또는 di - 서로 다른 리비젼 간에 차이점을 출력해준다.

$ svn diff [-r N:MTARGET

: 지정된 파일이나 경로에 대해 이전 리비젼하고 차이점을 보여준다. -r 을 지정하면 리비젼 N과 M사이의 차이점을 출력해준다.

예제) svn -r 30:45 test

설명) test 경로내에서 리비젼 번호 30과 45의 차이점을 출력해준다.

 

merge - 두 source 사이에 변경 내용을 작업 경로에 적용해준다.

1. $ svn merge URL1[@NURL2[@M] [PATH]

2. $ svn merge [-r N:MSOURCE [PATH]

: 1. URL1[리비젼 N]과 URL2[리비젼 M]을 비교하여, 변경 내용을 작업경로에 적용한다.

  2. SOURCE의 리비젼 N과 M을 비교하여, 해당 작업경로에 적용한다.

merge는 branch로 분리된 source에 대해 각각의 변경 내용을 현재의 작업에 병합하고자 할때 유용하다.

 

blame 또는 praise, annotate, ann - 지정한 파일이나 URL의 내용 수정내역을 각 라인별로 보여준다.

$ svn blame TARGET

: 해당 파일의 각 라인에 대해 리비젼과 작성자를 나타내 준다. 누가 언제 어떤행을 수정했는지 알수 있음.

 

import - 파일과 디렉토리를 저장소에 추가한다.

$ svn import [PATHURL

 

: URL에 지정된 PATH의 하위 디렉토리는 재귀적으로 추가되며, 필요시 상위 디렉토리가 자동으로 생성된다.

 

export - 저장소에서 순수하게 프로그램 소스만 가져온다.

$ svn export URL [PATH]

: export는 버전관리를 위한 부속 파일들은 제외하고 순수한 소스만 받아오기 때문에, 주로 source release 용도로 사용되게된다. -r 옵션을 지정해서 해당 리비젼의 소스를 받아올 수 있다.

:
Posted by 라면스프