Skip to content

Instantly share code, notes, and snippets.

View jcblw's full-sized avatar
💤
Don't wake me, my computer is sleeping in.

Jacob Lowe jcblw

💤
Don't wake me, my computer is sleeping in.
View GitHub Profile
import AsyncStorage from "@react-native-async-storage/async-storage";
import { useCallback, useEffect, useRef, useState } from "react";
const safeParse = <T extends unknown>(value: string | null) => {
if (value === null) {
return null;
}
try {
return JSON.parse(value) as T;
} catch (error) {
@jcblw
jcblw / create_model_train.py
Created October 10, 2022 15:50
Used for a Medium article
# Create a model for predicting the next word
model = tf.keras.Sequential()
# Load the data from local CSV file
data = pd.read_csv('data.csv')
# Split the data into training and testing
train, test = train_test_split(data, test_size=0.2)
@jcblw
jcblw / predict.py
Created October 10, 2022 14:59
Used for a medium article
# Use the model to predict a set of next words
# ^ I wrote this
predictions = model.predict(x)
# ^ Copilot wrote this
@jcblw
jcblw / create-model.js
Last active October 10, 2022 14:55
Used for a Medium article
// Create a model for predicting the next word
// ^ I wrote this
const model = tf.sequential()
model.add(tf.layers.lstm({ units: 128, inputShape: [null, 1] }))
model.add(tf.layers.dense({ units: 1, activation: 'softmax' }))
model.compile({ loss: 'categoricalCrossentropy', optimizer: 'adam' })
// ^ Copilot wrote all this code

Description

DESCRIPTION_HERE

@jcblw
jcblw / scribble-pad.ts
Created October 3, 2020 00:05
Scribble Pad demo.
// You will need to install these via npm or yarn.
import * as THREE from "three";
import glsl from "glslify";
import { OrbitControls } from "three/examples/jsm/controls/OrbitControls";
export const config = {
loop: true,
context: "webgl",
};
@jcblw
jcblw / get-all-rows-indexdb.js
Created August 3, 2019 07:57
A script you can paste in your console to logout all values in an indexDB table
// See bottom to see input variables
(async function(w, d, v, t, c) {
const s = "font-size:18px;";
const h = `color:#F06E1D;${s}`;
const getRows = () => {
return new Promise(resolve => {
const r = [];
w.indexedDB.open(d, v).onsuccess = event => {
event.target.result
.transaction(t)
export let hasWebPSupport = null;
export const loadImgSrc(src: string): Promise<void> {
return new Promise((resolve, reject) => {
const img = new Image();
img.onload = () => resolve();
img.onerror = () => reject();
img.src = src;
});
}
export const checkWebPSupport = () => {
### Keybase proof
I hereby claim:
* I am jcblw on github.
* I am jcblw (https://keybase.io/jcblw) on keybase.
* I have a public key ASA1S8AOaQfXp-RYKa3iMp_LGWjc4sgG2cc7uB3Z4xFZQAo
To claim this, I am signing this object:
const padEnd = require('string.prototype.padend');
const gaze = require('gaze');
const util = require('util');
const _ = require('lodash');
const chalk = require('chalk');
const { exec, spawn } = require('child_process');
const pexec = util.promisify(exec);
const log = (type, color = 'yellow') => (info, infoColor = 'reset') => {