반응형
반응형

https://jsfiddle.net/

 

Create a new fiddle - JSFiddle

 

jsfiddle.net

웹의 프론트엔드 기술인 HTML, CSS, JavaScript를 웹에서 작성해서 바로 테스트 해볼 수 있고, 그 소스를 저장 공유할 수 있는 서비스이다.

 

https://jsfiddle.net/user/mill01/fiddles/

 

kim hongwan's Fiddles - JSFiddle - Code Playground

 

jsfiddle.net

반응형
반응형

JAVA excel - [POI] POI 엑셀 - Using newlines in cells ( 셀에서 줄바꿈 )

 CellStyle cs = wb.createCellStyle();
    cs.setWrapText(true);
    cell.setCellStyle(cs);

   Workbook wb = new XSSFWorkbook();   //or new HSSFWorkbook();
    Sheet sheet = wb.createSheet();

    Row row = sheet.createRow(2);
    Cell cell = row.createCell(2);
    cell.setCellValue("Use \n with word wrap on to create a new line");

    //to enable newlines you need set a cell styles with wrap=true
    CellStyle cs = wb.createCellStyle();
    cs.setWrapText(true);
    cell.setCellStyle(cs);

    //increase row height to accomodate two lines of text
    row.setHeightInPoints((2*sheet.getDefaultRowHeightInPoints()));

    //adjust column width to fit the content
    sheet.autoSizeColumn((short)2);

    FileOutputStream fileOut = new FileOutputStream("ooxml-newlines.xlsx");
    wb.write(fileOut);
    fileOut.close(); 

반응형
반응형
반응형
반응형

[JEUS 8] response charset 변경하기 페이지 인코딩 변경

webApplication/WEB-INF/jeus-web-dd.xml 을 만듭니다.

 
<?xml version="1.0" encoding="UTF-8"?> 
<jeus-web-dd xmlns="http://www.tmaxsoft.com/xml/ns/jeus"> 
<context-path>/euckr</context-path> 
<encoding> 
<response-encoding> 
<default>EUC-KR</default> 
</response-encoding> 
</encoding> 
</jeus-web-dd>
 

 

자 이렇게 되면
받는 쪽 body 로 제우스는 EUC-KR의 인코딩 형태로 html 을 던져 줍니다.

출처:https://ipex.tistory.com/entry/JEUS-8-response-charset-변경하기-페이지-인코딩-변경[깍돌이]

----------------------------------------------------------------------------------------------------------------------------
 http://blog.naver.com/hwanwhat81/221181267297 
ja 로 jeus admin(관리자 모드 접속)하여

applist 하면 container 정보들이 출력..
jeus 홈디렉토리 config 파일에 가보면 서비스 디렉토리 안에 container list 가 존재한다.
한글깨짐 현상이 발생하는 컨테이너로 가보면
WEBmain.xml 이 존재.

vi 로 들어가서 편집해 준다.  

<context-group>
        <group-name>MyGroup</group-name>
        <encoding>
            <request-url-encoding>
                <default>utf-8</default>
                <forced>utf-8</forced>
            </request-url-encoding>
            <request-encoding>
                <default>utf-8</default>
                <forced>utf-8</forced>
            </request-encoding>
            <response-encoding>
                <default>utf-8</default>
                <forced>utf-8</forced>
            </response-encoding>
        </encoding>
생략 ....
</context-group> 



----------------------------------------------------------------------------------------------------------------------------
file.encoding ansi_x3.4-1968

분명히 utf-8로 셋팅 되었는데 Jeus는 가끔 미쳐서 파일 인코딩을 제대로 인지 못하는 경우가 있다.

String fileEncoding=System.getProperty("file.encoding");

이럴 경우 Jeus의 설정 파일에서( JEUSMain.xml ) 컨테이너 설정에 -Dfile.encoding=UTF-8 를 추가 해야 한다.

출처: https://lahuman.jabsiri.co.kr/57 [lahuman & jabsiri 노트]

----------------------------------------------------------------------------------------------------------------------------

----------------------------------------------------------------------------------------------------------------------------

https://waspro.tistory.com/183

 

[JEUS] Encoding 설정에 따른 출력 Test

본 포스팅은 Encoding 관련 우선순위 테스트입니다. Request Encoding, Response Encoding 각각 우선순위에 대한 테스트를 수행할 예정입니다. 먼저 Request Encoding 우선순위 테스트입니다. JEUS의 Encoding JEU..

waspro.tistory.com

 

반응형
반응형
반응형
반응형

12 Extremely Useful Hacks for JavaScript

https://github.com/maketroli/js-hacks/blob/master/README.md

 

maketroli/js-hacks

12 Extremely Useful Hacks for JavaScript. Contribute to maketroli/js-hacks development by creating an account on GitHub.

github.com

1) Converting to boolean using !! operator

function Account(cash) {
    this.cash = cash;
    this.hasMoney = !!cash;
}

var account = new Account(100.50);
console.log(account.cash); // 100.50
console.log(account.hasMoney); // true

var emptyAccount = new Account(0);
console.log(emptyAccount.cash); // 0
console.log(emptyAccount.hasMoney); // false

2) Converting to number using + operator

function toNumber(strNumber) {
    return +strNumber;
}

console.log(toNumber("1234")); // 1234
console.log(toNumber("ACB")); // NaN
This magic will work with Date too and, in this case, it will return the timestamp number:

console.log(+new Date()) // 1461288164385

3) Short-circuits conditionals

if (conected) {
    login();
}

conected && login();

user && user.login();

4) Default values using || operator

function User(name, age) {
    this.name = name || "Oliver Queen";
    this.age = age || 27;
}

var user1 = new User();
console.log(user1.name); // Oliver Queen
console.log(user1.age); // 27

var user2 = new User("Barry Allen", 25);
console.log(user2.name); // Barry Allen
console.log(user2.age); // 25

5) Caching the array.length in the loop

/*
This tip is very simple and causes a huge impact on the performance when 
processing large arrays during a loop. Basically, 
almost everybody writes this synchronous for to iterate an array:
*/
for(var i = 0; i < array.length; i++) {
    console.log(array[i]);
}

/*
If you work with smaller arrays – it’s fine, but if you process large arrays, 
this code will recalculate the size of array in every iteration of this loop and 
this will cause a bit of delays. 
To avoid it, you can cache the array.length in a variable to use it instead of invoking 
the array.length every time during the loop:
*/
var length = array.length;
for(var i = 0; i < length; i++) {
    console.log(array[i]);
}

//-- To make it smaller, just write this code:
for(var i = 0, length = array.length; i < length; i++) {
    console.log(array[i]);
}

; }

6) Detecting properties in an object

This trick is very useful when you need to check if some attribute exists and it avoids running undefined functions or attributes. If you are planning to write cross-browser code, probably you will use this technique too. For example, let’s imagine that you need to write code that is compatible with the old Internet Explorer 6 and you want to use the document.querySelector(), to get some elements by their ids. However, in this browser this function doesn’t exist, so to check the existence of this function you can use the in operator, see this example:

if ('querySelector' in document) {
    document.querySelector("#id");
} else {
    document.getElementById("id");
}

7) Getting the last item in the array

The Array.prototype.slice(begin, end) has the power to cut arrays when you set the begin and end arguments. But if you don’t set the end argument, this function will automatically set the max value for the array. I think that few people know that this function can accept negative values, and if you set a negative number as begin argument you will get the last elements from the array:

var array = [1,2,3,4,5,6];
console.log(array.slice(-1)); // [6]
console.log(array.slice(-2)); // [5,6]
console.log(array.slice(-3)); // [4,5,6]

8) Array truncation

var array = [1,2,3,4,5,6];
console.log(array.length); // 6
array.length = 3;
console.log(array.length); // 3
console.log(array); // [1,2,3]

9) Replace all

The String.replace() function allows using String and Regex to replace strings, natively this function only replaces the first occurrence. But you can simulate a replaceAll() function by using the /g at the end of a ​Regex:

var string = "john john";
console.log(string.replace(/hn/, "ana")); // "joana john"
console.log(string.replace(/hn/g, "ana")); // "joana joana"

10) Merging arrays

var array1 = [1,2,3];
var array2 = [4,5,6];
console.log(array1.concat(array2)); // [1,2,3,4,5,6];

/*
However, this function is not the most suitable to merge large arrays 
because it will consume a lot of memory by creating a new array. 
In this case, you can use Array.push.apply(arr1, arr2) which 
instead creates a new array – it will merge the second array in 
the first one reducing the memory usage:
*/
var array1 = [1,2,3];
var array2 = [4,5,6];
console.log(array1.push.apply(array1, array2)); // [1,2,3,4,5,6];

11) Converting NodeList to Arrays

If you run the document.querySelectorAll("p") function, it will probably return an array of DOM elements, the NodeList object. But this object doesn’t have all array’s functions, like: sort(), reduce(), map(), filter(). In order to enable these and many other native array’s functions you need to convert NodeList into Arrays. To run this technique just use this function: [].slice.call(elements):

var elements = document.querySelectorAll("p"); // NodeList
var arrayElements = [].slice.call(elements); // Now the NodeList is an array
var arrayElements = Array.from(elements); // This is another way of converting NodeList to Array

12) Shuffling array’s elements

var list = [1,2,3];
console.log(list.sort(function() { Math.random() - 0.5 })); // [2,1,3]

 

​#javascript

#!! #operator #+ #number

#Short-circuit

#array.length #loop

#detecting #properties #object

#item #array

#array_truncation

#replaceAll #replace

#merging #array #merging_array

#NodeList to #Array

#Shuffling #elements

반응형

+ Recent posts