A Pen by lynxerzhang on CodePen.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Listen for orientation changes | |
window.addEventListener("orientationchange", function() { | |
// Announce the new orientation number | |
alert(window.orientation); | |
}, false); | |
// Listen for resize changes | |
window.addEventListener("resize", function() { | |
// Get screen size (inner/outerWidth, inner/outerHeight) | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//es6 | |
const checkAryisEqual = (aryA, aryB) => JSON.stringify(aryA) == "[" + aryB.toString() + "]"; | |
//es5 | |
function checkAryisEqual(aryA, aryB) { | |
return JSON.stringify(aryA) === "[" + aryB.toString() + "]"; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package utils | |
{ | |
import flash.external.ExternalInterface; | |
//@see https://code.tutsplus.com/tutorials/quick-tip-how-to-communicate-between-flash-and-javascript--active-3370 | |
public class JS_LocalStorage | |
{ | |
public function JS_LocalStorage() | |
{ | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//@see https://www.paulirish.com/2009/log-a-lightweight-wrapper-for-consolelog/ | |
//inspired from paulirish's console.log function | |
!(function(win, funNameAry, titleAry, max){ | |
max = max || 100; | |
for(var i = 0, funName = ""; i < funNameAry.length, funName = funNameAry[i]; i ++){ | |
win[funName] = (function(i, n){ | |
return function(){ | |
this[n].history = this[n].history || []; | |
this[n].logMax = this[n].logMax || max; | |
this[n].history.push(arguments); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
*{ | |
box-sizing: border-box; | |
} | |
.blockBorder{ | |
border: 1px solid #000; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//在构造函数中创建了一个DataView对象和一个position变量追踪当前指针指向哪个字节。 | |
class ByteArray extends ArrayBuffer | |
{ | |
constructor(...args) { | |
super(...args); | |
this.dataView = new DataView(this); | |
this.position = 0; | |
} | |
get length(){ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<canvas id ="canvas" width="300", height="200"></canvas> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// StringExt.swift | |
// | |
// some useful swift string's extension | |
// | |
// Xcode version is 7.3, swift version is 2.2 | |
// | |
// TODO | |
// | |
// |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Jared Davidson's Random Colorization | |
//run in xcode7.1 and swift2.1 | |
//drand48返回0 - 1的随机Double数值 | |
var red = CGFloat(drand48()) | |
var green = CGFloat(drand48()) | |
var blue = CGFloat(drand48()) | |
var view = UIView(frame: CGRect(x: 0, y: 0, width: 100, height: 100)) | |
//随机色 | |
view.backgroundColor = UIColor(red: red, green: green, blue: blue, alpha: 1.0) |
NewerOlder