Skip to content

Instantly share code, notes, and snippets.

@inian
inian / split.sh
Created June 27, 2019 09:18
Convert image to Y, Cb, Cr components
convert image.png -colorspace YUV -sampling-factor 4:2:2 -separate \
\( -clone 0 \) \
\( -clone 1 -fill black -colorize 100% \) \
\( -clone 1 -negate \) \
\( -clone 1 \) \
image_b_temp.png
convert image_b_temp-4.png image_b_temp-5.png image_b_temp-6.png -channel RGB -combine image_b.png
convert image.png -colorspace YUV -sampling-factor 4:2:2 -separate \
@inian
inian / hapi.js
Last active August 30, 2019 04:15
Node Frameworks using http2
var fs = require('fs');
var Hapi = require('hapi');
var http2 = require('http2');
var options = {
key: fs.readFileSync('./selfsigned.key'),
cert: fs.readFileSync('./selfsigned.crt'),
};
var server = new Hapi.Server();
@inian
inian / test.ts
Last active November 15, 2022 14:02
test
import { Application } from "https://deno.land/x/oak@v9.0.0/mod.ts";
const app = new Application();
app.use((ctx) => {
ctx.response.body = "Hello World! ini1";
console.log(ctx);
});
await app.listen({ port: 8000 });
@inian
inian / index.js
Created January 19, 2022 06:18
Move Supabase storage objects between projects
const { createClient } = require("@supabase/supabase-js");
const OLD_PROJECT_URL = "https://xxx.supabase.co";
const OLD_PROJECT_SERVICE_KEY = "old-project-service-key-xxx";
const NEW_PROJECT_URL = "https://yyy.supabase.co";
const NEW_PROJECT_SERVICE_KEY = "new-project-service-key-yyy";
(async () => {
const oldSupabaseRestClient = createClient(
@inian
inian / rpc_pokemon.sql
Created January 16, 2024 05:28
Vercel plv8 bundle
CREATE OR REPLACE FUNCTION public.rpc_pokemon()
RETURNS text
LANGUAGE plv8
STRICT
AS $function$
var __rpc=(()=>{var mo=Object.create;var Ie=Object.defineProperty;var vo=Object.getOwnPropertyDescriptor;var go=Object.getOwnPropertyNames;var So=Object.getPrototypeOf,xo=Object.prototype.hasOwnProperty;var re=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),ko=(e,t)=>{for(var r in t)Ie(e,r,{get:t[r],enumerable:!0})},nr=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let l of go(t))!xo.call(e,l)&&l!==r&&Ie(e,l,{get:()=>t[l],enumerable:!(n=vo(t,l))||n.enumerable});return e};var Me=(e,t,r)=>(r=e!=null?mo(So(e)):{},nr(t||!e||!e.__esModule?Ie(r,"default",{value:e,enumerable:!0}):r,e)),wo=e=>nr(Ie({},"__esModule",{value:!0}),e);var lr=re(or=>{"use strict";(function(e){function t(){}function r(){}var n=String.fromCharCode,l={}.toString,o=l.call(e.SharedArrayBuffer),u=l(),i=e.Uint8Array,s=i||Array,a=i?ArrayBuffer:s,c=a.isView||function(y){return y&&"length"in y},h=l.call(a.prototype);a=r.proto
@inian
inian / brotli-sw.js
Last active February 27, 2024 00:40
Enabling Brotli on CDNs which don't support it yet
// MIT License
// Copyright (c) 2016 Dexecure
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions: