Skip to content

Instantly share code, notes, and snippets.

Pedro Casaubon xperiments

Block or report user

Report or block xperiments

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View TypescriptSerializer
module io.xperiments.utils.serialize
* The mini
export interface ISerializableObject
export interface ISerializable extends ISerializableObject
xperiments / $di.ts
Created Jul 16, 2014
AngularJS Typescript Static Injector References
View $di.ts
* $di.ts
* xperiments on 15/07/14.
module $di
/* service */
export class $ng
xperiments / svgfixer.js
Created Oct 9, 2015 — forked from leonderijke/svgfixer.js
Fixes references to inline SVG elements when the <base> tag is in use.
View svgfixer.js
* 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:
* -
* -
View svgfixer-clip-paths.js
// Original:
(function(document, window) {
"use strict";
document.addEventListener("DOMContentLoaded", function() {
var baseUrl = window.location.href
.replace(window.location.hash, "");
xperiments / NewableTypes.ts
Created Jun 20, 2013
Typescript Newable Types
View NewableTypes.ts
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;
View BrowserDetection.js
var isOpera = !!window.opera || navigator.userAgent.indexOf(' OPR/') >= 0;
// Opera 8.0+ (UA detection to detect Blink/v8-powered Opera)
var isFirefox = typeof InstallTrigger !== 'undefined'; // Firefox 1.0+
var isSafari ='Constructor') > 0;
// At least Safari 3+: "[object HTMLElementConstructor]"
var isChrome = !! && !isOpera; // Chrome 1+
var isIE = /*@cc_on!@*/false; // At least IE6
View OddNumber.js
The "trick" is to binary AND a value with 1.
Any odd number must have the first bit set to 1.
var foo = 7;
if( foo & 1 ) { // true }
Using a bitwise AND has a better performance in almost all platforms / browsers.
View xhr2base64.js
function getBinary(file){
var xhr = new XMLHttpRequest();"GET", file, false);
xhr.overrideMimeType("text/plain; charset=x-user-defined");
return xhr.responseText;
function base64Encode(str) {
var CHARS = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
xperiments / xhr2base64
Created Jul 10, 2013
XHR => base64 => Binary
View xhr2base64
View base64-binary.js
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
You can’t perform that action at this time.