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
@Quantalabs
Quantalabs / Differential-Privacy-Algorithm.js
Last active June 22, 2021 20:52
Simple differential privacy algorithm
var flip = function (dataArray) {
var a = dataArray;
for(var i = 0; i < a.length; i++) {
var b = Math.random(0,1);
var c = Math.round(b);
if(c === 0) {
a[i] = true;
}
if(c === 1) {
var b1 = Math.random(0,1);
@Quantalabs
Quantalabs / Fibbonacci Sequence.js
Created May 25, 2020 20:50
Outputs a number in the fibbonacci sequence in the console. Read about the fibbonacci sequence at https://en.wikipedia.org/wiki/Fibonacci_number
var calc = function (amount) {
var a = 1 //change the two variables to get a different fibbonacci sequence
var b = 1
for(var i = 0; i < amount; i++) {
var i = a+b
b = a
a = i
}
console.log(a) //outputs the 'amount' number in the fibbonacci sequence.
}
@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 {