Skip to content

Instantly share code, notes, and snippets.

View kiinlam's full-sized avatar
:octocat:
hard working

kiinlam kiinlam

:octocat:
hard working
View GitHub Profile
@kiinlam
kiinlam / dp_combine_yy.js
Created July 7, 2014 06:59
dp组合算法
/*
* @ref: http://lifesinger.googlecode.com/svn/trunk/lab/2009/combine-test.html
* dp组合算法
*/
function dp_combine_yy(a, m) {
var t = [[]], r = [];
for (var i = 0, n = a.length; i < n; i++) {
for (var j = 0, k = t.length; j < k; j++) {
var s = t[j].concat([a[i]]);
s.length < m ? t.push(s) : r.push(s);
@kiinlam
kiinlam / resourceTiming.js
Created July 23, 2014 07:21
window.performance
// window.performance
function resourceTiming()
{
var resourceList = window.performance.getEntriesByType("resource");
for (i = 0; i < resourceList.length; i++)
{
if (resourceList[i].initiatorType == "img")
{
alert("End to end resource fetch: "+ (resourceList[i].responseEnd - resourceList[i].startTime));
}
@kiinlam
kiinlam / css-content-triangle.css
Created August 1, 2014 08:26
模拟三角的一种方案
/* content 中使用特殊字符时需要先用escape转unicode再使用 */
.elem:after {
content: '\2662';
}
@kiinlam
kiinlam / chrome-extensions-app-Manifest.js
Created September 24, 2014 10:12
chrome extensions/app Manifest
// chrome extensions/app Manifest
// extensions: https://developer.chrome.com/extensions/manifest
// app: https://developer.chrome.com/apps/manifest
{
"app": {
"background": {
"scripts": ["background.js"]
}
},
@kiinlam
kiinlam / chrome-extensions-apps-manifest-template.json
Last active August 29, 2015 14:07
chrome extensions/apps manifest.json template
// 谷歌扩展/应用的manifest.json模板
// 扩展——https://developer.chrome.com/extensions, https://developer.chrome.com/extensions/api_index
// 应用——https://developer.chrome.com/apps, https://developer.chrome.com/apps/api_index
// APIs: http://www.ituring.com.cn/article/75729
{
"app": { // 谷歌应用配置
"background": { // 定义应用后台脚本: http://www.ituring.com.cn/article/74020
"scripts": ["background.js"] // 应用后台脚本,可以创建应用窗口: http://www.ituring.com.cn/article/74058
}
},
@kiinlam
kiinlam / AnimationFrameFix.js
Created November 21, 2014 05:58
make sure requestAnimationFrame and cancelAnimationFrame are defined
// make sure requestAnimationFrame and cancelAnimationFrame are defined
// polyfill for browsers without native support
// by Opera engineer Erik Möller
var lastTime = 0;
var vendors = ['webkit', 'moz', 'ms', 'o'];
for(var x = 0; x < vendors.length && !window.requestAnimationFrame; ++x) {
window.requestAnimationFrame = window[vendors[x]+'RequestAnimationFrame'];
window.cancelAnimationFrame =
window[vendors[x]+'CancelAnimationFrame'] || window[vendors[x]+'CancelRequestAnimationFrame'];
}
@kiinlam
kiinlam / css_resources.md
Last active August 29, 2015 14:10 — forked from jookyboi/css_resources.md
CSS libraries and guides to bring some order to the chaos.

Libraries

  • 960 Grid System - An effort to streamline web development workflow by providing commonly used dimensions, based on a width of 960 pixels. There are two variants: 12 and 16 columns, which can be used separately or in tandem.
  • Compass - Open source CSS Authoring Framework.
  • Bootstrap - Sleek, intuitive, and powerful mobile first front-end framework for faster and easier web development.
  • Font Awesome - The iconic font designed for Bootstrap.
  • Zurb Foundation - Framework for writing responsive web sites.
  • SASS - CSS extension language which allows variables, mixins and rules nesting.
  • Skeleton - Boilerplate for responsive, mobile-friendly development.

Guides

@kiinlam
kiinlam / frame-killer.js
Created November 25, 2014 04:01
防止网页被嵌入框架的代码
/*
* 作者: 阮一峰 http://www.ruanyifeng.com/
* http://www.ruanyifeng.com/blog/2010/08/anti-frameset_javascript_codes_continued.html
*/
try{
  top.location.hostname;
  if (top.location.hostname != window.location.hostname) {
    top.location.href =window.location.href;
  }
}
@kiinlam
kiinlam / stop-it.css
Last active August 29, 2015 14:11
阻止一切能阻止的
* {
-webkit-touch-callout: none;
-ms-user-select: none;
-webkit-user-select: none;
-moz-user-select: none;
user-select:none;
-webkit-tap-highlight-color: rgba(0,0,0,0);
}
::-webkit-scrollbar {
width: 0
@kiinlam
kiinlam / auto-font-size
Created December 11, 2014 08:56
根据屏幕宽度调整字体大小
@media screen and (min-width: 480px) {
html {
font-size:15.00px
}
}
@media screen and (max-width: 480px) {
html {
font-size:15.00px
}