Skip to content

Instantly share code, notes, and snippets.

View mariusbolik's full-sized avatar
🏠
Working from home

Marius Bolik mariusbolik

🏠
Working from home
View GitHub Profile
@t3dotgg
t3dotgg / try-catch.ts
Last active April 18, 2025 10:47
Theo's preferred way of handling try/catch in TypeScript
// Types for the result object with discriminated union
type Success<T> = {
data: T;
error: null;
};
type Failure<E> = {
data: null;
error: E;
};
@mehd-io
mehd-io / convert_file.sh
Created March 11, 2024 10:53
Convert csv<->parquet
#!/bin/bash
# A simple script for converting files between CSV and Parquet formats using DuckDB. Requires DuckDB installation.
convert_file() {
local input_file="$1"
local output_extension="$2"
# Extracting the filename without extension
local base_name=$(basename -- "$input_file")
local name="${base_name%.*}"
@perkinsjr
perkinsjr / middleware.ts
Last active August 7, 2024 11:04
Using Clerk with Upstash for Middleware rate limiting and API Protection
import { getAuth, withClerkMiddleware } from "@clerk/nextjs/server";
import { NextResponse, NextFetchEvent } from "next/server";
import type { NextRequest } from "next/server";
import { Ratelimit } from "@upstash/ratelimit";
import { Redis } from "@upstash/redis";
// Add public paths for Clerk to handle.
const publicPaths = ["/", "/sign-in*", "/sign-up*", "/api/blocked"];
// set your rate limit.
@Supamiu
Supamiu / apollo.interceptor.ts
Created December 9, 2019 13:06
Example interceptor for apollo-angular
import { Injectable } from '@angular/core';
import { HttpHandler, HttpInterceptor, HttpRequest } from '@angular/common/http';
import { filter, switchMap } from 'rxjs/operators';
@Injectable()
export class ApolloInterceptor implements HttpInterceptor {
constructor(private myAuthService: AuthService) {
}
@mayneyao
mayneyao / notion2blog.js
Last active April 6, 2025 01:54
Notion.so > Personal Blog | custom domain + disqus comment
const MY_DOMAIN = "agodrich.com"
const START_PAGE = "https://www.notion.so/gatsby-starter-notion-2c5e3d685aa341088d4cd8daca52fcc2"
const DISQUS_SHORTNAME = "agodrich"
addEventListener('fetch', event => {
event.respondWith(fetchAndApply(event.request))
})
const corsHeaders = {
"Access-Control-Allow-Origin": "*",
@santiq
santiq / config.yml
Created March 5, 2019 06:33
Automate generation Ionic App APK with CircleCI.
version: 2
jobs:
build:
docker:
- image: circleci/android:api-28-node
working_directory: ~/repo
environment:
JVM_OPTS: -Xmx3200m
steps:
- checkout
@qntmpkts
qntmpkts / m3u8-to-youtube-live.md
Last active January 2, 2025 12:48
Restream m3u8 stream with ffmpeg to youtube live

Setup YouTube Live Event

Head on over to your YouTube live Events page (https://www.youtube.com/my_live_events).

Create a new live event that is unlisted (or private) and of Custom type.

Under Basic ingestion choose 1500 Kbps - 4000 kbps (720p).

Check the Enable 60fps box.

@perguth
perguth / .htaccess
Last active October 7, 2024 10:34
Apache reverse proxy `.htaccess` file eg. for NodeJS. @Uberspace
SetEnvIf Request_URI "^(.*)" PORT=65300
RewriteEngine On
RewriteBase /
# CORS
Header add Access-Control-Allow-Origin "*"
# HTTPS
RewriteCond %{HTTPS} !=on
@jonalvarezz
jonalvarezz / Nginxg frontend proxy for Ghost
Created January 27, 2014 05:40
Nginx as frontend proxy for Ghost
server {
server_name www.sitedomain.com;
rewrite ^ http://sitedomain.com$request_uri? permanent;
}
server {
listen 0.0.0.0:80;
server_name sitedomain.com;
access_log /var/log/nginx/sitedomain.log;