{{ message }}

Instantly share code, notes, and snippets.

# Safsafiire

Last active Aug 29, 2015
Compute π with an infinite series
View pi_infinite_series
 def f(n) (2 * n + 1)**-1 end def g(n) ((-1)**n).to_f end def pi
Created Feb 10, 2014
RC Lowpass Filter Simulation in both Ruby and Rust for comparison.
View rc_filter_simulation.rb
 #!/usr/bin/env ruby # encoding: UTF-8 require 'complex' Tau = 2 * Math::PI TableWidth = 20 ####################################################################### ## This is a script I was using to simulate an analog Resistor ## Capacitor in series filter, to see if I had the math right.
Created Feb 12, 2014
This is likley the greatest English paragraph, of all.
View the_greatest_english_paragraph_of_all.txt
 For although light oftenest behaves as a wave, it can be looked on as a mote, the *lightbit*. We have already said by the way that a mote of stuff can behave not only as a chunk, but as a wave. Down among the unclefts, things do not happen in steady flowings, but in leaps between bestandings that are forbidden. The knowledge-hunt of this is called *lump beholding*.
Created Jul 8, 2014
One Zero Low Pass Filter
View lowpass.cpp
 #include #include #define PI 3.141592653589793 #define SAMPLE_RATE 64 using namespace std; // This lowpass is a weighted moving average // If you change the + to - it will become a highpass filter
Last active Aug 29, 2015
View make_wavetable.c
 #include #include #include #include #include "common.h" // Enums enum {SAW, SQUARE, SINE};
Created Aug 28, 2014
Line Intersection with Matrices
View intersect.rb
 require 'matrix' #### ## Random program that uses matrices to find intersection between 2 lines ## the linear algebra way. ## I am not sure why I made this, but it's probably because I like matrices class Line attr_reader :slope, :offset
Created Mar 30, 2015
NES sound demo from my blog post.
View blog_sound_demo.asm
 ;;;; ; Create an iNES header .ines {"prog": 1, "char": 0, "mapper": 0, "mirror": 0} ;;;; ; Include all the symbols in the nes library .inc
Created Apr 30, 2015
Example of returning a string initialized in the constructor
View main.cpp
 // Comple with g++ *.cpp -o prog // #include #include "test.h" using namespace std; int main(int argc, char **argv){ Test test;
Created Jun 9, 2015
Manipulation of Memory Mapped Registers using C++ Templates (Technique from Olivier Gillet's Avril AVR Library)
View memory_mapped_io.cpp
 #include #include //// Create some pretend Memory Mapped Registers volatile uint64_t memory_mapped_registers[] = {0, 0, 0, 0, 0, 0, 0, 0, 0}; #define bit_depth uint64_t #define mmio_byte(mem_addr) (*(volatile bit_depth *)(mem_addr))
Created Jun 11, 2015
Curiously Recurring Template Pattern
View curiously_recurring_template_pattern.cpp
 //// // Curiously Recurring Template Pattern #include template struct Counter { // Static class members variables static int objects_created; static int objects_alive;
You can’t perform that action at this time.