Skip to content

Instantly share code, notes, and snippets.

View metab0t's full-sized avatar
🚀
Work hard

Yue Yang metab0t

🚀
Work hard
  • Hefei University of Technology
  • China
  • 02:29 (UTC +08:00)
View GitHub Profile
@metab0t
metab0t / .nanorc
Created March 30, 2019 06:19
.nanarc
# set element fgcolor,bgcolor
set titlecolor brightwhite,blue
set statuscolor brightwhite,green
set errorcolor brightwhite,red
set selectedcolor brightwhite,magenta
set stripecolor ,yellow
set numbercolor cyan
set keycolor cyan
set functioncolor green
include "/usr/share/nano/*.nanorc"
@metab0t
metab0t / strides.cpp
Created April 23, 2019 08:30
Stride of multidimensional array
#include <vector>
#include <functional>
#include <numeric>
#include <cassert>
using std::vector;
struct Stride {
size_t n_dims, n_elem;
vector<size_t> dims;
@metab0t
metab0t / PKGBUILD
Created April 26, 2019 08:57
PKGBUILD for casadi
# Maintainer: Andrew Sun <adsun701@gmail.com>
# Contributor: Benjamin Chretien <chretien dot b +aur at gmail dot com>
pkgname=casadi
pkgver=3.4.5
pkgrel=1
pkgdesc="Symbolic framework for automatic differentiation and numeric optimization"
arch=('i686' 'x86_64')
url="https://github.com/casadi/casadi"
license=('GPL3')
@metab0t
metab0t / subsetperm.cpp
Created May 18, 2019 08:07
Generate subset of a vector
#include <vector>
#include <iostream>
#include <algorithm>
using std::cout;
using std::vector;
template <typename T> void printvec(const vector<T> &vec) {
cout << "{";
for (const auto &v : vec) {
@metab0t
metab0t / .clang-format
Created June 29, 2019 02:18
My clang-format config
BasedOnStyle: LLVM
IndentWidth: 4
SortIncludes: false
@metab0t
metab0t / prelude.py
Last active May 6, 2020 13:01
[Snippets for matplotlib plotting] Here are some snippets I use with matplotlib #Python #matplotlib
import matplotlib
import matplotlib.pyplot as plt
import numpy as np
matplotlib.rcParams["font.family"] = "Sarasa Gothic SC"
plt.style.use("seaborn-poster")
fig, ax = plt.subplots(figsize=(15,7.5), facecolor="w", edgecolor="k")
fig.savefig("xx.png", dpi=300, bbox_inches="tight")
@metab0t
metab0t / multinorm.py
Created May 8, 2020 00:30
Generate multivariate normal distribution samples
from scipy.stats import multivariate_normal as multinorm
import numpy as np
mean = np.zeros(3)
cov = np.eye(3)
dist = multinorm(mean=mean, cov=cov)
n_samples = 1000
samples = dist.rvs(size=n_samples)
samples.shape
# = (1000, 3)
@metab0t
metab0t / notes.md
Created June 16, 2020 15:26
Fix Qt issues when using PyCall.jl
#include <concepts>
template <typename T> concept CPLEXArrayLite = requires(T o)
{
{
o.getEnv()
}
->std::same_as<int>;
{
o.getSize()
@metab0t
metab0t / dll.c
Created November 16, 2020 12:34
Test Julia dlopen function
#include <windows.h>
#include <direct.h>
#include <assert.h>
#include <stdio.h>
#define _OS_WINDOWS_
int isabspath(const char *in) {
#ifdef _OS_WINDOWS_
char c0 = in[0];
if (c0 == '/' || c0 == '\\') {