Monday, October 19, 2020

Golang Calling Stack

 

package main

import (
"fmt"
"runtime"
)

func main() {
aa()
}

func aa() {
bb()
}

func bb() {
cc("hello")
}

func cc0(s string) {
callers := make([]uintptr, 8)
runtime.Callers(1, callers)
frames := runtime.CallersFrames(callers)
for {
f, ok := frames.Next()
if !ok {
break
}
fmt.Println("--")
fmt.Println("f: ", f)
fmt.Println("f: ", f.Entry)
fmt.Println("f: ", f.File)
fmt.Println("f: ", f.Func)
fmt.Println("f: ", f.Function)
}
}

func cc(s string) {
callers := make([]uintptr, 8)
runtime.Callers(1, callers)
frames := runtime.CallersFrames(callers)
f, _ := frames.Next()
fmt.Println("--")
fmt.Println("f: ", f)
fmt.Println("f: ", f.Entry)
fmt.Println("f: ", f.File)
fmt.Println("f: ", f.Func)
fmt.Println("f: ", f.Function)
}

Python Multiprocessing Snippet

 You can use a pool of worker processes and a Manager instance to manage access to tf_dict and df_dict dictionaries which are shared between workers:


import glob
import multiprocessing as mp

from utils import get_tokens, update_tf, update_df, save_dicts

WORKERS = 4

def update_dicts(filename, tf_dict, df_dict):
    tokens = get_tokens(filename)

    for tok in tokens:
        update_tf(tok, tf_dict)
        update_df(tok, df_dict)

def main():
    manager = mp.Manager()

    tf_dict = manager.dict()
    df_dict = manager.dict()

    pool = mp.Pool(WORKERS)

    for filename in glob.glob('/path/to/texts/*.txt'):
        pool.apply_async(update_dicts, args=(filename, tf_dict, df_dict))

    pool.close()
    pool.join()

    save_dicts(tf_dict, df_dict)

if __name__ == "__main__":
    main()

Cheap-n-Easy Enhanced Onesheet

 






Uploading ATMEGA328 Bootloader

 https://www.theengineeringprojects.com/2015/10/upload-bootloader-atmega328.html

QMK / Drop Notes

steps

cd ~/qmk_firmware; qmk compile
Fn-B, bootloader mode
cd ~/mdloader; /mdloader_mac --restart -f -D ../qmk_firmware/massdrop_ctrl_marhar.bin 

refs

https://drop.com/talk/9382/how-to-configure-your-ctrl-keyboard

https://drop.com/mechanical-keyboards/configurator/config/16042

https://github.com/qmk/qmk_firmware

https://github.com/Massdrop/mdloader/releases/tag/1.0.4

https://github.com/qmk/qmk_firmware

https://github.com/Massdrop/mdloader

https://www.storyspooler.com/using-qmk-for-lights-on-massdrop-ctrl/

https://www.reviewgeek.com/19076/drop-alt-has-everything-you-want-in-a-custom-keyboard-except-the-soldering/