Skip to content

Instantly share code, notes, and snippets.

View paidi's full-sized avatar

Páidí Creed paidi

View GitHub Profile
@paidi
paidi / gist:ea669037b68fd8ad2da25086b3d9d296
Last active September 7, 2023 08:59
Loading DM Sans in matplotib
import matplotlib.font_manager as fm
import matplotlib.pyplot as plt
# Fetch DM Sans font file from https://github.com/google/fonts/blob/main/ofl/dmsans/DMSans%5Bopsz%2Cwght%5D.ttf
font_dir = ['.']
for font in fm.findSystemFonts(font_dir):
fm.fontManager.addfont(font)
# Set font family globally
plt.rcParams['font.family'] = 'DM Sans'
git clone --bare https://github.com/paidi/dotfiles.git $HOME/.cfg
function config {
/usr/bin/git --git-dir=$HOME/.cfg/ --work-tree=$HOME $@
}
mkdir -p .config-backup
config checkout
if [ $? = 0 ]; then
echo "Checked out config.";
else
echo "Backing up pre-existing dot files.";
@paidi
paidi / gist:310d2d869ef74794b239
Last active February 14, 2017 10:29
Batch SparseLinear
m = nn.ParallelTable()
layer = nn.SparseLinear(inputSize,outputSize)
m:add(nn.Sequential():add(layer):add(nn.Reshape(1,outputSize)))
for i=2,batchSize do
local repLayer = layer:clone('weight', 'bias', 'gradWeight', 'gradBias')
m:add(nn.Sequential():add(repLayer):add(nn.Reshape(1,outputSize)))
end
batchLayer = nn.Sequential():add(m):add(nn.JoinTable(1))
local Adder = {}
Adder.__index = Adder
function Adder.new()
local adder = {}
setmetatable(adder, Adder)
adder.total = 0
return adder
end
local total = 0
for i=1,1000000 do
total = total + i
end
print(total)