Skip to content

Instantly share code, notes, and snippets.

View lucidfrontier45's full-sized avatar

杜世橋 Du Shiqiao lucidfrontier45

  • GROUND Inc.
  • Tochigi, Japan
View GitHub Profile
@lucidfrontier45
lucidfrontier45 / autoprior.py
Last active March 5, 2024 06:50
automatic generation of NumPyro prior sampling function for Flax model
import jax
import jax.random as jrand
import flax.linen as nn
import numpyro.distributions as dist
def autoprior(model: nn.Module, model_args, scale=1.0, prefix: str="param"):
key = jrand.PRNGKey(0)
init_params = model.init(key, *model_args)
flatten_params, tree_def = jax.tree.flatten(init_params)
shapes = [x.shape for x in flatten_params]
@lucidfrontier45
lucidfrontier45 / alacritty.toml
Last active December 31, 2023 09:00
alacritty.toml
# Campbell (Windows 10 default)
# Default colors
[colors.primary]
background = '#0c0c0c'
foreground = '#cccccc'
# Normal colors
[colors.normal]
black = '#0c0c0c'
@lucidfrontier45
lucidfrontier45 / export.py
Created October 17, 2023 00:44
PyTorch Multiple Input Model Onnx Example
import torch
import torch.nn.functional as F
from torch.nn import Linear, Module
class MyModel(Module):
def __init__(self):
super().__init__()
self.linear11 = Linear(3, 8)
self.linear12 = Linear(5, 8)
@lucidfrontier45
lucidfrontier45 / galera_cluster.yml
Last active April 14, 2023 17:24
docker-compose file for mariadb galera cluster
node1:
image: hauptmedia/mariadb:10.1
hostname: node1
ports:
- 13306:3306
environment:
- MYSQL_ROOT_PASSWORD=test
- REPLICATION_PASSWORD=test
- MYSQL_DATABASE=maria
- MYSQL_USER=maria
@lucidfrontier45
lucidfrontier45 / main.cpp
Last active October 8, 2022 10:41
cpp benchmark
#include <chrono>
#include <iostream>
#include <random>
double dot(const std::vector<double> &x, const std::vector<double> &y)
{
auto n = x.size();
double s = 0.0;
for (size_t i = 0; i < n; i++)
{
@lucidfrontier45
lucidfrontier45 / build.gradle
Last active July 2, 2022 13:17
VSCode and Gradle Settings for Modern Java Development
plugins {
id 'java'
id "jacoco"
id "com.diffplug.spotless" version "6.7.2"
}
repositories {
// Use Maven Central for resolving dependencies.
mavenCentral()
}
@lucidfrontier45
lucidfrontier45 / Makefile
Last active May 12, 2022 00:32
python linter and vscode settings
all: check
format:
black .
isort .
lint: format
flake8 --exit-zero .
mypy --show-column-numbers .
@lucidfrontier45
lucidfrontier45 / .clang-format
Last active May 2, 2022 15:54
VSCode settings for Python/C++ development with clangd LSP
BasedOnStyle: Webkit
AlignOperands: true
AlignAfterOpenBracket: Align
AllowShortIfStatementsOnASingleLine: true
AllowShortLoopsOnASingleLine: false
AllowShortFunctionsOnASingleLine: Empty
ConstructorInitializerAllOnOneLineOrOnePerLine: false
BreakConstructorInitializers: BeforeColon
AlwaysBreakTemplateDeclarations: true
ColumnLimit: 88
@lucidfrontier45
lucidfrontier45 / .hadoop_aliases
Created October 23, 2015 15:13
hadoop command aliases
alias hls='hdfs dfs -ls'
alias hlsr='hdfs dfs -lsr'
alias hdu='hdfs dfs -du'
alias hdus='hdfs dfs -dus'
alias hcount='hdfs dfs -count'
alias hmv='hdfs dfs -mv'
alias hcp='hdfs dfs -cp'
alias hrm='hdfs dfs -rm'
alias hrmr='hdfs dfs -rmr'
alias hexpunge='hdfs dfs -expunge'
@lucidfrontier45
lucidfrontier45 / test.cpp
Last active September 25, 2021 20:51
Test Copy and Move constructor
#include <iostream>
struct MyVector {
size_t current_size = 0;
size_t capacity = 0;
double* data = nullptr;
MyVector() : capacity { 10 }, current_size { 0 }
{