Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View kainy's full-sized avatar
Q Tiu HiuMiuLiu

Kainy Guo kainy

Q Tiu HiuMiuLiu
View GitHub Profile
kainy / obfuscate.js
Created March 19, 2019 13:02 — forked from olastor/obfuscate.js
Simple algorithm to quickly obfuscate a string in javascript.
* 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 December 25, 2017 09:16
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/(.*)',
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 April 29, 2016 03:21
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 December 27, 2015 09:14 — forked from commadelimited/harlem-shake.js
Harlem Shake Bookmarklet deconstructed
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 October 9, 2013 08:00
<!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 November 14, 2012 15:43 — forked from jambu/gmail-scrollbars.css
New Gmail like scrollbars for webkit browsers
/* Gmail style scrollbar */
::-webkit-scrollbar {
::-webkit-scrollbar-button {
kainy / gist:1142337
Created August 12, 2011 15:52
Incorrect ES5 fallbacks

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