Skip to content

Instantly share code, notes, and snippets.

View rameshvarun's full-sized avatar

Varun Ramesh rameshvarun

View GitHub Profile
@rameshvarun
rameshvarun / bash_import.sh
Created August 4, 2024 06:36
Load remote bash scripts with sha256sum verification.
#!/usr/bin/env bash
# Remotely load bash scripts with sha256sum verification.
# USAGE: bash_import [URL] [SHA256SUM]
function bash_import() {
TMPFILE=$(mktemp)
curl -sSL $1 -o $TMPFILE
if echo "$2 $TMPFILE" | sha256sum -c -; then
source $TMPFILE
else
@rameshvarun
rameshvarun / sqlite-migrator.py
Last active July 30, 2024 06:05
A single file ORM-less SQLite3 migration framework in Python.
#!/usr/bin/env python3
import sqlite3
import argparse
db = sqlite3.connect("test.db")
class Migration:
"""
The base migration class. Migrations that inherit from here can
@rameshvarun
rameshvarun / starsystem.rs
Created December 7, 2022 08:01
Keplerian Orbital Elements Simulation in Rust.
use na::Vector3;
use std::f64::consts::{PI};
const TICK_TIMESTEP: f64 = 86400.0;
const GM: f64 = 1.32712440042e20;
#[derive(Clone, Debug)]
pub struct OrbitalElements {
let x = 0;
// WORKS
Math.random()
Date.now()
function test_false() {
if (false) {
return x++;
}
@rameshvarun
rameshvarun / plot-sleep-schedule.py
Last active May 17, 2021 22:39
Plot FitBit sleep schedule using Matplotlib.
#!/usr/bin/env python3
import glob
import csv
import itertools
from datetime import datetime, timedelta, time
from collections import namedtuple
import numpy as np
import matplotlib.pyplot as plt
@rameshvarun
rameshvarun / litlua.lua
Last active July 31, 2021 03:27
Basic literate programming in Lua.
local litlua = {}
-- String split function - taken from Penlight
-- https://github.com/stevedonovan/Penlight/blob/master/lua/pl/utils.lua#L172
local function split(s, re, plain, n)
local i1, ls = 1, {}
if not re then re = '%s+' end
if re == '' then return {s} end
while true do
local i2, i3 = s:find(re, i1, plain)
@rameshvarun
rameshvarun / HTTP2 Streaming RPC.md
Last active August 29, 2019 18:59
How the HTTP2 API could be used to implement a streaming RPC more easily than other transport layers.

HTTP2 Streaming RPC

Output

Server

RPC from client to FindInProjectService/search
Sending search update.
Sending search update.
RPC from client to FindInProjectService/search
Sending search update.
@rameshvarun
rameshvarun / set_iptables.sh
Last active August 29, 2015 14:19
IP Tables Configurations
#!/bin/bash
# Flush all current rules
iptables -F
# Accept SSH Connections
iptables -A INPUT -p tcp --dport 22 -j ACCEPT
iptables -P INPUT DROP # By default, drop all incoming connections
iptables -P FORWARD DROP # By default refuse to forward packets
@rameshvarun
rameshvarun / Scene.cpp
Created December 4, 2014 05:18
Multi-threaded Scene Render.
#include "Scene.h"
#include <fstream>
#include <sstream>
#include <iostream>
#include <vector>
#include <thread>
Scene::Scene()
:currMaterial(NULL),currTexIndex(-1),use_shadow(true),use_transparent_shadow(false),attenuation_coefficient(1.f),camera(NULL),accel_structure(NONE),uniform_grid(NULL)
{

Point Charges Simulator

Basic program for simulating the motion of three point charges.

Example Graph

Config Dialog