Skip to content

Instantly share code, notes, and snippets.

Avatar
🍢
Learn Learn Learn

Yueh-Ting (eop) Chen eopXD

🍢
Learn Learn Learn
View GitHub Profile
View metadata.json
{"valueParameterDescriptions":[],"slotParameterDescriptions":[],"roleDescriptions":[],"contractType":"O","contractName":"","contractDescription":"","choiceDescriptions":[]}
@eopXD
eopXD / trySet.cpp
Last active Mar 18, 2021
std::set containing std::unique_ptr
View trySet.cpp
// 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 / onnx_gen_model.py
Last active Oct 8, 2020
Generate ONNX model via ONNX, input initialized
View onnx_gen_model.py
# 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 / coin.cpp
Last active Sep 21, 2020
Solution for https://pcs.cs.cloud.vt.edu/problems/277 (Canonical Coin System)
View coin.cpp
// 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 Sep 21, 2020
Morris Traversal / Deletion
View morris.cpp
// 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 / vm-backup.sh
Created Mar 12, 2019 — 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.
View vm-backup.sh
#!/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 / stats_on_accounts
Last active Sep 28, 2018
台灣議員建議/配合款的一些統計資料
View stats_on_accounts
######################################
field name: councilor
element in list: 102830
unique element: 947
top 30 repeating value:
0 : [2057, '黃國安']
1 : [1773, '張鎮榮']
2 : [1721, '陳見賢']
3 : [1125, '劉水復']
4 : [1049, '江維屏']