Skip to content

Instantly share code, notes, and snippets.

View lynxerzhang's full-sized avatar
🤒

frankwinter lynxerzhang

🤒
  • geckostudio
  • shanghai
View GitHub Profile
@lynxerzhang
lynxerzhang / gist:741c17ba53796d845a478f5ca576350b
Created January 12, 2021 07:22 — forked from snowman-repos/gist:3825198
JavaScript: Detect Orientation Change on Mobile Devices
// 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)
@lynxerzhang
lynxerzhang / checkAryisEqual.js
Created May 13, 2020 05:52
js check if two arrays are equal or not
//es6
const checkAryisEqual = (aryA, aryB) => JSON.stringify(aryA) == "[" + aryB.toString() + "]";
//es5
function checkAryisEqual(aryA, aryB) {
return JSON.stringify(aryA) === "[" + aryB.toString() + "]";
}
@lynxerzhang
lynxerzhang / JS_LocalStorage.as
Last active August 16, 2019 08:04
calling anonymous js (不需要额外书写js)
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()
{
}
@lynxerzhang
lynxerzhang / consoleUtil.js
Last active June 12, 2017 09:12
console.log and console.warn's Polyfill
//@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);
@lynxerzhang
lynxerzhang / ReactCreatColorPanel.css
Created May 31, 2017 06:02
React.js create a like flash's color plate feature
*{
box-sizing: border-box;
}
.blockBorder{
border: 1px solid #000;
}
@lynxerzhang
lynxerzhang / ByteArray.js
Created May 25, 2017 08:50
encapsulate js ArrayBuffer class and DataView class
//在构造函数中创建了一个DataView对象和一个position变量追踪当前指针指向哪个字节。
class ByteArray extends ArrayBuffer
{
constructor(...args) {
super(...args);
this.dataView = new DataView(this);
this.position = 0;
}
get length(){
@lynxerzhang
lynxerzhang / index.html
Created March 31, 2017 12:45
Simple HTML5 Motion
<canvas id ="canvas" width="300", height="200"></canvas>
//
// StringExt.swift
//
// some useful swift string's extension
//
// Xcode version is 7.3, swift version is 2.2
//
// TODO
//
//
@lynxerzhang
lynxerzhang / ColorRandom.swift
Created December 14, 2015 08:42
Random Color in Swift
//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)