Skip to content

Instantly share code, notes, and snippets.

View gnh1201's full-sized avatar
🍉
Your Watermelon OPEN UP!

Namhyeon, Go gnh1201

🍉
Your Watermelon OPEN UP!
View GitHub Profile
@gnh1201
gnh1201 / jsonrpc2.php
Last active March 25, 2024 09:02
Super-simple JSON-RPC 2.0 framework for PHP
<?php
// Super-simple JSON-RPC 2.0 framework for PHP
// MIT License
// Namhyeon Go <[email protected]>
// created: 2024-03-22
// updated: 2024-03-25
function jsonrpc2_encode($method, $params, $id = '') {
$data = array(
"jsonrpc" => "2.0",
@gnh1201
gnh1201 / hello.py
Last active March 27, 2024 04:15
A customized translation service that is compatible with the LibreTranslate API
#!/usr/bin/env python3
#
# hello.py
# serverless translation service gateway
#
# @author: Namhyeon Go <[email protected]>
# @created_on: 2024-03-15
# @updated_on: 2024-03-19
#
@gnh1201
gnh1201 / worker.js
Created October 27, 2023 09:46
Cloudflare Workers code to integrate IBM Translator to Mastodon
/**
* Welcome to Cloudflare Workers! This is your first worker.
*
* - Run "npm run dev" in your terminal to start a development server
* - Open a browser tab at http://localhost:8787/ to see your worker in action
* - Run "npm run deploy" to publish your worker
*
* Learn more at https://developers.cloudflare.com/workers/
*/
@gnh1201
gnh1201 / deobfusate_ps.py
Last active October 4, 2023 11:16
Powershell format string deobfusation
# Namhyeon Go <[email protected]>
# 2023-10-04
import re
# Text to search (Example text using PowerShell format strings)
text = """
&("{0}{1}{2}" -f 'Set','-Var','iable')
&("{0} {1} {2}" -f 'Set','-Var','iable')
&("This is a test {0}" -f 'arg1')
@gnh1201
gnh1201 / error.log
Last active September 9, 2023 21:12
IBM Cloud Language Translator in Mastodon (Not working yet)
Sep 9 20:44:08 gosomi bundle[782892]: [26a0d58f-e22c-4219-9dcd-6a04f953ced0] method=POST path=/api/v1/statuses/111036983556043247/translate format=html controller=Api::V1::Statuses::TranslationsController action=create status=500 error='NoMethodError: undefined method `model_name' for Request:Class
Sep 9 20:44:08 gosomi bundle[782892]: [26a0d58f-e22c-4219-9dcd-6a04f953ced0]
Sep 9 20:44:08 gosomi bundle[782892]: [26a0d58f-e22c-4219-9dcd-6a04f953ced0] NoMethodError (undefined method `model_name' for Request:Class
Sep 9 20:44:08 gosomi bundle[782892]: [26a0d58f-e22c-4219-9dcd-6a04f953ced0]
Sep 9 20:44:08 gosomi bundle[782892]: [26a0d58f-e22c-4219-9dcd-6a04f953ced0] app/controllers/api/v1/statuses/translations_controller.rb:14:in `create'
Sep 9 20:44:08 gosomi bundle[782892]: [26a0d58f-e22c-4219-9dcd-6a04f953ced0] app/controllers/concerns/localized.rb:11:in `set_locale'
Sep 9 20:44:08 gosomi bundle[782892]: [26a0d58f-e22c-4219-9dcd-6a04f953ced0] lib/mastodon/rack_middleware.rb:9:in `call'
@gnh1201
gnh1201 / ipfs_nat.md
Created August 19, 2023 10:37
IPFS configuration with NAT

IPFS configuration with NAT

IPFS (here, referring to go-ipfs or kubo) already supports NAT environments, but there is a lack of documentation explaining this, leading to difficulties in configuration for many users.

Below is an configuration example for supporting NAT environments in IPFS.

{
	"Addresses": {
 "API": "/ip4/0.0.0.0/tcp/5001",
@gnh1201
gnh1201 / video-trancoding-mastodon.md
Last active July 20, 2024 09:51
How to accelerate video trancoding (FFmpeg) in Mastodon

How to accelerate video trancoding (FFmpeg) in Mastodon

Let's build a remote video transcoder (FFmpeg) for Mastodon!

This post may be outdated. Please check https://github.com/gnh1201/topic-activitypub/blob/main/ffmpeg.md

Why?

Whenever there were incidents or similar events on X (formerly, Twitter), such as on July 1st, the Sidekiq queue in Mastodon would expand, resulting in latency exceeding 10 hours. However, no matter how many photos or videos were being exchanged, it seemed unreasonable in a network where text communication was the primary focus. Eventually, when I disabled all multimedia processing-related features, the latency dropped to zero.

Before following this tutorial

@gnh1201
gnh1201 / rqlite.env
Created June 12, 2023 07:44
rqlite with systemd
INTERFACE=venet0
NODE_ID=1
HTTP_PORT=2001
RAFT_PORT=2002
JOIN=
@gnh1201
gnh1201 / index.php
Created March 24, 2023 08:39
Extract all environment data from PHP runtime
<?php
// Extract all environment data from PHP runtime
// Go Namhyeon <[email protected]>
echo "Extracting...<br/><br/>";
$extracted_data = array();
// Extracting all defined functions
echo "Extracting all defined functions...<br/><br/>";
@gnh1201
gnh1201 / vault.repo
Last active March 16, 2023 20:20
CentOS vault (6.10) repo file example
# wget [this file URL]
# mv /etc/yum.repos.d /etc/yum.repos.d.old
# mkdir /etc/yum.repos.d
# cp vault.repo /etc/yum.repos.d/
# yum clean all
# yum update
[Catswords-C6.10-base]
name=Catswords-CentOS-6.10 - Base
baseurl=http://repo.catswords.com/centos-vault/6.10/os/$basearch/