Skip to content

Instantly share code, notes, and snippets.

@yiidtw
yiidtw / run_qemu_ubuntu2204_arm64.sh
Created March 31, 2024 18:21
This is a simple script to run qemu arm64 system simulation on x86 host with prebuilt image. Tested on QEMU emulator version 6.2.0 on Ubuntu22.04 LTS host.
#!/bin/sh
# Disclaimer:
# This is a simple script to run qemu arm64 system simulation on x86 host with
# prebuilt image. Tested on QEMU emulator version 6.2.0 on Ubuntu22.04 LTS host.
#
# Directory layout:
# qemu_ubuntu2204_arm64;
# ├── cloud-config.img
@yiidtw
yiidtw / run_starter_fs.sh
Last active March 31, 2024 14:17
simple script to run gem5 full system simulation with configs/example/arm/starter_fs.py
#!/bin/sh
# Disclaimer:
# This is a simple script to run gem5 full system simulation.
# Tested on gem5 version 23.1.0.0.
# Quickstart and compile gem5: https://www.gem5.org/getting_started/
# prebuilt kernel image: http://dist.gem5.org/dist/v22-0/arm/aarch-system-20220707.tar.bz2
# prebuilt rootfs: http://dist.gem5.org/dist/current/arm/disks/linaro-minimal-aarch64.img.bz2
# Author of this script: yiidtw
@yiidtw
yiidtw / random_quote_bot.js
Created June 16, 2021 00:25
Google Script for random quote Line Bot
function doPost(e) {
var CHANNEL_ACCESS_TOKEN = '<your channel access token>';
var msg= JSON.parse(e.postData.contents);
console.log(msg);
var replyToken = msg.events[0].replyToken;
var userMessage = msg.events[0].message.text;
if (typeof replyToken === 'undefined') {
return;
# .bashrc
################################################################################
# python environment control
################################################################################
export PYTHON_ENV=""
function entervirtualenv
{
if type virtualenvwrapper.sh >/dev/null 2>&1; then
# .bashrc
################################################################################
# python environment control
################################################################################
export PYTHON_ENV=""
function entervirtualenv
{
if type virtualenvwrapper.sh >/dev/null 2>&1; then
@yiidtw
yiidtw / todo.html
Last active July 19, 2020 10:02
todo-list app using vue.js in 100 lines of code (create, read, update, delete todo list using local storage)
<!DOCTYPE html>
<html>
<head>
<script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>
<style>
.done {
text-decoration: line-through
}
</style>
</head>
@yiidtw
yiidtw / gist:2db129b7244143b0e49bb8eb85f42289
Created October 2, 2019 07:16 — forked from johanmeiring/gist:3002458
"git lg" alias for pretty git log
# From http://garmoncheg.blogspot.com/2012/06/pretty-git-log.html
git config --global alias.lg "log --color --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit --"
@yiidtw
yiidtw / str_to_timestamp.py
Created August 30, 2019 09:28
convert UTC datetime in string to unix timestamp using python3
import datetime
import dateutil.parser # pip install python-dateutil
s = '2019-05-15T01:23:54Z'
d = dateutil.parser.parse(s)
t = d.replace(tzinfo=datetime.timezone.utc).timestamp()
# s = '2019-05-15T01:23:54Z'
# d = datetime.datetime(2019, 5, 15, 1, 23, 54, tzinfo=tzutc())
# t = 1557883434.0
@yiidtw
yiidtw / migration_ad_hoc_command.sh
Last active August 16, 2019 09:13
snippet for pg and es migration
pg_dump -h db_host -U user_name -p 5432 -F c -v -f /path/to/backup/data.bak db_name
pg_restore -v -h db_host -p 5432 -U user_name -d db_name /path/to/backup/data.bak
curl -X GET 'http://localhost:9200/_cat/indices?v'
# dump
elasticdump --input=http://localhost:9200/index_name --output=/path/to/backup/data.json --type=data
# restore
elasticdump --input=/tmp/aa.aisoc/ds_as.json --output=http://localhost:9200 --type=data --headers='{"content-type": "application/json"}'