Skip to content

Instantly share code, notes, and snippets.

Avatar

Alan Smith alanwsmith

View GitHub Profile
View gist:8f5c16b21a386dd594291a9d13842728
#!/usr/bin/env python3
stuff = {
"x": 10,
"y": 10
}
sinput = "x == y"
parts = sinput.split(" == ")
@alanwsmith
alanwsmith / i-do-not-get-it.js
Created Nov 26, 2021
Trying to figure out why https calls happen together at the end instead of interspersed
View i-do-not-get-it.js
// The code below will output:
//
// Getting: https://www.example.com/
// Getting: https://www.example.org/
// Getting: https://www.example.net/
// 200
// 200
// 200
//
// Given that there's a 5 second delay between https
@alanwsmith
alanwsmith / preview_file.lua
Created Jun 11, 2021
Is this a safe way to preview files in Neovim with a Lua plugin? Is there a better way?
View preview_file.lua
local search_buffer, search_window
local document_buffer, document_window
local storage_dir = "/Users/alans/Desktop/neovim-test-files/"
local function open_file()
local file_name = vim.api.nvim_buf_get_lines(search_buffer, 0, 1, true)
-- I do scrubbing to make sure the file is valid but
-- have removed it to focus on the preview part of the example
local file_path = storage_dir..'/'..file_name[1]
vim.api.nvim_set_current_win(document_window)
View gist:c72539123bc8009f85d56147b0cead85
from PIL import Image
with Image.open('image-2021-05-01T13-10-39-0400.png') as im:
img = Image.new('RGB', (1000, 1000), color = 'white')
px = im.load()
for x in range(301, 309):
for y in range(61, 67):
@alanwsmith
alanwsmith / gist:a908202622af3ec3bfd8f3148af6179c
Created Apr 30, 2021
Basic Twitch EventSub Server Example
View gist:a908202622af3ec3bfd8f3148af6179c
import json
import os
from flask import Flask, request, Response
app = Flask(__name__)
@app.route('/webhooks/twitch-callback', methods=['POST'])
def respond():
@alanwsmith
alanwsmith / example.js
Created Apr 7, 2021
Playing around with alternative to Newspaper Code Structure (via: https://kentcdodds.com/blog/newspaper-code-structure)
View example.js
///////////////////////////////////////////////////////////////////////
// This is changing the grouping and alphabetization of the initial //
// example to gauge readability. //
///////////////////////////////////////////////////////////////////////
export const thereIsABetterWay = true
export const bar = {
View gist:4b6e5dfa467a2774475bc72c0503a768
100101110111011102132|01011001002020|010110010012|010110010021|10010111011101110
@alanwsmith
alanwsmith / gist:7d344c2b60e79bac39b122ccb186b508
Created Dec 15, 2020
Example of viewing permissions in postgres with `\du` vs `\l`
View gist:7d344c2b60e79bac39b122ccb186b508
postgres-# \du
List of roles
Role name | Attributes | Member of
---------------------+------------------------------------------------------------+-----------
launchpad_dev_user | | {}
launchpad_prod_user | | {}
postgres | Superuser, Create role, Create DB, Replication, Bypass RLS | {}
toolkit_dev_user | | {}
toolkit_prod | | {}
toolkit_prod_user | | {}
View keybase.md

Keybase proof

I hereby claim:

  • I am alanwsmith on github.
  • I am alanwsmith (https://keybase.io/alanwsmith) on keybase.
  • I have a public key whose fingerprint is C0F2 EE68 14B7 0E30 6CF6 1089 00BE 4373 A2A5 1665

To claim this, I am signing this object:

@alanwsmith
alanwsmith / jump-to-marks.zsh
Created Aug 25, 2013
A version of Jeroen Janssens' "Quickly navigate your filesystem from the command-line" code (including autocomplete) setup for a Mac running OS X 10.8 and a ZSH shell. (Note that I've changed the name of the 'jump' command to 'jt' to make it shorter and easier to type.) Original article: http://jeroenjanssens.com/2013/08/16/quickly-navigate-your…
View jump-to-marks.zsh
# Based on: Quickly navigate your filesystem from the command-line
# http://jeroenjanssens.com/2013/08/16/quickly-navigate-your-filesystem-from-the-command-line.html
# by Jeroen Janssens
# Notes:
# - This version is for Mac OSX 10.8 using ZSH.
# - It includes autocomplete functionality.
# - The original 'jump' command changed to 'jt' (think Jump To).
# - Marks are stored in '~/.jumptomarks' instead of '~/.marks'.
# - The '~/.jumptomarks' dir is created automatically by using 'mark'