Skip to content

Instantly share code, notes, and snippets.

View alfonmga's full-sized avatar
👁️
What you look for is what you find.

Alfon alfonmga

👁️
What you look for is what you find.
View GitHub Profile
@alfonmga
alfonmga / readme.md
Created March 9, 2024 15:10 — forked from bagusnl/readme.md
Setting up Cloudflare R2 as CDN with HTTP frontend also uploads files from GitHub repository to said CDN with Actions

Setting up Cloudflare R2 as CDN

This guide will set up a CDN with URL frontend and sync them up from GitHub Repo with Actions

Things needed:

  • A domain that is tied to Cloudflare (free CF account is probably enough, depends on the load to your CDN)

Steps:

  1. Make a Cloudflare R2 bucket > Take a note of its bucket name.
@alfonmga
alfonmga / bitcoin-rake-method.go
Last active October 25, 2023 13:11
A Sane and Simple bitcoin Savings plan <https://bitcointalk.org/index.php?topic=345065.0>
package main
import (
"fmt"
"log"
"os"
"strconv"
krakenapi "github.com/beldur/kraken-go-api-client"
"github.com/jedib0t/go-pretty/v6/table"
jA0ECQMCkewmFwhXEF7a0q8Brk+gBttvaSpDiTpk/triurvh5xipY5ydUGM7ayiY
pdzvgF4nTfBPAQRhG+R5IY0kVBLJ/ke0ZwwbPVPS3NABvz6wLOblc70LcTJTrIzQ
3QcSX0WFnrbUat6NRfWRZLhKMP8MlawMNDQY1mD/ZmCIPC/daHkzSA48lQAqJir1
K9D04J5Eq138dWJb7vWX8hSSCi7QLE8zg7157d5MmoF0mlwW7SsuZF7pQOD7xEOy
=brT2
//go:build darwin
package common
/*
#cgo CFLAGS: -x objective-c
#cgo LDFLAGS: -framework Cocoa
#import <Cocoa/Cocoa.h>
int
@alfonmga
alfonmga / down.sh
Created February 21, 2023 20:08
Deploy an Ubuntu 22.04 LTS Desktop on Google Cloud Platform with RDP ready.
#!/bin/sh
set -e
# Zone
ZONE=europe-west8-a
echo "Destroying cloud Ubuntu Desktop..."
gcloud compute instances delete ubuntu-desktop --zone=$ZONE --quiet
@alfonmga
alfonmga / main.c
Last active January 23, 2023 16:14
/proc/loadavg manipulation by monkey-patching `loadavg_proc_show` function https://github.com/torvalds/linux/blob/master/fs/proc/loadavg.c
#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);
@alfonmga
alfonmga / logrus2telegram.go
Last active August 17, 2022 14:29
Logrus -> Telegram
package logrus2telegram
import (
"fmt"
"time"
tgbotapi "github.com/go-telegram-bot-api/telegram-bot-api/v5"
"github.com/sirupsen/logrus"
"errors"
@alfonmga
alfonmga / ginlogrus.go
Created August 16, 2022 17:11
Gin -> Logrus
package ginlogrus
import (
"fmt"
"math"
"net/http"
"os"
"time"
"github.com/gin-gonic/gin"
@alfonmga
alfonmga / gormlogrus.go
Created August 16, 2022 17:10
Gorm -> Logrus
package gormlogrus
import (
"context"
"errors"
"time"
"github.com/sirupsen/logrus"
"gorm.io/gorm"
gormlogger "gorm.io/gorm/logger"
@alfonmga
alfonmga / gcs_reverse_proxy.go
Last active August 12, 2022 16:53
Google Cloud Storage reverse proxy code extracted from https://github.com/daichirata/gcsproxy
package main
import (
"context"
"flag"
"io"
"log"
"net/http"
"strconv"
"time"