Skip to content

Instantly share code, notes, and snippets.

@flc
flc / gist:cc9cd8856a24a58531cc7aaf1de15231
Created November 8, 2021 18:58
WSL2 optimize VHD size
wsl --shutdown
diskpart
# open window Diskpart
select vdisk file="<path_to_vhdx>"
attach vdisk readonly
compact vdisk
detach vdisk
exit
@flc
flc / pytorch_colab
Created April 5, 2019 17:37
pytorch install google colab
from os.path import exists
from wheel.pep425tags import get_abbr_impl, get_impl_ver, get_abi_tag
platform = '{}{}-{}'.format(get_abbr_impl(), get_impl_ver(), get_abi_tag())
cuda_output = !ldconfig -p|grep cudart.so|sed -e 's/.*\.\([0-9]*\)\.\([0-9]*\)$/cu\1\2/'
accelerator = cuda_output[0] if exists('/dev/nvidia0') else 'cpu'
!pip install -q http://download.pytorch.org/whl/{accelerator}/torch-0.4.1-{platform}-linux_x86_64.whl torchvision
@flc
flc / ubuntu_sublime_install.sh
Last active March 25, 2018 01:07
ubuntu_sublime_install
wget -qO - https://download.sublimetext.com/sublimehq-pub.gpg | sudo apt-key add -
sudo apt-get install apt-transport-https
echo "deb https://download.sublimetext.com/ apt/stable/" | sudo tee /etc/apt/sources.list.d/sublime-text.list
sudo apt-get update
sudo apt-get install sublime-text
@flc
flc / xdotool.txt
Last active December 31, 2015 01:09
xdotool compile requirements
sudo apt-get install libx11-dev libxtst-dev libxinerama-dev libxkbcommon-dev
@flc
flc / hg_vs_git.txt
Last active August 29, 2015 14:05
hg vs git
hg init || git init
hg add <path> || git add <path>
hg commit -m 'Commit message' || git commit -m 'Commit message'
hg commit || git commit -a
hg status || git status -s
hg clone <path> || git clone <path>
hg branch <branchname> || git checkout -b <branchname> (-b also switch to new branch)
hg pull & hg update || git pull --all
hg diff || git diff HEAD
hg rm || git rm
@flc
flc / commands.txt
Last active May 25, 2022 14:20
useful unix commands
# display file with line numbers
cat file -n
# display gzipped file with line numbers
zcat file | cat -n
# display file from the i. line to j. line (that is j minus i there)
cat file | head -n j | tail -n j-i
# remove first line of the file (efficient)
@flc
flc / geany_go.sh
Last active December 22, 2015 09:49
little script that adds .go filetype support to Geany
cp /usr/share/geany/filetype_extensions.conf ~/.config/geany
echo "Go=*.go;" >> ~/.config/geany/filetype_extensions.conf
cp /usr/share/geany/filetypes.c ~/.config/geany/filedefs/filetypes.Go.conf
sed -i 's/extension=c/extension=go\nlexer_filetype=C/g' ~/.config/geany/filedefs/filetypes.Go.conf
sed -i 's/primary=.*/primary=break case chan const continue default defer else fallthrough for func go goto if import interface map package range return select struct switch type var/g' ~/.config/geany/filedefs/filetypes.Go.conf
sed -i 's/secondary=.*/secondary=byte int int8 int16 int32 int64 uint uint8 uint16 uint32 uint64 float32 float64 complex64 complex128 uintptr string/g' ~/.config/geany/filedefs/filetypes.Go.conf
@flc
flc / btrees_eq.go
Created September 5, 2013 16:07
A Tour of Go - Exercise: Equivalent Binary Trees http://tour.golang.org/#70
package main
import "code.google.com/p/go-tour/tree"
import "fmt"
func _walk(t *tree.Tree, ch chan int) {
if t.Left != nil {
_walk(t.Left, ch)
}
@flc
flc / rot13.go
Created September 4, 2013 15:59
A Tour of Go - Exercise: Rot13 Reader http://tour.golang.org/#61
package main
import (
"io"
"os"
"strings"
//"fmt"
"bytes"
)
@flc
flc / image.go
Created September 4, 2013 14:17
A Tour of Go - Exercise: Images http://tour.golang.org/#60
package main
import (
"code.google.com/p/go-tour/pic"
"image"
"image/color"
)
type Image struct{