Skip to content

Instantly share code, notes, and snippets.

View 2bbb's full-sized avatar

2bit 2bbb

View GitHub Profile
@2bbb
2bbb / ofApp.cpp
Created March 30, 2016 08:30
check order of xorshift32 is 2^32 - 1
#include "ofMain.h"
#include <array>
template <std::size_t size_, typename T>
struct mat {
static constexpr std::size_t size = size_;
std::array<std::array<T, size>, size> body;
std::array<T, size> &operator[](std::size_t index) {
@2bbb
2bbb / ofApp.cpp
Created October 2, 2016 11:10
ofxExtendedOscMessage
#include "ofMain.h"
#include "ofxOsc.h"
#include "ofxExtendedOscMessage.h"
class ofApp : public ofBaseApp {
ofxOscReceiver receiver;
ofxOscSender sender;
public:
void setup() {
sender.setup("localhost", 9005);
@2bbb
2bbb / open_code.scpt
Created February 28, 2017 11:56
open directory on current Finder window on code
const Finder = Application("Finder");
Finder.activate();
const window = Finder.finderWindows()[0];
const path = decodeURI(window.target().url().slice(7));
const currentApp = Application.currentApplication();
currentApp.includeStandardAdditions = true;
currentApp.doShellScript("/usr/local/bin/code " + path);
@2bbb
2bbb / ofxListenerUtils.h
Created March 3, 2017 19:49
ofxListenerUtils
//
// ofxListenerUtils.h
//
// Created by ISHII 2bit on 2017/03/04.
//
//
#pragma once
#ifndef ofxListenerUtils_h
@2bbb
2bbb / build.sh
Last active March 6, 2017 06:43
ableton link test on Linux with node-abletonlink
#!/bin/bash
g++ -Inode_modules/abletonlink/libs/link/include -Inode_modules/abletonlink/libs/link/modules/asio-standalone/asio/include -std=c++11 -DLINK_PLATFORM_LINUX=1 -pthread link.cpp -o link.o
@2bbb
2bbb / iterator_utils.hpp
Last active March 13, 2017 22:25
container_util
#include <iterator>
namespace bbb {
namespace detail {
template <typename _>
std::true_type make_true(_ = std::declval<_>());
};
template <typename checkee_type>
struct is_iteratable {
@2bbb
2bbb / MatF2.js
Created June 1, 2017 11:06
MatF2
const MatF2 = {
from_string: M => M.split('\n').map(l => l.replace(/ /g, '')).filter(l => l != '').map(l => l.split('').map(b => 0 ^ b)),
translate: M => M[0].map(() => (M.map(() => 0))).map((l, i) => l.map((_, j) => M[j][i])),
product: (G, H) => {
const res = [];
for(let i = 0; i < G.length; i++) {
const arr = [];
for(let j = 0; j < H[0].length; j++) {
let tmp = 0;
for(let k = 0; k < H.length; k++) {
@2bbb
2bbb / vec2.js
Created June 5, 2017 13:07
vec2
var bbb = {};
bbb.extend = function(dst, src) {
for(var key in src) if(src.hasOwnProperty(key)) dst[key] = src[key];
return dst;
};
bbb.math = {};
var vec2 = (function() {
@2bbb
2bbb / overloadable_function.js
Last active June 10, 2017 17:40
overloadable_function
function fun(org = function(...args) { throw new Error("overload failed", args.map(a => typeof a)); }, ... others) {
const overload_functions = {};
if(others.length) {
overload_functions[others.map(a => a.constructor.name)] = org;
org = function(...args) { throw new Error("overload failed", args.map(a => typeof a)); };
}
const f = function(... args) {
return ((overload_functions[args.map(a => a.constructor.name)] || org).bind(this))(... args);
}
f.overload = function(overloading_function, ...args) {
@2bbb
2bbb / pipe_ex.cpp
Created June 16, 2017 04:20
pipe example
#include <bbb/pipe.hpp>
#include <iostream>
int main(int argc, char *argv[]) {
std::string str = "a/b/cdcd/ezzzf/ghi/azzz/czzzd/ef";
auto res = str
| bbb::replace("zzz", "Z") // "a/b/cdcd/eZf/ghi/aZ/cZd/ef"
| bbb::split("/") // {"a", "b", "cdcd", "eZf", "ghi", "aZ", "cZd", "ef"}
| bbb::filter([](std::string str) { return str.length() < 3; }) // {"a", "b", "aZ", "ef"}