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 composing-regexps.js
const RE_YEAR = re`(?<year>[0-9]{4})`;
const RE_MONTH = re`(?<month>[0-9]{2})`;
const RE_DAY = re`(?<day>[0-9]{2})`;
const RE_DATE = re`${RE_YEAR}-${RE_MONTH}-${RE_DAY}`;
const matchObj = RE_DATE.exec('1999-12-31');
const year = matchObj.groups.year; // 1999
const month = matchObj.groups.month; // 12
const day =; // 31
dy / saveAs.js
Created Mar 18, 2017
Open data-uri in new window
View saveAs.js
function saveAs(arrayBuffer, fileName, mime) {
window.requestFileSystem = window.requestFileSystem || window.webkitRequestFileSystem;
window.requestFileSystem(window.TEMPORARY, arrayBuffer.byteLength, function(fs) {
fs.root.getFile(fileName, {create: true}, function(fileEntry) {
fileEntry.createWriter(function(writer) {
var dataView = new DataView(arrayBuffer);
var blob = new Blob([dataView], {type: 'font/opentype'});
writer.addEventListener('writeend', function() {
jherax / is-private-mode.js
Last active Feb 22, 2020
Detect if the browser is running in Private mode (Promise based)
View is-private-mode.js
* Lightweight script to detect whether the browser is running in Private mode.
* @returns {Promise<boolean>}
* Live demo:
* @see
* This snippet uses Promises. If you want to run it in old browsers, polyfill it:
* @see
View _hidden-scrollbar.sass
* Hidden scrollbar
width: 0px
background-color: transparent
-webkit-border-radius: 6px
tzmartin /
Last active Feb 26, 2020
Embedded File Viewer: Google Drive, OneDrive

Office Web Apps Viewer

('.ppt' '.pptx' '.doc', '.docx', '.xls', '.xlsx')[OFFICE_FILE_URL]

<iframe src='[OFFICE_FILE_URL]' width='px' height='px' frameborder='0'>

OneDrive Embed Links

gund /
Last active Sep 14, 2017
Concept of Http Interceptor for Angular 2

First, we need to define interfaces with which we will work:

export interface Interceptable<T extends Interceptor<any, any>> {
  addInterceptor(interceptor: T): Interceptable<T>;
  removeInterceptor(interceptor: T): Interceptable<T>;
  clearInterceptors(interceptors?: T[]): Interceptable<T>;

export interface Interceptor<T, D> {
tizmagik / getLastInMap.js
Created Aug 13, 2016
ES6 Last Item in Map()
View getLastInMap.js
// Since ES6 Map()'s' retain their order of insertion, it can sometimes be useful to get the last item or value inserted:
export const getLastItemInMap = map => Array.from(map)[map.size-1]
export const getLastKeyInMap = map => Array.from(map)[map.size-1][0]
export const getLastValueInMap = map => Array.from(map)[map.size-1][1]
// Obviously getLastKey and getLastValue can reuse getLastItem, but for maximum portability I opted for verbosity.
robertpenner / employee_salaries.ts
Last active May 14, 2018
Employee Average Salaries | Victor Savkin's Functional TypeScript
View employee_salaries.ts
class Employee {
constructor(public name: string, public salary: number) {}
class Department {
constructor(public employees: Employee[]) {}
works(employee: Employee): boolean {
bennadel / app.component.ts
Last active Jun 12, 2017
Experimenting With Dynamic Template Rendering In Angular 2 RC 1
View app.component.ts
// Import the core angular services.
import { Component } from "@angular/core";
// Import the application components and services.
import { DynamicRepeaterComponent } from "./dynamic-repeater.component";
selector: "my-app",
directives: [ DynamicRepeaterComponent ],
davidguttman / split-unspaced-text.js
Created Apr 26, 2016
Split text without spaces into list of words
View split-unspaced-text.js
// port of
var _ = require('lodash')
var fs = require('fs')
var tape = require('tape')
var dictStr = fs.readFileSync(__dirname + '/dump/words-by-freq.txt', 'utf8')
var wordsByFreq = dictStr.split('\n')
var maxWord = 0
You can’t perform that action at this time.