Skip to content

Instantly share code, notes, and snippets.

View ronsims2's full-sized avatar
🏀
Ballin'

Ron Sims II ronsims2

🏀
Ballin'
View GitHub Profile
@ronsims2
ronsims2 / build.sh
Created May 1, 2023 02:06
Fix wasm-pack package file by adding a main entry to the package.json
#!/bin/zsh
# Run this from the root of the project!!!
wasm-pack build --target web --release
python fix_package_file.py
cd pkg
npm link
@ronsims2
ronsims2 / skills.txt
Last active May 1, 2023 13:25
Web Dev Skills Inventory - A growing list of what you need to know to be a web dev
## JS Fundamentals
data types | coersion | int vs float, strings, numerics
data structures | classic (array, object) | newer (map, frozen objects)
functions | named, anonymous, lambdas,
prototype | inheritance, this keyword
data types | coercion | int vs float, string numerics
logic expression
regular expressions
date and time
loops
@ronsims2
ronsims2 / 00-README-NEXT-SPA.md
Created March 30, 2023 13:19 — forked from rxs182/00-README-NEXT-SPA.md
Next.js SPA example with dynamic client-only routing and static hosting

Next.js client-only SPA example

Made this example to show how to use Next.js router for a 100% SPA (no JS server) app.

You use Next.js router like normally, but don't define getStaticProps and such. Instead you do client-only fetching with swr, react-query, or similar methods.

You can generate HTML fallback for the page if there's something meaningful to show before you "know" the params. (Remember, HTML is static, so it can't respond to dynamic query. But it can be different per route.)

Don't like Next? Here's how to do the same in Gatsby.

@ronsims2
ronsims2 / dogteam.py
Created December 3, 2022 22:16
Example: making API call is Python
import requests
import csv
def get_img(b, sub=''):
image_url = f'https://dog.ceo/api/breed/{b}/{sub}/images/random' if sub else f'https://dog.ceo/api/breed/{b}/images/random'
img_resp = requests.get(image_url)
img_data = img_resp.json()['message']
return img_data
@ronsims2
ronsims2 / jupyter_nb_tips.py
Last active August 5, 2022 17:04
Jupyter Notebook Tips
# Add spaces between plots
from IPython.core.display import Javascript
# place this after the code that displays the plots
# This code adds a small amount of margin to the bottom of each div that contains a plot image
Javascript('Array.from(document.querySelectorAll(".display_data")).forEach(item => item.style.marginBottom = "1rem")')
# Get the number of missing values group the the number of rows missing the same number of values
@ronsims2
ronsims2 / tricks.py
Last active June 28, 2022 01:34
Useful Colab/Jupyter Notebook Tricks
from google.colab import drive, files
drive.mount('/content/drive')
file_root = '/content/drive/MyDrive/Colab Notebooks/week_3/'
# The command below will list everything in the specified folder.
# Notice the statement converts the python variable into a shell variable if you prepend a "$"
%ls "$file_root"
function RocketFunc (payloadFunc, payloadParams, payloadContext) {
let launched = false
return (params, override) => {
if (!launched || override) {
launched = true
let parms = params ? params : payloadParams
return payloadFunc.apply(payloadContext, payloadParams)
}
}
}
@ronsims2
ronsims2 / hitchhikers_guide.md
Created November 26, 2019 14:44
Don't Panic!

Hitchhikers guide to Developer Sanity

  • pip is configured with locations that require TLS/SSL, however the ssl module in Python is not available.
    Delete virtual environmnet directory and install a new venv with a proper (brew installed) interpreter as the base.
@ronsims2
ronsims2 / commands.sh
Last active November 24, 2023 21:19
Command Line Fun
# XML - get a value using xmlint with xpath the @something (in this case "@string" is an attribute selector
xmllint --xpath "string(//Project/stuff/stuff/Stuff/@string)" some-data.pretty.xml | less
#Select by node index
xmllint --xpath "string(//Project/stuff/stuff[2]/Stuff/@string)" some.pretty.xml | less
# get password for MacOs keycahin assuming that the item is called foobar and the 'account' values is the same as the logged in user
MYPASSWORD=`security find-generic-password -a ${USER} -s foobar -w`
#Pretty print xml