Skip to content

Instantly share code, notes, and snippets.

@Anmo
Anmo / index.php
Created November 19, 2013 14:14
Ink.Util.Router example (hash mode)
<!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">
@Anmo
Anmo / index.php
Created November 19, 2013 14:14
Ink.Util.Router example (pushState mode)
<!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">
@Anmo
Anmo / index.php
Created November 19, 2013 14:15
Ink.Util.Router example (pushState mode with compatibility)
<!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">
@Anmo
Anmo / 000-default.conf
Created November 19, 2013 14:17
Ink.Util.Router example (RewriteRules)
<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
@Anmo
Anmo / example.sh
Last active May 30, 2024 13:04
Use of submodules and sparse-checkout
#!/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 ../
@Anmo
Anmo / jsonp.js
Last active August 29, 2015 14:07 — forked from JosePedroDias/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( '' ) );
[alias]
co = checkout
cob = checkout -b
cod = branch -D
st = status
pl = pull
ps = push -u origin
pf = push --force-with-lease
rb = rebase
ri = rebase -i
Verifying that "anmo26.id" is my Blockstack ID. https://onename.com/anmo26
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) })
@Anmo
Anmo / oneliner.js
Last active November 8, 2017 20:00
My summition at OLX websummit challenge
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((_) =>