Skip to content

Instantly share code, notes, and snippets.

:octocat:
Q Tiu HiuMiuLiu

Kainy Guo kainy

:octocat:
Q Tiu HiuMiuLiu
Block or report user

Report or block kainy

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@kainy
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
kainy / gulpfile.js
Created Dec 25, 2017
使用workbox生成SW脚本的gulpfile配置。
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 = '//url.cn/';
distConfig.output.filename = '[chunkhash].js';
distConfig.resolve.alias = {
'moment': 'moment/min/moment.min.js',
@kainy
kainy / otitle.js
Last active Apr 29, 2016
显示页面上otitle埋点的元素(webtrends埋点验证)
View otitle.js
javascript: (function() {
[].forEach.call(document.querySelectorAll('*[otitle]'), function(a) {
a.title= 'otitle内容:【 '+ a.getAttribute('otitle')+' 】';
setInterval(function(){
a.style.outline = "2px solid #" + (~~(Math.random() * (1 << 12))).toString(16)
}, 100)
}, 6);
})();
@kainy
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);
document.body.appendChild(e)
}
function h() {
@kainy
kainy / ieImg.html
Created Oct 9, 2013
通过vml解决IE下图片缩小失真(有锯齿)的问题。
View ieImg.html
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:v="urn:schemas-microsoft-com:vml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>解决IE下图片缩小失真(有锯齿)的问题_西山刀客</title>
<style>
img{ width:24px; height:24px;}
.ie7{-ms-interpolation-mode:bicubic;display:none;}
View meta-tags.md

Copied from http://code.lancepollard.com/complete-list-of-html-meta-tags/

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
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 {
height:16px;
overflow:visible;
width:16px
}
::-webkit-scrollbar-button {
height:0;
width:0
}
@kainy
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

You can’t perform that action at this time.