Skip to content

Instantly share code, notes, and snippets.

View nofishleft's full-sized avatar

Rishaan Gupta nofishleft

View GitHub Profile
@nofishleft
nofishleft / switch_mic.sh
Created December 7, 2022 01:22
Linux microphone switching
#!/bin/bash
# Name of the device in pactl, use the following to discover names
# pactl list sources | grep -e 'Name' -e 'Description'
steel_series='alsa_input.usb-SteelSeries_Arctis_Pro_Wireless-00.analog-mono'
snowball='alsa_input.usb-BLUE_MICROPHONE_Blue_Snowball_201712-00.analog-stereo'
# Get the active source, ideally would use 'pactl get-default-source',
# but that isn't supported in my version of pulseaudio,
# Should be noted that this work around may break if there are multiple sources that are being used
@nofishleft
nofishleft / lfsr_test.py
Created June 8, 2020 09:47
Prints all combinations attainable with this lfsr implementation and seed value. It also graphs the distribution.
def incr (rand):
return [rand[1], rand[2], rand[3] ^ rand[0], rand[4], rand[5], rand[6], rand[7], rand[8] ^ rand[0], rand[0]]
# Check if the last combination equals the seed/starting combination
def equal(a, b):
for i in range(len(a)):
if a[i] != b[i]:
return False
return True
@nofishleft
nofishleft / PerlinMesh.cs
Last active July 26, 2019 06:57
Multithreaded PerlinNoise & Runtime Mesh Editing Alternative
//Uses Coroutines & LateUpdate to do processing over a larger percentage of the game loop
//Uses WaitForEndOfFrame (called after rending before next frame) instead of Update
// and LateUpdate (called before rendering)
// see: https://docs.unity3d.com/Manual/ExecutionOrder.html
using System.Collections;
using System.Threading;
using System.Threading.Tasks;
using UnityEngine;
@nofishleft
nofishleft / roll.js
Last active July 26, 2019 06:45
DND dice roll summary
let input = "1d6 + 2d8 + 5";
//let rollEXP = /[^ ,.+]+/gi;
const rollEXP = /(?:[0-9]*d[0-9]+)|(?:[0-9]+)/gi;
let segments = input.match(rollEXP);
let max = new Array(segments.length);
let min = new Array(segments.length);
let avg = new Array(segments.length);
@nofishleft
nofishleft / PerlinMesh.cs
Last active July 25, 2019 03:26
Multithreaded PerlinNoise & Runtime Mesh Editing (No coroutines)
//Uses Update & LateUpdate to synchronize background threads
//Uses Update (Called after physics updates)
// and LateUpdate (called before rendering)
// see: https://docs.unity3d.com/Manual/ExecutionOrder.html
using System.Threading;
using System.Threading.Tasks;
using UnityEngine;
@nofishleft
nofishleft / Find4thPoint.cs
Created May 13, 2019 01:25
Finds the 4th point in a rectangle, given three known points
using UnityEngine;
public class Find4thPoint {
public Vector3 Find4th(Vector3 a, Vector3 b, Vector3 c) {
Vector3 point, cornerA, cornerB;
Vector3[] points = new Vector3[] {a, b, c};
float angleDelta = 180;
@nofishleft
nofishleft / mines.js
Last active March 1, 2019 03:33
Node module to add minesweeper to any discord bot
//Example Usage:
/*
const mines = require('./mines.js');
let msg = mines(14,14,20,'X',true);
*/
//X - Width
//Y - Height