Skip to content

Instantly share code, notes, and snippets.

View ramcandrews's full-sized avatar
🏠
Working from home

Ryan McAndrews ramcandrews

🏠
Working from home
View GitHub Profile
@ramcandrews
ramcandrews / base reset css
Created April 22, 2023 00:42
Use this to reset the css styles so thigns are easier to debug.
*, *::before, *::after {
box-sizing: border-box;
}
* {
margin: 0;
padding: 0;
font: inherit;
}
@ramcandrews
ramcandrews / select empty elements
Last active April 22, 2023 00:33
hide anything that does not have inner text
div:empty {
outline: 2px solid deeppink;
height: 1em;
}
:empty:not(img, picture, button, input) {
display: none;
}
/* https://youtube.com/shorts/zoJkZ7GC1s4?feature=share */
@ramcandrews
ramcandrews / easy responsive width
Last active April 22, 2023 00:27
responsive container with gutter and a max width, center horizontally,
.container {
width: min(100% - 2rem, 600px);
margin-inline: auto;
}
/* https://youtube.com/shorts/SGlpOnIgk1w */
@ramcandrews
ramcandrews / regexJP.py
Last active July 26, 2022 04:39
a python regex to grab every japanese word from an HTML file
import re
with open(rootdir + "something in japanese.html", encoding='utf-8', errors='ignore') as reader:
for line in reader:
words = re.findall(r"[一-龯ぁ-んァ-ン!:/・()ー]*", line)
for word in words:
if word:
print(word)
[^@ \t\r\n]+@[^@ \t\r\n]+\.[^@ \t\r\n]+
[^@ \\t\\r\\n] matches for anything other than @, space, tab, new lines repetitions of a non-whitespace character.
https://ihateregex.io/expr/email/ (04/17/2022)
@ramcandrews
ramcandrews / email regex
Last active March 17, 2022 06:55
General Email Regex (RFC 5322 Official Standard) https://www.regular-expressions.info/email.html
(?:[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*|"(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21\x23-\x5b\x5d-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])*")@(?:(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?|\[(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?|[a-z0-9-]*[a-z0-9]:(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21-\x5a\x53-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])+)\])
Regex for matching ALL Japanese common & uncommon Kanji (4e00 – 9fcf) ~ The Big Kahuna!
([一-龯])
Regex for matching Hirgana or Katakana
([ぁ-んァ-ン])
Regex for matching Non-Hirgana or Non-Katakana
([^ぁ-んァ-ン])
Regex for matching Hirgana or Katakana or basic punctuation (、。’)
first create a spatial lite db file. the sqlite file will be more than twice as large as the GDB directory.
ogr2ogr -f SQlite db.sqlite -f OpenFileGDB -overwrite tlgdb_2019_a_us_areawater.gdb
# this is mor than 100 years of global weather data 110GB
wget https://www.ncei.noaa.gov/data/global-hourly/archive/csv/{1901..2020}.tar.gz
@ramcandrews
ramcandrews / pytorch chunk for RNN.py
Last active February 26, 2020 08:55
Batch data into chunks using the pytorch TensorDataset and Dataloader classes
from torch.utils.data import TensorDataset, DataLoader
import torch
# Check for a GPU
train_on_gpu = torch.cuda.is_available()
if not train_on_gpu:
print('No GPU found. Please use a GPU to train your neural network.')
def batch_data(words, sequence_length, batch_size):