Skip to content

Instantly share code, notes, and snippets.

View towry's full-sized avatar
🎯
Focusing

Towry Wang towry

🎯
Focusing
View GitHub Profile
@towry
towry / changeip.md
Last active August 29, 2015 14:06
rj

/etc/network/interfaces

append the following line:

# interfaces(5) file used by ifup(8) and ifdown(8)
auto lo
iface lo inet loopback

auto eth0

Keybase proof

I hereby claim:

  • I am towry on github.
  • I am towry (https://keybase.io/towry) on keybase.
  • I have a public key whose fingerprint is 9BBD 36E0 E105 7858 862D 3BD5 9862 205C 3B7E AB40

To claim this, I am signing this object:

/* C99 systems have <inttypes.h>. Non-C99 systems may or may not. */
#if defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
/* C99 says to define __STDC_LIMIT_MACROS before including stdint.h,
* if you want the limit (max/min) macros for int types.
*/
#ifndef __STDC_LIMIT_MACROS
#define __STDC_LIMIT_MACROS 1
#endif
var b = new Promise(function (resolve, reject) {
setTimeout(function(){
reject(new Error("haha"));})
});
b.then(function(v){
console.log(v); return 3;
}, function(e) {
console.log("error: " + e);
}).then(function(v){
<!DOCTYPE html>
<html>
<head>
<script src="http://code.jquery.com/jquery-2.1.1.min.js"></script>
<meta charset="utf-8">
<title>JS Bin</title>
<style>
.circle {
width: 100px;
height: 100px;
<style>
.b {
width: 100px;
height: 100px;
background-color: blue;
margin-top: -30px;
}
.b-child {
width: 50px;
height: 50px;
#!/usr/bin/env ruby
# -*- encoding: UTF-8 -*-
class Base
attr_reader :blocks
class << self
def get(path, &block)
@blocks ||= []
@blocks << block
@towry
towry / what-forces-layout.md
Last active September 20, 2015 11:17 — 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()
@towry
towry / p4merge4git.md
Created November 4, 2015 13:58 — forked from tony4d/p4merge4git.md
Setup p4merge as a visual diff and merge tool for git
@towry
towry / emojid.js
Created November 12, 2015 04:40
detect emoji support
var emojiSupported = (function() {
var node = document.createElement('canvas');
if (!node.getContext || !node.getContext('2d') ||
typeof node.getContext('2d').fillText !== 'function')
return false;
var ctx = node.getContext('2d');
ctx.textBaseline = 'top';
ctx.font = '32px Arial';
ctx.fillText('\ud83d\ude03', 0, 0);
return ctx.getImageData(16, 16, 1, 1).data[0] !== 0;