Skip to content

Instantly share code, notes, and snippets.

View ianchanning's full-sized avatar

Ian Channing ianchanning

View GitHub Profile
@tcvieira
tcvieira / setupFastaiV1.md
Last active October 12, 2021 13:10
Setup Fast.ai v1 on Paperspace Fast.ai Template

Setup Fastai v1 on Paperspace

Machine

  • Create a Fast.ai machine from public templates w/ P4000 and public IP

Connect to the machine

  • $ source deactivate fastai
  • $ pip install virtualenv
@rxwei
rxwei / ad-manifesto.md
Last active December 6, 2024 16:54
First-Class Automatic Differentiation in Swift: A Manifesto
@cvburgess
cvburgess / SQLCache.js
Created August 28, 2018 02:23
Knex - caching
const { InMemoryLRUCache } = require("apollo-server-caching");
class SQLCache {
constructor(cache = new InMemoryLRUCache()) {
this.cache = cache;
}
async knexPlugin(knexThen, ctx, args) {
const isSelectStatement = ctx._method === "select";
@cvburgess
cvburgess / SQLCache.js
Created August 28, 2018 02:13
Knex - caching and batching
const { InMemoryLRUCache } = require("apollo-server-caching");
const DataLoader = require("dataloader");
class SQLCache {
constructor(cache = new InMemoryLRUCache(), knex) {
this.cache = cache;
this.loader = new DataLoader(queries =>
Promise.all(queries.map(query => knexInstance.raw(query)))
);
}
@endolith
endolith / DFT_ANN.py
Last active March 7, 2025 15:22
Training neural network to implement discrete Fourier transform (DFT/FFT)
"""
Train a neural network to implement the discrete Fourier transform
"""
import matplotlib.pyplot as plt
import numpy as np
from tensorflow.keras.layers import Dense
from tensorflow.keras.models import Sequential
N = 32
batch = 10000
@rusty-key
rusty-key / index.re
Created July 5, 2018 07:17
Reason HMR
[@bs.val] [@bs.scope ("module")]
external isHotEnabled : bool = "hot";
[@bs.val] [@bs.scope ("module", "hot")] external hotAccept : unit => unit = "accept";
ReactDOMRe.renderToElementWithId(<App />, "root");
if (isHotEnabled) {
hotAccept();
}
@vladbat00
vladbat00 / parcel-node-target-hotreload.js
Created May 9, 2018 13:36
Parcel bundler for hotreloading node.js target. Start with `run` argument in order get your index.js running after each rebuild
const Bundler = require('parcel-bundler');
const childProcess = require('child_process');
const file = 'index.js';
const options = {};
const bundler = new Bundler(file, options);
const runBundle = process.argv.includes('run');
let bundle = null;
@adcreare
adcreare / npm-beta-publish.md
Last active March 26, 2025 16:15
npm publish a beta package

Steps to publish a npm package to beta that won't be available via latest and won't auto install on ncu updates etc

  1. Ensure any compile is run npm run dist etc
  2. Modify version in package.json to the following format (match with existing verion numbers etc) "version": "0.1.120-beta.1" where beta.x is the number of those betas
  3. Publish to npm npm publish --tag beta

There are two options for install:

  • Always install beta with npm install packagename@beta
  • Install specific version with npm install [email protected]
@trueadm
trueadm / adopt-syntax.js
Last active November 27, 2021 03:32
Adding a the "adopt" keyword to the JSX syntax
// I'm suggesting we add a new "adopt X from <Y />" syntax to the JSX language
// it would de-sugar to render prop children, but look and read better than
// what we currently have. For example:
// 1.
// this sugar
function MyComponent(props) {
adopt foo from <Bar />;
return <div>{foo}</div>;
}
@soulmachine
soulmachine / jwt-expiration.md
Last active April 10, 2025 12:28
How to deal with JWT expiration?

First of all, please note that token expiration and revoking are two different things.

  1. Expiration only happens for web apps, not for native mobile apps, because native apps never expire.
  2. Revoking only happens when (1) uses click the logout button on the website or native Apps;(2) users reset their passwords; (3) users revoke their tokens explicitly in the administration panel.

1. How to hadle JWT expiration

A JWT token that never expires is dangerous if the token is stolen then someone can always access the user's data.

Quoted from JWT RFC: