Skip to content

Instantly share code, notes, and snippets.

@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,
@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 / 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 / iterm2-send-zmodem.sh
Created December 16, 2019 06:58 — forked from dalei2019/iterm2-send-zmodem.sh
iterm2 send zmodem clone from matthew@mastracci.com
#!/bin/bash
# Author: Matt Mastracci (matthew@mastracci.com)
# AppleScript from http://stackoverflow.com/questions/4309087/cancel-button-on-osascript-in-a-bash-script
# licensed under cc-wiki with attribution required
# Remainder of script public domain
osascript -e 'tell application "iTerm2" to version' > /dev/null 2>&1 && NAME=iTerm2 || NAME=iTerm
if [[ $NAME = "iTerm" ]]; then
FILE=`osascript -e 'tell application "iTerm" to activate' -e 'tell application "iTerm" to set thefile to choose file with prompt "Choose a file to send"' -e "do shell script (\"echo \"&(quoted form of POSIX path of thefile as Unicode text)&\"\")"`
else
@clarksun
clarksun / iterm2-recv-zmodem.sh
Created December 16, 2019 06:58 — forked from dalei2019/iterm2-recv-zmodem.sh
iterm2 recv zmodem clone from matthew@mastracci.com
#!/bin/bash
# Author: Matt Mastracci (matthew@mastracci.com)
# AppleScript from http://stackoverflow.com/questions/4309087/cancel-button-on-osascript-in-a-bash-script
# licensed under cc-wiki with attribution required
# Remainder of script public domain
osascript -e 'tell application "iTerm2" to version' > /dev/null 2>&1 && NAME=iTerm2 || NAME=iTerm
if [[ $NAME = "iTerm" ]]; then
FILE=$(osascript -e 'tell application "iTerm" to activate' -e 'tell application "iTerm" to set thefile to choose folder with prompt "Choose a folder to place received files in"' -e "do shell script (\"echo \"&(quoted form of POSIX path of thefile as Unicode text)&\"\")")
else
@clarksun
clarksun / tmux.conf
Created October 10, 2019 07:55
tmux conf
set-option -g allow-rename off
set-option -g default-shell "/usr/local/bin/fish"
set-option -g default-command "/usr/local/bin/fish"
# set-option -g default-command "reattach-to-user-namespace -l zsh"
# tmux display things in 256 colors
set -g default-terminal "screen-256color"
# automatically renumber tmux windows
set -g renumber-windows on
@clarksun
clarksun / go-os-arch.md
Created August 2, 2019 01:19 — forked from asukakenji/0-go-os-arch.md
Go (Golang) GOOS and GOARCH

Go (Golang) GOOS and GOARCH

All of the following information is based on go version go1.8.3 darwin/amd64.

A list of valid GOOS values

(Bold = supported by go out of the box, ie. without the help of a C compiler, etc.)

  • android
  • darwin
@clarksun
clarksun / GPG and git on macOS.md
Created June 6, 2019 06:58 — forked from danieleggert/GPG and git on macOS.md
How to set up git to use the GPG Suite

GPG and git on macOS

Setup

No need for homebrew or anything like that. Works with https://www.git-tower.com and the command line.

  1. Install https://gpgtools.org -- I'd suggest to do a customized install and deselect GPGMail.
  2. Create or import a key -- see below for https://keybase.io
  3. Run gpg --list-secret-keys and look for sec, use the key ID for the next step
  4. Configure git to use GPG -- replace the key with the one from gpg --list-secret-keys
@clarksun
clarksun / pex.md
Created November 24, 2018 09:43 — forked from simeonf/pex.md
Creating a PEX from a python script

So you want to create a pex that packages your script and its dependencies?

Ok - first to make our script! Call it foo.py:

import requests

if __name__ == '__main__':
  req = requests.get("https://raw.githubusercontent.com/pantsbuild/pex/master/README.rst")
  print req.text.split("\n")[0]
@clarksun
clarksun / mkdocs.yml
Last active November 6, 2018 07:15
tmuxinator mkdocs config
# /Users/sunwei/.config/tmuxinator/mkdocs.yml
name: mkdocs-<%= @args[0] %>
root: /Users/sunwei/MyLib/practices/mkdocsP
on_project_start: mkdocs new <%= @args[0] %>
windows:
- mkdocs:
layout: main-vertical
panes:
- list:
- cd <%= @args[0] %>