Skip to content

Instantly share code, notes, and snippets.

View 2bbb's full-sized avatar

2bit 2bbb

View GitHub Profile
@2bbb
2bbb / crc8.js
Created July 28, 2015 10:31
crc8
function crc8(arr) {
var crc = 0;
for(var i = 0; i < arr.length; i++) {
crc ^= arr[i];
for(var j = 0; j < 8; j++) {
if(crc & 0x80) {
crc <<= 1;
crc ^= 0x85;
} else {
crc <<= 1;
@2bbb
2bbb / ofApp.cpp
Created September 10, 2015 11:42
taylor
#include "ofMain.h"
double frac_table[101];
double frac(int n) {
double v = 1;
for(int i = 1; i <= n; i++) {
v *= i;
}
return v;
@2bbb
2bbb / symbolic.cpp
Last active September 14, 2015 21:46
symbolic
#include <functional>
#include <tuple>
#include <memory>
namespace symbolic {
template <typename T>
using ref = std::shared_ptr<T>;
template <typename type>
struct value {
@2bbb
2bbb / main.cpp
Created October 24, 2015 20:50
memset_pattern4 test
#include <iostream>
#include <chrono>
#include <string.h>
namespace laziness {
struct SimpleStopWatch {
void start() {
_start = std::chrono::high_resolution_clock::now();
}
@2bbb
2bbb / ofApp.cpp
Last active November 4, 2015 08:32
Linear Transform
#include "ofMain.h"
class LinearTransform {
public:
LinearTransform() {
}
LinearTransform(float u11, float u12, float u13,
float u21, float u22, float u23,
@2bbb
2bbb / ofTrueTypeFont.cpp
Created December 13, 2015 07:09
ofTrueTypeFont
#include "ofTrueTypeFont.h"
//--------------------------
#include <ft2build.h>
#ifdef TARGET_LINUX
#include <fontconfig/fontconfig.h>
#endif
#include FT_FREETYPE_H
@2bbb
2bbb / main.cpp
Created December 13, 2015 12:12
iterator
#include <iostream>
#include <string>
#include <vector>
struct custom_vectroid {
using data_type = std::vector<std::string>;
data_type data;
using iterator = data_type::iterator;
using const_iterator = data_type::const_iterator;
@2bbb
2bbb / main.cpp
Created December 13, 2015 12:14
lambda_template
#include <iostream>
#include <functional>
#include <tuple>
namespace bbb {
template <typename T>
struct function_info : public function_info<decltype(&T::operator())> {};
template <typename class_type, typename ret, typename ... arguments>
struct function_info<ret(class_type::*)(arguments ...) const> {
@2bbb
2bbb / main.cpp
Created December 13, 2015 12:16
black_magic
#include <iostream>
#include <type_traits>
template<typename T, typename U>
struct lambda_check {
static constexpr bool value = !std::is_same<T, U>::value;
};
template <typename fun1, typename fun2>
constexpr bool is_lambda_(fun1, fun2) {
@2bbb
2bbb / iterator_delegation.cpp
Last active December 18, 2015 01:28
iterator_delegation
#include <type_traits>
#include <iterator>
namespace bbb {
template <typename container>
struct iteratable_class_traits {
#pragma mark iterator
struct forward_iterator_check {