Instantly share code, notes, and snippets.

View oneliner.js
var oneLiner = (script, {
splitter = /( +|\n+|\t+|\/|'|")/g,
varDeclaration = /^(var|const|let)$/,
testRegex = '/',
testString = /'|"/,
filterer = /[ \n\t]+/
} = {}, prev = '', insideRegex = false, insideString = false) =>
script
.split(splitter)
.map((_) =>
View mapLimit.js
const split = (arr = [], n, ...arrs) => arr.length ? split(arr.slice(n), n, ...arrs, arr.slice(0, n)) : arrs
const splitIn = (arr = [], n) => split(arr, Math.ceil(arr.length / n))
const flat = (arr) => arr.reduce((a, b) => a.concat(b), [])
const mapParallel = (prom) => (arr) => Promise.all(arr.map(prom))
const mapSeries = (arr, prom, prevProm = Promise.resolve()) =>
Promise.all(arr.map(val => (prevProm = prevProm.then(() => prom(val)))))
const allLimit = (arr, limit) => ({ then: (prom) => mapSeries(split(arr, limit), mapParallel(prom)).then(flat) })
View gist:8510daab444f1baaa00a5658b7f0657a
Verifying that "anmo26.id" is my Blockstack ID. https://onename.com/anmo26
View .gitconfig
[alias]
co = checkout
cob = checkout -b
ll = branch
cm = !git add -A && git commit -m
theirs = checkout --theirs
ours = checkout --ours
for-p2c = "!f() { cmd=\"$1\"; msg=\"${2-continue}\"; eval $cmd; git submodule foreach --recursive \"eval $cmd || echo $msg\"; }; f"
View jsonp.js
window.jsonpCbs = { };
var jsonp = function( o ) {
var key = 'cb' + Math.floor( Math.random( ) * 100000 );
var sep = o.uri.indexOf( '?' ) < 0 ? '?' : '&';
var scriptEl = document.createElement( 'script' );
scriptEl.setAttribute( 'type' , 'text/javascript' );
scriptEl.setAttribute( 'src' , [ o.uri , sep , o.jsonp || 'jsonp' , '=jsonpCbs.' , key ].join( '' ) );
View example.sh
#!/bin/bash
#First create a repo
mkdir A && cd A && git init && touch a.dev && touch a.prod && git add -A && git commit -m 'init A' && cd ../
#Lets create another repo that will use A as submodule with sparse-checkout
mkdir B && cd B && git init && touch b && git add -A && git commit -m 'init B'
#Now we will clone A as submodule of B and will say that file/dir we only want to use in B
git submodule add ../A/ A && cd A && git config core.sparsecheckout true && echo a.prod >> ../.git/modules/A/info/sparse-checkout && git read-tree -mu HEAD && cd ../ && git add -A && git commit -m 'add A as submodule/sparse-checkout' && cd ../
View 000-default.conf
<VirtualHost *:80>
# The ServerName directive sets the request scheme, hostname and port that
# the server uses to identify itself. This is used when creating
# redirection URLs. In the context of virtual hosts, the ServerName
# specifies what hostname must appear in the request's Host: header to
# match this virtual host. For the default virtual host (this file) this
# value is not decisive as it is used as a last resort host regardless.
# However, you must set it for any further virtual host explicitly.
#ServerName www.example.com
View index.php
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<title>test pushState (with compatibility)</title>
<meta name="og:description" content=<?php echo '"este é o pedido: '. urldecode( $_SERVER[ 'REQUEST_URI' ] ) .'"'; ?>/>
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0">
<meta name="HandheldFriendly" content="True">
<meta name="MobileOptimized" content="320">
View index.php
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<title>test pushState</title>
<meta name="og:description" content=<?php echo '"este é o pedido: '. urldecode( $_SERVER[ 'REQUEST_URI' ] ) .'"'; ?>/>
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0">
<meta name="HandheldFriendly" content="True">
<meta name="MobileOptimized" content="320">
View index.php
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<title>test Hash</title>
<meta name="og:description" content=<?php echo '"este é o pedido: '. urldecode( $_SERVER[ 'REQUEST_URI' ] ) .'"'; ?>/>
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0">
<meta name="HandheldFriendly" content="True">
<meta name="MobileOptimized" content="320">