Skip to content

Instantly share code, notes, and snippets.

@Anmo
Anmo / example.sh
Last active April 2, 2024 06:08
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 / App.js
Created July 22, 2020 08:58
Creating one event handler for all input types in React by Akash Thakur
import React, { useState, useCallback } from 'react';
import useForm from './use-form';
import './styles.css';
export default function App() {
const [state, handleChange] = useForm({
userName: '',
age: '',
status: 'beginner',
@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((_) =>
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) })
Verifying that "anmo26.id" is my Blockstack ID. https://onename.com/anmo26
@Anmo
Anmo / .gitconfig
Last active January 4, 2016 09:17
[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"
@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 / 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">