Skip to content

Instantly share code, notes, and snippets.

Avatar

Yao Lu AStupidBear

View GitHub Profile
View julia-pkg-gen.jl
#!/usr/bin/env julia
using Pkg
if !haskey(Pkg.installed(), "PkgTemplates")
pkg"add https://github.com/invenia/PkgTemplates.jl#master"
end
using PkgTemplates
t = Template(
View lstm.jl
using Flux, Random, Statistics
Random.seed!(1234)
x = randn(Float32, 10, 1, 100)
y = mean(x, dims = 1)
model = Chain(LSTM(10, 100), LSTM(100, 1))
function loss(x, y)
View nfs-install.sh
#!/bin/bash
iface=$(ip addr show | awk '/inet.*brd/{print $NF; exit}')
hostip=$(ip addr show $iface | grep 'inet ' | awk '{print $2}' | cut -f1 -d'/')
user=${1-$USER}
pass=${2-abc1234}
root=${3-/BIGDATA1}
cat |sudo tee -a /etc/exports << EOF
$root *(rw,sync,no_root_squash,no_subtree_check)
EOF
View prsync.sh
#!/bin/bash
args=("$@")
src=${args[$(($#-2))]}
dst=${args[$(($#-1))]}
rsyncopt=${@:1:$#-2}
if [[ ! $dst == *:* ]]; then
mkdir -p $dst
fi
find $src -mindepth 1 -maxdepth 1 | sort -nr | xargs -n 1 -P 10 -I {} bash -c """
name=\$(basename {})
View shape_inference.py
import numpy as np
import onnx
import sys
from onnx import helper, numpy_helper, shape_inference
import sympy
from packaging import version
assert version.parse(onnx.__version__) >= version.parse("1.5.0")
View onnxruntime.Dockerfile.py
#!/usr/bin/env python
try:
from pydocker import DockerFile
except ImportError:
try:
from urllib.request import urlopen
except ImportError:
from urllib import urlopen
exec(urlopen('https://raw.githubusercontent.com/AStupidBear/pydocker/master/pydocker.py').read())
@AStupidBear
AStupidBear / plots-compile.jl
Last active Mar 30, 2020
Compile Plots.jl to shorten first-to-plot time
View plots-compile.jl
#!/usr/bin/env julia
using Pkg
pkg"add PackageCompiler Plots StatsPlots PyPlot"
using PackageCompiler
snoop = tempname()
open(snoop, "w") do fid
println(fid, "using Plots")
println(fid, "p=plot(rand(5), rand(5))")
View sysbench.sh
#!/usr/bin/sudo bash
mkdir sysbench && cd sysbench
# install docker
if ! which docker; then
apt-get install docker.io hardinfo
fi
if ! which nvidia-container-cli; then
distribution=$(. /etc/os-release;echo $ID$VERSION_ID)
@AStupidBear
AStupidBear / elemental-install.sh
Created Oct 6, 2019
Install Elemental for Julia
View elemental-install.sh
#!/bin/bash
julia -e 'using Pkg; Pkg.rm("Elemental"); Pkg.gc(); Pkg.add("Elemental")'
script="$JULIA_DEPOT_PATH/packages/Elemental/*/deps/build.jl"
sed -i 's:79987d38b04838acf6b6195be1967177521ee908:477e503a7a840cc1a75173552711b980505a0b06:g' $script
sed -i 's:-D PYTHON_EXECUTABLE="":-D PYTHON_EXECUTABLE=""\n-D EL_DISABLE_PARMETIS=ON:g' $script
julia -e 'using Pkg; Pkg.build("Elemental")'
sed -i 's:\n-D EL_DISABLE_PARMETIS=ON::g' $script
sed -i 's:477e503a7a840cc1a75173552711b980505a0b06:79987d38b04838acf6b6195be1967177521ee908:g' $script
View win32openssh-install.ps1
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
Invoke-WebRequest "https://github.com/PowerShell/Win32-OpenSSH/releases/download/v8.0.0.0p1-Beta/OpenSSH-Win64.zip" -OutFile OpenSSH-Win64.zip
Add-Type -AssemblyName System.IO.Compression.FileSystem
function Unzip
{
param([string]$zipfile, [string]$outpath)
[System.IO.Compression.ZipFile]::ExtractToDirectory($zipfile, $outpath)
}
Unzip OpenSSH-Win64.zip "C:\Program Files\"