Skip to content

Instantly share code, notes, and snippets.

View xiaojue's full-sized avatar
🤚
waiting

xiaojue xiaojue

🤚
waiting
View GitHub Profile
@xiaojue
xiaojue / clipboard2img.js
Created July 24, 2018 07:40
clipboard2img
function clipboard2Img(options){
var self = this;
this.URL = options.host + options.api;
this.success = options.success || function(){};
if(!options.ele){
return alert('options ele must have');
}
options.ele.addEventListener('paste', self.getClipboardImage.bind(this), false)
}
function getRandom(n, arr, ret) {
ret = ret || [];
var randomNum = parseInt(Math.random() * (arr.length - 1), 10);
if (ret.indexOf(randomNum) === -1) {
ret.push(randomNum);
} else {
getRandom(n, arr, ret);
}
return ret.length === n ? ret : getRandom(n, arr, ret);
}
@xiaojue
xiaojue / AMN.js
Created June 7, 2017 09:14
AMN.js
function combine(a) {
var fn = function(n, src, got, all) {
if (n == 0) {
if (got.length > 0) {
all[all.length] = got;
}
return;
}
for (var j = 0; j < src.length; j++) {
fn(n - 1, src.slice(j + 1), got.concat([src[j]]), all);
data:image/jpeg;base64,/9j/4AAQSkZJRgABAQAAAQABAAD/2wBDAAIBAQEBAQIBAQECAgICAgQDAgICAgUEBAMEBgUGBgYFBgYGBwkIBgcJBwYGCAsICQoKCgoKBggLDAsKDAkKCgr/2wBDAQICAgICAgUDAwUKBwYHCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgr/wAARCAGgA1IDASIAAhEBAxEB/8QAHQABAAICAwEBAAAAAAAAAAAAAAcIAwYCBQkEAf/EAGQQAAEDAgQCBQYIBwcODAUFAAABAgMEBQYHCBESIQkTFDFBIlFUcZPRMjY4YXV2s7QVFiNCUoGRJDNicnOCoRcYNDc5U3R3kpajsbLTGSUmNUNGVVZXY4PCWWSEwdJlZpXDxP/EAB0BAQABBQEBAQAAAAAAAAAAAAAGAgMEBQcBCAn/xABTEQACAQMCAwQECQcJAwoHAAAAAQIDBBEFIQYSMRNBUWEicYGxBxQyMzRykaGyIzVCUmJzwRU2N0NTdLPR8IKStBYXRUeDhMLE0uEkRGNkk6Lx/9oADAMBAAIRAxEAPwDq+21vpk3tV947bW+mTe1X3mMHA8s/TvC8DJ22t9Mm9qvvHba30yb2q+8xgZYwvAydtrfTJvar7x22t9Mm9qvvMYGWMLwMnba30yb2q+8dtrfTJvar7zGBljC8DJ22t9Mm9qvvHba30yb2q+8xgZYwvAydtrfTJvar7x22t9Mm9qvvMYGWMLwMnba30yb2q+8dtrfTJvar7zGBljC8DJ22t9Mm9qvvHba30yb2q+8xgZYwvAydtrfTJvar7x22t9Mm9qvvMYGWMLwMnba30yb2q+8dtrfTJvar7zGBljC8DJ22t9Mm9qvvHba30yb2q+8xgZYwvAydtrfTJvar7x22t9Mm9qvvMYGWMLwMnba30yb2q+8dtrfTJvar7zGBljC8DJ22t9Mm9qvvHba30yb2q+8xgZYwv
@xiaojue
xiaojue / t.js
Last active August 29, 2019 06:46
countdown
/**
* @author xiaojue
* @date 20160420
* @fileoverview 倒计时
*/
(function() {
function timer(delay) {
this._queue = [];
this.stop = false;
@xiaojue
xiaojue / rem.js
Created October 13, 2015 13:48
rem.js
/*
* rem.js
* v0.1.1
* fixed 2015-3-12
*/
(function (win){
var doc = win.document,
html = doc.documentElement,
option = html.getAttribute('data-use-rem');
@xiaojue
xiaojue / common.css
Created August 27, 2015 13:18
common.css
/*css reset*/
html,body,div,span,applet,object,iframe,h1,h2,h3,h4,h5,h6,p,blockquote,pre,a,abbr,acronym,address,big,cite,code,del,dfn,em,img,ins,kbd,q,s,samp,small,strike,strong,sub,sup,tt,var,b,u,i,center,dl,dt,dd,ol,ul,li,fieldset,form,label,legend,table,caption,tbody,tfoot,thead,tr,th,td,article,aside,canvas,details,figcaption,figure,footer,header,hgroup,menu,nav,section,summary,time,mark,audio,video{margin:0;padding:0;border:0;outline:0}html,body,form,fieldset,p,div,h1,h2,h3,h4,h5,h6{-webkit-text-size-adjust:none}article,aside,details,figcaption,figure,footer,header,hgroup,menu,nav,section{display:block;clear:both;}
html { font-family: 'Microsoft YaHei',"Helvetica Neue", Helvetica, STHeiTi, Arial, sans-serif; -ms-text-size-adjust: 100%; -webkit-text-size-adjust: 100%; font-size: 62.5%; }
body {font-size: 1.4rem;overflow-x: hidden;min-width:320px; /*-webkit-overflow-scrolling: touch;*/color:#1a1a1a;background:#f9f9f9; }
a { background: transparent; text-decoration: none; -webkit-tap-highlight-color: transp
@xiaojue
xiaojue / .jsbeautifyrc
Created July 21, 2015 04:28
jsbeautifyrc
{
"indent_size": 4,
"indent_char": " ",
"eol": "\n",
"indent_level": 0,
"indent_with_tabs": false,
"preserve_newlines": true,
"max_preserve_newlines": 10,
"jslint_happy": false,
"space_after_anon_function": false,
@xiaojue
xiaojue / .jshintrc
Last active August 29, 2015 14:25
jshintrc
{
// JSHint Default Configuration File (as on JSHint website)
// See http://jshint.com/docs/ for more details
"maxerr" : 50, // {int} Maximum error before stopping
// Enforcing
"bitwise" : true, // true: Prohibit bitwise operators (&, |, ^, etc.)
"camelcase" : true, // true: Identifiers must be in camelCase
"curly" : true, // true: Require {} for every new block or scope
@xiaojue
xiaojue / liveweb.js
Created October 23, 2014 15:02
liveweb
var express = require('express')
var http = require('http')
var net = require('net');
var child = require('child_process');
var app = express();
var httpServer = http.createServer(app);
app.get('/', function(req, res) {
var date = new Date();