'Programming'에 해당되는 글 1762건

  1. 2018.11.30 브라우저 닫기, 창 이동시 이벤트
  2. 2018.11.27 d3 axis
  3. 2018.11.26 node.js 혹은 sqlite?
  4. 2018.11.26 d3 온도/습도 그래프
  5. 2018.11.26 node.js sqlite3
  6. 2018.11.26 javascript 변수 정확도
  7. 2018.11.25 node.js xml <-> json
  8. 2018.11.23 node.js mysql blob
  9. 2018.11.21 js object array sort by key
  10. 2018.11.21 d3 multi line graph

jquery에서는 1.8 이후에 deprecated 되었고 3.0 이후에 완전 삭제 된 기능으로

.unload()가 존재하는데, 얘가 좀 직관적인 이름이긴 하다..

[링크 : https://api.jquery.com/unload/]


아무튼 document가 아니라 window에 대해서 before unload 이벤트를 등록하면

창을 이동하거나 닫거나 X 누를때(크롬에서 확인) 이벤트가 발생한다.

$(window).on("beforeunload", function() { 

    return confirm("Do you really want to close?"); 

}) 


[링크 : https://stackoverflow.com/questions/16707249/detect-close-windows-event-by-jquery]

[링크 : https://www.w3schools.com/jquery/event_unload.asp]

[링크 : http://suyou.tistory.com/86]


+

해보니.. 로그인 확인 누를때도 떠서 해제해줄 필요가 있네..

등록은 on() / bind()로 한다면

해제는 off() / unbind()로 한다.

//onBeforeUnload 이벤트 지정

$(window).bind('beforeunload', function()

{

    //페이지 변경이 있었는지 체크..

    var isChanged = ....; 


    //출력할 내용을 Return 해주면 확인 창이 뜨게 됩니다.

    if(isChanged) 

        return '변경된 사항이 있습니다. 페이지에서 나가시겠습니까?';<br>

    //확인 창을 띄우지 않으려면 아무 내용도 Return 하지 마세요!! (Null조차도)

};


//Form Submit 등 onBeforeUnload Event가 발생하길 원하지 않는 경우, 이벤트 해제

$('form').submit(function() 

{

    $(window).unbind('beforeunload'); 

}); 

[링크 : http://nsinc.tistory.com/101]

'Programming > javascript & HTML' 카테고리의 다른 글

모바일 크롬 select-option  (0) 2018.11.30
HTML border style 지정  (0) 2018.11.30
javascript 변수 정확도  (0) 2018.11.26
js object array sort by key  (0) 2018.11.21
wavesurfer.js 그리고 HE-AACv2  (0) 2018.11.21
Posted by 구차니
Programming/d32018. 11. 27. 13:44

d3.time.scale.utc() // 시간

d3.time.scale() // 월&일

[링크 : http://bl.ocks.org/jebeck/9671241]


domain

[링크 : https://stackoverflow.com/questions/11807574/d3-using-strings-as-axis-ticks]

[링크 : https://bl.ocks.org/mbostock/3259783]


d3.extent

[링크 : http://lumiamitie.github.io/r_tutorial/D3vis02]

'Programming > d3' 카테고리의 다른 글

d3 time domain  (0) 2018.12.21
d3 double line graph  (0) 2018.12.21
d3 온도/습도 그래프  (0) 2018.11.26
d3 multi line graph  (0) 2018.11.21
d3.time.format  (0) 2018.11.21
Posted by 구차니
Programming/node.js2018. 11. 26. 14:54

어디선가 대충짜서 메모리가 터져나가고 있나 본데..


Cannot enlarge memory arrays. Either (1) compile with  -s TOTAL_MEMORY=X  with X higher than the current value 16777216, (2) compile with  -s ALLOW_MEMORY_GROWTH=1  which allows increasing the size at runtime but prevents some optimizations, (3) set Module.TOTAL_MEMORY to a higher value before the program runs, or (4) if you want malloc to return NULL (0) instead of this abort, compile with  -s ABORTING_MALLOC=0 



sqlite-sync를 쓰는데 connect.close() 안해줘서 메모리 터져나간듯..

'Programming > node.js' 카테고리의 다른 글

node.js compressed http  (0) 2018.12.06
waveform-data.js  (0) 2018.11.30
node.js sqlite3  (0) 2018.11.26
node.js xml <-> json  (0) 2018.11.25
node.js mysql blob  (0) 2018.11.23
Posted by 구차니
Programming/d32018. 11. 26. 13:13

서로 다른 계열의 데이터를 출력하는 방법을 찾는 중..


[링크 : https://github.com/LonnyGomes/attic-temperature-graph]



+

2018.12.21


[링크 : http://blog.fraggod.net/2016/08/05/d3-chart-for-common-temperaturerh-time-series-data.html[

'Programming > d3' 카테고리의 다른 글

d3 double line graph  (0) 2018.12.21
d3 axis  (0) 2018.11.27
d3 multi line graph  (0) 2018.11.21
d3.time.format  (0) 2018.11.21
d3 pie 칸색 바꾸기  (0) 2018.11.15
Posted by 구차니
Programming/node.js2018. 11. 26. 10:14

win10에 sqlite3 모듈을 써서 먼가 하려는데 안되서 찾아보니.. 걍 깔면됨 ㅋ


$ npm install


> sqlite3@4.0.4 install D:\work2\hjelec_tf\node\node_modules\sqlite3

> node-pre-gyp install --fallback-to-build


'node-pre-gyp'은(는) 내부 또는 외부 명령, 실행할 수 있는 프로그램, 또는

배치 파일이 아닙니다.

npm ERR! code ELIFECYCLE

npm ERR! errno 1

npm ERR! sqlite3@4.0.4 install: `node-pre-gyp install --fallback-to-build`

npm ERR! Exit status 1

npm ERR!

npm ERR! Failed at the sqlite3@4.0.4 install script.

npm ERR! This is probably not a problem with npm. There is likely additional logging output above. 



[링크 : https://www.npmjs.com/package/sqlite3]

[링크 : https://github.com/mapbox/node-pre-gyp]



+

sqlite-sync는 sqlite3 와는 API 구조가 많이 다르네..

[링크 : https://www.npmjs.com/package/sqlite-sync]

[링크 : https://github.com/JayrAlencar/sqlite-sync.js/wiki]

'Programming > node.js' 카테고리의 다른 글

waveform-data.js  (0) 2018.11.30
node.js 혹은 sqlite?  (0) 2018.11.26
node.js xml <-> json  (0) 2018.11.25
node.js mysql blob  (0) 2018.11.23
sqlite for node.js  (0) 2018.11.21
Posted by 구차니

어쩌면 당연한건데.. 먼가 생소하게만 느껴지는 녀석



The maximum number of decimals is 17, but floating point arithmetic is not always 100% accurate:

Example

var x = 0.2 + 0.1;         // x will be 0.30000000000000004 

[링크 : https://www.w3schools.com/js/js_numbers.asp]

'Programming > javascript & HTML' 카테고리의 다른 글

HTML border style 지정  (0) 2018.11.30
브라우저 닫기, 창 이동시 이벤트  (0) 2018.11.30
js object array sort by key  (0) 2018.11.21
wavesurfer.js 그리고 HE-AACv2  (0) 2018.11.21
requireJS  (0) 2018.11.21
Posted by 구차니
Programming/node.js2018. 11. 25. 18:56

에어 코리아 API 한번 발급받아 볼까 하는데

기술문서를 보니 XML과 JSON으로 된다고 해서 검색..

[링크 : https://www.data.go.kr/dataset/15000581/openapi.do]



[링크 : https://www.npmjs.com/package/js2xmlparser]

[링크 : https://www.npmjs.com/package/xml2js]

'Programming > node.js' 카테고리의 다른 글

node.js 혹은 sqlite?  (0) 2018.11.26
node.js sqlite3  (0) 2018.11.26
node.js mysql blob  (0) 2018.11.23
sqlite for node.js  (0) 2018.11.21
node.js swagger  (0) 2018.11.12
Posted by 구차니
Programming/node.js2018. 11. 23. 10:52

mysql.escape()

[링크 : https://stackoverflow.com/.../er-parse-error-on-node-mysql-when-inserting-multiple-values]


timestamp는 CURRENT_TIMESTAMP 로 설정시 자동으로 입력됨

[링크 : https://blog.naver.com/star_breeze/220534943357]



이것저것 해보는데.. new Buffer().toString()이 유효했다!

$ node

> var tt = [39,91,92,39,105,110,112,117,116,35,115,101,108,95,48,95,49,92,39,44,92,39,105,110,112,117,116,35,115,101,108,95,48,95,51,92,39,44,92,39,105,110,112,117,116,35,115,101,108,95,48,95,53,92,39,93,39]

undefined

> var buffer = new Buffer(tt)

undefined

> buffer

<Buffer 27 5b 5c 27 69 6e 70 75 74 23 73 65 6c 5f 30 5f 31 5c 27 2c 5c 27 69 6e 70 75 74 23 73 65 6c 5f 30 5f 33 5c 27 2c 5c 27 69 6e 70 75 74 23 73 65 6c 5f ... >

> buffer.toString('base64')

'J1tcJ2lucHV0I3NlbF8wXzFcJyxcJ2lucHV0I3NlbF8wXzNcJyxcJ2lucHV0I3NlbF8wXzVcJ10n'

> var buffer = new Buffer(tt, 'binary')

undefined

> buffer.toString('base64')

'J1tcJ2lucHV0I3NlbF8wXzFcJyxcJ2lucHV0I3NlbF8wXzNcJyxcJ2lucHV0I3NlbF8wXzVcJ10n'

> tt.toString('utf-8')

'39,91,92,39,105,110,112,117,116,35,115,101,108,95,48,95,49,92,39,44,92,39,105,110,112,117,116,35,115,101,108,95,48,95,51,92,39,44,92,39,105,110,112,117,116,35,115,101,108,95,48,95,53,92,39,93,39'

> buffer.toString('utf-8')

'\'[\\\'input#sel_0_1\\\',\\\'input#sel_0_3\\\',\\\'input#sel_0_5\\\']\'' 

> new Buffer(tt).toString(

... 'utf-8')

'\'[\\\'input#sel_0_1\\\',\\\'input#sel_0_3\\\',\\\'input#sel_0_5\\\']\''

> new Buffer(tt).toString()

'\'[\\\'input#sel_0_1\\\',\\\'input#sel_0_3\\\',\\\'input#sel_0_5\\\']\''


[링크 : https://stackoverflow.com/questions/9042327/node-js-reading-blob-from-mysql]

[링크 : https://gist.github.com/akirattii/86e2eda8e110976cce144c991e9cada8]


그나저나 escape의 향연 어쩔꺼야...



+

mysql에 BLOB 타입으로 JSON을 저장하면 

node.js에서는 아래와 같이 Buffer에다가 값을 넣고 toString() 으로 문자열로 바꾸어준 다음

mysql.escape()를 통해 \" 식으로 된걸 원래대로 돌려주어야 한다.


server-side(node.js)

mysql.escape(new Buffer(row.element).toString("utf-8")); 


그리고 받는 쪽에서는 JSON이 아닌 일반 plain-text니까

JSON.parse를 통해서 JSON으로 변환해 주어야 한다.(eval은 빼도 되는지 확인 필요)


client-side(chrome, web browser)

JSON.parse(eval(data.json));


'Programming > node.js' 카테고리의 다른 글

node.js sqlite3  (0) 2018.11.26
node.js xml <-> json  (0) 2018.11.25
sqlite for node.js  (0) 2018.11.21
node.js swagger  (0) 2018.11.12
node.js axios delete에 body 쓰기  (0) 2018.11.12
Posted by 구차니



[링크 : https://stackoverflow.com/questions/5467129/sort-javascript-object-by-key/31102605]


'Programming > javascript & HTML' 카테고리의 다른 글

브라우저 닫기, 창 이동시 이벤트  (0) 2018.11.30
javascript 변수 정확도  (0) 2018.11.26
wavesurfer.js 그리고 HE-AACv2  (0) 2018.11.21
requireJS  (0) 2018.11.21
[Violation] 'setInterval' handler took  (0) 2018.11.18
Posted by 구차니
Programming/d32018. 11. 21. 19:06


[링크 : https://beta.observablehq.com/@mbostock/d3-multi-line-chart]


d3.v4

d3.line 

[링크 : https://bl.ocks.org/d3noob/4db972df5d7efc7d611255d1cc6f3c4f]

[링크 : https://codepen.io/zakariachowdhury/pen/JEmjwq]



d3 3.5.3

[링크 : https://bl.ocks.org/larsenmtl/e3b8b7c2ca4787f77d78f58d41c3da91]


+ 2018.11.22

[링크 : http://bl.ocks.org/hunzy/11110940] grid

'Programming > d3' 카테고리의 다른 글

d3 axis  (0) 2018.11.27
d3 온도/습도 그래프  (0) 2018.11.26
d3.time.format  (0) 2018.11.21
d3 pie 칸색 바꾸기  (0) 2018.11.15
d3 update 두번째 검색내용..  (0) 2018.11.15
Posted by 구차니