Skip to content

Instantly share code, notes, and snippets.

@oddmario
oddmario / tune_go_http_server.md
Last active June 24, 2024 09:10
Tuning a Golang (Go) HTTP server

Tune a Go http.Server

by adjusting its default buffer sizes


In some situations, you may need to adjust the default buffer sizes of a Golang HTTP server.

Adjusting the default buffer sizes allows you to benefit from higher throughput and improve the performance of your HTTP servers overall.

For the cherry on the top,

Installing QEMU with the qemu-anti-detection patch

This procedure was done on an Ubuntu 24.04 system


Install the dependencies required for the building process:

sudo apt install git build-essential ninja-build python3-venv libglib2.0-0 libglib2.0-dev flex bison libpixman-1-dev libsdl2-dev libsdl2-image-dev mesa-common-dev libglfw3-dev libgles2-mesa-dev libgl-dev libepoxy-dev libpipewire-0.3-dev libspice-protocol-dev libspice-server-dev libvirglrenderer-dev libjson-c-dev libcmocka-dev libusbredirparser-dev libgtk-3-dev libusb-1.0-0-dev
@oddmario
oddmario / Backend example (NodeJS).js
Last active June 29, 2023 13:00
Send push notifications on your website using Firebase Cloud Messaging
const bodyparser = require("body-parser");
const express = require("express");
var admin = require("firebase-admin");
var serviceAccount = require("./serviceAccountFile.json");
// init
admin.initializeApp({
credential: admin.credential.cert(serviceAccount),
@oddmario
oddmario / AndroidManifest.xml
Last active June 27, 2023 13:41
Send push notifications in an Android app (Java) using Firebase Cloud Messaging
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools">
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<application
"""
https://github.com/0sir1ss/Carbon
"""
import ast
import re
import random
import io
import tokenize
import os
import zlib, base64
@oddmario
oddmario / server.js
Last active February 23, 2021 17:02
Sample WebSocket server
const WebSocket = require('ws');
const wss = new WebSocket.Server({ port: 25595 });
wss.on('connection', function connection(ws, req) {
var timer;
var firstMessageSent = false;
var areYouSureAsked = false;
const ip = req.socket.remoteAddress;
@oddmario
oddmario / scrape_numbers.py
Created May 18, 2020 10:50
A Python script to scrape the mobile numbers from the famous SMS receiving sites. You can use this script to block those numbers in your site.
import phonenumbers
import requests
import threading
import time
import string
import random
import urllib3
urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)
@oddmario
oddmario / drive.php
Last active June 17, 2024 16:30
A PHP script to give a direct download link for a Google Drive file. (bypasses the Virus scan warning for big files)
<?php
// NOTE: Also follow this answer: https://stackoverflow.com/a/2429162/8524395
set_time_limit(0);
$requireds = array("fid", "fname");
foreach($requireds as $required) {
if( !isset($_GET[$required]) || empty($_GET[$required]) ) {
die("error.");
}
}
$gdrive_api_key = ""; // Not necessary to be API key for the account which uploaded the file. The file just have to be enabled for sharing with anyone.
@oddmario
oddmario / Delete all messages in Discord channel or DM.js
Last active July 28, 2019 17:28
Delete all messages in Discord channel/DM
function sleep(milliseconds) {
var start = new Date().getTime();
while (true) {
if ((new Date().getTime() - start) > milliseconds) {
break;
}
}
}
function deleteMessages() {
@oddmario
oddmario / ThreadSafeWriter.java
Created September 7, 2018 20:36
Thread safe writer for Java
public static void ThreadsafeWriter(String text, String file) throws IOException {
/*
@author: mariolatiffathy
@source: gist.github
@description: A thread-safe writer that you can use to write to the same file through multiple threads.
@usage: ThreadsafeWriter(String: text, String: file)
@example: ThreadsafeWriter("Hello World", "File.txt")
@methodType: public, static
*/
String nodeValue = text;