Skip to content

Instantly share code, notes, and snippets.

View jakubriedl's full-sized avatar

Jakub Riedl jakubriedl

View GitHub Profile
@jakubriedl
jakubriedl / 1asyncawait.js
Last active March 30, 2022 02:45 — forked from phuctm97/1asyncawait.js
Use Go Channels as Promises and Async/Await
// Javascript.
const one = async () => {
// Simulate a workload.
sleep(Math.floor(Math.random() * Math.floor(2000)))
return 1
}
const two = async () => {
// Simulate a workload.
@jakubriedl
jakubriedl / batchFetchExchange.ts
Last active June 10, 2023 04:13
URQL batchFetchExchange
import DataLoader from 'dataloader'
import { Exchange, Operation } from 'urql'
import { pipe, map } from 'wonka'
interface BatchRequest {
url: string
options?: RequestInit
}
const batchFetch = (
@jakubriedl
jakubriedl / npm-install-force.sh
Created February 4, 2019 06:20
Force install npm outdated dependencies
npm outdated | awk '{if (NR!=1) {print $1 "@latest"}}' | xargs npm i
@jakubriedl
jakubriedl / config.js
Created March 25, 2018 23:38
Apollo cache nesting patch
import {patchApolloHints} from './patchApollo'
const apolloConfig = {
formatResponse: (response, options) => {
patchApolloHints(response)
// and some more stuff
},
cacheControl: true
}
@jakubriedl
jakubriedl / jwtToken.js
Last active September 29, 2017 11:20
JWT oidc tokens
// Simplified version how we inject JWT AccessToken into panva/oidc-provider
const provider = new Provider(...)
function getTokenData () {
const authorization = _.get(this, 'claims._authorization', {})
return {
...authorization,
...(_.omit(this, ['claims']))
}
@jakubriedl
jakubriedl / script.sh
Last active October 7, 2017 01:36
Git lines per author
# Authors
git ls-files | grep "yarn.lock" -v | grep "package-lock.json" -v | while read f; do git blame --line-porcelain $f | grep '^author '; done | sort -f | uniq -ic | sort -n
# Size of repository
git ls-files | grep "yarn.lock" -v | grep "package-lock.json" -v | while read f; do git blame --line-porcelain $f | grep '^author '; done | wc -l
@jakubriedl
jakubriedl / nginx-server
Created March 4, 2016 15:50
Nginx reverse proxy conf
location / {
proxy_set_header Host arrivacz-custom.bileto.com;
proxy_ssl_verify off;
proxy_ssl_session_reuse off;
proxy_ssl_server_name on;
proxy_pass https://arrivacz-custom.bileto.com;
# try_files $uri $uri/ =404;
@jakubriedl
jakubriedl / file.sh
Created August 31, 2015 09:14
show stats of all running containers
docker ps | awk '{print $1}' | sed -n -e '/[^CONTAINER]/p' | xargs docker stats
@jakubriedl
jakubriedl / sql.md
Last active August 29, 2015 14:17
Composite Types in Postgres

Price

Create custom type

CREATE TYPE price AS ("amount" float, "currency" char(3));
CREATE TYPE vat AS ("base" float, "amount" float, "rate" smallint);

Use the type in table column

@jakubriedl
jakubriedl / flow.md
Last active August 29, 2015 14:14
Concept of new development and deploy flow

Concept of development and deploy flow

  • based on github flow
  • promotes devOps
  • covers all parts of Deming Cycle
  • 4 eyes rule - every task result is seen by at least 4 eyes before deployment

Benefits of this flow

  • smaller releases