Skip to content

Instantly share code, notes, and snippets.

View raszia's full-sized avatar
🏠
Working from home

Rasool Ziafaty raszia

🏠
Working from home
View GitHub Profile
@raszia
raszia / client.go
Last active March 9, 2023 07:33
Here is an example of how you could implement a TCP server and client in Go that handles incoming messages with a fixed-length header:
package main
import (
"encoding/binary"
"fmt"
"net"
)
const (
headerSize = 4 // the size of the message header, in bytes
@raszia
raszia / multicast.go
Last active March 9, 2023 07:33
multicast with golang
package main
import (
"fmt"
"net"
"golang.org/x/net/ipv4"
)
func main() {
@raszia
raszia / pygo.go
Last active November 20, 2023 08:31
Python script inside Golang
package main
/*
#cgo CFLAGS: -I/usr/include/python3.8
#cgo LDFLAGS: -lpython3.8
#include <Python.h>
*/
import "C"
import (
@raszia
raszia / oci8.pc
Last active November 14, 2022 11:11 — forked from fredericobenevides/oci8.pc
Setup for go-oci8
prefix=/opt/oracle
includedir=${prefix}/instantclient_12_1/sdk/include
libdir=${prefix}/instantclient_12_1
Name: oci8
Description: Oracle Instant Client
Version: 12.1
Cflags: -I${includedir}
Libs: -L${libdir} -lclntsh
# Python3 program to create target string, starting from
# random string using Genetic Algorithm
import random
# Number of individuals in each generation
POPULATION_SIZE = 100
# Valid genes
GENES = '''abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOP
@raszia
raszia / meliGenerator.py
Created March 28, 2020 07:05
Generate a valid and random iranian meli code
#!/usr/bin/python3
import random
import sys
def meli_code_generator():
while True:
meli_code = random.sample(range(1, 10), 9)
place_list = [10,9,8,7,6,5,4,3,2]
@raszia
raszia / cardGenerator.py
Created March 28, 2020 07:00
Random shomare-cart generator
#!/usr/bin/python3
import random
def card_generator():
while True:
rand_list = [random.randint(0, 9) for iter in range(16)]
rand_list[0] = random.randint(4, 6)
numbers_add = 0
#print (rand_list)
@raszia
raszia / benchmark.py
Created September 11, 2019 12:26
Cython performance benchmark vs pure python
import cybubble
import pybubble
from timeit import default_timer as timer
from decimal import *
import random
import copy
getcontext().prec = 8
if __name__ == '__main__':
random_list = [random.randrange(0,10) for i in range(9999)]