Skip to content

Instantly share code, notes, and snippets.

View 2bbb's full-sized avatar

2bit 2bbb

View GitHub Profile
@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 / 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 / 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 / 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 / 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 / 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 / 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 / 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 / ofxVersionMacro.h
Created March 24, 2016 11:53
OFX_VERSION_MACRO
#pragma once
#include "ofConstants.h"
#define OFX_MAKE_OF_VERSION(major, minor, patch) (major * 10000 + minor * 100 + patch)
#define OFX_THIS_OF_VERSION OFX_MAKE_OF_VERSION(OF_VERSION_MAJOR, OF_VERSION_MINOR, OF_VERSION_PATCH)
#define OFX_THIS_OF_IS_OLDER_THAN(major, minor, patch) (OFX_OF_VERSION < OFX_MAKE_OF_VERSION(major, minor, patch))
#define OFX_THIS_OF_IS_OLDER_THAN_EQ(major, minor, patch) (OFX_OF_VERSION <= OFX_MAKE_OF_VERSION(major, minor, patch))
#define OFX_THIS_OF_IS_NEWER_THAN(major, minor, patch) (OFX_MAKE_OF_VERSION(major, minor, patch) < OFX_OF_VERSION)
#define OFX_THIS_OF_IS_NEWER_THAN_EQ(major, minor, patch) (OFX_MAKE_OF_VERSION(major, minor, patch) <= OFX_OF_VERSION)
@2bbb
2bbb / cloneclone
Created March 7, 2016 12:27
clone cloned addons from $1 to $2
#!/bin/bash
cd $1
FILES="*"
for FILEPATH in $FILES;
do
if [ -d $FILEPATH ];
then
cd $FILEPATH
git config --get remote.origin.url >/dev/null 2>&1