Skip to content

Instantly share code, notes, and snippets.

#!/bin/bash
set -eEuxo pipefail
export PATH="$HOME/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
export LD_LIBRARY_PATH="$HOME/.local/lib64"
trap 'exit -1' ERR
pushd "$HOME/llvm-project"
rm -r ./build || true
@shunghsiyu
shunghsiyu / model-checking-bpf-verifier-presentation.ipynb
Last active August 11, 2022 05:24
Fix description of tnum.mask, and use C-style comment
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@shunghsiyu
shunghsiyu / work_history.py
Created February 15, 2022 05:49
Python script for review usage history
#!/usr/bin/env python3
#
# Output both history of bash commands and Firefox visits in reverse
# chronological order.
import configparser
import logging
import os
import re
import shutil
import sqlite3
@shunghsiyu
shunghsiyu / README.md
Last active June 7, 2021 07:37 — forked from somic/udp_hole_punch_tester.py
Scripts to setup mosh connection with server behind firewall

mosh-nat

Scripts to setup mosh connection with server behind firewall

Setup

  • Install the stuntman package to get the stunclient binary both locally and on the server
  • Place the udp_hole_punch script inside a directory that is in $PATH so that it can be called; both locally and on the server
  • Compile mosh-nat-bind.c into mnb.so and place it inside $HOME/bin/ locally (don't need it on server)
@shunghsiyu
shunghsiyu / README.md
Created July 12, 2020 08:14
PyCon TW 2020 Fixtures

How to import

python manage.py loaddata $PATH_TO_FIXTURES_JSON

How to create

The fixtures.json is created by running python manage.py dumpdata --indent=2 users proposals events

Reference

@shunghsiyu
shunghsiyu / graph.html
Created January 21, 2018 10:14
Show Analytic Data
This file has been truncated, but you can view the full file.
<html><head><meta charset="utf-8" /></head><body><script type="text/javascript">/**
* plotly.js v1.31.2
* Copyright 2012-2017, Plotly, Inc.
* All rights reserved.
* Licensed under the MIT license
*/
!function(t){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else{var e;e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this,e.Plotly=t()}}(function(){var t;return function t(e,r,n){function i(o,s){if(!r[o]){if(!e[o]){var l="function"==typeof require&&require;if(!s&&l)return l(o,!0);if(a)return a(o,!0);var u=new Error("Cannot find module '"+o+"'");throw u.code="MODULE_NOT_FOUND",u}var c=r[o]={exports:{}};e[o][0].call(c.exports,function(t){var r=e[o][1][t];return i(r||t)},c,c.exports,t,e,r,n)}return r[o].exports}for(var a="function"==typeof require&&require,o=0;o<n.length;o++)i(n[o]);return i}({1:[function(t,e,r){"use strict";var n=t("../src/lib"),i={"X,X div":"font-family:'Open
@shunghsiyu
shunghsiyu / index.html
Created October 19, 2017 08:13
ThaiWebpage1
<!DOCTYPE html>
<html lang="zh-TW">
<head>
<meta charset="utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="https://fonts.googleapis.com/icon?family=Material+Icons">
<link rel="stylesheet" href="https://code.getmdl.io/1.3.0/material.teal-orange.min.css" />
<script src="https://code.getmdl.io/1.3.0/material.min.js"></script>
<style>
@shunghsiyu
shunghsiyu / app.js
Last active August 23, 2017 09:41
Show the query URL
const express = require('express')
const app = express()
app.get('*', function (req, res) {
res.send(`<body style="white-space: pre-wrap" width="100%" height="100%">
You are visiting: ${req.path}
You send the following query:
${JSON.stringify(req.query, null, 4)}
@shunghsiyu
shunghsiyu / wifi-login.js
Last active February 1, 2017 13:22
This is a script to be used together with Phantomjs to automatically login to CHT wifi access-points.
var url = 'http://captive.apple.com/';
var fs = require('fs');
var file = fs.open('credential', 'r');
var credentials = file.read().split('\n');
file.close();
// How often (in milliseconds) the program should check the login status.
var checkInterval = 5000;
// How long (in millisecond) should be program wait after the submit button
// on the login form is pressed before closing the page object.
@shunghsiyu
shunghsiyu / intro_to_python_20150825.ipynb
Last active August 26, 2015 13:51
An Introduction to Python for Developers
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.