Skip to content

Instantly share code, notes, and snippets.

Avatar
🤙
!

Sean Robertson spro

🤙
!
View GitHub Profile
@spro
spro / next-ssr-recoil-effects.js
Last active May 2, 2022
Another attempt at SSR with Recoil - setting initial atom values with Next.js getServerSideProps, this time with effects
View next-ssr-recoil-effects.js
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
View next-recoil-effects.js
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 Jan 5, 2021
Karabiner complex mapping to set Control_L to Esc when tapped, or Control when held
View ctrl-esc-karabiner.json
{
"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 Nov 20, 2022
Attempt at SSR with Recoil - setting initial atom values with Next.js getServerSideProps
View next-ssr-recoil.js
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 Nov 4, 2020
Example makefile for ESP8266/ESP32 with NodeMCU
View esp-example-Makefile
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 )
View grande-model.py
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 Aug 23, 2019
Installing Docker 18.09 on Amazon Linux 2 (As of August 22 2019)
View install-docker-18.09.sh
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
View build-countries-json.rb
require 'countries'
require 'json'
ISO3166.configure do |config|
config.locales = [:en, :cs, :de, :es, :fr, :ja, :nl, :sk]
end
# {
# AF: {
# name: {
View pytorch-conv1d-rnn.py
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
View aws-pytorch-anaconda-cuda.sh
#!/bin/bash
HOSTNAME=$1
# Set up environment
git clone http://github.com/spro/dotfiles
cd dotfiles && ./bin/install-dotfiles
cd ~
sudo hostname $HOSTNAME
source ~/.bash_profile