Programming/node.js2018. 10. 22. 15:11

javascript로는 ip를 얻을 수 없지만 node.js라면 가능하니까 머..

(자기 자신의 IP를 얻어서 보낸다거나)


var ip = require("ip");

console.dir ( ip.address() ); 

[링크 : https://stackoverflow.com/questions/3653065/get-local-ip-address-in-node-js]

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

node-rtsp-stream 과 node-rtsp-stream-es6 차이  (0) 2018.10.24
node.js undefined 확인하기  (0) 2018.10.22
웹소켓 그리고 공유기?  (4) 2018.10.18
node-rtsp-stream의 pid 얻기  (0) 2018.10.18
node.js post body  (0) 2018.10.17
Posted by 구차니
Linux API2018. 10. 22. 14:52

[링크 : https://linux.die.net/man/3/system]

[링크 : https://linux.die.net/man/2/wait]


+

system으로는 실행 내용을 돌릴수 없으므로 ppipe 이용

[링크 : http://wanochoi.com/?p=178]


+

POST 인자로 body에 id와 password를 넘겨주는 curl을 실행하는 예제

#include <stdio.h>

#include <stdlib.h>


void main()

{

        int ret = 0;

        int status = 0;


        unsigned char cmd[255];

        unsigned char id[32] = "admin";

        unsigned char pw[32] = "admin";

        unsigned char url[] = "http://localhost:3000/api/test";

        unsigned char header[] = "-H 'Content-Type: application/json'";

        unsigned char data = "-d '{ \"id\":\"%s\",\"password\":\"%s\"}'";

        sprintf(cmd, "curl -X POST %s %s -d '{ \"id\":\"%s\",\"password\":\"%s\"}'",

                url, header, id, pw);

        printf("%s\n",cmd);


//      ret = system(cmd);

//      wait(&status);


        FILE *output = popen(cmd, "r");

        char buf[255];

        int pos = 0;

        while( !feof(output) && !ferror(output) )

        {

                int bytesRead = fread( buf + pos , 1, 128, output );

                pos += bytesRead;

        }


        printf("buf : [%s]\n",buf);


//      printf("ret : [%d]\n",ret);

//      printf("sta : [%d]\n",WEXITSTATUS(status));


+

이상한 메시지는 curl 을 콘솔에서 실행할때에도 안나오는데 아무튼. pipe로 실행하면 넘겨져 온다. 

보기 싫으면 --silent 옵션주면 끝

# ./a.out

curl -X POST http://localhost:3000/api/test -H 'Content-Type: application/json' -d '{ "id":"1234","password":"1234"}'

  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current

                                 Dload  Upload   Total   Spent    Left  Speed

100   397  100   363  100    34  18426   1725 --:--:-- --:--:-- --:--:-- 19105 

[링크 : https://makandracards.com/makandra/1615-disable-output-when-using-curl[

'Linux API' 카테고리의 다른 글

libescp  (0) 2019.01.03
cups api  (0) 2018.12.20
lirc - linux IR Remote control  (0) 2015.03.31
vaapi vdpau uvd  (6) 2015.03.26
linux 최대 thread 갯수  (0) 2015.01.22
Posted by 구차니

git pull 하다 보니 에러가 나서 확인하려고 보는데

detached branch 라던가

You are not currently on a branch 이라던가 나오는데


생각해보니 구버전으로 잠시 돌려놓았던 것이 문제..

아무튼 결론(?)은 master로 돌리고 나서 손을 보면 된다?


[링크 : https://okky.kr/article/437352]

[링크 : https://blog.npcode.com/2012/09/02/git-pull-할-때-옵션-안줘도-알아서-되게-하기/]

[링크 : http://sunphiz.me/wp/archives/2266?ckattempt=1]

[링크 : https://stackoverflow.com/...-currently-on-a-branch-error-when-trying-to-sync-fork-with-upstream]


+

2018.10.23

$ git branch

* (detached from 7ea96f5)

  master

$ git checkout master

Switched to branch 'master'

Your branch is behind 'origin/master' by 3 commits, and can be fast-forwarded.

  (use "git pull" to update your local branch) 


'프로그램 사용 > Version Control' 카테고리의 다른 글

git log . - 현재 디렉토리 이하의 변경내역 보기  (0) 2018.11.02
.gitignore  (0) 2018.10.22
git 리비전 돌아 다니기  (0) 2018.10.18
git 상태 다시 읽기  (0) 2018.09.20
git 원격지 주소 변경하기  (0) 2018.09.06
Posted by 구차니
Programming/C Win32 MFC2018. 10. 22. 11:44

c언어에서 uuid 생성하기

$ cat uuid.c

#include <uuid/uuid.h>

#include <stdio.h>


void main()

{

        uuid_t out;

        uuid_generate_random(out);

        printf("%x",out);

}

$ gcc uuid.c -luuid

[링크 : https://linux.die.net/man/3/uuid_generate]

[링크 : https://superuser.com/questions/1175935/how-can-i-fix-uuid-uuid-h-no-such-file-error-in-centos]


 typedef unsigned char uuid_t[16];

[링크 : https://git.busybox.net/busybox/plain/e2fsprogs/uuid/uuid.h?h=1_3_stable]

'Programming > C Win32 MFC' 카테고리의 다른 글

while(-1) 이 될까?  (0) 2019.05.24
c언어용 JSON 라이브러리 목록  (0) 2018.10.23
엔디안 급 멘붕..  (0) 2018.05.29
const char *과 char * const 차이  (0) 2018.01.31
소스 코드 포맷 적용하기  (0) 2018.01.08
Posted by 구차니

오늘 어린이집 같은반 애 엄마와 같이 키즈카페 가서 아내와 셋트로 협공을 당하다 오니 멘탈이 털리는데

방어기제였을지 모르겠지만 

육아에 있어서 아이에게 있어서 남성성이란 없어져야 할 것. 나쁜 것일 뿐인가? 라는 생각이 들었다.


남성성이 무엇인가 싶으면서도

폭력으로 요약되어 그 존재 자체가 부정당하는 현재에서

남성성이란 단순히 사라져야 할 존재인가 고민이 되어진다.


아이가 위험하게 있으면

위험하지 하지 말라는 설득도 방법이지만

통제된 위험함 속에서 위험함을 체험하게 하고 그걸 하지 않게 하는 것도 방법이 아닌가 싶은데

후자는 아동 학대 딱지를 받아 버렸으니 써서는 안될 나쁜 것이 되어버렸다.

'개소리 왈왈 > 육아관련 주저리' 카테고리의 다른 글

키즈카페 다녀옴  (2) 2018.10.28
혓바늘..  (2) 2018.10.27
피로하다..  (0) 2018.10.19
누군가의 죽음  (2) 2018.10.14
명절 증후근?  (2) 2018.09.23
Posted by 구차니

장모님댁 들렀다가 왔는데

오히려 원주 쪽은 단풍이 별로고 장모님댁 근처가 더 나았는데

아직 절정이려면 2주는 더 있어야 겠다 라고 생각했는데


집에와서 보니 절정이라 단풍놀이갔다가 차막힌다고.. 머야 -_-???

내가 가는 길목에만 단풍이 안들었나?

'개소리 왈왈 > 직딩의 비애' 카테고리의 다른 글

내 하루 어디갔어..  (2) 2018.11.04
우울할 땐 아내 몰래 하나 지르자~  (1) 2018.10.23
회사 워크샾 - 에버랜드  (3) 2018.10.08
9월의 끝  (2) 2018.09.30
읭? 타겟 광고인가?  (4) 2018.09.28
Posted by 구차니

졸려여~ 하면서도 이제야 원인 발견!

바닥이 차가워서 잠 뒤척이고 일찍 깨던거..


얼마나 머리가 안돌아갔으면 이걸 2주나 지나서야 겨우 생각해 낸걸까..

'개소리 왈왈 > 육아관련 주저리' 카테고리의 다른 글

혓바늘..  (2) 2018.10.27
남성성이란 무엇일까.. 그리고 없어져야 할 것 인가?  (4) 2018.10.21
누군가의 죽음  (2) 2018.10.14
명절 증후근?  (2) 2018.09.23
물티슈 난리났네  (2) 2018.09.21
Posted by 구차니
Programming/d32018. 10. 18. 20:57

어쩌다 받은거라 최신버전이 얼마인지도 모르고 했는데

다시 확인해보니 v3.. ㅠㅠ


현재 최신버전은 v5.7.0

[링크 : https://d3js.org/]



덕분에.. v3.x 에서 v5.x로 마이그레이션 하게 생겼네.. ㅠㅠ

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

d3 background image  (0) 2018.10.29
d3 pulse / blink  (0) 2018.10.29
d3 v3 doc  (0) 2018.10.17
d3 arc 직접 그리기  (0) 2018.10.17
d3 pie with padding  (0) 2018.10.16
Posted by 구차니

checkout을 이용해서 특정 리비전을 돌아 다닐수 있다.

예전에 branch 오가던 느낌이네..


git checkout HEAD~10

git checkout master 

[링크 : https://mytory.net/archives/10078]

'프로그램 사용 > Version Control' 카테고리의 다른 글

.gitignore  (0) 2018.10.22
git 리비전 이동 후 pull 안되는 문제  (0) 2018.10.22
git 상태 다시 읽기  (0) 2018.09.20
git 원격지 주소 변경하기  (0) 2018.09.06
git archive (svn export)  (0) 2018.09.05
Posted by 구차니
Programming/node.js2018. 10. 18. 17:53

localhost로 쓸때는 생각이 없었는데..

공인IP가 아닌 공유기 안에서 서버가 존재하고

그걸 외부에서 접속하게 해야 할때는 도대체 어떻게 해야하지? ㅠㅠ


[링크 : https://stackoverflow.com/questions/40450233/how-to-make-the-websocket-server-be-at-a-router]

[링크 : https://www.npmjs.com/package/web-socket-router]


+

일단은.. 그냥 기능 제한을 하고 이건 나중에 고민을 하자.. ㅠㅠ

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

node.js undefined 확인하기  (0) 2018.10.22
node.js를 이용한 자기 자신의 ip 얻기  (4) 2018.10.22
node-rtsp-stream의 pid 얻기  (0) 2018.10.18
node.js post body  (0) 2018.10.17
node spawn args  (0) 2018.10.17
Posted by 구차니