Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View fredyang's full-sized avatar

Fred Yang fredyang

View GitHub Profile
{
"files.autoSave": "onFocusChange",
"vim.easymotion": true,
"vim.incsearch": true,
"vim.useSystemClipboard": true,
"vim.useCtrlKeys": true,
"vim.hlsearch": true,
"vim.sneak": true,
"vim.easymotionMarkerooundColor": "#020202",
"vim.normalModeKeyBindings": [
@fredyang
fredyang / settiings.json
Created July 13, 2022 02:44
vscode settings
{
"[html]": {
"editor.defaultFormatter": "vscode.html-language-features"
},
"[javascript]": {
"editor.defaultFormatter": "vscode.typescript-language-features"
},
"[json]": {
"editor.defaultFormatter": "vscode.json-language-features"
},
@fredyang
fredyang / microsyntax.md
Created August 29, 2020 10:33 — forked from mhevery/microsyntax.md
Angular microsyntax gramar

Microsyntax

Microsyntax in Angular allows you to write <div *ngFor="let item of items">{{item}}</div> instead of <ng-template ngFor [ngForOf]="items"><div>{{item}}</div></ng-template.

Constraints

The microsyntax must:

  • be know ahead of time so that IDEs can parse it without knowing what is the underlying semantics of the directive or what directives are present.
  • must translate to key-value attributes in the DOM.
#https://stackoverflow.com/questions/42591099/how-do-i-remove-a-hosted-site-from-firebase
firebase hosting:disable
//this function return a color in constrast with the input color
// https://medium.com/@MikeKellyWeb/calculating-color-contrast-with-sass-eff39ef23f96
// Color contrast
// see demo https://codepen.io/fredyang/pen/RwWQJVo
$yiq-text-dark: $gray-900 !default;
$yiq-text-light: $white !default;
$yiq-contrasted-threshold: 150 !default
@function color-yiq($color, $dark: $yiq-text-dark, $light: $yiq-text-light) {
$r: red($color);
@fredyang
fredyang / catchit.ts
Last active May 4, 2020 02:22
a function that allow you convert async express middleware without worry about exception
const catchit = asynFn => (req, res, next) => asynFn(req, res, next).catch(next);
//usage
router.get('/', catchit(async (req, res, next) => {
await data = db.get();
throw 'err';
res.json(data);
}));
interface Constructor<T> {
new(...args: []): T;
}
interface Base {
}
interface Items {
items: [];
}
@fredyang
fredyang / client.js
Created April 23, 2020 01:31 — forked from PaulMougel/client.js
File upload in Node.js to an Express server, using streams
// node: v0.10.21
// request: 2.27.0
var request = require('request');
var fs = require('fs');
var r = request.post("http://server.com:3000/");
// See http://nodejs.org/api/stream.html#stream_new_stream_readable_options
// for more information about the highWaterMark
// Basically, this will make the stream emit smaller chunks of data (ie. more precise upload state)
var upload = fs.createReadStream('f.jpg', { highWaterMark: 500 });
@fredyang
fredyang / cloudSettings
Last active May 21, 2020 00:55
Visual Studio Code Settings Sync Gist
{"lastUpload":"2020-04-22T13:57:07.464Z","extensionVersion":"v3.4.3"}