Skip to content

Instantly share code, notes, and snippets.

View benbotto's full-sized avatar
💭
Because code.

benbotto

💭
Because code.
View GitHub Profile
@benbotto
benbotto / linear.cpp
Last active May 26, 2019 03:13
Sequentially Indexing Permutations O(n)
#include <array>
using std::array;
#include <bitset>
using std::bitset;
#include <iostream>
using std::cout;
using std::endl;
unsigned factorial(unsigned n)
{
@benbotto
benbotto / quadratic.cpp
Last active May 26, 2019 16:54
Sequentially Indexing Permutations O(n^2)
#include <array>
using std::array;
#include <iostream>
using std::cout;
using std::endl;
unsigned factorial(unsigned n)
{
return n <= 1 ? 1 : n * factorial(n - 1);
}
@benbotto
benbotto / loss.py
Created February 12, 2018 21:34
huber_loss for Tensorflow Keras
def huber_loss(y_true, y_pred, clip_delta=1.0):
error = y_true - y_pred
cond = tf.keras.backend.abs(error) < clip_delta
squared_loss = 0.5 * tf.keras.backend.square(error)
linear_loss = clip_delta * (tf.keras.backend.abs(error) - 0.5 * clip_delta)
loss = tf.where(cond, squared_loss, linear_loss)
return tf.keras.backend.mean(loss)
@benbotto
benbotto / Temp.java
Last active September 17, 2019 00:41
Modified http://www.cs.ubc.ca/~poole/demos/mdp/vi.html to work as a JFrame
import java.awt.Dimension;
public class Temp {
public static void main(String[] args) {
VIgui gui = new VIgui();
gui.pack();
gui.setSize(new Dimension(1024, 768));
gui.setVisible(true);
}
}
@benbotto
benbotto / gcd.sass
Created May 23, 2017 22:27
Greatest common divisor function in SASS
@function gcd($a, $b) {
@if $b == 0 {
@return $a;
}
@return gcd($b, $a%$b);
}
@for $i from 1 through 11 {
@for $j from $i+1 through 12 {