Skip to content

Instantly share code, notes, and snippets.

View parsibox's full-sized avatar

Mohsen Davari parsibox

View GitHub Profile
@parsibox
parsibox / RateLimiter.go
Created July 8, 2023 07:52
rate limitter with go
package main
import (
"context"
"fmt"
"time"
"golang.org/x/time/rate"
)
@parsibox
parsibox / localdns.go
Last active September 9, 2023 06:34
add a local dns for address in windows with golang
package main
import (
"fmt"
"io/ioutil"
"os"
)
func main() {
// Read existing hosts file
@parsibox
parsibox / go-redis.go
Created June 14, 2023 18:20
add 1000000 record in redis with max Concurrency
package main
import (
"context"
"fmt"
"github.com/redis/go-redis/v9"
"sync"
"time"
)
@parsibox
parsibox / Goroutines.go
Created June 14, 2023 12:00
view all running Goroutines in golang
fmt.Println(runtime.NumGoroutine())
// Get the stack traces of all currently running Goroutines.
stackTrace := make([]runtime.StackRecord, 1024)
length, ok := runtime.GoroutineProfile(stackTrace)
// Print out the stack traces.
fmt.Println("Stack traces of all Goroutines:")
for i := 0; i < length; i++ {
fmt.Println(stackTrace[i].Stack())
@parsibox
parsibox / https.go
Created June 8, 2023 13:50
go lang https fix handshake error
package main
import (
"crypto/tls"
"fmt"
"log"
"net/http"
"time"
)
@parsibox
parsibox / keygen.go
Created May 19, 2023 07:51
Create private_key and public_key size 2048 with golang for use in JWT
package main
import (
"crypto/rand"
"crypto/rsa"
"crypto/x509"
"encoding/pem"
"fmt"
"io/ioutil"
)
#!/usr/bin/python
# -*- coding: utf-8 -*-
import ssl
import socket
import os
import sys
from argparse import ArgumentParser
from argparse import RawTextHelpFormatter
from threading import Thread
@parsibox
parsibox / worker.js
Created April 6, 2023 10:43
getafreenode check remaining Traffic with cloadflare worker
addEventListener('scheduled', event => {
event.waitUntil(
handleScheduledEvent()
)
})
async function handleScheduledEvent() {
//in ghesmat ra taghir bedid
const uuid='xxxxx-038D-xxxxx-9F95-xxxxx';
const telegram_token='123123:xxxxxx';
sudo su
Suppress lengthy login messages:
touch .hushlogin
Get the existing package metadata up to date, and upgrade all existing packages:
apt -y update
apt -y upgrade
apt -y install mlocate
<?
protected static $firstNameMale = array(
'آبان', 'آبتین', 'آبید', 'آتش', 'آتشبان', 'آتشبند', 'آتیلا', 'آدر', 'آذران', 'آذربُد', 'آذرتش', 'آذرداد', 'آذرنگ', 'آرآسب', 'آرا', 'آراد', 'آرام', 'آران', 'آرتاباز', 'آرتان', 'آرتای', 'آرتمان', 'آرتین', 'آرش', 'آرمان', 'آرمون', 'آرمین', 'آرنگ', 'آرون', 'آروین', 'آریا', 'آریاآسب', 'آریابد', 'آریارمنا', 'آریامن', 'آریامنش', 'آریان', 'آریانا', 'آریانو', 'آریوبرزن', 'آزاد', 'آصف', 'آلتون', 'آوگان', 'آوند', 'آیتان', 'آیدین',
'ابراهیم', 'ابوعلی', 'ابی', 'اپرنگ', 'اتابک', 'اُجای', 'احد', 'احسان', 'احمد', 'اُخشان', 'ادریس', 'ارجاسپ', 'ارجان', 'ارجمند', 'اردا', 'اردشیر', 'اردلان', 'اردوان', 'اردون', 'ارزین', 'ارژن', 'ارژنگ', 'ارستو', 'ارسلان', 'ارسیا', 'ارشاسب', 'ارشام', 'ارشاما', 'ارشان', 'ارشد', 'ارشک', 'ارشمید', 'ارشن', 'ارشیا', 'ارمیا', 'اُرند', 'اروند', 'اسد', 'اسفندیار', 'اسفندیار', 'اسلان', 'اسماعیل', 'اشکان', 'اصغر', 'افراسیاب', 'افرند', 'افرنگ', 'افشار', 'افشین', 'اقبال', 'اکبر', 'اکتای', 'البرز', 'الوند', 'الیا', 'الیاس', 'امجد', 'امید', 'امیر', 'ام