Skip to content

Instantly share code, notes, and snippets.

View eopXD's full-sized avatar
🍢
Learn Learn Learn

Yueh-Ting (eop) Chen eopXD

🍢
Learn Learn Learn
View GitHub Profile
@eopXD
eopXD / stats_on_accounts
Last active September 28, 2018 16:52
台灣議員建議/配合款的一些統計資料
######################################
field name: councilor
element in list: 102830
unique element: 947
top 30 repeating value:
0 : [2057, '黃國安']
1 : [1773, '張鎮榮']
2 : [1721, '陳見賢']
3 : [1125, '劉水復']
4 : [1049, '江維屏']
@eopXD
eopXD / vm-backup.sh
Created March 12, 2019 07:38 — forked from cabal95/vm-backup.sh
I use this script to backup my QEMU/KVM/libVirt virtual machines. The script requires KVM 2.1+ since it uses the live blockcommit mode. This means the data in the snapshot disk is rolled back into the original instead of the other way around. Script does NOT handle spaces in paths.
#!/bin/bash
#
BACKUPDEST="$1"
DOMAIN="$2"
MAXBACKUPS="$3"
if [ -z "$BACKUPDEST" -o -z "$DOMAIN" ]; then
echo "Usage: ./vm-backup <backup-folder> <domain> [max-backups]"
exit 1
@eopXD
eopXD / coin.cpp
Last active September 21, 2020 15:47
Solution for https://pcs.cs.cloud.vt.edu/problems/277 (Canonical Coin System)
// see https://eopxd.com/2020/09/15/canonical-coin-system/ for some explaination
#include <cstdio>
#include <vector>
#define N 1000006
using namespace std;
int dp[2*N];
vector<int> coin;
int G ( int x ) {
int ret = 0;
for ( auto it=coin.rbegin(); it!= coin.rend(); ++it ) {
@eopXD
eopXD / morris.cpp
Last active September 21, 2020 15:48
Morris Traversal / Deletion
// see https://eopxd.com/2020/08/30/morris-traversal/ for explaination
#include <iostream>
#include <cassert>
#include <vector>
#include <memory>
using namespace std;
template<class T>
struct Tree {
@eopXD
eopXD / onnx_gen_model.py
Last active October 8, 2020 16:48
Generate ONNX model via ONNX, input initialized
# By eopXD (eopxd.com)
# Since it took me some time to figure it out, I guess this file can help out.
import onnx
from onnx import helper
from onnx import AttributeProto, TensorProto, GraphProto
from onnx import numpy_helper
xNP = np.array([[[[0., 1., 2.], # (1, 1, 3, 3)
[3., 4., 5.],
[6., 7., 8.]]]]).astype(np.float32)
@eopXD
eopXD / trySet.cpp
Last active March 18, 2021 10:23
std::set containing std::unique_ptr
// C++ 14
#include <iostream>
#include <memory>
#include <set>
// template specialization
template<typename T> struct std::less<std::unique_ptr<T>> {
bool operator()(const std::unique_ptr<T>& a, const std::unique_ptr<T>& b) const {
return *a < *b;
}
@eopXD
eopXD / blockly.xml
Created April 7, 2021 02:08
New Project
?contract
@eopXD
eopXD / blockly.xml
Created April 7, 2021 02:09
TryMarlowe
?contract
@eopXD
eopXD / metadata.json
Created April 7, 2021 02:55
TryMarlowe
{"valueParameterDescriptions":[],"slotParameterDescriptions":[],"roleDescriptions":[],"contractType":"O","contractName":"","contractDescription":"","choiceDescriptions":[]}
@eopXD
eopXD / rounding_mode_and_exception_csr.adoc
Last active January 5, 2023 06:35
Intrinsics Support for Rounding Modes and Exception Flags

Intrinsics Support for Rounding Modes and Exception Flags

Introduction

Most RISC-V vector (RVV) instructions access control and status registers (CSRs), which can be understood as additional instruction operands that were implemented separately due to encoding constraints. The assembly programmer must manually access these CSRs. The C-languge RVV intrinsics do have any such encoding constraints, so the intrinsics programmer can enjoy a simpler programming model.