[컴] 개인을 식별하는 방법

개인 식별 코드 / unique id / uuid / 구분 / 개인 구분

개인을 식별하는 방법

아래의 것들을 이용해서 개인을 구별할 수 있다.

  • 고유 개인 식별자
    • 장치 식별자
    • 쿠키
    • 비콘
    • 픽셀 태그
    • 모바일 광고 식별자 및 유사 기술
    • 기타 형태의 영구 식별자 또는 확률적 식별자
  • 온라인 식별자
  • 인터넷 프로토콜 주소

References


  1. 칼럼ㅣ삼성이 당신의 데이터를 팔고 있을 수 있다 - CIO Korea, 2020-01-29

[컴] RabbitMQ 로 celery메시지 보내기

publish message / 메시지 보내기 / publishing messages / celery  사용 / 메세지 / rabbitmq monitor


RabbitMQ 로 celery메시지 보내기

NodeJS에서 celery RabbitMQ 로 메시지 보내기

아래는 celery 가 사용하는 rabbitMQ 로 보낼때 사용하는 code 이다.

celery 는 기본적으로 queue 이름을 celery 로 exchange 를 celery 로 만들고, routingKey 는 없다.(empty)

'use strict';

const amqplib = require('amqplib');
const Logger = use('Logger');

class MsgIssuer {

    constructor() {
        // for test
        this.rabbitMqUrl = 'amqp://userid:userpw@192.168.10.136//';
    }


    issueTask() {
        this._issuing('tasks.issueTask', {}, 'cbill0');
    }

    _issuing(task, kwargs, idHead) {


        const open = amqplib.connect(this.rabbitMqUrl);

        const body = {
            id: `${idHead}-${(new Date()).getTime()}`,
            task: task,
            args: [],
            kwargs,
            retries: 0,
            timelimit: [null, null],
        }

        // Publisher
        const routingKey = 'celery';
        open.then(function (conn) {
            return conn.createChannel();
        }).then(function (ch) {
            // return ch.purgeQueue(routingKey); // to purge message in the queue
            return ch.assertQueue(routingKey)
                .then(function (ok) {
                    return ch.sendToQueue(
                        routingKey,
                        Buffer.from(JSON.stringify(body)),
                        {
                            contentType: 'application/json',
                            contentEncoding: 'UTF-8',
                            deliveryMode: 1,
                        });
                });
        }).catch(Logger.error);
    }
}
module.exports = MsgIssuer;

python 에서 celery RabbitMQ 로 보내기


import pika
import json
parameters = pika.URLParameters(
    "amqp://id:pass@14.14.117.10/%2F"
)
connection = pika.BlockingConnection(parameters)
ch = connection.channel()
ch.queue_declare(queue="celery", durable=True)
ch.basic_publish(
    exchange="celery",
    routing_key="celery",
    body=json.dumps(
        {
            "id": "myid",
            "task": "task.tasks.mytask",
            "args": [],
            "kwargs": {
                "mykey1": "123",
                "mykey2": "456",
            },
            "retries": 0,
        }
    ),
    properties=pika.BasicProperties(
        content_type="application/json", content_encoding="utf-8"
    ),
)

monitoring

web browser 에서 http://localhost:15672/ 로 접속해서 확인하자.(참고)

여기서 queue 에 message 가 몇개 있는지 등도 알 수 있게 message 를 publish 할 수도 있고, 어떤 queue 가 현재 존재하는지 등도 알 수 있다.(Management Plugin — RabbitMQ)
sudo rabbitmq-plugins enable rabbitmq_management

The RabbitMQ management plugin이 제공하는 것

  • HTTP-based API
    • 관리(management)
    • RabbitMQ nodes and clusters 에 대한 monitoring
  • browser-based UI
  • command line tool, rabbitmqadmin.

rabbitmqadmin

rabbitmqadmin 은 .py 이다. 그래서 python rabbitmqadmin 이런식으로 사용하면 된다. rabbitmq 가 설치되면 downlod 는 아래처럼 하면 받을 수 있다.
curl http://localhost:15672/cli/rabbitmqadmin > rabbitmqadmin

queue, exchange 확인

python rabbitmqadmin.py list queues vhost name messages
python rabbitmqadmin.py list exchanges 

# 그냥 rabbitmqctl 로도 가능하다
sudo rabbitmqctl list_queues name messages messages_ready messages_unacknowledged

purge

rabbitmqadmin purge queue name=name_of_the_queue_to_be_purged  

queue 삭제

python3 rabbitmqadmin.py delete queue name='celery' 

그 외

다음 같은 것들을 할 수 있다.
  • Get a list of exchanges
  • Get a list of queues, with some columns specified
  • Get a list of queues, with all the detail we can take
  • Connect to another host as another user
  • Declare an exchange
  • Declare a queue, with optional parameters
  • Publish a message
  • And get it back
  • Export Configuration (Definitions)
  • Import Configuration (Definitions), quietly
  • Close all connections


See Also

  1. php 에서 Celery 사용하기
  2. 쿠...sal: [컴] RabbitMQ 자료들
  3. rabbitmqctl - Is it possible to view RabbitMQ message contents directly from the command line? - Stack Overflow

References

  1. GitHub - squaremo/amqp.node: AMQP 0-9-1 library and client for Node.JS
  2. RabbitMQ tutorial - "Hello World!" — RabbitMQ
  3. javascript - RabbitMQ Node JS Validate User ID - Stack Overflow, 2020-01-08


[컴][유틸] fzf - fuzzy finder

linux command line util / bash util / tools / 쓸만한 툴 / totalcmd / 리눅스에서 유용한 툴 / fuzzy search / fuzzy

fzf

우연찮게 한 커뮤니티에서 이 프로그램이 좋다고 해서 한번 사용해 보려한다. 개발자가 한국인이라서 더 궁금하다.

설치

choco install fzf

사용

아래처럼 pipe 를 이용해서 사용하면 된다.
c:\> dir c: /b /s | fzf

demo 영상

다양한 예제

개인적인 의견

linux 에서는 꽤나 쓸모있어 보인다. 더구나 bash 에서 다양한 function 을 만들어서 사용하면 정말 효과적인 듯 하다.

하지만, 윈도우즈 환경에서는 잘 모르겠다. 개인적으로 windows 에서는 launchy, totalcmd 를 많이 사용하는데, 이 2개를 사용하는 이점이 fzf 를 사용하는 것보다 더 큰 듯 보인다.

그리고 전체 파일에서 찾기를 시도했는데,(dir /b /s | fzf) 이것은 일단 file 을 전부 보여주는 시간이 오래 걸려서 유용하지 않다.

특정 파일을 검색하는 command(dir "\*.mp4" /b /s 등) 과 함께 사용하는 건 괜찮을 듯도 하다.

windows 환경
- cpu : i3-2100 3.1GHz
- RAM : 8GB


[컴][웹] node-simple-encryptor 의 decrypt 를 python 으로 구현하기

node-simple-encryptor 를 python  에서 / 복호화 함수 / 암호화 함수 / 아도니스 암호화 / 복호화 / 파이썬으로

node-simple-encryptor 의 decrypt 를 python 으로 구현

Adonijs 의 Encryptor 는 node-simple-encryptor 를 사용한다. 여기서는 Encryptor.decrypt() 의 decrypt 부분을 python 으로 구현해 보자.


node-simple-encryptor 의 decrypt() 부분


module.exports = function(opts) {
  if( typeof(opts) == 'string' ) {
    opts = {
      key: opts,
      hmac: true,
      debug: false
    };
  }
  var key = opts.key;
  var verifyHmac = opts.hmac;
  var debug = opts.debug;
  var reviver = opts.reviver;

  ...
  // Use SHA-256 to derive a 32-byte key from the specified string.
  // NOTE: We could alternatively do some kind of key stretching here.
  var cryptoKey = crypto.createHash('sha256').update(key).digest();
  ...

  function decrypt(cipherText) {
    if( !cipherText ) {
      return null;
    }
    try {
      if( verifyHmac ) {
        // Extract the HMAC from the start of the message:
        var expectedHmac = cipherText.substring(0, 64);
        // The remaining message is the IV + encrypted message:
        cipherText = cipherText.substring(64);
        // Calculate the actual HMAC of the message:
        var actualHmac = hmac(cipherText);
        if( !scmp(Buffer.from(actualHmac, 'hex'), Buffer.from(expectedHmac, 'hex')) ) {
          throw new Error('HMAC does not match');
        }
      }

      // Extract the IV from the beginning of the message:
      var iv = new Buffer(cipherText.substring(0,32), 'hex');
      // The remaining text is the encrypted JSON:
      var encryptedJson = cipherText.substring(32);

      // Make sure to use the 'iv' variant when creating the decipher object:
      var decipher = crypto.createDecipheriv('aes256', cryptoKey, iv);
      // Decrypt the JSON:
      var json = decipher.update(encryptedJson, 'base64', 'utf8') + decipher.final('utf8');

      // Return the parsed object:
      return JSON.parse(json, reviver);
    } catch( e ) {
      // If we get an error log it and ignore it. Decrypting should never fail.
      if( debug ) {
        console.error('Exception in decrypt (ignored): %s', e);
      }
      return null;
    }
  }

python 구현

class NodeSimpleEncrypter:
    """

    """


    KEY = b"FFfBEVh5Dr1BhJiEi3mnCsB6nByGv1iL"
    IV_LEN = 16

    def __init__(self):
        pass


    @staticmethod
    def decryptForV2(value):
        m = hashlib.sha256()
        m.update(NodeSimpleEncrypter.KEY)
        key = m.digest()

        cipherText = value[64:]

        ivstr = cipherText[:32]
        iv = binascii.unhexlify(ivstr)

        encodedBody = cipherText[32:]
        body = base64.b64decode(encodedBody)

        # CBC MODE
        # https://gist.github.com/forkd/168c9d74b988391e702aac5f4aa69e41
        # https://pycryptodome.readthedocs.io/en/latest/src/cipher/classic.html#cbc-mode
        aes = AES.new(key=key, mode=AES.MODE_CBC, iv=iv)

        return unpad(aes.decrypt(body), AES.block_size)

[컴] 게임 엔진 클론 오픈 프로젝트

게임 클론 / 게임 엔진 오픈 프로젝트 / 오픈 소스 프로젝트 / 엔진 개발 기초 자료 /  참고자료

game clone open projects

[웹] github 에서 issue templates 설정하기

github 이슈 커스터마이징 / customize / customization / customizing / new issue / github template / github templates / 템플릿 / issue 템플릿

github 에서 issue templates 설정하기

  •  repository 선택 --> settings tab --> options --> Feature 부분


template 을 추가하고, issue 를 누르면 아래처럼 보인다.
그러면 아래처럼 template 이 보이게 된다.



References

  1. Configuring issue templates for your repository - GitHub Help

[컴][웹] firefox 에서 banner_ 로 시작하는 class 이름

파이어폭스 / 광고 / 배너 / 배너이미지 / 광고 이미지 / 광고 차단 방법

Firefox 에서 banner_ class 사용시 주의사항

firefox 를 사용하는데, class name 을 banner_image 로 설정했다. 그랬더니 firefox 에서 보이지 않게 됐다. 그래서 다른 class name (banner 가 들어가지 않은) 으로 변경하였다.
  • 사용한 firefox version : 7.1.0 64 bit

See Also