Skip to content

Instantly share code, notes, and snippets.

@ronaldpetty
ronaldpetty / md
Created July 29, 2022 17:30
sa core example
![](images/2022-07-28-15-30-32.png)
```
~$ pip install SQLAlchemy
Defaulting to user installation because normal site-packages is not writeable
Collecting SQLAlchemy
Downloading SQLAlchemy-1.4.39-cp310-cp310-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.6 MB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 1.6/1.6 MB 8.5 MB/s eta 0:00:00
import threading
import time
class X:
def __init__(self):
self.a = 1
self.b = 2
self.lock = threading.RLock()
def changeA(self):
* `docker container run --rm -d --name mdb mongo`
* `docker container inspect mdb | grep IPA` # to get IP for code unless this is the only container
* `python3 -m venv faster`
* cd `faster`
* `source ./bin/activate`
* `python3 -m pip install pymongo
To run the code:
* `python3 code.py #writers #readers #docs`
from multiprocessing import Pool
from pymongo import MongoClient
import datetime
import sys
def insert(x):
print("insert")
print(f"instance {x}")
client = MongoClient('172.17.0.2', 27017)
db = client.test_database
/game-of-life# cat pom.xml
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.wakaleo.gameoflife</groupId>
<artifactId>gameoflife</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>pom</packaging>
<name>gameoflife</name>
<url>https://github.com/wakaleo/game-of-life</url>
@ronaldpetty
ronaldpetty / READEME.md
Last active December 9, 2021 00:48
KlusterD Attempt 1

Hack 1 - Replace scheduler

Process #1 - build replacement scheduler

  • NOTE - if control changes IPs, code will need updates (for api, currently not ENV or file)
  • On a machine with Docker
  • git clone http://github.com/ronaldpetty/scheduler.git (derived from kelseyhightower/scheduler)
  • cd ~/scheduler
  • git checkout tls_healthz
  • build image - sudo docker build -t k8s.gcr.io/kube-scheduler:v1.22.4 --no-cache .
  • extract image - sudo docker save k8s.gcr.io/kube-scheduler:v1.22.4 -o hightower.tar
@ronaldpetty
ronaldpetty / env.md
Created December 6, 2021 10:43
env package demo
ronaldpetty@Ronalds-MBP src % pwd
/Users/ronaldpetty/go/src
ronaldpetty@Ronalds-MBP src % tree pc                         
pc
└── driver.go

0 directories, 1 file
ronaldpetty@Ronalds-MBP src % cat pc/driver.go 
package main
@ronaldpetty
ronaldpetty / code.go
Created October 29, 2021 08:10
Demo - channel is blocked with tuple form if its open and unbuffered
package main
import (
"strconv"
"time"
)
func main() {
c := make(chan string)
w := make(chan struct{})
@ronaldpetty
ronaldpetty / hctx.go
Created October 29, 2021 07:41
try cancel
package main
import (
"context"
"time"
)
func one(ctx context.Context) {
print("one create\n")
ctx5, _ := context.WithTimeout(ctx, time.Second*5)
@ronaldpetty
ronaldpetty / deprecated-options-alt-via-kustomize.md
Created October 1, 2021 18:00
Example of using kustomize to handle deprecated option.

Convert:

kubectl run curler --image giantswarm/tiny-tools --serviceaccount app-sa --command -- /usr/bin/tail -f /dev/null

Since --serviceaccount is deprecated. One alternative is using kustomize. Its more work, but a good technique you can reuse for other deprecated options or automation.

kubectl --dry-run=client -o yaml run curler --image giantswarm/tiny-tools --command -- /usr/bin/tail -f /dev/null > curler.yaml

cat &lt; addsa.yaml