Skip to content

Instantly share code, notes, and snippets.

@clarksun
clarksun / gostring.md
Created August 5, 2020 10:26 — forked from helinwang/gostring.md
Call go (or c) code from python with string as argument and string as return value

go code (foo.go) compiled into a shared library and a c header (foo.h) is generated.

For calling go from c, please see here

Arguments

The code below shows two ways of passing string parameter to go function:

  1. Using GoString structure as argument, without making a copy in go code: no conversion to go string needed.
  2. Using c_char_p as argument, making a copy in go code when converting to go string.

When using the first method without the copy, I don't know how python will do the memory management with the pointer passed into go. So the second method is preferred.

@clarksun
clarksun / logger.py
Created September 18, 2020 23:19 — forked from nkhitrov/logger.py
Configure uvicorn logs with loguru for FastAPI
"""Configure handlers and formats for application loggers."""
import logging
import sys
from pprint import pformat
# if you dont like imports of private modules
# you can move it to typing.py module
from loguru import logger
from loguru._defaults import LOGURU_FORMAT
@clarksun
clarksun / overrides.lua
Created May 14, 2023 08:31 — forked from ianchesal/overrides.lua
copilot.lua + copilot-cmp in NvChad
-- Add the following in your custom/configs/overrides.lua file. You can configure copilot to meet your needs here.
M.copilot = {
-- Possible configurable fields can be found on:
-- https://github.com/zbirenbaum/copilot.lua#setup-and-configuration
suggestion = {
enable = false,
},
panel = {
enable = false,