Skip to content

Instantly share code, notes, and snippets.

View jyhsu2000's full-sized avatar

KID jyhsu2000

View GitHub Profile
@jyhsu2000
jyhsu2000 / SerializationUtil.java
Last active February 18, 2024 16:05
Serialize and deserialize ItemStack in Bukkit/Spigot
package club.kid7.bannermaker.util;
import org.bukkit.util.io.BukkitObjectInputStream;
import org.bukkit.util.io.BukkitObjectOutputStream;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.util.Base64;
@jyhsu2000
jyhsu2000 / aggregate_timers.py
Last active June 30, 2023 06:31
Aggregate timing data of `codetiming.Timer`
import pandas as pd
from codetiming import Timer
timer_dfs = []
for timer_name in Timer.timers:
timer_dfs.append(pd.DataFrame({
'timer': timer_name,
'count': Timer.timers.count(timer_name),
'total': Timer.timers.total(timer_name),
'min': Timer.timers.min(timer_name),
@jyhsu2000
jyhsu2000 / tmux_start.sh
Created July 7, 2021 03:22
tmux start command
# Start session and run htop and nvtop
tmux new-session \; splitw -v -p 50 'htop' \; selectp -t 1 \; splitw -h -p 50 'nvtop' \; selectp -t 1
<!DOCTYPE html>
<html>
<head>
<title>Image drawing with canvas</title>
</head>
<body>
<input type="file" name="fileChooser" id="fileChooser" accept="image/jpeg"><br />
<canvas width="400" height="300" id="canvas" />
find . -maxdepth 1 -mindepth 1 -type d -exec sh -c 'echo "{} : $(find "{}" -type f | wc -l)" file\(s\)' \;
@jyhsu2000
jyhsu2000 / find_inactive_users.sh
Last active January 30, 2020 02:48
Find inactive users
lastlog -b 90 | tail -n+2 | grep -v 'Never log'
lastlog -b 90 | tail -n+2 | grep -v '從未登入過'
lastlog -b 90 | tail -n+2 | grep -v '\*\*'
@jyhsu2000
jyhsu2000 / jupyterhub.service
Created July 3, 2019 06:51
/etc/systemd/system/jupyterhub.service
[Unit]
Description=Jupyterhub
After=syslog.target network.target
[Service]
User=root
Environment="PATH=/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin"
ExecStart=/usr/local/bin/jupyterhub -f /etc/jupyterhub/jupyterhub_config.py
[Install]
@jyhsu2000
jyhsu2000 / BukkitDev-Redirect.user.js
Last active February 21, 2019 17:51
BukkitDev Redirect
// ==UserScript==
// @name BukkitDev Redirect
// @namespace https://gist.github.com/jyhsu2000
// @version 1.0
// @description Redirect old url of bukkit to new one
// @author KID
// @include http://dev.bukkit.org/server-mods/*
// @include https://dev.bukkit.org/server-mods/*
// @grant none
// @run-at document-start
@jyhsu2000
jyhsu2000 / pivot_example.php
Created January 24, 2019 10:07 — forked from lighta971/pivot_example.php
Laravel Custom Pivot Model definition example
<?php
//https://github.com/laravel/framework/issues/2093#issuecomment-39154456
use Illuminate\Database\Eloquent\Model as Eloquent;
use Illuminate\Database\Eloquent\Relations\Pivot;
class User extends Eloquent {
public function groups() {
return $this->belongsToMany('Group');
@jyhsu2000
jyhsu2000 / plurk-custom.css
Last active August 18, 2018 03:43
Plurk Custom Style
@font-face {
font-family: DSEG7-Classic;
src: url(https://cdn.rawgit.com/keshikan/DSEG/8a05bd89/fonts/DSEG7-Classic/DSEG7Classic-Regular.woff2) format('woff2'),url(https://cdn.rawgit.com/keshikan/DSEG/8a05bd89/fonts/DSEG7-Classic/DSEG7Classic-Regular.woff) format('woff'),url(https://cdn.rawgit.com/keshikan/DSEG/8a05bd89/fonts/DSEG7-Classic/DSEG7Classic-Regular.ttf) format('truetype');
font-weight: 200;
}
#updater .item a {
background-color: #fb0047;
color: white;
}