Skip to content

Instantly share code, notes, and snippets.

@ikbear
ikbear / gist:14e8efe091e9ed33ecc0
Created September 22, 2015 17:02 — forked from paulirish/gist:4158604
Learn JavaScript concepts with recent DevTools features

Learn JavaScript concepts with the Chrome DevTools

Authored by Peter Rybin , Chrome DevTools team

In this short guide we'll review some new Chrome DevTools features for "function scope" and "internal properties" by exploring some base JavaScript language concepts.

Closures

Let's start with closures – one of the most famous things in JS. A closure is a function, that uses variables from outside. See an example:

@ikbear
ikbear / what-forces-layout.md
Created September 22, 2015 16:53 — 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()
@ikbear
ikbear / Memory-Management.md
Last active September 12, 2015 15:34 — forked from githubutilities/Memory-Management.md
Memory Management
@ikbear
ikbear / combination.go
Last active September 12, 2015 17:27
从 n 个数中选择 m 个的组合(n >= m)
package main
import "fmt"
func main() {
fmt.Println(f(5, 3))
}
func f(n, m int) int {
if n <= 0 || m <= 0 {
@ikbear
ikbear / docker-registry.go
Created September 7, 2015 01:37
Docker Registry V1 示例
package main
import (
"fmt"
"github.com/CenturyLinkLabs/docker-reg-client/registry"
"net/url"
)
func main() {
@ikbear
ikbear / keyrepeat.shell
Last active August 29, 2015 14:28 — forked from kconragan/keyrepeat.shell
Enable key repeat in Apple Lion for Sublime Text in Vim mode
# Mac OS X Lion introduced a new, iOS-like context menu when you press and hold a key
# that enables you to choose a character from a menu of options. If you are on Lion
# try it by pressing and holding down 'e' in any app that uses the default NSTextField
# for input.
#
# It's a nice feature and continues the blending of Mac OS X and iOS features. However,
# it's a nightmare to deal with in Sublime Text if you're running Vintage (Vim) mode,
# as it means you cannot press and hold h/j/k/l to move through your file. You have
# to repeatedly press the keys to navigate.
@ikbear
ikbear / json-unmarshal.go
Created August 24, 2015 02:58
JSON 解析出错
package main
import (
"encoding/json"
"fmt"
)
func main() {
var jsonBlob = []byte(`{
"repo_info": {
#!/bin/bash
/bin/sh -c "while true; do echo hello world; sleep 1; done"
@ikbear
ikbear / Makefile
Last active August 29, 2015 14:27 — forked from border/Makefile
json example in golang
include $(GOROOT)/src/Make.inc
GOFMT=gofmt -spaces=true -tabindent=false -tabwidth=4
all:
$(GC) jsontest.go
$(LD) -o jsontest.out jsontest.$O
format:
$(GOFMT) -w jsontest.go
@ikbear
ikbear / directive-attrs.js
Created August 7, 2015 08:25
Angularjs - how do i access directive attribute in controller
// URL: http://stackoverflow.com/questions/24864956/angularjs-how-do-i-access-directive-attribute-in-controller
app.directive('rating', [function () {
return {
restrict: 'E',
scope: {
maxStars: '=',
url: '@'
},
controller: 'ratingController'