Skip to content

Instantly share code, notes, and snippets.

View NivenT's full-sized avatar

Niven Achenjang NivenT

View GitHub Profile
#!/bin/bash
####### Constants ############
USER=$(who | grep -o "^[^ ]\+" | head -n 1)
USER_ID=$(id -u $USER)
HDMI_FLDR="/sys/class/drm/"
PULSE_SERVER="unix:/run/user/$USER_ID/pulse/native"
# Use different lock files depending on if this is run by udev or manually from the terminal
@NivenT
NivenT / ps5.py
Created December 1, 2020 02:10
Don't you hate not owning a ps5? This might help (but probably won't). Periodically checks for in-stock ps5s and then launches firefox when one is found. If you want, you can make a free trial [Twilio account](www.twilio.com/referral/DNJ8MN) and then provide a file containing your account sid, account auth token, account phone number, and person…
#!/usr/bin/python3
import requests
import sys
from html.parser import HTMLParser
from validators import url as is_url
from os import system as cmdline
from time import sleep
from twilio.rest import Client
@NivenT
NivenT / StaticVector.h
Created December 2, 2019 22:55
A StaticVector (fixed capacity, data stored in stack) class in C++ where every function is implemented in one line of code (Admittedly, I do use the comma operator in a few places which is kinda cheating)
#ifndef STATICVECTOR_H_INCLUDED
#define STATICVECTOR_H_INCLUDED
#include <memory>
#include <new>
/// A (fixed capacity) vector with data stored on the stack instead of the heap.
/// Every function in implemented in "one line"
/// Does no error checking
template<typename T, std::size_t Cap>
@NivenT
NivenT / netflix_shows.py
Last active May 26, 2023 21:03
Prints out a list of the shows you have seen on Netflix (+ when you first watched them). Supply the program a .csv downloaded from https://www.netflix.com/viewingactivity
#!/usr/bin/python3
# ^^^^^^^
# I originally wrote this in python2, and then later the minimal edits necessary to get it to run on
# python3, so the code isn't always idiomatic.
import sys
import csv
from datetime import datetime
@NivenT
NivenT / mat.lisp
Last active November 4, 2016 00:32
Had to find the determinant of a 5x5 matrix using row reduction, and show my steps as part of a homework problem, so I put together some code to do it for me and generate the latex I need while it's at it.
(defun range (max &key (min 0) (step 1) (runninglist nil))
(if (<= max min) runninglist (range max :min (+ min step) :step step :runninglist (append runninglist `(,min)))))
(defun entry (mat i j)
(elt (elt mat i) j))(defun row->latex (row)
(format t "~a ~{& ~a ~}\\\\~%" (car row) (cdr row))
)
(defun mat->latex (mat)
(princ "\\begin{vmatrix}")
(princ #\newline)
(loop for row in mat do (row->latex row))