Skip to content

Instantly share code, notes, and snippets.

View parsibox's full-sized avatar

Mohsen Davari parsibox

View GitHub Profile
@parsibox
parsibox / gist:00c13bf8c1afcc165de3b52e644b05ea
Created September 9, 2023 14:38
windows rename file with powershell
Get-ChildItem -Path D:\wamp64\www\product_golang\telirco\product\sms_esb\bin\linux_service\worker_db_queue_bulk\* -Recurse | Where-Object {$_ -match "peertopeer"} | Ren -NewName {$_ -replace "peertopeer","bulk"}
echo "_ZNSt12_Bind_simpleIFPFvSsSsEPcS2_EE9_M_invokeIJLm0ELm1EEEEvSt12_Index_tupleIJXspT_EEE+0xa0" | c++filt
nm -D telircoampq.so
@parsibox
parsibox / updateBash.sh
Created July 9, 2023 07:03
Update output of Bash script
for i in $(seq 1 100); do printf "\r%s%%" "$i"; sleep 0.1; done
for i in {1..100}; do
percent=$(($i))
printf "\r%s%%" "${percent}"
sleep 0.1
done
@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