Skip to content

Instantly share code, notes, and snippets.

@mattfelsen
mattfelsen / gist:9467420
Last active February 2, 2023 22:28
Splitting strings by a delimiter for Arduino
//
// This is tested and works!
//
String input = "123,456";
int firstVal, secondVal;
for (int i = 0; i < input.length(); i++) {
if (input.substring(i, i+1) == ",") {
firstVal = input.substring(0, i).toInt();
secondVal = input.substring(i+1).toInt();
@mattfelsen
mattfelsen / VideoView-DrawMode.diff
Last active August 21, 2018 22:37
Bluecadet Views VideoView DrawMode for unwrapping a video in bands
diff --git a/apps/CentralStandard/src/Video/VideoView.cpp b/apps/CentralStandard/src/Video/VideoView.cpp
index c0c574e..750afab 100644
--- a/apps/CentralStandard/src/Video/VideoView.cpp
+++ b/apps/CentralStandard/src/Video/VideoView.cpp
@@ -13,7 +13,7 @@ using namespace bluecadet::utils;
namespace bluecadet {
namespace views {
-VideoView::VideoView() {
+VideoView::VideoView() : mDrawMode(DrawMode::Normal) {
@mattfelsen
mattfelsen / gist:8484e1d8ec26ef5443616dd80b10813e
Created December 7, 2017 13:36
Rotate point cloud into proper world space
// Transforms to move point cloud into correct world space
folder->addSlider("Camera tilt", -75, 75, 0)->bind(cameraTilt);
folder->addSlider("Camera roll", -30, 30, 0)->bind(cameraRoll);
folder->addSlider("Camera height", -60, 60, 0)->bind(cameraHeight);
// Shift around the rotated point cloud so its center sits on the origin
folder->addSlider("Shift X", -10, 10, 0)->bind(sceneShiftX);
folder->addSlider("Shift Y", -10, 10, 0)->bind(sceneShiftY);
folder->addSlider("Shift Z", -10, 10, 0)->bind(sceneShiftZ);
folder->addSlider("Floor plane", -100, 100, 0)->bind(floorPlane);
var builder = require('botbuilder');
var botbuilder_azure = require('botbuilder-azure');
var azure_storage = require('azure-storage');
var blobService = azure_storage.createBlobService();
var useEmulator = (process.env.NODE_ENV == 'development');
var connector = useEmulator ? new builder.ChatConnector() : new botbuilder_azure.BotServiceConnector({
appId: process.env['MicrosoftAppId'],
appPassword: process.env['MicrosoftAppPassword'],
@mattfelsen
mattfelsen / gist:9dce6913b4e034045a13
Last active August 21, 2016 02:06
Useful OS X command line system stuff

Number of connected displays

system_profiler SPDisplaysDataType | grep Resolution | wc -l | sed 's/ //g'

Whether the system is sleeping or not

1 is alseep, 4 is not sleeping

ioreg -n IODisplayWrangler | grep -i IOPowerManagement | perl -pe 's/^.*DevicePowerState\"=([0-9]+).*$/\1/'

Set or check scheduled sleep/shutdown/wake settings

@mattfelsen
mattfelsen / software-setup.md
Last active July 27, 2016 17:19
So you got a new computer, eh?

So you got a new computer, eh?

Point & click stuff

Xcode

  • Monokai theme
  • OF Addon Plugin
  • Prefs
    • Text editing -> indentation -> prefer tabs
    • Text editing -> show line numbers, trim whitespace from empty lines
@mattfelsen
mattfelsen / gist:e174f032fa10fa16cfb5
Last active March 2, 2016 22:36
Useful Git Commands

Commits

Undo last commit

git reset --soft HEAD~1

Add stuff to last commit

git add file.cpp
git commit --amend
@mattfelsen
mattfelsen / gist:3b32e1dac09eb6ad3534
Created January 14, 2015 05:14
3D -> 2D on a Cylinder
float theta, x, y, z;
theta = ofDegToRad(230); // 0 -> 360
x = cylRadius * cos(theta);
y = cylHeight * -0.4; // -h/2 -> h/2
z = cylRadius * sin(theta);
ofVec3f center = cam.worldToScreen( ofVec3f(x, y, z) );
cam.end();
@mattfelsen
mattfelsen / setup.sh
Last active August 29, 2015 14:08
Local Projects openFrameworks New Project Setup
#!/bin/bash
#
# NOTE: The openFrameworks folder structure (particularly with regard to the projectGenerator)
# has changed since this script was written, so this will probably not work!
# (The parts about creating a new project toward the end, at least.)
#
#
# usage:
@mattfelsen
mattfelsen / gist:9e0bae657104f98c2c95
Created October 13, 2014 15:58
WebSocket proxy server
var WebSocket = require('ws');
var WebSocketServer = require('ws').Server;
var client = new WebSocket('ws://localhost:7204/myo/1');
var wss = new WebSocketServer({ port: 9000 });
wss.broadcast = function(data) {
for (var i in this.clients) this.clients[i].send(data, function(){});
};