Skip to content

Instantly share code, notes, and snippets.

View SiZapPaaiGwat's full-sized avatar

饭特稀 SiZapPaaiGwat

View GitHub Profile
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8">
<title>One Graph</title>
<script type="text/javascript" src="http://mbostock.github.com/d3/d3.v2.js"></script>
<script type="text/javascript" src="simple-graph.js"></script>
<style type="text/css">
body { font: 13px sans-serif; }
rect { fill: #fff; }
<?xml version="1.0" encoding="UTF-8"?>
<CORSConfiguration xmlns="http://s3.amazonaws.com/doc/2006-03-01/">
<CORSRule>
<AllowedOrigin>*</AllowedOrigin>
<AllowedMethod>GET</AllowedMethod>
<AllowedMethod>POST</AllowedMethod>
<AllowedMethod>PUT</AllowedMethod>
<MaxAgeSeconds>3000</MaxAgeSeconds>
<AllowedHeader>*</AllowedHeader>
</CORSRule>
// See comments below.
// This code sample and justification brought to you by
// Isaac Z. Schlueter, aka isaacs
// standard style
var a = "ape",
b = "bat",
c = "cat",
d = "dog",
function a(x,y){
y = function() { x = 2; };
return function(){
var x = 3;
y();
console.log(x);
}.apply(this, arguments);
}
a();
// Cross-browser but not absolutely strong.
function isArguments( obj ) {
return typeof obj === "object" && ( "callee" in obj ) && typeof obj.length === "number";
}
// Ideally strong, but broken on Opera...
var isArguments = (function( undefined ) {
@SiZapPaaiGwat
SiZapPaaiGwat / interval.js
Last active August 29, 2015 14:19 — forked from manast/interval.js
add ES6 support
export default function timer(fn, duration) {
this.baseline = 0
this.run = function(exec){
if(!this.baseline){
this.baseline = Date.now()
}
exec && fn()

IMPORTANT! Remember to check out the wiki page at https://github.com/bebraw/jswiki/wiki/Game-Engines for the most up to date version. There's also a "notes" column in the table but it simply does not fit there... Check out the raw version to see it.

This table contains primarily HTML5 based game engines and frameworks. You might also want to check out the [[Feature Matrix|Game-Engine-Feature-Matrix]], [[Game Resources]] and [[Scene Graphs]].

Name Size (KB) License Type Unit Tests Docs Repository Notes
Akihabara 453 GPL2, MIT Classic Repro no API github Intended for making classic arcade-style games in JS+HTML5
AllBinary Platform Platform Dependent AllBinary 2D/2.5D/3D n
@SiZapPaaiGwat
SiZapPaaiGwat / base64encode.js
Created September 7, 2015 07:43
simple base64 encode relied on window.btoa
function base64Encode( str ) {
str = str.replace( /[^\x00-\x7F]/g, function ( char ) {
var hex = char.charCodeAt( 0 ).toString( 16 );
while ( hex.length < 4 ) hex = '0' + hex;
return '\\u' + hex;
});
return btoa( str );
}
@SiZapPaaiGwat
SiZapPaaiGwat / ajax-button.html
Created September 7, 2015 08:05
single file ractive component
<button on-click="{{loading ? '' : 'request'}}" type="{{type || 'button'}}"
class="{{className}}" {{#if disable}} disable {{/if}}>
{{#if loading}}
{{loadingText}}
{{else}}
{{text}}
{{/if}}
</button>
<script>

@kangax's ES6 quiz, explained

@kangax created a new interesting quiz, this time devoted to ES6 (aka ES2015). I found this quiz very interesting and quite hard (made myself 3 mistakes on first pass).

Here we go with the explanations:

Question 1:
(function(x, f = () =&gt; x) {