npm install bluebird ws
node server.js
node client.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const pino = require('pino') | |
const pkafka = require('pino-kafka') | |
// this can be from .env, via JSON.parse | |
const kafkaLogConfig = { | |
"clientId":"some-producer1", | |
"defaultTopic": "some-log-topic", | |
"brokers":["some-host:9092"] | |
} | |
const streams = [{ stream: process.stdout, level: 'info' }] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function aws_translate($text, $sourceLang = 'zh-TW', $targetLang = 'en') | |
{ | |
$aws_access_key_id = 'key_id'; | |
$aws_secret_access_key = 'key'; | |
// AWS region and Host Name (Host names are different for each AWS region) | |
// As an example these are set to us-east-1 (US Standard) | |
$aws_region = 'us-east-1'; | |
$host_name = 'translate.us-east-1.amazonaws.com'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const fetch = require('node-fetch') | |
const delay = (ms) => { | |
return new Promise(resolve => { | |
setTimeout(() => { | |
resolve() | |
}, ms) | |
}) | |
} | |
const retryFetch = (url, fetchOptions={}, retries=3, retryDelay=1000) => { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const faker = require('faker') | |
// const N = 30 | |
const N = 2000000 | |
const fs = require('fs') | |
const record = () => { | |
// faker.fake( | |
// '{{name.lastName}},{{name.lastName}},{{address.city}},{{address.county}},{{address.zipCode}},{{hacker.adjective}}\n' | |
return [ | |
faker.name.firstName(), | |
faker.name.lastName(), |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const inquirer = require('inquirer') | |
const genList = (list) => { | |
const choices = list.map((item, index) => { | |
return { | |
key: index, | |
name: `${item.id}: ${item.quantity}@${item.price}`, | |
value: item.id | |
} | |
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<form class="well span8"> | |
<div class="row"> | |
<div class="span3"> | |
<label>First Name</label> | |
<input type="text" class="span3" placeholder="Your First Name"> | |
<label>Last Name</label> | |
<input type="text" class="span3" placeholder="Your Last Name"> | |
<label>Email Address</label> | |
<div class="input-prepend"> | |
<span class="add-on"><i class="icon-envelope"></i></span><input type="text" id="inputIcon" class="span2" style="width:233px" placeholder="Your email address"> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
RUST_TARGET="aarch64-unknown-linux-gnu" | |
RUST_VERSION="latest" | |
PROJECT_NAME=${PWD##*/} | |
zipRustLambda() { | |
cp ./target/${RUST_TARGET}/release/${PROJECT_NAME} ./bootstrap && zip lambda.zip bootstrap && rm bootstrap | |
} | |
al2build() { | |
cross build --release --target ${RUST_TARGET} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// main.rs | |
use std::env; | |
use std::error::Error; | |
use std::fs; | |
use std::fmt; | |
#[derive(Debug)] | |
struct MyError(String); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const Hapi = require('@hapi/hapi') | |
;(async () => { | |
const server = Hapi.server({ | |
port: 3000 | |
}) | |
server.events.on('log', logObject => { | |
console.log(JSON.stringify(logObject)) | |
}) |
NewerOlder