Skip to content

Instantly share code, notes, and snippets.

@anhdiepmmk
anhdiepmmk / better-sqlite3-example.js
Last active January 15, 2022 00:15
a small script that demonstrate how to use better-sqlite3
const Database = require('better-sqlite3');
const db = new Database('foobar.db', { verbose: console.log });
const commandToCreateUserTable = `
CREATE TABLE IF NOT EXISTS users (
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(255) NOT NULL,
email VARCHAR(255) NOT NULL,
created_at timestamp NOT NULL DEFAULT current_timestamp,
updated_at timestamp NOT NULL DEFAULT current_timestamp
/////////////////////////////////////////////////////////
// //
// _oo0oo_ //
// o8888888o //
// 88" . "88 //
// (| -_- |) //
// 0\ = /0 //
// ___/`---'\___ //
// .' \\| |// '. //
const images = document.querySelectorAll('div#block-ibmedia-content img');
const imageUrls = Array.from(images).map(image => image.src);
const gallery = document.createElement('div');
gallery.id = 'ibmedia-gallery';
gallery.style.display = 'none';
for (var i = 0; i < images.length; i++) {
const image = images[i];
@anhdiepmmk
anhdiepmmk / dau-don.js
Last active October 4, 2021 05:43
Bốc thăm chia bảng các nghệ sĩ tham dự motal kombat
const _ = require('lodash');
const ngheSiUuTu = [
'Tuan',
'Tung',
'Vinh',
'Kien',
'Linh',
];
@anhdiepmmk
anhdiepmmk / compose.js
Last active September 28, 2021 04:24
A quick introduction to pipe() and compose() in JavaScript
// What about compose()?
// It’s just pipe in the other direction.
compose = (...function) => (value) => fns.reduceRight((currentValue, currentFunction) => currentFunction(currentValue), value);
compose(
reverse,
get6Characters,
uppercase,
getName
@anhdiepmmk
anhdiepmmk / configuration.json
Created September 27, 2021 08:56
a configuration example
{
"enableSomeThings": true
}
@anhdiepmmk
anhdiepmmk / blockchain.js
Last active September 5, 2021 11:32
blockchain with javascript
const SHA256 = require("crypto-js/sha256");
class Block {
constructor(index, timestamp, data, previousHash = "") {
this.index = index;
this.timestamp = timestamp;
this.data = data;
this.previousHash = previousHash;
this.hash = this.calculateHash();
}
@anhdiepmmk
anhdiepmmk / sqs.js
Last active December 2, 2021 08:00
an example proof how we can do exponetial backoff retries with sqs
const _ = require("lodash");
const moment = require("moment");
// Load the AWS SDK for Node.js
const AWS = require("aws-sdk");
// Set the region to us-west-2
AWS.config.update({ region: "us-west-2" });
// Create the SQS service object
const sqs = new AWS.SQS({ apiVersion: "2012-11-05" });

Semantic Commit Messages

See how a minor change to your commit message style can make you a better programmer.

Format: <type>(<scope>): <subject>

<scope> is optional

Example

-Xmx8192m
-XX:ReservedCodeCacheSize=1024m
-Xms2048m
-XX:+UseG1GC
-XX:SoftRefLRUPolicyMSPerMB=250
-XX:CICompilerCount=2
-XX:+HeapDumpOnOutOfMemoryError
-XX:-OmitStackTraceInFastThrow
-ea
-Dsun.io.useCanonCaches=false