Skip to content

Instantly share code, notes, and snippets.

View taozhi8833998's full-sized avatar
🐃
Focusing

taozhi taozhi8833998

🐃
Focusing
View GitHub Profile
@taozhi8833998
taozhi8833998 / memorySizeOfObject.js
Created March 1, 2018 08:01
calculate memory size of javascript object, it is not a accurate value!
function memorySizeOf(obj) {
var bytes = 0;
function sizeOf(obj) {
if(obj !== null && obj !== undefined) {
switch(typeof obj) {
case 'number':
bytes += 8;
break;
case 'string':
@taozhi8833998
taozhi8833998 / .tmux.conf
Created February 8, 2018 06:43 — forked from paulodeleo/.tmux.conf
Tmux configuration to enable mouse scroll and mouse panel select, taken from: http://brainscraps.wikia.com/wiki/Extreme_Multitasking_with_tmux_and_PuTTY
# Make mouse useful in copy mode
setw -g mode-mouse on
# Allow mouse to select which pane to use
set -g mouse-select-pane on
# Allow mouse dragging to resize panes
set -g mouse-resize-pane on
# Allow mouse to select windows

Writing template strings in Markdown

With template strings coming to ES6, the backtick (`) means something in Markdown and in JavaScript. If you write this:

To display a message, write `alert(`hello world!`)`.

it'll render like this:

To display a message, write alert(hello world!).

@taozhi8833998
taozhi8833998 / README.md
Created November 2, 2017 02:14 — forked from joyrexus/README.md
RAF replacements for setTimeout and setInterval

Drop in replace functions for setTimeout and setInterval that make use of requestAnimationFrame.

See overview article and Paul Irish's earlier post.

Courtesty of Joe Lambert

Copyright 2011, Joe Lambert.
Free to use under the MIT license.
http://www.opensource.org/licenses/mit-license.php
@taozhi8833998
taozhi8833998 / byte-sizetuts.md
Created October 27, 2017 07:54 — forked from honkskillet/byte-sizetuts.md
A series of golang tutorials with youtube videos.
@taozhi8833998
taozhi8833998 / fabricBezierCurve.js
Created August 31, 2017 06:16 — forked from paulkaplan/fabricBezierCurve.js
Cubic bezier curves with fabric.js renderer
var CubicBezier = function(canvas, opts){
if(!opts) opts = {};
this.start = opts.start || new Vec2(100,100);
this.end = opts.end || new Vec2(400, 400);
this.c1 = opts.c1 || new Vec2(100, 300);
this.c2 = opts.c2 || new Vec2(300, 100);
this.curve = new fabric.Path( this.toSVGPath() );
@taozhi8833998
taozhi8833998 / what-forces-layout.md
Created June 16, 2017 04:12 — forked from paulirish/what-forces-layout.md
What forces layout/reflow. The comprehensive list.

What forces layout / reflow

All of the below properties or methods, when requested/called in JavaScript, will trigger the browser to synchronously calculate the style and layout*. This is also called reflow or layout thrashing, and is common performance bottleneck.

Element

Box metrics
  • elem.offsetLeft, elem.offsetTop, elem.offsetWidth, elem.offsetHeight, elem.offsetParent
  • elem.clientLeft, elem.clientTop, elem.clientWidth, elem.clientHeight
  • elem.getClientRects(), elem.getBoundingClientRect()
@taozhi8833998
taozhi8833998 / current-dir-in-iterm-tab-title.sh
Created May 11, 2017 06:35 — forked from phette23/current-dir-in-iterm-tab-title.sh
Set the iTerm tab title to the current directory, not full path.
# put this in your .bash_profile
if [ $ITERM_SESSION_ID ]; then
export PROMPT_COMMAND='echo -ne "\033];${PWD##*/}\007"; ':"$PROMPT_COMMAND";
fi
# Piece-by-Piece Explanation:
# the if condition makes sure we only screw with $PROMPT_COMMAND if we're in an iTerm environment
# iTerm happens to give each session a unique $ITERM_SESSION_ID we can use, $ITERM_PROFILE is an option too
# the $PROMPT_COMMAND environment variable is executed every time a command is run
# see: ss64.com/bash/syntax-prompt.html
@taozhi8833998
taozhi8833998 / iterm2.zsh
Created May 10, 2017 09:02 — forked from wadey/iterm2.zsh
Change iTerm2 tab color when using SSH
# Usage:
# source iterm2.zsh
# iTerm2 window/tab color commands
# Requires iTerm2 >= Build 1.0.0.20110804
# http://code.google.com/p/iterm2/wiki/ProprietaryEscapeCodes
tab-color() {
echo -ne "\033]6;1;bg;red;brightness;$1\a"
echo -ne "\033]6;1;bg;green;brightness;$2\a"
echo -ne "\033]6;1;bg;blue;brightness;$3\a"
@taozhi8833998
taozhi8833998 / README.md
Created February 14, 2017 11:30 — forked from clhenrick/README.md
PostgreSQL & PostGIS cheatsheet (a work in progress)