Skip to content

Instantly share code, notes, and snippets.

@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
# frozen_string_literal: true
# The game engine
class Engine
def initialize(running)
@running = running
end
def game_loop(&update)
update.call while @running
# frozen_string_literal: true
def bubblesort(array)
array.each_with_index do |_, i|
(0..(array.length - 2 - i)).each_with_index do |_, j|
array[j], array[j + 1] = array[j + 1], array[j] if array[j] > array[j + 1]
end
end
end
# frozen_string_literal: true
def stock_picker(prices)
curr_buy = curr_sell = best_buy = best_sell = max_profit = 0
(1..(prices.length - 1)).each do |i|
diff = prices[i] - prices[curr_buy]
curr_sell = i
curr_buy = i if diff.negative?
# frozen_string_literal: true
# Counts each
def substrings(string, valid_substrings)
downcase_string = string.downcase
Hash[
valid_substrings
.collect { |substring| [substring, downcase_string.scan(substring).length] }
.reject { |_substring, substring_length| substring_length.zero? }
]