Skip to content

Instantly share code, notes, and snippets.

import fs from "fs";
import { NextApiRequest, NextApiResponse } from "next";
import path from "path";
type Data = {
files: string[];
};
export default function handler(
req: NextApiRequest,
@airicbear
airicbear / diffaugment.py
Created February 20, 2023 19:09
DiffAugment
from typing import Callable, Dict, List
import tensorflow as tf
from .consts import strategy
with strategy.scope():
def diff_augment(x: tf.Tensor,
policy: str = '',
channels_first: bool = False) -> tf.Tensor:
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@airicbear
airicbear / fit.jl
Created March 28, 2022 22:07
Linear fit on x and y, in y = mx + b form
function fit(x,y)
x̄ = mean(x)
ȳ = mean(y)
# Calculation of fit parameters
m = sum([(xi - x̄) * yi for (xi, yi) ∈ zip(x, y)]) / sum([(xi - x̄)^2 for xi ∈ x])
b = ȳ - m*x̄
# Calculation of standard error
D = sum([(xi - x̄)^2 for xi ∈ x])
@airicbear
airicbear / gvdoom.md
Created March 25, 2022 20:37
Using Graphviz on Doom Emacs

Using GraphViz on Doom Emacs

Installation

Install graphviz:

brew install graphviz
@airicbear
airicbear / derivatives.jl
Created January 25, 2022 17:34
Derivatives and Taylor series in Julia using ForwardDiff.jl
using FowardDiff
# Derivative of f
D(f) = x -> FowardDiff.derivative(f, x)
# nth Derivative of f
D(f, n) = let
F = f
while n > 0
F = D(F)
@airicbear
airicbear / installing_bc_stencil_cli_on_windows.md
Created January 6, 2022 15:56
Install BigCommerce Stencil CLI on Windows

How to install BigCommerce Stencil CLI on Windows

First, try following the instructions on the BigCommerce Theme Docs.

If you encounter an error about Microsoft.Cpp.Default.props not being found, open the Windows Registry Editor and navigate to HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Microsoft\MSBuild\ToolsVersions\4.0. Add the string key VCTargetsPath with the value C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\Common7\IDE\VC\VCTargets.

@airicbear
airicbear / unity_android_build_error.md
Created November 23, 2021 00:33
Unity APK installation error

Build Error in Unity APKs

If you get an error trying to install your Unity build on Android saying App not installed, then you need to change your project's package name in the Player Settings. To do this, go to File > Build Settings > Player Settings... > Player > Other Settings and find the Identification section. Make sure Override Default Package Name is checked and then change the value of Package Name to something like com.example.mygame.

Additionally, you may want to change Install Location to Automatic.

Relevant Error Messages

From adb logcat you might see

@airicbear
airicbear / riemann_midpoint.py
Created September 3, 2021 20:07
Riemann Sum (Midpoint)
def rsm(f, x0, xn, n):
"""Approximates integral using Riemann sum of the midpoint.
Takes the function f(x), bounds a and b, and number of partitions, n as arguments."""
dx = (xn - x0) / n
return [f(x0 + i*dx) for i in range(0,n)]
x0 = 0
xn = 2
n = 4
dx = (xn - x0) / n
@airicbear
airicbear / upload_keystore.md
Created August 17, 2021 21:36
Android upload keystore

The upload-keystore.jks file should be saved somewhere secure along with the upload_certificate.pem file.

In your Android app, make sure there is a key.properties file in the following format:

storePassword=password
keyPassword=password
keyAlias=upload
storeFile=/../upload-keystore.jks