Skip to content

Instantly share code, notes, and snippets.

View freakynit's full-sized avatar

Nitin Bansal freakynit

View GitHub Profile

1. Overall Architecture

  • Structure & Flow:
    Your code follows a common Cloudflare Workers pattern:

    • An event listener intercepts fetch events.
    • The handleRequest() function rewrites the incoming URL, creates a new request with modified headers, forwards it to the target server, and then post-processes the response (rewriting redirects, CORS, cookies, and even HTML content).
  • HTML Rewriting:
    You’re using Cloudflare’s HTMLRewriter to adjust links (a[href]), images (img[src]), and form actions (form[action]). This is a good approach for making proxied HTML interactive through your proxy.

Key Observations:

  1. The code implements a basic reverse proxy that:
    • Routes requests through a specific domain (stratosphericus.workers.dev)
    • Rewrites URLs in HTML responses
    • Handles CORS
    • Manages cookies
    • Supports redirects

Potential Issues & Improvements:

@freakynit
freakynit / github-social.md
Last active February 17, 2025 16:32
Using Github as a censorship resitant social media network.

1. Authentication & User Management

  • Authentication: Fallback to GitHub's own signup/login flow..
  • Identities and User Profiles: Users will be identified by their GitHub usernames, and their GitHub profiles act as their social profiles.

2. Data Model

Repositories as Groups

  • Each group is a GitHub repository.
  • The repo name represents the group name.
@freakynit
freakynit / cost.js
Created February 17, 2025 05:42
Calculates total costs of your chatgpt chats if you were using API (text only, no muiltimedia consideration)
const fs = require('fs');
// ToDo: Update these values if needed
const CONVERSATIONS_FILE_PATH = './conversations.json'; // From your chatGPT data export
const CHARACTERS_PER_TOKEN = 4;
const PRICING_DOLLARS_PER_MILLION_TOKENS = {
input: 2.50,
output: 10
};
@freakynit
freakynit / get_subtitle_files.js
Created February 12, 2025 09:53 — forked from dansleboby/get_subtitle_files.js
Suno.com Aligned Words Fetcher to SRT or LRC file
// ==UserScript==
// @name Suno Aligned Words Fetcher with Auth
// @namespace http://tampermonkey.net/
// @version 1.2
// @description Fetch aligned words with auth and add a button under the image on Suno pages.
// @author Your Name
// @match https://suno.com/song/*
// @grant none
// ==/UserScript==
const {
DuckDBBitValue,
DuckDBBlobValue, DuckDBDateValue, DuckDBDecimalValue,
DuckDBIntervalValue, DuckDBListType,
DuckDBListValue, DuckDBMapType,
DuckDBMapValue, DuckDBStructType,
DuckDBStructValue,
DuckDBTimestampMillisecondsValue,
DuckDBTimestampNanosecondsValue,
DuckDBTimestampSecondsValue,
@freakynit
freakynit / pocket_exporter.js
Created March 28, 2022 06:45
Exports pocket items as csv compatible with raindrop.io. Exported fields: 'url', 'folder', 'title', 'description', 'tags', 'created'
import axios from 'axios'
import {createArrayCsvWriter as createCsvWriter} from 'csv-writer'
// Add your consumer key and access token.
const pocketConsumerKey = '';
const pocketAccessToken = '';
const pocketItemsFilePath = './pocket_items.csv';
const axiosConfig = {
'headers': {
@freakynit
freakynit / readMemStatsExample.go
Created November 29, 2021 04:08
Example usage of runtime.ReadMemStats function
package main
import (
"fmt"
"runtime"
"strconv"
"time"
)
func printMemStats(message string, rtm runtime.MemStats){
package main
import (
"fmt"
"time"
)
func testMakeSlice(numIterations int, numRuns int){
a := make([]int32, 0)
for k := 0; k < numRuns; k++ {
@freakynit
freakynit / main.go
Created November 28, 2021 03:14
Iterate string containing emoji with skin tone modifier (not working)...
package main
import (
"fmt"
)
func main() {
var s string = "h👍🏻e"
for i, c := range []rune(s) {
fmt.Println(i, string(c))