Skip to content

Instantly share code, notes, and snippets.

View hallfox's full-sized avatar

Taylor Foxhall hallfox

  • Bloomberg LP
View GitHub Profile
use_bpm 65
with_fx :reverb, mix: 0.5 do
live_loop :oceans do
s = synth [:cnoise].choose, amp: rrand(0.1, 0.5), attack: rrand(0, 4), sustain: rrand(0, 2), release: rrand(1, 5), cutoff_slide: rrand(0, 5), cutoff: rrand(60, 100), pan: rrand(-1, 1), pan_slide: rrand(1, 5), amp: rrand(0.5, 1)
control s, pan: rrand(-1, 1), cutoff: rrand(60, 110)
sleep rrand(2, 4)
end
end
@hallfox
hallfox / slicing.cpp
Created November 15, 2019 03:06
An example of how shared_ptr goes the extra mile when you write bad classes
class Base {
public:
Base(size_t len);
~Base();
private:
char* data_;
};
Base::Base(size_t len):
data_(new char[len]) {
@hallfox
hallfox / Circle.cpp
Last active January 27, 2018 01:41
How curious...
#include "Circle.h"
const double Circle::PI = 3.14;
Circle::Circle(double radius):
radius_(radius) {}
double Circle::area() const {
return _radius * _radius * PI;
}
@hallfox
hallfox / Circle.cpp
Last active January 27, 2018 01:00
A pure virtual class, notably because of methods that = 0 (also called "pure virtual" methods.) Classes that are pure virtual cannot be instantiated, only subclasses that implement the pure virtual methods can.
#include "Circle.h"
const double Circle::PI = 3.14;
Circle::Circle(double radius):
radius_(radius) {}
double Circle::area() const {
return _radius * _radius * PI;
}
@hallfox
hallfox / encapsulation.cpp
Created September 24, 2017 19:03
Example of proper encapsulation in C++
#include <wand.h>
#include <spell.h>
#include <vector>
class Wizard {
public:
// Just showing off a public type alias
using SpellBook = std::vector<Spell>;

Keybase proof

I hereby claim:

  • I am hallfox on github.
  • I am hallfox (https://keybase.io/hallfox) on keybase.
  • I have a public key ASC2R9ChxGiJiml7qV90eamiEfg6HtQjLzBT7m3fnmnlfAo

To claim this, I am signing this object:

s, t, xs, start = input(), input(), 26*[0], ord('a')
for x,y in zip(s,t):
xs[ord(x)-start] += 1
xs[ord(y)-start] -= 1
print("anagram") if len(s) == len(t) and xs == 26*[0] else print("no")
class LinkedList;
class Node {
public:
// You can do it this way but eehhhh
friend LinkedList;
Node(int data): data{data}, next{nullptr} {}
// Otherwise just use this if you have it
Node *get_next() { return next; }
private:
bool binsearch(int *nums, int numsSize, int target, int *range) {
int start = 0, end = numsSize - 1;
int mid;
while (start <= end) {
mid = (start + end) / 2;
if (nums[mid] == target) {
range[0] = start;
range[1] = mid;
range[2] = end;
" Use Vim settings, rather then Vi settings (much better!).
" This must be first, because it changes other options as a side effect.
set nocompatible
" ================ General Config ====================
set showcmd "Show incomplete cmds down the bottom
set showmode "Show current mode down the bottom
set visualbell "No sounds
set autoread "Reload files changed outside vim