Skip to content

Instantly share code, notes, and snippets.

View PiJoules's full-sized avatar

PiJoules

  • Gotta increase that Github score
  • Not in Kansas
View GitHub Profile
#include <initializer_list>
#include <iostream>
#include <memory>
#include <string>
// Example base type
class Base
{
public:
Base(const double a, const double b) :
@PiJoules
PiJoules / area.py
Created August 13, 2017 20:57
This took me longer than I would have liked it to
#!usr/bin/env python
class Rectangle:
"""All rectangle methods are constant time."""
def __init__(self, x1, y1, x2, y2):
"""Opposite corners of a rectangle.
These points will not be changed once set."""
assert(x1 != x2)
@PiJoules
PiJoules / visitor.cpp
Created August 2, 2017 18:54
Visitor design pattern using templates for abstract visitor and visitable
#include <iostream>
#include <vector>
/******* Lib start *****/
class BaseVisitor {
public:
virtual ~BaseVisitor(){}
};
https://www.hackerrank.com/contests/code-golf-challenges/challenges/leibniz
0.7266
f=lambda:range(int(input()))
for _ in f():print(sum((-1)**i/(2*i+1) for i in f()))
@PiJoules
PiJoules / valgrind_on_windows.txt
Created December 16, 2016 20:14
How to get valgrind on linux subsystem for windows to work
http://www.albertgao.xyz/2016/09/28/how-to-use-valgrind-on-windows/
# Enable colors for ls, etc. Prefer ~/.dir_colors #64489
if [[ -f ~/.dir_colors ]] ; then
eval $(dircolors -b ~/.dir_colors)
elif [[ -f /etc/DIR_COLORS ]] ; then
eval $(dircolors -b /etc/DIR_COLORS)
fi
alias ls='ls --color=auto'
alias grep='grep --colour=auto'
@PiJoules
PiJoules / test.c
Created November 18, 2015 00:22
Test I ran to see if there were any faster ways of finding the sum of digits in an integer than looping and dividing by 10.
#include <stdio.h>
#include <time.h>
#include <string.h>
/**
* Test to see how fast it takes to fund the sum of
* the digits of an integer.
*/
/**
@PiJoules
PiJoules / backup.c
Created July 22, 2015 15:45
ayy lmao
#include <stdlib.h>
int main(){
int ret = system("rm backup.c a.out");
return 0;
}
clear all; close all; clc;
W = 2;
Fs = 100; % frequency meant to replicate continuous data
t = 0:1/Fs:W-1/Fs;
N = length(t);
x = cos(2*pi*t);
% Sampled x
fs = 20; % sampling frequency
@PiJoules
PiJoules / cosine2.m
Created July 10, 2015 20:42
Cosine Inverse Fourier Transform Example
clear all; close all; clc;
W = 5;
fs = 100;
t = -W:1/fs:W;
N = length(t);
x = cos(2*pi*t);
% Fourier transform
bin_inc = fs/N;