Skip to content

Instantly share code, notes, and snippets.

View paranoidjk's full-sized avatar

paranoidjk paranoidjk

View GitHub Profile
@paranoidjk
paranoidjk / speed_test.js
Created October 20, 2017 15:14
Test speed for vultr
const childPross = require('child_process');
const hosts = [
"fra-de-ping.vultr.com",
"par-fr-ping.vultr.com",
"ams-nl-ping.vultr.com",
"lon-gb-ping.vultr.com",
"sgp-ping.vultr.com",
"nj-us-ping.vultr.com",
"hnd-jp-ping.vultr.com",
@paranoidjk
paranoidjk / index.js
Last active September 20, 2017 05:53
requirebin sketch
// Welcome! require() some modules from npm (like you were using browserify)
// and then hit Run Code to run your code on the right side.
// Modules get downloaded from browserify-cdn and bundled in your browser.
var co = require('co');
console.log = function() {
var text = '<div>' + Date.now() + ' ' + [].slice.call(arguments).join(' ') + '</div>';
document.body.innerHTML += text;
}

Keybase proof

I hereby claim:

  • I am paranoidjk on github.
  • I am paranoidjk (https://keybase.io/paranoidjk) on keybase.
  • I have a public key whose fingerprint is 2828 F71E 3114 74E7 0D8D 004C 04B6 6497 C45E 5B5D

To claim this, I am signing this object:

var cache = {};
function tmpl(str, data) {
var fn = ! /\W/.test(str) ? cache[str] = cache[str] || tmpl(document.getElementById(str).innerHTML) :
new Function("obj", "var p=[],print=function(){p.push.apply(p,arguments);};" +
"with(obj){p.push('" +
str.replace(/[\r\t\n]/g, " ")
.split("<%").join("\t")
.replace(/((^|%>)[^\t]*)'/g, "$1\r")
.replace(/\t=(.*?)%>/g, "',$1,'")
.split("\t").join("');")
@paranoidjk
paranoidjk / cookie.js
Created December 24, 2016 07:24
cookie
@paranoidjk
paranoidjk / .editorconfig
Created December 1, 2016 13:23
EditorConfig
# EditorConfig helps developers define and maintain
# consistent coding styles between different editors and IDEs.
# http://EditorConfig.org
# top-must EditorConfig file
root = true
# Unix-style newlines with a newline ending every file
[*]
end_of_line = lf
@paranoidjk
paranoidjk / contentloaded.js
Created November 21, 2016 10:01
contentloaded.js
/*!
* contentloaded.js
*
* Author: Diego Perini (diego.perini at gmail.com)
* Summary: cross-browser wrapper for DOMContentLoaded
* Updated: 20101020
* License: MIT
* Version: 1.2
*
* URL:
@paranoidjk
paranoidjk / formatter.js
Last active November 18, 2016 05:22
formatter of javascript
// refer: http://frontenddev.org/column/one-line-of-code/
// 千位分隔符
var format = function (number) {
return String(number).replace(/(\d)(?=(\d{3})+$)/g, '$1,');
};
if ('ontouchend' in document.body) {
// 移动端
}
if (/mobile/i.test(navigator.userAgent)) {
@paranoidjk
paranoidjk / opacity.md
Created October 25, 2016 08:22
opacity.md
.opacity{
    filter:alpha(opacity=50);       /* IE */
    -moz-opacity:0.5;              /* 老版Mozilla */
    khtml-opacity:0.5;              /* 老版Safari */
    opacity: 0.5;           /* 支持opacity的浏览器*/
}
object.filter = "alpha(opacity=" + opacity + ")"; /* IE */
@paranoidjk
paranoidjk / parseUri.js
Created October 25, 2016 07:15
use browser api to parse uri for you
// This function creates a new anchor element and uses location
// properties (inherent) to get the desired URL data. Some String
// operations are used (to normalize results across browsers).
 
function parseURL(url) {
    var a =  document.createElement('a');
    a.href = url;
    return {
        source: url,
        protocol: a.protocol.replace(':',''),