Skip to content

Instantly share code, notes, and snippets.

View Staticity's full-sized avatar

Jaime Rivera Staticity

View GitHub Profile
@Staticity
Staticity / mle.py
Created December 4, 2022 17:42
quick script to show likelihood stuff
import numpy as np
import random
import plotly.graph_objects as go
from plotly.subplots import make_subplots
class GaussianDistribution:
def __init__(self, mean, sigma):
self.u = mean
@Staticity
Staticity / dondact.py
Created November 26, 2022 11:54
Tracking Deal or No Deal [incomplete]
import cv2
import numpy as np
import sys
import matplotlib.pyplot as plt
# Create a VideoCapture object and read from input file
# If the input is the camera, pass 0 instead of the video file name
cap = cv2.VideoCapture(sys.argv[1])
@Staticity
Staticity / deal_or_no_deal_sim.py
Last active November 26, 2022 11:47
Deal or No Deal Mini-Arcade Simulator
import pygame
import os
import random
import time
import sys
import subprocess
import ffmpeg
import shutil
pygame.init()
@Staticity
Staticity / metronome.jsx
Created December 19, 2019 21:02
Metronome
import React, {useState} from "react";
import {useInterval} from "../Common/timers";
import Tick from '../static/sounds/tick.wav';
export default function Metronome(props)
{
let [delay, setDelay] = useState(1000);
let [startTime, setStartTime] = useState(null);
let [r, setR] = useState(255);
@Staticity
Staticity / ToBinaryString.cpp
Created July 24, 2017 19:07
Templated version of a `ToBinaryString` function
#include <iostream>
#include <string>
template <int N>
struct ToBinaryString
{
inline static std::string result()
{
return ToBinaryString<N / 2>::result() + ((N & 1) == 0 ? "0" : "1");
}
@Staticity
Staticity / ConvenientPrint.cpp
Created July 23, 2017 01:15
A silly, yet convenient, way to print data in competitive programming.
#include <iostream>
#include <string>
#include <vector>
int main()
{
// Some random data to play with.
const std::vector<std::string> a = {"This", "is", "sort", "of", "silly"};
// We wish to print the data separated by spaces, but only print
@Staticity
Staticity / SortAndMaintainOrder.cpp
Created July 21, 2017 19:44
Sort elements of an array without modifying the original array
#include <algorithm>
#include <iostream>
int main()
{
// Original data won't change order
const std::vector<int> data{1, 7, 3, 6, 4, 5, 2, 8, 0, 9};
// The objective is to make `data[sortedIndices[i]]` represent
// the following pseudocode: `sorted(data)[i]`.
void update(int x, int* sieve, std::map<int, int>& freq, int inc)
{
while (x > 1)
{
int factor = sieve[x];
freq[factor] += inc;
x /= factor;
}
}
@Staticity
Staticity / timer.cpp
Created March 8, 2016 19:34
Timer Macro
#include <opencv.hpp>
#include <stdio.h>
#define PROFILE(function_name, ...) \
{ \
long long start = cv::getTickCount(); \
function_name(__VA_ARGS__); \
long long end = cv::getTickCount(); \
double time_spent = (end - start) / cv::getTickFrequency(); \
@Staticity
Staticity / Merge.java
Last active October 8, 2015 19:31
Merge two sorted generic lists.
import java.util.List;
import java.util.ArrayList;
public class Merge
{
public static void main(String args[])
{
List<Integer> a = new ArrayList<Integer>();
List<Integer> b = new ArrayList<Integer>();