Skip to content

Instantly share code, notes, and snippets.

View ozkansen's full-sized avatar
:octocat:

Özkan ŞEN ozkansen

:octocat:
View GitHub Profile
// Fill inside of the optimizeFunction function
function doExpensiveTask(input) {
const result = 2 * input
console.log("Doing expensive task...:", result);
return result;
}
function optimizeFunction(func) {
/*
* Only write code in this function.
* This function returns an optimized version of the func
@ozkansen
ozkansen / bind_socket.py
Created July 6, 2021 21:53 — forked from tuxfight3r/bind_socket.py
python tcp socket client / server examples
#!/usr/bin/python
import socket #for sockets
import sys #for exit
try:
#create an AF_INET, STREAM socket (TCP)
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
except socket.error, msg:
print 'Failed to create socket. Error code: ' + str(msg[0]) + ' , Error message : ' + msg[1]
import datetime
from dataclasses import dataclass
@dataclass
class ArduinoStatus:
sicaklik : float
battery : float
isik_sens : int
isik_role : int
kasa_kapak : int
package main
import (
"fmt"
"math/rand"
"time"
)
func main() {
package main
import (
"fmt"
"sync"
"sync/atomic"
)
type ObjectPool[T any] struct {
pool sync.Pool
@ozkansen
ozkansen / custom_json_pgx.go
Created May 25, 2024 17:26
Go Postgresql Client: pgx custom json marshaller & unmarshaller
package example
import (
pgx "github.com/jackc/pgx/v5"
"github.com/jackc/pgx/v5/pgtype"
"github.com/jackc/pgx/v5/pgxpool"
)
func postgresCustomJSONUpgrade(conn *pgxpool.Pool) {
conn.Config().AfterConnect = func(ctx context.Context, conn *pgx.Conn) error {
#!/usr/bin/env bash
export GOTOOLCHAIN="go1.25.0"
export CGO_ENABLED="0"
export GOAMD64="v4"
export GOARM64="v8.4,lse,crypto"
export GOFLAGS="-ldflags=-s -ldflags=-w -trimpath -buildvcs=false -installsuffix=cgo"
export GOEXPERIMENT="newinliner,greenteagc"
export CGO_CFLAGS="-O3 -march=native"