Skip to content

Instantly share code, notes, and snippets.

View mygoare's full-sized avatar
:octocat:

Gore mygoare

:octocat:
View GitHub Profile
@mygoare
mygoare / new.js
Last active October 27, 2017 06:41
javascript new 操作符
总的来说,理解了下面这句话,对于下面的例子就很好理解了,都是为了加深理解而举得下面的例子。
按照javascript语言精粹中所说,
如果在一个函数前面带上new来调用该函数,那么将创建一个隐藏连接到该函数的prototype成员的新对象,同时this将被绑定到那个新对象上.
1. 如果就一个函数,没有返回值,没有prototype成员,然后使用new,会是什么结果呢?如果一个函数没有返回值,那么如果不使用new来创建变量,那么该变量的值为undefined.如果用了new,那么就是Object.说明一个函数的默认的Prototype是Object.
function Test1(str) {
this.a = str;
@mygoare
mygoare / co.js
Created August 24, 2016 17:39
understand co (a simple co)
function co(GenFunc) {
return function(cb) {
var gen = GenFunc()
next()
function next(err, args) {
if (err) {
cb(err)
} else {
if (gen.next) {
var ret = gen.next(args)
However, if you have a normal parent div with a background, the lower element will be hidden. In this case, give the parent relative positioning and a z-index of 1. See: jsbin.com/juputice/3/edit
@mygoare
mygoare / install_docker.sh
Created July 21, 2016 16:58
install docker on ubuntu trusty 14.04
# This script is used for ubuntu Trusty 14.04
sudo apt-get update
sudo apt-get install apt-transport-https ca-certificates -y
sudo apt-get install vim -y
sudo apt-key adv --keyserver hkp://p80.pool.sks-keyservers.net:80 --recv-keys 58118E89F3A912897C070ADBF76221572C52609D
sudo touch /etc/apt/sources.list.d/docker.list
sudo echo 'deb https://apt.dockerproject.org/repo ubuntu-trusty main' > /etc/apt/sources.list.d/docker.list
sudo apt-get update
sudo apt-get purge lxc-docker
@mygoare
mygoare / README.md
Created January 12, 2016 02:48 — forked from joyrexus/README.md
form-data vs -urlencoded

Nice answer on stackoverflow to the question of when to use one or the other content-types for POSTing data, viz. application/x-www-form-urlencoded and multipart/form-data.

“The moral of the story is, if you have binary (non-alphanumeric) data (or a significantly sized payload) to transmit, use multipart/form-data. Otherwise, use application/x-www-form-urlencoded.”


Matt Bridges' answer in full:

The MIME types you mention are the two Content-Type headers for HTTP POST requests that user-agents (browsers) must support. The purpose of both of those types of requests is to send a list of name/value pairs to the server. Depending on the type and amount of data being transmitted, one of the methods will be more efficient than the other. To understand why, you have to look at what each is doing

http://stackoverflow.com/questions/26882177/react-js-inline-style-best-practices
@mygoare
mygoare / 范式
Last active November 20, 2015 09:28
Database 设计
通过entity relation diagram 设计数据库
1. 表中属性唯一,不重复
2. 属性完全只依赖于主键
3. 表中不含非关键字信息
索引是用来定位的
@mygoare
mygoare / css实践.rtf
Last active November 25, 2015 07:06
css实践
分离 用于展示效果的 css className 和 javascript 用来绑定或附加效果的 css className
css 命名:
prefixName-block-element--modifier
e.g.
qm-header-title
qm-header-title--highLight
qm-header-navList
@mygoare
mygoare / mp3player.js
Created October 30, 2015 03:31 — forked from TooTallNate/mp3player.js
node.js command line MP3 player in 9 lines of code!
var fs = require('fs');
var lame = require('lame');
var Speaker = require('speaker');
fs.createReadStream(process.argv[2])
.pipe(new lame.Decoder())
.on('format', function (format) {
this.pipe(new Speaker(format));
});