Skip to content

Instantly share code, notes, and snippets.

@curlyz
curlyz / thread.py
Last active September 3, 2022 16:12
test_thread.py
import _thread
def pid_routine():
global kp
global ki
global kd
while True:
# calculate here
@curlyz
curlyz / go_generic_struct.md
Created March 24, 2022 02:27
go_generic_struct
  type OrderRevenue interface {
          MarshalMyself() ([]byte, error)
  }

  type Anonymous struct {}
  func (a Anonymous) MarshalMyself() ([]byte, error) {
          // implementation's up to you
          return []byte{}, nil
 }
@curlyz
curlyz / letsencrypt.md
Last active February 28, 2022 14:48
letsencrypt.md
sudo snap install --classic certbot
sudo ln -s /snap/bin/certbot /usr/bin/certbot
sudo certbot certonly --standalone
@curlyz
curlyz / golang.md
Last active March 2, 2022 16:02
awesome-go

Popular library

package.envconfig

github.com/kelseyhightower/envconfig
// first, define the structure
type CustomConfig struct {
 Targets []string `envconfig:"TARGETS" default:"SOMETHING"`
import boto3
import deepdiff
import copy
import json
class SimpleTable(boto3.resources.factory.dynamodb.Table):
def __init__(self, table, partition_key = 'pk', sort_key = None):
self.table = table
self.partition_key = partition_key
self.sort_key = sort_key