Skip to content

Instantly share code, notes, and snippets.

Avatar

Pengfei Liu prafulliu

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

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
View learning_scala.org
@mxriverlynn
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
kevinwright / scaladays2014.md
Last active Mar 8, 2018
Scaladays 2014 slides
View scaladays2014.md

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 May 4, 2022
fast IEEE 754 float random
View ffr.c
#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 Sep 20, 2022
Better local require() paths for Node.js
View better-nodejs-require-paths.md

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 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
jdegoes / iso8601.g4
Created Jun 24, 2013
ISO8601 ANTLR4
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
lotem / default.custom.yaml
Last active Sep 12, 2022
在Rime輸入方案選單中添加五筆、雙拼、粵拼、注音,保留你需要的
View default.custom.yaml
# 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 # 朙月拼音 简化字模式