Skip to content

Instantly share code, notes, and snippets.

View crazyguitar's full-sized avatar
🎯
Focusing

CHANG-NING TSAI crazyguitar

🎯
Focusing
View GitHub Profile

Linux - Systemd cheatsheet

systemctl

Activates a service immediately:

systemctl start foo.service

Deactivates a service immediately:

@crazyguitar
crazyguitar / bot.rb
Created May 31, 2021 09:53 — forked from dideler/bot.rb
Sending a notification message to Telegram using its HTTP API via cURL
# Use this script to test that your Telegram bot works.
#
# Install the dependency
#
# $ gem install telegram_bot
#
# Run the bot
#
# $ ruby bot.rb
#
@crazyguitar
crazyguitar / list.md
Last active August 25, 2021 15:54 — forked from ih2502mk/list.md
Quantopian Lectures Saved
@crazyguitar
crazyguitar / adf.py
Created August 8, 2021 12:37 — forked from jcorrius/adf.py
Augmented Dickey-Fuller unit root test
import numpy as np
from statsmodels.regression.linear_model import OLS
from statsmodels.tsa.tsatools import lagmat, add_trend
from statsmodels.tsa.adfvalues import mackinnonp
def adf(ts):
"""
Augmented Dickey-Fuller unit root test
"""
# make sure we are working with an array, convert if necessary
@crazyguitar
crazyguitar / simd-vmv.c
Created October 5, 2021 08:14 — forked from kbarbary/simd-vmv.c
Vector-matrix-vector multiplication with SIMD (AVX) intrinsics
// Doing the operation:
//
// | a a a a | | y |
// x * A * y = [ x x x x ] | a a a a | | y |
// | a a a a | | y |
// | a a a a | | y |
//
// with SIMD intrinics (specifically AVX).
//
// adapted from https://gist.github.com/rygorous/4172889
#include <stdio.h>
#include <gmmintrin.h>
// x4 ~ x0 must have either value 0 or 1.
#define MM256_SHUFFLE(x3, x2, x1, x0) \
((x3 << 3) | (x2 << 2) | (x1 << 1) | (x0))
void
test()
{
@crazyguitar
crazyguitar / avx2_transpose_kernel.cpp
Created October 5, 2021 18:57 — forked from nanaHa1003/avx2_transpose_kernel.cpp
[AVX2 matrix transpose] A double precision matrix transpose kernel implemented in avx2 intrinsics. You can compile this code with -mavx2 flag. #NLA
#include <iostream>
#include <immintrin.h>
inline void transpose_kernel(double *A, int lda, double *B, int ldb) {
__m256d row0, row1, row2, row3;
row0 = _mm256_load_pd(A + 0 * lda);
row1 = _mm256_load_pd(A + 1 * lda);
row2 = _mm256_load_pd(A + 2 * lda);
row3 = _mm256_load_pd(A + 3 * lda);
@crazyguitar
crazyguitar / m256.cc
Created October 5, 2021 20:18 — forked from kaityo256/m256.cc
//----------------------------------------------------------------------
#include <stdio.h>
#include <emmintrin.h>
#include <immintrin.h>
//----------------------------------------------------------------------
void
printm256(__m256d r){
double *a = (double*)(&r);
printf("%f %f %f %f\n",a[0],a[1],a[2],a[3]);
}
@crazyguitar
crazyguitar / libpng_test.c
Created October 21, 2021 06:43 — forked from niw/libpng_test.c
How to read and write PNG file using libpng. Covers trivial method calls like png_set_filler.
/*
* A simple libpng example program
* http://zarb.org/~gc/html/libpng.html
*
* Modified by Yoshimasa Niwa to make it much simpler
* and support all defined color_type.
*
* To build, use the next instruction on OS X.
* $ brew install libpng
* $ clang -lz -lpng16 libpng_test.c
@crazyguitar
crazyguitar / Clang-format Comparison.md
Last active October 24, 2021 18:00 — forked from andrewseidl/ Clang-format Comparison.md
Clang-format style comparison

This is a comparison of the different formatting styles including with clang-format.

Generated via:

styles=( LLVM Google Chromium Mozilla WebKit )
for style in $styles
do
  clang-format -style=$style ChLcpIterativeAPGD.h > ChLcpIterativeAPGD.$style.h

done