Skip to content

Instantly share code, notes, and snippets.

View spro's full-sized avatar
🤙
!

Sean Robertson spro

🤙
!
View GitHub Profile
@spro
spro / init.lua
Last active September 30, 2023 18:05
A simpler nvim setup
-- Indentation
vim.o.autoindent = true
vim.o.smarttab = true
vim.o.expandtab = true
vim.o.tabstop = 4
vim.o.shiftwidth = 4
vim.o.softtabstop = 4
vim.o.backspace = "2"
-- Searching
@spro
spro / next-ssr-recoil-effects.js
Last active December 23, 2022 09:16
Another attempt at SSR with Recoil - setting initial atom values with Next.js getServerSideProps, this time with effects
import {useEffect, useMemo} from 'react'
import {RecoilRoot, useRecoilState, atom} from 'recoil'
// User data
const user1 = {username: 'joe', bio: "You will never see me, unless of course this example is totally broken."}
const user2 = {username: 'bob', bio: "I am the one true user."}
const user3 = {username: 'fred', bio: "Just kidding, make way for the new guy."}
// A potentially dangerous mutable global variable for initial state. The main
import {useEffect} from 'react'
import {RecoilRoot, useRecoilState, atom} from 'recoil'
// User data
const user1 = {username: 'joe', bio: "You will never see me, unless of course this example is totally broken."}
const user2 = {username: 'bob', bio: "I am the one true user."}
const user3 = {username: 'fred', bio: "Just kidding, make way for the new guy."}
// Recoil atom to store user. The default user is user1, but it will be
@spro
spro / ctrl-esc-karabiner.json
Created January 5, 2021 02:13
Karabiner complex mapping to set Control_L to Esc when tapped, or Control when held
{
"title": "Control_L to Esc when tapped",
"rules": [
{
"description": "Control_L to Esc when tapped, Control when held.",
"manipulators": [
{
"type": "basic",
"from": {
"key_code": "left_control",
@spro
spro / next-ssr-recoil.js
Last active January 7, 2024 16:22
Attempt at SSR with Recoil - setting initial atom values with Next.js getServerSideProps
import {useEffect} from 'react'
import {RecoilRoot, useRecoilState, atom} from 'recoil'
// User data
const user1 = {username: 'joe', bio: "You will never see me, unless of course this example is totally broken."}
const user2 = {username: 'bob', bio: "I am the one true user."}
const user3 = {username: 'fred', bio: "Just kidding, make way for the new guy."}
// Recoil atom to store user. The default user is user1, but it will be
@spro
spro / esp-example-Makefile
Created November 4, 2020 05:19
Example makefile for ESP8266/ESP32 with NodeMCU
PORT=/dev/cu.usbserial-AL00FP1H
LUAS=name.lc helpers.lc sta.lc blink.lc tcpclient.lc ir.lc
all: name init $(LUAS)
init:
nodemcu-tool -p $(PORT) upload init.lua
name:
@[ "${DEVICE_NAME}" ] || ( echo ">> DEVICE_NAME is not set"; exit 1 )
class User(Model):
name: str
email: str
@to_one
def best_friend(self) -> User: pass
@to_many
def following(self) -> List[User]: pass
@spro
spro / install-docker-18.09.sh
Last active August 23, 2019 00:15
Installing Docker 18.09 on Amazon Linux 2 (As of August 22 2019)
sudo yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
sudo yum install -y http://mirror.centos.org/centos/7/extras/x86_64/Packages/container-selinux-2.68-1.el7.noarch.rpm
sudo yum install -y docker-ce-18.09.5 containerd.io-1.2.2
sudo usermod -a -G docker ec2-user
sudo systemctl start docker
require 'countries'
require 'json'
ISO3166.configure do |config|
config.locales = [:en, :cs, :de, :es, :fr, :ja, :nl, :sk]
end
# {
# AF: {
# name: {
import torch
from torch import nn
from torch.autograd import Variable
import torch.nn.functional as F
class RNN(nn.Module):
def __init__(self, input_size, hidden_size, output_size, n_layers=1):
super(RNN, self).__init__()
self.input_size = input_size
self.hidden_size = hidden_size