Skip to content

Instantly share code, notes, and snippets.

View prafulliu's full-sized avatar

Pengfei Liu prafulliu

  • teambition
  • shanghai
View GitHub Profile
@silver-xu
silver-xu / ts-boilerplate.md
Last active April 28, 2024 02:07
Setup a Node.js project with Typescript, ESLint, Prettier, Husky

Setup a Node.js project with Typescript, ESLint, Prettier, Husky

1_D8Wwwce8wS3auLAiM3BQKA

Starting a personal node project could be easy; starting a team node project could be challenging.

I am a developer currently working in SEEK Australia.

In my experience, common mistakes developer make when starting a projects are:

  • No Linting
@mxriverlynn
mxriverlynn / 1_overlap.js
Last active January 21, 2020 13:59
checking for date range overlap
// this function takes an array of date ranges in this format:
// [{ start: Date, end: Date}]
// the array is first sorted, and then checked for any overlap
function overlap(dateRanges){
var sortedRanges = dateRanges.sort((previous, current) => {
// get the start date from previous and current
var previousTime = previous.start.getTime();
var currentTime = current.start.getTime();
@kevinwright
kevinwright / scaladays2014.md
Last active March 8, 2018 20:25
Scaladays 2014 slides

As compiled by Kevin Wright a.k.a @thecoda

(executive producer of the movie, and I didn't even know it... clever huh?)

please, please, please - If you know of any slides/code/whatever not on here, then ping me on twitter or comment this Gist!

This gist will be updated as and when I find new information. So it's probably best not to fork it, or you'll miss the updates!

Monday June 16th

@cloudwu
cloudwu / ffr.c
Last active January 30, 2023 04:29
fast IEEE 754 float random
#include <stdint.h>
#include <stdlib.h>
// assert(RAND_MAX >= 0x7fff)
float
random_0_to_1() {
union {
uint32_t d;
float f;
} u;
@branneman
branneman / better-nodejs-require-paths.md
Last active April 27, 2024 04:16
Better local require() paths for Node.js

Better local require() paths for Node.js

Problem

When the directory structure of your Node.js application (not library!) has some depth, you end up with a lot of annoying relative paths in your require calls like:

const Article = require('../../../../app/models/article');

Those suck for maintenance and they're ugly.

Possible solutions

@joeyAghion
joeyAghion / mongodb_collection_sizes.js
Last active February 9, 2024 22:37
List mongodb collections in descending order of size. Helpful for finding largest collections. First number is "size," second is "storageSize."
var collectionNames = db.getCollectionNames(), stats = [];
collectionNames.forEach(function (n) { stats.push(db[n].stats()); });
stats = stats.sort(function(a, b) { return b['size'] - a['size']; });
for (var c in stats) { print(stats[c]['ns'] + ": " + stats[c]['size'] + " (" + stats[c]['storageSize'] + ")"); }
@jdegoes
jdegoes / iso8601.g4
Created June 24, 2013 20:40
ISO8601 ANTLR4
dateFullyear : Digit{4};
dateMonth : Digit{2};
dateMday : Digit{2};
timeHour : Digit{2};
timeMinute : Digit{2};
timeSecond: Digit{2};
timeSecfrac : '.' Digit{1,};
timeNumOffset : ('+' | '-') timeHour ':' timeMinute;
timeOffset: 'Z' | timeNumOffset;
partialTime : timeHour ':' timeMinute ':' timeSecond timeSecfrac?;
@lotem
lotem / default.custom.yaml
Last active January 25, 2024 08:47
在Rime輸入方案選單中添加五筆、雙拼、粵拼、注音,保留你需要的
# default.custom.yaml
# save it to:
# ~/.config/ibus/rime (linux)
# ~/Library/Rime (macos)
# %APPDATA%\Rime (windows)
patch:
schema_list:
- schema: luna_pinyin # 朙月拼音
- schema: luna_pinyin_simp # 朙月拼音 简化字模式