Skip to content

Instantly share code, notes, and snippets.

@namhyun-gu
namhyun-gu / config.yml
Last active October 5, 2020 14:27
repo-watcher-config
lang: ko
notification:
mail:
smtpService: Naver
smtpHost: smpt.naver.com
smtpPort: 587
senderMail: mnhan0403@naver.com
receiverMail: mnhan0403@gmail.com
targets:
- jobhope/TechnicalNote
@namhyun-gu
namhyun-gu / Main2.java
Created October 8, 2019 07:20
java-analyzer-example
import java.util.Scanner;
public class Main2 {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
int count = scanner.nextInt();
for (int index = 0; index < count; index++) {
System.out.println("Hello");
}
}
@namhyun-gu
namhyun-gu / sharding-test.js
Last active May 11, 2018 15:32
MongoDB Shading Snippets
// Hashed Sharding 방식을 이용하여 테스트합니다. 다른 방식을 이용해도 무방합니다.
sh.enableSharding("sharding-test")
use sharding-test
db.items.createIndex({"index": "hashed"})
sh.shardCollection("sharding-test.items", {"index": "hashed"})
for (var n=1; n<=100000; n++) db.items.insert({index: n, name: "test"})
db.items.count() // 10만개의 데이터가 정상적으로 작성되었는지 확인합니다
// 각 Primary Shard 서버에 접속하여 아래의 명령어를 실행합니다.
use sharding-test
@namhyun-gu
namhyun-gu / mongos.config.conf
Created May 11, 2018 15:21
MongoDB Shading Snippets
sharding:
configDB: "configRepl/<server1 hostname or ip>:<port>,<server2 hostname or ip>:<port>,<server3 hostname or ip>:<port>"
net:
bindIpAll: true
port: 30000 // 없을 경우 27017이 기본 값
@namhyun-gu
namhyun-gu / config-replicaset-init.js
Created May 11, 2018 15:12
MongoDB Shading Snippets
rs.initiate( {
_id : "configRepl",
members: [
{ _id: 0, host: "<server1 hostname>:<port>" },
{ _id: 1, host: "<server2 hostname>:<port>" },
{ _id: 2, host: "<server3 hostname>:<port>" }
]
})
@namhyun-gu
namhyun-gu / mongod.config.conf
Last active May 12, 2018 02:30
MongoDB Shading Snippets
sharding:
clusterRole: configsvr
replication:
replSetName: “configRepl”
net:
bindIpAll: true
port: 20000 // 없을경우 27019이 기본 값
storage:
dbPath: "/mongodb/config"
@namhyun-gu
namhyun-gu / current_directory.js
Created August 23, 2017 04:49
Get current directory (Node.js)
process.cwd() // Call this line. Returned current path to string.
@namhyun-gu
namhyun-gu / enum.js
Last active August 23, 2017 04:27
Javascript Enum Example
// Javascript is not support enum type.
const State = {
SUCCESS: 1,
UNKNOWN: 2,
FAILED: 4
};
console.log(State.SUCCESS); // prints 1.
console.log(State.UNKNOWN); // prints 2.
console.log(State.FAILED); // prints 4.
@namhyun-gu
namhyun-gu / samples.js
Last active August 22, 2017 07:36
How to get package info in package.json (Node.js)
// in node application.
const pkg = require('./package.json'); // Declare this line.
pkg.version // package version
pkg.name // pacakge name
pkg.author // package author
// ... etc
@namhyun-gu
namhyun-gu / extract_font_url.js
Last active April 20, 2024 10:27
Extract font url from css (in javascript)
const regex = /url\((.*?)\) format\((\'|\")(.*?)(\'|\")\)/g;
const str = `CSS Input`;
let m;
while ((m = regex.exec(str)) !== null) {
// This is necessary to avoid infinite loops with zero-width matches
if (m.index === regex.lastIndex) {
regex.lastIndex++;
}