This file contains 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
module io.xperiments.utils.serialize | |
{ | |
/** | |
* The mini | |
*/ | |
export interface ISerializableObject | |
{ | |
"@serializable":string; | |
} | |
export interface ISerializable extends ISerializableObject |
This file contains 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
/** | |
* $di.ts | |
* http://www.xperiments.io/posts/typescript-angularjs-best-practices/ | |
* xperiments on 15/07/14. | |
*/ | |
module $di | |
{ | |
/* service */ | |
export class $ng | |
{ |
This file contains 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
/** | |
* SVG Fixer | |
* | |
* Fixes references to inline SVG elements when the <base> tag is in use. | |
* Firefox won't display SVG icons referenced with | |
* `<svg><use xlink:href="#id-of-icon-def"></use></svg>` when the <base> tag is on the page. | |
* | |
* More info: | |
* - http://stackoverflow.com/a/18265336/796152 | |
* - http://www.w3.org/TR/SVG/linking.html |
This file contains 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
// Original: https://gist.github.com/leonderijke/c5cf7c5b2e424c0061d2 | |
(function(document, window) { | |
"use strict"; | |
document.addEventListener("DOMContentLoaded", function() { | |
var baseUrl = window.location.href | |
.replace(window.location.hash, ""); | |
[].slice.call(document.querySelectorAll("use[*|href]")) |
This file contains 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
http://stackoverflow.com/questions/13407036/how-does-typescript-interfaces-with-construct-signatures-work | |
Construct signatures in interfaces are not implementable in classes; they're only for defining existing JS APIs that define a 'new'-able function. Here's an example involving interfaces new signatures that does work: | |
interface ComesFromString { | |
name: string; | |
} | |
interface StringConstructable { | |
new(n: string): ComesFromString; |
This file contains 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
The "trick" is to binary AND a value with 1. | |
Any odd number must have the first bit set to 1. | |
So | |
var foo = 7; | |
if( foo & 1 ) { // true } | |
Using a bitwise AND has a better performance in almost all platforms / browsers. |
This file contains 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
function getBinary(file){ | |
var xhr = new XMLHttpRequest(); | |
xhr.open("GET", file, false); | |
xhr.overrideMimeType("text/plain; charset=x-user-defined"); | |
xhr.send(null); | |
return xhr.responseText; | |
} | |
function base64Encode(str) { | |
var CHARS = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; |
This file contains 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
http://stackoverflow.com/questions/7370943/retrieving-binary-file-content-using-javascript-base64-encode-it-and-reverse-de | |
https://gist.github.com/jonleighton/958841 | |
https://github.com/danguer/blog-examples/blob/master/js/base64-binary.js |
This file contains 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
/* | |
Copyright (c) 2011, Daniel Guerrero | |
All rights reserved. | |
Redistribution and use in source and binary forms, with or without | |
modification, are permitted provided that the following conditions are met: | |
* Redistributions of source code must retain the above copyright | |
notice, this list of conditions and the following disclaimer. | |
* Redistributions in binary form must reproduce the above copyright | |
notice, this list of conditions and the following disclaimer in the |
This file contains 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
module x | |
{ | |
export class Singleton | |
{ | |
private static _instance : Singleton; | |
constructor( singletonEnforcer:()=>void ) | |
{ | |
if( singletonEnforcer !== SingletonEnforcer ) | |
{ | |
throw new Error("Error: Instantiation failed: Use Singleton.getInstance() instead of new."); |
OlderNewer