View down.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
set -e | |
# Zone | |
ZONE=europe-west8-a | |
echo "Destroying cloud Ubuntu Desktop..." | |
gcloud compute instances delete ubuntu-desktop --zone=$ZONE --quiet |
View main.c
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <linux/seq_file.h> | |
KHOOK_EXT(int, loadavg_proc_show, struct seq_file *, void *v); | |
static int khook_loadavg_proc_show(struct seq_file *m, void *v) | |
{ | |
unsigned int random_number; | |
unsigned char rands[sizeof(unsigned int)]; | |
get_random_bytes(rands, sizeof(unsigned int)); | |
random_number = *(unsigned int*)rands; | |
random_number = (random_number % 6) + 14; | |
seq_printf(m, "0.%d 0.16 0.11 1/127 10420\n", random_number); |
View logrus2telegram.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package logrus2telegram | |
import ( | |
"fmt" | |
"time" | |
tgbotapi "github.com/go-telegram-bot-api/telegram-bot-api/v5" | |
"github.com/sirupsen/logrus" | |
"errors" |
View ginlogrus.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package ginlogrus | |
import ( | |
"fmt" | |
"math" | |
"net/http" | |
"os" | |
"time" | |
"github.com/gin-gonic/gin" |
View gormlogrus.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package gormlogrus | |
import ( | |
"context" | |
"errors" | |
"time" | |
"github.com/sirupsen/logrus" | |
"gorm.io/gorm" | |
gormlogger "gorm.io/gorm/logger" |
View gcs_reverse_proxy.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"context" | |
"flag" | |
"io" | |
"log" | |
"net/http" | |
"strconv" | |
"time" |
View validator_interceptor.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var validatorInterceptor = connect.UnaryInterceptorFunc( | |
func(next connect.UnaryFunc) connect.UnaryFunc { | |
return connect.UnaryFunc(func(ctx context.Context, request connect.AnyRequest) (connect.AnyResponse, error) { | |
validator, ok := request.Any().(interface{ ValidateAll() error }) | |
if !ok { | |
// Handle this however you'd like; maybe return an error with | |
// CodeInternal if all your types should support validation? | |
return next(ctx, request) | |
} | |
if err := validator.ValidateAll(); err != nil { |
View ffmpeg-format-to-mimetype.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// INCOMPLETE | |
// This command will give you list of available FFMPEG formats and their default Mime types | |
// ffmpeg -formats -hide_banner | tail -n +5 | cut -c5- | cut -d' ' -f1 | xargs -i{} ffmpeg -hide_banner -h demuxer={} | pcregrep -o2 -o4 -M '(Muxer (\w+) )|(Mime type:( .*).)' | |
// And then parse the output with regex to JSON format in JavaScript for example: | |
// str.match(/(.*)\n (.*)/gm).map(m => `"${m.replace(/\n /, '": "')}"`).join(',\n'); | |
// Combine the output with MDN - Common MIME types | |
// https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/MIME_types/Common_types | |
// And with IANA: |
View useModals.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* Usage: | |
* const { alert, confirm, prompt } = useModals() | |
* alert("Hey!") // awaitable too | |
* if (await confirm("Are you sure?")) ... | |
* const result = await prompt("Enter a URL", "http://") | |
*/ | |
import React, { | |
createContext, |
View promisified-grpc-client.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Client, ServiceError, Metadata, CallOptions, ClientUnaryCall } from '@grpc/grpc-js'; | |
import { Message } from 'google-protobuf'; | |
type OriginalCall<T, U> = (request: T, metadata: Metadata, options: Partial<CallOptions>, callback: (error: ServiceError, res: U) => void) => ClientUnaryCall; | |
type PromisifiedCall<T, U> = ((request: T, metadata?: Metadata, options?: Partial<CallOptions>) => Promise<U>); | |
export type Promisified<C> = { $: C; } & { | |
[prop in Exclude<keyof C, keyof Client>]: (C[prop] extends OriginalCall<infer T, infer U> ? PromisifiedCall<T, U> : never); | |
} |
NewerOlder