This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var Events = { | |
bind: function(){ | |
if (!this.o) this.o = $({}); | |
this.o.bind.apply(this.o, arguments); | |
}, | |
trigger: function(){ | |
if (!this.o) this.o = $({}); | |
this.o.trigger.apply(this.o, arguments); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Add a field | |
db.products.update( | |
{ }, | |
{ $set: | |
{ quantity: "", | |
instock: "" | |
} | |
}, | |
{ multi: true } | |
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
int match_type(char *str, char *type) | |
{ | |
printf("%s\n", str); | |
printf("%s\n", type); | |
int i = 0, j = 0, count = 0; | |
char tmp1[10]; | |
char c; | |
while ((c = str[i]) != '\0') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function url_param(url) { | |
var _url = url || window.location.href; | |
var array = _url.match(/\w+=\w+/g); | |
var result = {}; | |
var tmp = []; | |
for (var i = 0; i < array.length; i++) { | |
tmp = array[i].split("="); | |
result[tmp[0]] = tmp[1]; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* horizontal centering | |
method 1; negative margin | |
h1 { | |
width: 350px; | |
position: relative; | |
left: 50%; | |
margin-left: -175px; | |
}*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* vertical and horizontal centering | |
method 1: absolute position + negative margin | |
h1 { | |
position: absolute; | |
width: 350px; | |
height: 50px; | |
left: 50%; | |
top: 50%; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
h3 { | |
font-size: 15px; | |
color: #333; | |
font-family: 'arial'; | |
} | |
ul { | |
list-style: none; | |
padding-left: 0px; | |
width: 600px; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
curl https://s3.amazonaws.com/heroku-jvm-buildpack-vi/vim-7.3.tar.gz --output vim.tar.gz | |
mkdir vim && tar xzvf vim.tar.gz -C vim | |
export PATH=$PATH:/app/vim/bin |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function tableToDiv(html) { | |
return html.replace(/<(\/?)(table|thead|tbody|tfoot|th|td|tr)/gi, '<$1div data-original-tag="$2"'); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// save | |
require('fs').writeFile("/Users/guanxiongding/Desktop/test.html", body, function() {}); | |
// load | |
body = require('fs').readFileSync('/Users/guanxiongding/Desktop/test.html', {encoding: 'utf8'}) | |
$ = require('bb_platform/node_modules/cheerio').load(body); |
OlderNewer