View rbf.py
#!/usr/bin/python | |
import math | |
import numpy as np | |
from numpy import linalg as LA | |
# Function to approximate | |
def f(x): |
View bitfield.cpp
#include <array> | |
#include <assert.h> | |
#include <bitset> | |
#include <iostream> | |
#include <limits.h> | |
#include <ostream> | |
template <size_t N> class bitfield : public std::bitset<N> { | |
public: | |
bitfield(std::array<unsigned char, N / CHAR_BIT> bytes) |
View alu16.cpp
#include <assert.h> | |
#include <bitset> | |
#include <iostream> | |
#include <limits> | |
#include <random> | |
#define ALU_ADD 0 | |
#define ALU_SUB 1 | |
#define ALU_AND 2 | |
#define ALU_OR 3 |
View convert_n_based_numbersystem.py
def convert(x, N): | |
y = x % N | |
x = x // N | |
if (x == 0): | |
return [y] | |
else: | |
return convert(x, N) + [y] | |
print(convert(10001, 16)) |
View threadpool.c
// | |
// threadpool.c | |
// threadpool | |
// | |
#include "threadpool.h" | |
static void *sweep(void *voidtask) | |
{ | |
task *task = voidtask; |
View bc.py
import sys | |
# Constants | |
OPERATORS = ['*', '/', '+', '-'] | |
DECIMAL_SYMBOLS = [',', '.'] | |
SIGN_SYMBOLS = ['-', '+'] | |
PARENTHESIS_OPEN = '(' | |
PARENTHESIS_CLOSE = ')' | |
PRECEDENCE = [[PARENTHESIS_OPEN], ['*', '/'], ['+', '-']] |
View collatz.cpp
#include <iostream> | |
#include <ctime> | |
#include <tuple> | |
constexpr const std::tuple<unsigned long, unsigned long> max(const unsigned int a, const unsigned int b) | |
{ | |
const auto c = [](auto&& s, const unsigned long n) constexpr -> const unsigned int { | |
if (n == 1) return 1; | |
return 1 + s(s, n % 2 ? n * 3 + 1 : n / 2); | |
}; |
View git submodule rm
#!/bin/bash | |
if [ "$1" != "" ]; then | |
git submodule deinit -f -- $1 | |
rm -rf .git/modules/$1 | |
git rm -f $1 | |
fi |
View Lens distortion GLSL
float k1 = 0.0; | |
float k2 = 0.0; | |
float k3 = 0.0; | |
float p1 = 0.0; | |
float p2 = 0.0; | |
const int lk = 12; | |
void mainImage( out vec4 fragColor, in vec2 fragCoord ) |
View gist:f3b28f5765b5a7d8edc3
#!/usr/bin/python | |
import sys | |
import numpy | |
import Queue | |
import numpy as np | |
import random | |
import matplotlib.pyplot as plt | |
NewerOlder