Skip to content

Instantly share code, notes, and snippets.


Pengfei Liu prafulliu

  • teambition
  • shanghai
View GitHub Profile
silver-xu /
Last active Oct 7, 2022
Setup a Node.js project with Typescript, ESLint, Prettier, Husky

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


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 / 1_overlap.js
Last active Jan 21, 2020
checking for date range overlap
View 1_overlap.js
// 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 /
Last active Mar 8, 2018
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 / ffr.c
Last active May 4, 2022
fast IEEE 754 float random
View ffr.c
#include <stdint.h>
#include <stdlib.h>
// assert(RAND_MAX >= 0x7fff)
random_0_to_1() {
union {
uint32_t d;
float f;
} u;
branneman /
Last active Sep 20, 2022
Better local require() paths for Node.js

Better local require() paths for Node.js


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 / mongodb_collection_sizes.js
Last active Sep 27, 2022
List mongodb collections in descending order of size. Helpful for finding largest collections. First number is "size," second is "storageSize."
View mongodb_collection_sizes.js
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 / iso8601.g4
Created Jun 24, 2013
View iso8601.g4
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 / default.custom.yaml
Last active Sep 12, 2022
View default.custom.yaml
# default.custom.yaml
# save it to:
# ~/.config/ibus/rime (linux)
# ~/Library/Rime (macos)
# %APPDATA%\Rime (windows)
- schema: luna_pinyin # 朙月拼音
- schema: luna_pinyin_simp # 朙月拼音 简化字模式