This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
export GOTOOLCHAIN="go1.23.3" | |
export CGO_ENABLED="1" | |
export GOAMD64="v4" | |
export GOFLAGS="-ldflags=-s -ldflags=-w -trimpath -buildvcs=false -installsuffix=cgo" | |
export GOEXPERIMENT="newinliner" | |
export CGO_CFLAGS="-O3 -march=native" | |
go install golang.org/x/tools/gopls@latest |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"fmt" | |
"sync" | |
"sync/atomic" | |
) | |
type ObjectPool[T any] struct { | |
pool sync.Pool |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"fmt" | |
"math/rand" | |
"time" | |
) | |
func main() { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import datetime | |
from dataclasses import dataclass | |
@dataclass | |
class ArduinoStatus: | |
sicaklik : float | |
battery : float | |
isik_sens : int | |
isik_role : int | |
kasa_kapak : int |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import random | |
import string | |
class RandomPassword: | |
def __init__(self, length=8, string=True, number=True, special=False) -> None: | |
self.length = length | |
self.string = string | |
self.number = number | |
self.special = special |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def connect_channel(self, channel, delay=1/4): | |
listen = self.r.pubsub() | |
listen.subscribe(channel) | |
self.r.publish(channel, "a::1") | |
def start_process(): | |
while True: | |
message = listen.get_message() | |
time.sleep(delay) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
# Using python package : https://pypi.org/project/pyFirmata/ | |
from pyfirmata import Arduino, util | |
board = Arduino("/dev/ttyACM0") | |
it = util.Iterator(board) | |
it.start() |
NewerOlder