Skip to content

Instantly share code, notes, and snippets.

Q Tiu HiuMiuLiu

Kainy Guo kainy

Q Tiu HiuMiuLiu
View GitHub Profile
kainy / obfuscate.js
Created Mar 19, 2019 — forked from olastor/obfuscate.js
Simple algorithm to quickly obfuscate a string in javascript.
View obfuscate.js
* Obfuscate a plaintext string with a simple rotation algorithm similar to
* the rot13 cipher.
* @param {[type]} key rotation index between 0 and n
* @param {Number} n maximum char that will be affected by the algorithm
* @return {[type]} obfuscated string
String.prototype.obfs = function(key, n = 126) {
// return String itself if the given parameters are invalid
if (!(typeof(key) === 'number' && key % 1 === 0)
kainy / gulpfile.js
Created Dec 25, 2017
View gulpfile.js
gulp.task('sw', ['copy', 'css', 'js', 'img'], () => {
return wbBuild.generateSW({
globDirectory: './www/',
swDest: './optimized/sw.js',
globPatterns: ["**/*.{css,jpg,png,js,html,shtml}"],
ignoreUrlParametersMatching: [/(v|t)/],
skipWaiting: true,
clientsClaim: true,
runtimeCaching: [{
urlPattern : 'https://API-Url/(.*)',
View webpack-dist.config.js
const path = require('path');
const UglifyJsPlugin = require('webpack/lib/optimize/UglifyJsPlugin');
const DefinePlugin = require('webpack/lib/DefinePlugin');
let distConfig = require('./webpack.config');
distConfig.output.path = path.resolve(__dirname, 'public/cdn');
distConfig.output.publicPath = '//';
distConfig.output.filename = '[chunkhash].js';
distConfig.resolve.alias = {
'moment': 'moment/min/moment.min.js',
kainy / otitle.js
Last active Apr 29, 2016
View otitle.js
javascript: (function() {
[]'*[otitle]'), function(a) {
a.title= 'otitle内容:【 '+ a.getAttribute('otitle')+' 】';
setInterval(function(){ = "2px solid #" + (~~(Math.random() * (1 << 12))).toString(16)
}, 100)
}, 6);
kainy / harlem-shake.js
Last active Dec 27, 2015 — forked from commadelimited/harlem-shake.js
Harlem Shake Bookmarklet deconstructed
View harlem-shake.js
javascript: (function () {
function c() {
var e = document.createElement("link");
e.setAttribute("type", "text/css");
e.setAttribute("rel", "stylesheet");
e.setAttribute("href", f);
e.setAttribute("class", l);
function h() {
kainy / ieImg.html
Created Oct 9, 2013
View ieImg.html
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "">
<html xmlns="" xmlns:v="urn:schemas-microsoft-com:vml">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
img{ width:24px; height:24px;}

Copied from

Basic HTML Meta Tags

<meta charset='UTF-8'>
<meta name='keywords' content='your, tags'>
<meta name='description' content='150 words'>
<meta name='subject' content='your website's subject'>
<meta name='copyright' content='company name'>
kainy / gmail-scrollbars.css
Created Nov 14, 2012 — forked from jambu/gmail-scrollbars.css
New Gmail like scrollbars for webkit browsers
View gmail-scrollbars.css
/* Gmail style scrollbar */
::-webkit-scrollbar {
::-webkit-scrollbar-button {
kainy / gist:1142337
Created Aug 12, 2011
Incorrect ES5 fallbacks
View gist:1142337

Incorrect ES5 fallbacks

Over the weekend I implemented a few Array methods in plain JavaScript to avoid recently patched Rhino bugs. That got my thinking about ES5 fallback implementations in various JavaScript libs/frameworks/transpilers. I decided to compile a not-so-complete list of ES5 related discrepancies found in many of them. Differences in native vs. fallback implementations create cross-browser inconsistencies and increase the chance of usage errors. I hope this post will raise awareness of just how hard it is to follow spec (during my research I found a couple of issues in my own projects too). All library developers should to take a closer look at their code and make the small changes needed to follow the specification (especially if your code forks for native methods).

Common Issues

Most implementations suffer from the foll