Skip to content

Instantly share code, notes, and snippets.

View yen3's full-sized avatar

Yen3 yen3

  • Taiwan
View GitHub Profile
from __future__ import print_function
class Attribute(object):
def __init__(self):
pass
def main():
a = Attribute();
print(a.__dict__)
a.__setattr__("test", 5)
@yen3
yen3 / list_dir.hs
Last active August 29, 2015 14:22
List files in a directory recursively
module ListFiles where
import System.Directory
import System.FilePath.Posix
split:: [a] -> [Bool] -> ([a], [a])
split xs bs = foldr s ([], []) (zip xs bs)
where s (d, i) (y, z) = if i then (d:y, z) else (y, d:z)
isSpecialFile :: FilePath -> Bool
@yen3
yen3 / Mandelbrot.hs
Last active September 20, 2021 06:33
MandelbrotSet practice --- sequence and basic parallel version
{-# LANGUAGE BangPatterns #-}
-- Compile command: ghc -O2 Mandelbrot.hs -rtsopts -threaded -fllvm
import qualified Control.Monad.Par as Par
import Control.Parallel.Strategies (parList, rseq, using)
import Data.Binary.IEEE754 (putFloat64le)
import Data.Binary.Put
import qualified Data.ByteString.Lazy as BL
import Data.Time.Clock (diffUTCTime, getCurrentTime)
@yen3
yen3 / gist:3a264578e79e213a692135f98bd1a2a2
Created June 14, 2016 05:54 — forked from stuart11n/gist:9628955
rename git branch locally and remotely
git branch -m old_branch new_branch # Rename branch locally
git push origin :old_branch # Delete the old branch
git push --set-upstream origin new_branch # Push the new branch, set local branch to track the new remote
@yen3
yen3 / zshrc.zsh
Created October 10, 2016 14:11
Try set zshrc with zplug
source ~/.zplug/init.zsh
zplug "zplug/zplug"
#zplug "zsh-users/zsh-history-substring-search"
#zplug "zsh-users/zsh-completions"
#zplug "zsh-users/zsh-syntax-highlighting"
# Prezto
zplug "modules/prompt", from:prezto
zstyle ':prezto:module:prompt' theme 'yen3'
@yen3
yen3 / build_ctags_cscope_gcc.sh
Last active November 11, 2016 03:32
A simple script to create ctags & cscope files for gcc 6.2.0
#!/usr/bin/env bash
find . -type f ! -path "*testsuite*" \
! -path "./.git/*" \
! -path "./gcc/testsuite/*" \
! -path "./INSTALL/*" \
! -path "./config/*" \
! -path "./libquadmath/*" \
! -path "./libssp/*" \
! -path "./libgo/*" \
! -path "./libtm/*" \
@yen3
yen3 / dump_call_graph.cpp
Last active November 11, 2016 14:09
GCC plugin: dump call graph for a single file.
#include "gcc-plugin.h"
#include "plugin-version.h"
#include "tree.h"
#include "cgraph.h"
#include <string>
#include <vector>
#include <map>
@yen3
yen3 / build_llvm.sh
Last active September 9, 2019 05:50
Build llvm manually
#!/bin/bash
set -ex
PREFIX=$HOME/usr/tools/llvm
LLVM_VERSION=7.0.0
BASE_URL=https://github.com/llvm/llvm-project/releases/download/llvmorg-${LLVM_VERSION}
COMPOMENT=(llvm cfe compiler-rt libcxx libcxxabi openmp clang-tools-extra polly libunwind)
@yen3
yen3 / striter.py
Created March 9, 2018 09:31 — forked from anacrolix/striter.py
A Python IO class wrapping an iterable of strings.
import io
class StringIteratorIO(io.TextIOBase):
def __init__(self, iter):
self._iter = iter
self._left = ''
def readable(self):
return True
@yen3
yen3 / aarch64_virt_install.sh
Last active April 6, 2025 01:20
aarch64 virt-install commands
#!/bin/bash
rm -rf /home/yen3/ubuntu.qcow2
qemu-img create -f qcow2 /home/yen3/ubuntu.qcow2 10G
virsh undefine ubuntu1604arm64 --nvram
install_from_localtion() {
virt-install -n ubuntu1604arm64 --memory 1024 --arch aarch64 --vcpus 1 \
--disk /home/yen3/ubuntu.qcow2,device=disk,bus=virtio \