Skip to content

Instantly share code, notes, and snippets.

Avatar

Saf safiire

View GitHub Profile
View keybase.md

Keybase proof

I hereby claim:

  • I am safiire on github.
  • I am safiire (https://keybase.io/safiire) on keybase.
  • I have a public key whose fingerprint is 06DC 5901 70E2 350A 4BCE 7C1D 9EFD 7244 59CC 7EB0

To claim this, I am signing this object:

@safiire
safiire / dual.h
Created Oct 11, 2016
My Dual Number implementation
View dual.h
#pragma once
#include <iostream>
#include <cmath>
#include <limits>
#include "saf_math.h"
//// Some more information for adding more functionality here:
//// http://www.euclideanspace.com/maths/algebra/realNormedAlgebra/other/dualNumbers/functions/
@safiire
safiire / difference_equation.rb
Last active Sep 19, 2016
Modeling a filter's difference equation, so that it can invert itself.
View difference_equation.rb
#!/usr/bin/env ruby
# Really inefficient toy
####
## A little wrapper to make signals either with
## lambda functions or arrays.
class SignalFunction
def self.ramp
SignalFunction.new(lambda{|n| n < 0 ? 0r : n/1r})
end
@safiire
safiire / variadic_print.cpp
Created May 16, 2016
Interesting way of using the new variadic templates to create a variadic print() function.
View variadic_print.cpp
// Compile with: g++ -std=c++11 variadic_print.cpp -o variadic_print
#include <iostream>
// No argument case
void print() {}
// Recursive Variadic Template
template <typename HEAD, typename ... TAIL>
void print(const HEAD& head, const TAIL& ... tail) {
@safiire
safiire / pokémon_decrypt.c
Last active Mar 15, 2016
This is a C program to decrypt pokémon files
View pokémon_decrypt.c
#include <stdio.h>
#include <stdint.h>
#include <stdlib.h>
#include <stdbool.h>
#include <string.h>
#define NICKNAMED(x) ((x & 0x80000000) >> 31)
#define IS_EGG(x) ((x & 0x40000000) >> 30)
#define SP_DEF_IV(x) ((x & 0x3e000000) >> 25)
#define SP_ATT_IV(x) ((x & 0x01f00000) >> 20)
@safiire
safiire / rc_filter_simulation.scm
Last active Sep 4, 2015
RC Filter Circuit simulation in Scheme
View rc_filter_simulation.scm
;;;; RC Filter Simulation
;; Calculates the frequency response of an RC filter
;; and displays it with ASCII art
;; This is just a program I always write to learn a new programming language
;; I tried out Scheme's lazy lists for this
;;
;; Frequency Response
;; ----------------------------------------------------------------
;; |****************************** |
;; | ***** |
@safiire
safiire / .csirc
Created Sep 3, 2015
A working .csirc file for Scheme readline
View .csirc
(use readline)
(current-input-port (make-readline-port))
(install-history-file #f ".csi.history")
(parse-and-bind "set editing-mode vi")
@safiire
safiire / template_magicks.cpp
Last active May 24, 2016
Using template meta-programming as a functional language in C++11
View template_magicks.cpp
#include <iostream>
using namespace std;
////
// Pattern match on a list of types, recursively ask for the last one
template <typename Head, typename... Tail>
struct last {
using type = typename last<Tail...>::type;
};
@safiire
safiire / curiously_recurring_template_pattern.cpp
Created Jun 11, 2015
Curiously Recurring Template Pattern
View curiously_recurring_template_pattern.cpp
////
// Curiously Recurring Template Pattern
#include <stdio.h>
template <typename T>
struct Counter {
// Static class members variables
static int objects_created;
static int objects_alive;
@safiire
safiire / rc_filter.py
Last active Jan 17, 2019
Rewrote RC filter in Python as a refresher
View rc_filter.py
#/usr/bin/env python
from sys import stdout
from math import pi, log10, pow
Tau = 2 * pi
TableWidth = 20
## Calculate Decibels
def db(ref, val):
You can’t perform that action at this time.