Skip to content

Instantly share code, notes, and snippets.

View PatrickHeneise's full-sized avatar
🏡
Working remote

Patrick Heneise PatrickHeneise

🏡
Working remote
View GitHub Profile
@PatrickHeneise
PatrickHeneise / gcp-function-storage-file-stream.js
Created July 29, 2022 16:57
Google Cloud Function to stream a file from multipart/form-data to Google Cloud Storage
/**
* Copyright (c) 2022 Zentered OÛ, patrick@zentered.co
* This code is licensed under the terms of the MIT license
*
* This code demonstrates how to create a Google Cloud Function to receive
* a file sent via `multipart/form-data`. The file is then streamed directly
* to Google Cloud Storage, without using a temporary file.
*
* The function returns any `fields` sent as FormData
*
@PatrickHeneise
PatrickHeneise / parse.js
Created October 12, 2021 12:39
Read a file, skip every second line, write file (when copying code with line numbers)
const fs = require('fs')
const { join } = require('path')
function parse(file) {
const path = join(process.env.PWD, 'test', 'fixtures', file)
const content = fs.readFileSync(path, 'utf8')
const lines = content.split('\n')
let data = ''
let stringified = 'data = '
lines.forEach((line, idx) => {
@PatrickHeneise
PatrickHeneise / add-files-to-git.js
Created October 6, 2021 09:54
Add files to git with Octokit.js
const path = join(__dirname, 'templates', 'issues')
let files = [
'sponsor-request.md',
'suggestion.md',
'talk-feature.md',
'talk-lightning.md',
'talk-request.md'
]
try {
const committedTemplates = await github.rest.repos.getContent({
@PatrickHeneise
PatrickHeneise / perf_hooks.js
Last active September 17, 2020 07:35
stream transform
const { PerformanceObserver, performance } = require('perf_hooks')
const getJSONParse = (data) => {
performance.mark('getJSONParse init')
JSON.parse(data)
performance.mark('getJSONParse end')
performance.measure('getJSONParse', 'getJSONParse init', 'getJSONParse end')
}
@PatrickHeneise
PatrickHeneise / docker-compose.yml
Created August 13, 2020 08:46
docker-compose file for n*xt/node with nginx ssl proxy and path rewrites
version: "3"
services:
nginx:
image: nginx:latest
container_name: universal_nginx
volumes:
- ./nginx/nginx.conf:/etc/nginx/nginx.conf
- ./nginx/mime.types:/etc/nginx/mime.types
- ./certs/:/usr/share/certs/
@PatrickHeneise
PatrickHeneise / nginx.conf
Last active August 26, 2020 14:28
nginx config for nuxt/node in compose, with ssl and path rewrite
events {
worker_connections 1024;
}
http {
upstream frontend {
# run web container on port 5000
server web:5000;
}

Keybase proof

I hereby claim:

  • I am patrickheneise on github.
  • I am patrickheneise (https://keybase.io/patrickheneise) on keybase.
  • I have a public key ASD-jppyGKVHTsRFmbq2ANEDkchabjZMGhafmXNzP9EUiAo

To claim this, I am signing this object:

Verifying my Blockstack ID is secured with the address 14Q9sFUCgWfBmWi5aWGogpX2C7ANEEj38q https://explorer.blockstack.org/address/14Q9sFUCgWfBmWi5aWGogpX2C7ANEEj38q
const a = [{ a: 'a' }, { a: 'b' }]
const b = ['1', '2']
const res = []
a.forEach(str => {
b.forEach(num => {
str.b = num
res.push(str)
})
})
@PatrickHeneise
PatrickHeneise / upgrade.sh
Last active November 21, 2018 08:59
Update all packages in subfolders
#!/bin/bash
parse_git_branch() {
git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/ (\1)/'
}
for i in * ; do
if [ -d "$i" ]; then
cd "$i"
printf '\n\n%s\n' "${PWD##*/}$(parse_git_branch):"