Skip to content

Instantly share code, notes, and snippets.

View naiteluo's full-sized avatar
:electron:

mob naiteluo

:electron:
  • School of Software, Sun Yat-sen University
  • Guangzhou, China
View GitHub Profile
@cvan
cvan / webgl-detect-gpu.js
Last active September 5, 2024 07:22
use JavaScript to detect GPU used from within your browser
var canvas = document.createElement('canvas');
var gl;
var debugInfo;
var vendor;
var renderer;
try {
gl = canvas.getContext('webgl') || canvas.getContext('experimental-webgl');
} catch (e) {
}
@naiteluo
naiteluo / DOM动画操作.js
Created August 31, 2012 06:45
JavaScript snippets
/**
* DOM动画方法扩展
* 使用方法:
* document.getElementsByTagName('div')[0].hide(200);
* document.getElementsByTagName('div')[0].show(500);
* document.getElementsByTagName('div')[0].animate(300, 300, 500);
*/
(function (d) {
@RandomEtc
RandomEtc / escaped-json.js
Created May 11, 2012 05:18
Extra escapey JSON encoding for node.js
// preserve Twitter's style of JSON string encoding...
// escape higher value unicode (lowercase hex)
// escape < and > (uppercase hex)
// escape / in strings (\/)
// hugs! https://gist.github.com/1306986
// http://stackoverflow.com/questions/4901133/json-and-escaping-characters
function escapedStringify(s, emit_unicode) {
var json = JSON.stringify(s);
return emit_unicode ? json : json.replace(/\//g,
function(c) {
@caseypugh
caseypugh / gifplayer.as
Created September 23, 2011 18:26
GIFPlayer - How to resize an animated GIF
// See http://www.bytearray.org/?p=95
// Insert into GIFPlayer.as
import flash.geom.Rectangle;
public function resize(w:Number, h:Number):void
{
for (var i = 0; i < aFrames.length; i++) {
aFrames[i].resize(w, h);
}
}