Skip to content

Instantly share code, notes, and snippets.

View codepunkt's full-sized avatar

Christoph Werner codepunkt

View GitHub Profile
@codepunkt
codepunkt / index.ts
Created January 2, 2024 22:54
Async Iterate over Node Readable stream
async function streamToString(stream: Readable) {
const chunks: Buffer[] = [];
for await (const chunk of stream) {
chunks.push(Buffer.from(chunk));
}
return Buffer.concat(chunks).toString('utf-8');
}
@codepunkt
codepunkt / script.sh
Created December 1, 2023 07:37
Check available platforms for docker image:tag
# to be pasted into .bashrc or .zshrc
docker_image_platform() {
if [ -z "$1" ]; then
echo "Error: Please provide a Docker image name with version."
return 1
fi
local image="$1"
local version=$(docker --version | awk '{print $3}' | tr -d ',')
@codepunkt
codepunkt / createDualUseDestructurable.ts
Created January 17, 2023 20:44
Dual use destructurable
/**
* Creates a return value that is destructurable as both an object and an array.
*
* Usage example:
*
* ```ts
* const obj = createDualUseDestructurable({ foo, bar } as const, [ foo, bar ] as const)
* let { foo, bar } = obj
* let [ foo, bar ] = obj
* ```
@codepunkt
codepunkt / wilson-manifest.json
Created July 2, 2021 07:10
Wilson asset manifest
{
"index.html": {
"file": "assets/index.b5da49da.js",
"src": "index.html",
"isEntry": true,
"imports": [
"_vendor.616da2c3.js"
],
"dynamicImports": [
"@wilson/page-source/0/page/0",
@codepunkt
codepunkt / index.js
Created March 12, 2020 09:28
adblock banner delete - work in progress
document.querySelectorAll('*').forEach(el => {
const cs = getComputedStyle(el)
//const zIndex = +cs.zIndex
//const aboveThreshold = zIndex > 100000
if (cs.position === 'fixed') {
console.log(el)
el.style.cssText += ';position:static !important;'
}
if (cs.overflow === 'hidden') {
el.style.cssText += ';overflow:auto !important;'
@codepunkt
codepunkt / SomeProject.csproj
Created September 22, 2017 09:42
Zip file in msbuild build event
<Target Name="Build">
<ZipDir
ZipFileName="MyZipFileName.zip"
DirectoryName="MyDirectory"
/>
</Target>
<UsingTask TaskName="ZipDir" TaskFactory="CodeTaskFactory" AssemblyFile="$(MSBuildToolsPath)\Microsoft.Build.Tasks.v12.0.dll">
<ParameterGroup>
<ZipFileName ParameterType="System.String" Required="true" />
@codepunkt
codepunkt / .hyper.js
Last active July 17, 2017 20:13
hyper config (windows)
module.exports = {
config: {
fontSize: 14,
fontFamily:
'"Fira Code", Menlo, "DejaVu Sans Mono", Consolas, "Lucida Console", monospace',
cursorColor: 'rgba(255,255,255,0.8)',
cursorShape: 'BEAM',
foregroundColor: '#fff',
backgroundColor: '#000',
borderColor: '#666',
@codepunkt
codepunkt / config.json
Last active October 18, 2022 16:04
Host react app built with webpack in non-root directory
{
"basePath": "/"
}
@codepunkt
codepunkt / react-motion-preset-keyframes.styl
Last active January 21, 2017 00:35
react-motion preset keyframe generator in stylus
sqrt(x)
if x == 0
result = 0
else
result = 4
for i in (0..10)
result = ((result + (x / result)) / 2)
spring-noWobble(t)
return 2.71828 ** (-13 * t) * (2.71828 ** (13 * t) - 13 * sin(t) - cos(t))
@codepunkt
codepunkt / kill_port.sh
Last active June 7, 2016 11:22
Kill process running on a port
#!/bin/bash
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[0;33m'
NC='\033[0m'
if [ $# -eq 0 ] ; then
echo -e "${RED}Error: No port given${NC}"
exit 1
fi