Skip to content

Instantly share code, notes, and snippets.

View bbirec's full-sized avatar

Heehong Moon(문희홍) bbirec

View GitHub Profile
@bbirec
bbirec / index.js
Created September 8, 2021 06:01
SES -> SNS -> DynamoDB
var aws = require("aws-sdk");
var DynamoDB = new aws.DynamoDB.DocumentClient();
exports.handler = function (event, context, callback) {
var SnsPublishTime = event.Records[0].Sns.Timestamp;
var SESMessage = event.Records[0].Sns.Message;
SESMessage = JSON.parse(SESMessage);
var SESEventType = SESMessage.eventType;
@bbirec
bbirec / label.json
Created February 22, 2021 08:05
바코드 라벨지 템플릿
{
"type": "Container",
"flex": {
"size": {
"width": "100%",
"height": "100%"
},
"padding": {
"top": "8",
// Channels-driven concurrency with Go
// Code examples from Rob Pike's talk on Google I/O 2012:
// http://www.youtube.com/watch?v=f6kdp27TYZs&feature=youtu.be
//
// Concurrency is the key to designing high performance network services.
// Go's concurrency primitives (goroutines and channels) provide a simple and efficient means
// of expressing concurrent execution. In this talk we see how tricky concurrency
// problems can be solved gracefully with simple Go code.
// (7) Fake Google search
// Channels-driven concurrency with Go
// Code examples from Rob Pike's talk on Google I/O 2012:
// http://www.youtube.com/watch?v=f6kdp27TYZs&feature=youtu.be
//
// Concurrency is the key to designing high performance network services.
// Go's concurrency primitives (goroutines and channels) provide a simple and efficient means
// of expressing concurrent execution. In this talk we see how tricky concurrency
// problems can be solved gracefully with simple Go code.
// (7) Fake Google search
@bbirec
bbirec / index.js
Last active June 28, 2016 03:02
AWS Lambda function notifying to slack webhook from github release webhook.
'use strict';
let https = require('https');
let url = require('url');
let hookUrl = "https://hooks.slack.com/services/.....";
exports.handler = (event, context, callback) => {
var opt = url.parse(hookUrl);
opt.method = 'POST';
opt.headers = {
@bbirec
bbirec / ssl.md
Last active April 29, 2016 04:36
SSL 구입

SSL 인증서 구입

SSL을 먼저 구입한다. 구입할수 있는 다른 여러 사이트가 있는데, https://www.ssls.com 에서 싸게 구입할 수 있다. 결제를 완료하면 CSR파일을 업로드 해라고 나오는데 로컬 컴퓨터에서 생성해서 올려야 한다.

CSR파일 만들기

Private key 만들기

private key를 만든다. pass phrase는 바로 복호화한 server.key파일을 만들것 이기 때문에 아무 패스워드나 넣는다.

$ openssl genrsa -des3 -out server.pass.key 2048
@bbirec
bbirec / util.sql
Last active April 11, 2018 02:11
Postgres 유용한 query모음.
-- auto vaccum이 되었던 시간과 개수
select relname, autovacuum_count, last_autovacuum::timestamp with time zone at time zone 'Asia/Seoul' from pg_stat_all_tables where last_autovacuum is not null order by last_autovacuum desc limit 20;
-- 현재 실행중인 query
SELECT pid,query,now()-query_start as diff,query_start,state_change FROM pg_stat_activity where state='active' order by query_start desc;
-- 실행중인 pid kill
SELECT pg_terminate_backend(
--pid
@bbirec
bbirec / set-mac.sh
Created August 11, 2013 13:28
A simple bash script to change MAC address in MacOS.
#!/bin/bash
MAC=${1:-`openssl rand -hex 6 | sed 's/\(..\)/\1:/g; s/.$//'`}
INF=${2:-"en0"}
echo "Set a new MAC address($MAC) for $INF"
ifconfig $INF lladdr $MAC
;; SQS에 쌓인 메세지의 갯수를 보고 worker를 scale함
(def heroku-api-key (get (System/getenv) "HEROKU_API_KEY"))
(def heroku-app-id (get (System/getenv) "HEROKU_APP_ID"))
(def heroku-worker-name (get (System/getenv) "HEROKU_WORKER_NAME"))
(defn heroku-scale [api-key app-id type qty]
(client/post (format "https://api.heroku.com/apps/%s/ps/scale" app-id)
{:basic-auth ["" api-key]
:accept :json
@bbirec
bbirec / gist:5748489
Last active June 7, 2019 00:56
ISO8601 Adapter for Gson.
package com.bbirec.dabang.common;
import com.google.gson.*;
import java.lang.reflect.Type;
import java.sql.Timestamp;
import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;