Skip to content

Instantly share code, notes, and snippets.

@icemilo
icemilo / ncloud_postman_pre-request.js
Last active April 11, 2023 09:04
Pre-Request Script for Ncloud API
const accessKey = pm.environment.get("accessKey")
const secret = pm.environment.get("secret")
const moment = require('moment');
const timestamp = moment().valueOf();
const message = pm.request.method + " " + pm.request.url.getPath() + "?" + pm.request.url.getQueryString() + "\n" + timestamp + "\n" + accessKey
const signature = CryptoJS.enc.Base64.stringify(CryptoJS.HmacSHA256(message, secret));
pm.collectionVariables.set("currentTimestamp", timestamp);
@icemilo
icemilo / findAddressByTxId.js
Created May 23, 2016 07:52
Fetches Bitcoin addresses from transaction ids using Google Spreadsheet
var requestPromise = require('request-promise');
var _ = require('lodash');
var Promise = require('bluebird');
var GoogleSpreadSheet = require('google-spreadsheet');
var doc = new GoogleSpreadSheet('<GOOGLE_SPREAD_SHEET_ID');
var creds = {
"jwt_secret": "",
"type": "service_account",
@icemilo
icemilo / calculateBusinessDays.js
Last active October 1, 2021 09:27
Calculates business days between two dates using moment.js
var moment = require('moment');
function calculateBusinessDays(firstDate, secondDate){
//Initiallize variables
var day1 = moment(firstDate);
var day2 = moment(secondDate);
var adjust = 0;
if((day1.dayOfYear() === day2.dayOfYear()) && (day1.year() === day2.year())){
return 0;
@icemilo
icemilo / inverse_integer.c
Created July 4, 2015 15:29
Inverse Integer
//
// main.c
// InverseNumber
//
// Created by JAE SEUNG KOO on 7/4/15.
// Copyright (c) 2015 JAE SEUNG KOO. All rights reserved.
//
#include <stdio.h>
@icemilo
icemilo / Question1.4.c
Last active August 29, 2015 14:23
Cracking the Coding Interview Question 1.4
//
// main.c
// Question1.4
//
// Created by JAE SEUNG KOO on 6/24/15.
// Copyright (c) 2015 JAE SEUNG KOO. All rights reserved.
//
#include <stdio.h>
#define LENGTH 18
"""
Copies all keys from the source Redis host to the destination Redis host.
Useful to migrate Redis instances where commands like SLAVEOF and MIGRATE are
restricted (e.g. on Amazon ElastiCache).
The script scans through the keyspace of the given database number and uses
a pipeline of DUMP and RESTORE commands to migrate the keys.
Requires Redis 2.8.0 or higher.