Skip to content

Instantly share code, notes, and snippets.

View schnell18's full-sized avatar

Justin Zhang schnell18

View GitHub Profile
@schnell18
schnell18 / virtualization-check.sh
Last active February 11, 2021 05:35
Verify the virtualization support on various OSes
# Verify the virtualization support on your Linux OS
# (a non-empty output indicates supported virtualization):
grep -E --color 'vmx|svm' /proc/cpuinfo
# Verify the virtualization support on your macOS
# (VMX in the output indicates enabled virtualization)
sysctl -a | grep -E --color 'machdep.cpu.features|VMX'
@schnell18
schnell18 / max-temp-reducer.rb
Created June 5, 2020 13:02
Max temperature reducer in Ruby
#!/usr/bin/env ruby
last_key, max_val = nil, -1000000
STDIN.each_line do |line|
key, val = line.split("\t")
if last_key && last_key != key
puts "#{last_key}\t#{max_val}"
last_key, max_val = key, val.to_i
else
last_key, max_val = key, [max_val, val.to_i].max
@schnell18
schnell18 / ipython-setup.md
Created April 19, 2020 10:22
Load line_profiler and memory_profiler

Introduction

install line_profiler module

conda install line_profiler

load line_profiler into ipython on startup

cat<<EOF > ~/.ipython/profile_default/startup/001-load-line-profiler.ipy

%load_ext line_profiler

@schnell18
schnell18 / settings-manjaro.json
Created April 4, 2020 13:11
VS Code LaTeX Workshop manjaro settings /w okular
{
"latex-workshop.latex.autoBuild.run": "onFileChange",
"latex-workshop.message.error.show": true,
"latex-workshop.message.warning.show": true,
"latex-workshop.latex.tools": [{
"name": "xelatex",
"command": "xelatex",
"args": [
"-synctex=1",
"-shell-escape",
@schnell18
schnell18 / settings.json
Last active March 22, 2020 15:06
VS Code settings.json w/ LaTeX workshop synctex setting
{
"go.formatTool": "goimports",
"go.docsTool": "guru",
"editor.largeFileOptimizations": false,
"latex-workshop.latex.autoBuild.run": "never",
"latex-workshop.message.error.show": false,
"latex-workshop.message.warning.show": false,
"latex-workshop.latex.tools": [{
"name": "xelatex",
"command": "xelatex",
@schnell18
schnell18 / fix_wifi.sh
Created March 10, 2020 14:43
Manjaro fix wifi connection disappear
sudo systemctl stop NetworkManager
sudo mv /var/lib/NetworkManager/NetworkManager.state /var/lib/NetworkManager/NetworkManager.state.bak
sudo systemctl stop NetworkManager
@schnell18
schnell18 / remove_vb_disk_file.sh
Last active February 24, 2020 04:53
remove virtualbox disk file
GUEST="slave-1"
vboxmanage list hdds \
| sed -e '/./{H;$!d;}' -e 'x;/'"$GUEST"'/!d;' \
| grep UUID | egrep -v Parent | awk '{print $2}' \
| xargs -I{} vboxmanage closemedium disk {} --delete
# vboxmanage list hdds \
# | sed -e '/./{H;$!d;}' -e 'x;/'"$GUEST"'/!d;' \
# | grep UUID | egrep -v Parent | awk '{print $2}' \
# | xargs -I{} echo vboxmanage closemedium disk {} --delete
@schnell18
schnell18 / flyway-mysql-5.6-error.txt
Created January 5, 2020 11:19
flyway mysql 5.6 error
> Task :flyway:flywayMigrate FAILED
:flyway:flywayMigrate (Thread[Execution worker for ':',5,main]) completed. Took 9.075 secs.
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':flyway:flywayMigrate'.
> Error occurred while executing flywayMigrate
Flyway Enterprise Edition or MySQL upgrade required: MySQL 5.6 is no longer supported by Flyway Community Edition, but still supported by Flyway Enterprise Edition.
@schnell18
schnell18 / disable-appamor.sh
Last active January 5, 2020 10:59
Script to fix failure to stop docker container on Ubuntu 18.04 w/ appamor enabled.
# sudo docker-compose down
# Stopping flyway_db_1 ... error
#
# ERROR: for flyway_db_1 cannot stop container: b507d5ca35c67a38164df406656c32484390353b51f43357d565b25aa7cfbfd1: Cannot kill container b507d5ca35c67a38164df406656c32484390353b51f43357d565b25aa7cfbfd1: unknown error after kill: runc did not terminate sucessfully: container_linux.go:388: signaling init process caused "permission denied"
# : unknown
# Removing network flyway_default
# ERROR: error while removing network: network flyway_default id 8bdd09b60e327fce1aad7bf887ec9a14a2aade50b03b1acee6f3befc1fc08b56 has active endpoints
#
# uname -a
# Linux omen4-hp 5.0.0-37-generic #40~18.04.1-Ubuntu SMP Thu Nov 14 12:06:39 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux
@schnell18
schnell18 / add-to-developer-group.sh
Created October 20, 2019 14:27
Add user to developer groups
sudo dscl . append /Groups/_developer GroupMembership justin