Skip to content

Instantly share code, notes, and snippets.

#!/bin/sh
sudo chmod 666 /sys/bus/pci/devices/0000\:$1\:00.0/remove
sudo echo 1 > /sys/bus/pci/devices/0000\:$1\:00.0/remove
sudo chmod 666 /sys/bus/pci/rescan
sudo echo "1" > /sys/bus/pci/rescan
git filter-branch --tree-filter "rm -f <file>" HEAD
git filter-branch --tree-filter "rm -f -r <directory>/" HEAD
hex_str = '10010000214601360121470136007EFE09D21901'
sum = sum(int(b) for b in bytearray.fromhex(hex_str)) & 0xff
print(hex((0x100-(sum)) & 0xff))
@nv-h
nv-h / github.user.css
Last active December 1, 2021 03:42
Custom CSS for Typora
/* refer: https://support.typora.io/Custom-Font/ */
#typora-source {
font-family: Utatane;
--monospace: Utatane; /* for code blocks and inline code inside source code mode */
}
body {
--monospace: Utatane /* for all code blocks, inline code, and source code mode */
}
git filter-branch -f --env-filter "\
GIT_AUTHOR_NAME='nv-h'; \
GIT_AUTHOR_EMAIL='saido_nv@gmail.com'; \
GIT_COMMITTER_NAME='nv-h'; \
GIT_COMMITTER_EMAIL='saido_nv@gmail.com'; \
" HEAD
@nv-h
nv-h / Microsoft.PowerShell_profile.ps1
Last active November 15, 2021 05:25
Windows PowerShell Ctrl+R history with fzf
# PowerShell Core7でもConsoleのデフォルトエンコーディングはsjisなので必要
[System.Console]::OutputEncoding = [System.Text.Encoding]::GetEncoding("utf-8")
[System.Console]::InputEncoding = [System.Text.Encoding]::GetEncoding("utf-8")
# git logなどのマルチバイト文字を表示させるため (絵文字含む)
$env:LESSCHARSET = "utf-8"
# 音を消す
Set-PSReadlineOption -BellStyle None
@nv-h
nv-h / plotly_place_image_on_datetime_xaxis.py
Last active December 1, 2020 10:50
In Plotly, place an image of any size at any position on the X axis in datetime format.
import plotly.graph_objects as go
from datetime import datetime, timedelta
# Create figure
fig = go.Figure()
now = datetime.now()
print(now)
# Increment 1 hour
@nv-h
nv-h / fsbl_build_debug.tcl
Created October 12, 2018 02:35
Zynq FSBL script
setws .
set symbol [configapp -app fsbl define-compiler-symbols]
if {[string first "FSBL_DEBUG_INFO" $symbol] == -1} {
configapp -app fsbl -add define-compiler-symbols FSBL_DEBUG_INFO
projects -clean -type app -name fsbl
}
projects -build -type app -name fsbl
@nv-h
nv-h / usb_config_multi.sh
Last active September 27, 2022 00:02
USB Gadget Ether & Mass Storage
#!/bin/sh
# https:/github.com/torvalds/linux/blob/master/Documentation/usb/gadget_configfs.txt
# http:/irq5.io/2016/12/22/raspberry-pi-zero-as-multiple-usb-gadgets/
# 上記2つを参考に同時に二つのガジェットを有効化する。
# 1. mass storageで、SDカードをUSBメモリとして見せる
# 2. rndisで、USBをetherデバイスとして見せる
# ドライバを依存関係含めてロード
modprobe usb_f_rndis