Skip to content

Instantly share code, notes, and snippets.

View kidrigger's full-sized avatar

Anish Bhobe kidrigger

View GitHub Profile
@kidrigger
kidrigger / fact-rec.rkt
Created December 9, 2023 22:27
Racket recursions.
#lang racket/base
;; Naive factorial
;; Keep stack for all recursion levels
;; Can do arbitrary processing at each level
(define (naive-fact n)
(if (<= n 0)
1
(* n (naive-fact (- n 1)))))
@kidrigger
kidrigger / godot_audio_frame_operators.h
Last active February 22, 2022 13:16
Audio Frame Operators for GDExtension
#include <godot_cpp/classes/audio_frame.hpp>
namespace godot {
AudioFrame operator*(const AudioFrame & frame, double scalar) {
return AudioFrame{ frame.left * scalar, frame.right * scalar };
}
AudioFrame operator*(double scalar, const AudioFrame & frame) {
return AudioFrame{ frame.left * scalar, frame.right * scalar };
}
@kidrigger
kidrigger / bfs_short_path.cpp
Created April 11, 2019 19:08
BFS to find the shortest path in an unweighted graph.
#include <deque>
#include <iostream>
#include <map>
#include <unordered_map>
#include <vector>
using namespace std;
bool shortestPathBFS(const vector<vector<int>> &graph, int start, int goal) {
@kidrigger
kidrigger / bfs_printing.cpp
Created April 11, 2019 19:06
Simple BFS implementation to print the nodes.
#include <deque>
#include <iostream>
#include <map>
#include <unordered_map>
#include <vector>
using namespace std;
void printBFS(const vector<vector<int>> &graph, int start) {
@kidrigger
kidrigger / init.vim
Created March 8, 2019 19:01
NVim configuration files
""""""""""""""""""""""""""""""""""""""""
" KidRigger's NVIM Configuration
""""""""""""""""""""""""""""""""""""""""
""""""""""""""""""""""""""""""""""""""""
" Setting up Vim Plug
""""""""""""""""""""""""""""""""""""""""
call plug#begin('~/.local/share/nvim/plugged')
@kidrigger
kidrigger / osx_renamer.py
Created March 2, 2019 05:41
A python script to change the install names on macOS from a given pattern to a given pattern.
import os
from sys import argv
import subprocess
name, filename, prefix, changeto = argv
renamer_buffer = 'RENAMER_BUFFER_314159265358979'
with open(renamer_buffer,'w') as fle:
subprocess.call(['otool','-L',filename],stdout=fle)
@kidrigger
kidrigger / sorting.cpp
Created February 18, 2019 13:36
DSA 2018-19 Sorting Tutorial
#include <algorithm>
#include <iostream>
#include <map>
#include <vector>
using namespace std;
#pragma region
void print(vector<int> v) {
cout << "vector: ";
@kidrigger
kidrigger / OpenGL-Skeleton.cpp
Last active February 3, 2019 11:43
Skeleton code for an OpenGL application.
#include <iostream>
#include "glad/glad.h"
#include "GLFW/glfw3.h"
int main() {
GLFWwindow* window = nullptr;
const int WIDTH = 1920;
const int HEIGHT = 1080;
# OSX
--enable-shared --enable-version3 --disable-programs \
--enable-libmp3lame --enable-libtheora \
--enable-libvorbis --enable-libvpx --enable-libwebp \
--enable-opencl --enable-opengl --disable-debug \
--prefix=<path-to-videodecoder-folder>/godot-videodecoder/test/addons/bin/osx
# Linux
--enable-shared --enable-version3 --disable-programs \
--enable-libmp3lame --enable-libtheora \
@kidrigger
kidrigger / functions.cpp
Created November 19, 2018 11:29
AlgoManiaX example on Functions.
#include <iostream>
///////////////////////////////////////////////////////////////////////////////////////////////////
#ifdef P1
void Foo() { std::cout << "Hello World" << std::endl; }
int main() {