Skip to content

Instantly share code, notes, and snippets.

View d6u's full-sized avatar

Daiwei Lu d6u

View GitHub Profile
@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 / 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 / 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 / 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;
var Bluebird = require('bluebird');
function Something() {
this.queue = [];
this.currentJob = null;
}
Something.prototype.queueJob = function (job) {
if (this.currentJob) {
this.queue.push(job);
'use strict';
function collectForm(form) {
var q = {};
var i;
var j;
if (!form || form.nodeName !== 'FORM') {
return null;
}
//: Playground - noun: a place where people can play
import Foundation
import UIKit
import XCPlayground
class DLLabel: UILabel {
let textContainer = NSTextContainer()
let layoutManager = NSLayoutManager()
@d6u
d6u / usage.js
Last active August 29, 2015 14:21 — forked from jasonfarrell/usage.js
var my_element = document.getElementById('my-element');
//-- Returns true/false
my_element.isVisible(my_element);
module.exports = {
// Modern
//
bs_chrome_osx: {
base: 'BrowserStack',
os: 'OS X',
os_version: 'Yosemite',
browser: 'chrome',
browser_version: '39.0'
},