Skip to content

Instantly share code, notes, and snippets.

View d6u's full-sized avatar

Daiwei Lu d6u

View GitHub Profile
@d6u
d6u / gist:e12c9c599befbd2dd5ce
Created January 13, 2015 22:14
Binary Operations
// shiftOperation.cpp : 定义控制台应用程序的入口点。
/*******************************************
author:老六是Jerry
functoin:位运算
********************************************/
#include "stdafx.h"
#include <Windows.h>
#include <iostream>
using namespace std;
@d6u
d6u / bluebird_promise.js
Created November 27, 2014 21:18
bluebird promise
Promise.resolve().then(function() {
throw new MyCustomError();
}).catch(MyCustomError, function(e) {
//will end up here now
});
// custom error type
function MyCustomError() {}
MyCustomError.prototype = Object.create(Error.prototype);
@d6u
d6u / xss_defense.js
Last active August 29, 2015 14:08
xss defense
__defineSetter__
__lookupSetter__
Function.prototype.apply = function() {
this // is the function being "applied"
};
Object.defineProperty(Function.prototype, 'call', {
value: Function.prototype.call,
writable: false,
@d6u
d6u / common.r
Last active August 29, 2015 14:08
common used r command
library() # installed
search() # active
install.package("package name")
library("name") # load from script
require("name") # load in function and package
library(help = "name") # documentation
vignette(package = "name") # example
browseVignettes(package = "name") # example in browser
@d6u
d6u / inst737-tweet.js
Last active August 29, 2015 14:08
inst737
{ _id: { type: [ 'Object' ] },
created_at: { type: [ 'String' ] },
id: { type: [ 'Number' ] },
id_str: { type: [ 'String' ] },
text: { type: [ 'String' ] },
source: { type: [ 'String' ] },
truncated: { type: [ 'Boolean' ] },
in_reply_to_status_id: { type: [ 'Null', 'Number' ] },
in_reply_to_status_id_str: { type: [ 'Null', 'String' ] },
in_reply_to_user_id: { type: [ 'Number', 'Null' ] },
@d6u
d6u / mongodb-adduser.js
Created October 22, 2014 18:10
mongodb common notes
conn = new Mongo();
db = conn.getDB('admin');
db.createUser({
user: 'siteUserAdmin',
pwd: 'password',
roles: [{
role: 'userAdminAnyDatabase',
db: 'admin'
@d6u
d6u / bash.sh
Created October 21, 2014 22:52
# check empty dir
if [[ -z $(ls -A $DIR) ]]
then
echo "empty"
else
echo "not empty"
fi
@d6u
d6u / syslog-ng.conf
Created October 9, 2014 23:27
syslog-ng config files
@version: 3.5
@include "scl.conf"
@include "`scl-root`/system/tty10.conf"
# Syslog-ng configuration file, compatible with default Debian syslogd
# installation.
# First, set some global options.
options { chain_hostnames(off); flush_lines(0); use_dns(no); use_fqdn(no);
owner("root"); group("adm"); perm(0640); stats_freq(0);