Skip to content

Instantly share code, notes, and snippets.

var crypto = require('crypto')
var data = process.argv[2]
console.log(data)
var result = crypto.createHash('md5').update(data).digest("hex")
console.log(result)
@daclouds
daclouds / gcloud-help--master-ipv4-cidr.md
Last active January 12, 2019 03:06
gcloud help -- master-ipv4-cidr

To search the help text of gcloud commands, run: gcloud help -- SEARCH_TERMS

$ gcloud help -- master-ipv4-cidr

┌────────────────────────────────────────┬───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐
│                COMMAND                 │                                                                            SUMMARY                                                                            │
├────────────────────────────────────────┼───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┤
│ gcloud container clusters create       │ Create a cluster for running containers.                                                                                                                      │
│                                        │ FLAGS                                        
@daclouds
daclouds / remaining-time.js
Created July 15, 2017 13:01
getting remaining time until next period using "momentjs"
const moment = require('moment');
function nextResetAt(period, current) {
const added = current.clone().add(period, 'h');
if (period >= 1) {
const secondsOfAdded = added.hour() * 3600 + added.minute() * 60 + added.second();
const next = secondsOfAdded - (secondsOfAdded % moment.duration(period, 'h').asSeconds());
return added.hour(next / 3600).minute(next % 3600).seconds(0);
} else {
return moment(+added - (+added % +moment.duration(period, 'h')));
// 다음 중 가장 빠른 primality test 는?
//
// #1
public boolean isPrime(int n) {
if (n <= 1) return false;
for (int i=2; i<n; i++) {
if (n%i==0) return false;
}
return true;
@daclouds
daclouds / password-generator.sh
Created January 6, 2016 08:06
Strong password generator
#!/bin/sh
exec scala -deprecation "$0" "$@"
!#
import scala.util.Random
object Generator {
def main(args: Array[String]) {
if (args.length != 1) {
import java.io._
import Math._
object ManyPrizes extends App {
val input = new BufferedReader(new FileReader("B-large-practice.in"))
val T: Int = input.readLine().toInt
def lowRankCanWin(N: Int, P: Double): Double = {
if (P == 0) return -1
import java.io.{BufferedReader, FileReader}
object DataPacking extends App {
val input = new BufferedReader(new FileReader("A-large-practice.in"))
val T = input.readLine().toInt
for (i <- 1 to T) {
val size = input.readLine.split(" ")(1).toInt
val arr = input.readLine.split(" ").map(_.toInt).sorted.toBuffer
var cnt = arr.length
object App extends App {
val testCaseNum = io.Source.fromFile("input.txt").getLines.toSeq.headOption.map(_.toLong)
// parse the range..
// val houses: Seq[(Long, Long)] = ???
// (0.0)
object sudoku extends App {
def check(input: Array[Int]): Boolean = {
Range(1, 10).toSet[Int] == input.map(_.toInt).toSet
}
def process(lineIn: Iterator[String])(lineOut: String => Unit) = {
var amountCases: Int = lineIn.next().toInt
var sizeOfSquare: Int = lineIn.next().toInt
for (i <- 1 to amountCases) {
package vending.machine;
import static org.junit.Assert.assertEquals;
import java.util.ArrayList;
import java.util.List;
import org.junit.Test;
public class VendingMachineTest {