Skip to content

Instantly share code, notes, and snippets.

View 2bbb's full-sized avatar

2bit 2bbb

View GitHub Profile
@2bbb
2bbb / method_checker.cpp
Created December 18, 2015 02:34
method_checker_macro
#define method_checker(name, method, result, ...)\
template <typename T>\
struct name {\
template <typename testee, result (testee::*)(__VA_ARGS__) = &testee::method> struct tester {};\
template <typename testee> static std::true_type test(tester<testee> *);\
template <typename> static std::false_type test(...);\
static constexpr bool has_method = decltype(test<T>(nullptr))::value;\
};
method_checker(has_update, update, void);
@2bbb
2bbb / osx_sdk_setup.sh
Last active December 22, 2015 00:19
osx_sdk_setup
#!/bin/bash
# MacOSX-SDKs: download from https://github.com/phracker/MacOSX-SDKs
FROM=5
TO=10
CMD="/usr/bin/sudo /bin/ln -s"
MY_PATH=`pwd`
@2bbb
2bbb / ofApp.cpp
Last active January 6, 2016 14:31
linear regression study
#include "ofMain.h"
namespace linear_regression {
using default_value_type = float;
template <std::size_t num, typename value_type = default_value_type>
struct model {
using record = std::array<value_type, num>;
using result = value_type;
using datum = std::pair<record, result>;
@2bbb
2bbb / vector.cpp
Created January 8, 2016 06:55
vector
#include <iostream>
#include <type_traits>
#include <array>
#include <cmath>
#if 201402L <= __cplusplus
# define constexpr_14 constexpr
#else
# define constexpr_14
#endif
//
// logistic_regression.hpp
//
// Created by ISHII 2bit on 2016/01/08.
//
//
#pragma once
#include "vec.hpp"
@2bbb
2bbb / flex_array.cpp
Last active January 13, 2016 13:37
flex_array
#include <iostream>
#include <array>
namespace bbb {
template <typename type>
using get_type = typename type::type;
namespace sequences {
template <typename type, type ... ns>
struct integer_sequence {
using value_type = type;
@2bbb
2bbb / cpwd
Created March 2, 2016 19:08
copy path of current directory to clipboard in terminal
#!/bin/bash
echo -n "`pwd`" | pbcopy
@2bbb
2bbb / get_cloned
Last active March 7, 2016 12:22
get list of addons remote
#!/bin/bash
cd $1
FILES="./*"
for FILEPATH in $FILES;
do
if [ -d $FILEPATH ];
then
cd $FILEPATH
/usr/bin/git config --get remote.origin.url >/dev/null 2>&1
@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
@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)