This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def recursive_sort: | |
if type == "object" then | |
to_entries | |
| sort_by(.key) | |
| map( {key: .key, value: (.value | recursive_sort)} ) | |
| from_entries | |
elif type == "array" then | |
map( if type == "object" or type == "array" then . | recursive_sort else . end ) | |
| if length == 0 or (first | type) != "object" then | |
sort |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
git grep --name-only app *.ts | gawk 'system("sed -i \"\" sAappA@yyy/zzzA "$1)' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
for i in {0..255}; do | |
printf "\x1b[38;5;${i}mcolour${i}\x1b[0m\n" | |
done |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Example POST method implementation: | |
async function postData(url = '', data = {}) { | |
// Default options are marked with * | |
const response = await fetch(url, { | |
method: 'POST', // *GET, POST, PUT, DELETE, etc. | |
mode: 'cors', // no-cors, *cors, same-origin | |
cache: 'no-cache', // *default, no-cache, reload, force-cache, only-if-cached | |
credentials: 'same-origin', // include, *same-origin, omit | |
headers: { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fib_(1,[1]). | |
fib_(2,[1,1]). | |
fib_(3, [H|[A|[B|Tail]]]) :- fib_(2, [A|[B|Tail]]), H is A + B. | |
fib_(N, [H|[A|[B|Tail]]]) :- N2 is N - 1, fib_(N2, [A|[B|Tail]]), H is A + B. | |
fib(N, List) :- fib_(N, List0), reverse(List0, List). |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { fromEvent, interval } from 'rxjs'; | |
import { tap, throttle } from 'rxjs/operators'; | |
const clicks = fromEvent(document, 'click'); | |
//const result = clicks.pipe(throttle(ev => interval(1000))); | |
const result = interval(2000).pipe(tap(x => console.log('v:', x)), throttle( i => clicks, {leading: true, trailing: true})); | |
result.subscribe(x => console.log(x)); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { fromEvent, interval } from 'rxjs'; | |
import { throttle } from 'rxjs/operators'; | |
const clicks = fromEvent(document, 'click'); | |
//const result = clicks.pipe(throttle(ev => interval(1000))); | |
const result = interval(2000).pipe(throttle( i => clicks)); | |
result.subscribe(x => console.log(x)); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Control.Monad | |
import System.IO | |
pi_ = g(1,0,1,1,3,3) where | |
g (q,r,t,k,n,l) = | |
if 4*q+r-t < n*t | |
then n : g (10*q, 10*(r-n*t), t, k, div (10*(3*q+r)) t - 10*n, l) | |
else g (q*k, (2*q+r)*l, t*l, k+1, div (q*(7*k+2)+r*l) (t*l), l+2) | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.tpl_install_npm: &npm_install | |
before_script: | |
- node -v && npm -v | |
- npm rebuild node-sass | |
- npm install --unsafe-perm --no-save | |
.build_staging_and_upload: &upload_gui_for_staging | |
image: vmdev/base_node:chrome-alpine | |
stage: staging_build |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Dispatcher extends Rx.Subject{ | |
dispatch(value : any) : void { | |
this.next(value); | |
} | |
} | |
class Store extends Rx.BehaviorSubject{ | |
constructor( | |
private dispatcher, | |
private reducer, |
NewerOlder