Skip to content

Instantly share code, notes, and snippets.

var now = new Date(); // Date object
now.toDateString() // "Sun Jul 17 2016"
now.toLocaleDateString() // "2016/7/17"
now.toGMTString() // "Sun, 17 Jul 2016 03:16:49 GMT"
now.toISOString() // "2016-07-17T03:16:49.141Z"
now.toUTCString() // "Sun, 17 Jul 2016 03:16:49 GMT"
now.toLocaleTimeString() // "上午11:16:49"
now.toLocaleString() // "2016/7/17 上午11:16:49"
now.toString() // "Sun Jul 17 2016 11:16:49 GMT+0800 (台北標準時間)"
now.toTimeString() // "11:16:49 GMT+0800 (台北標準時間)"
@jrson83
jrson83 / deno-tools.js
Created January 10, 2023 15:17 — forked from ndesmic/deno-tools.js
node tools
async function directoryToObject(dir, walkOpts){
const obj = {};
for await(const file of walk(dir, walkOpts)){
const path = relative(dir, file.path);
const split = path.split("/");
let currObj = obj;
for(let i = 0; i < split.length; i++){
const part = split[i];
@jrson83
jrson83 / Glob.js
Created December 30, 2022 00:35 — forked from bgoonz/Glob.js
class Glob {
constructor(glob) {
this.glob = glob;
// We implement glob matching using RegExp internally.
// ? matches any one character except /, and * matches zero or more
// of those characters. We use capturing groups around each.
let regexpText = glob.replace("?", "([^/])").replace("*", "([^/]*)");
// We use the u flag to get Unicode-aware matching.
@jrson83
jrson83 / commit-msg.issue-id-prompt.js
Created December 29, 2022 23:47 — forked from romaricpascal/commit-msg.issue-id-prompt.js
commit-msg Git hook to ask user for an issue ID when he commits and prepend it to the original commit message
#!/usr/bin/env node
var fs = require('fs'),
util = require('util');
// Rattern to format the message with the issue ID
var MESSAGE_FORMAT = '[%s] %s';
// Git commit messages are stored in a file, passed as argument to the script
// First and second arguments will be 'node' and the name of the script
var commitFile = process.argv[2];
@jrson83
jrson83 / conventional_commit_messages.md
Created December 21, 2022 04:07 — forked from qoomon/conventional-commits-cheatsheet.md
Conventional Commit Messages

Conventional Commit Messages

See how a minor change to your commit message style can make a difference. Examples

Have a look at CLI util git-conventional-commits to ensure this conventions and generate changelogs

Commit Formats

Default

@jrson83
jrson83 / install.sh
Last active December 15, 2022 02:37
idea laravel install.sh
#!/bin/bash
RED="\e[41m"
GREEN="\e[42m"
BLUE="\e[44m"
CYAN="\e[36m"
MAGENTA="\e[45m"
ENDCOLOR="\e[0m"
###
@jrson83
jrson83 / typescript-monorepo.md
Created December 14, 2022 20:28 — forked from khalidx/typescript-monorepo.md
A simple setup for a TypeScript monorepo.

There are countless guides online for setting up a TypeScript monorepo.

Most rely on external tools like Lerna, Yarn, Turborepo, Yalc, or something else.

Here's a simple, zero-opinion way to get a monorepo going.

First, make a structure like this:

root/
@jrson83
jrson83 / README.md
Created December 14, 2022 19:23 — forked from gustavopch/README.md
TypeScript with project references and incremental build in a monorepo

So, in summary, we have:

packages/
  app/
    tsconfig.json
  shared/
    tsconfig.json
tsconfig.base.json
tsconfig.json
@jrson83
jrson83 / mod.ts
Last active November 20, 2022 23:06
Lume reading time plugin
import { merge } from "lume/core/utils.ts";
import type { Page, Site } from "lume/core.ts";
export interface Options {
/** The list extensions this plugin applies to */
extensions: string[];
/** The words per minute a reader can read (default: 275) */
wordsPerMinute: number;