Skip to content

Instantly share code, notes, and snippets.

View benjaminbojko's full-sized avatar

Benjamin Bojko benjaminbojko

View GitHub Profile
@benjaminbojko
benjaminbojko / ProjectConfig.props
Created December 21, 2018 21:53
VS CinderPath Property Sheet
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" InitialTargets="CreateUserConfig; AddCinderDir">
<ImportGroup Label="PropertySheets" />
<ItemDefinitionGroup />
<PropertyGroup Label="FileReferences">
<!-- Default Cinder path relative to this file; Override in custom props file -->
<CinderDir>$([System.IO.Path]::GetFullPath('$(MSBuildThisFileDirectory)\..'))</CinderDir>
<UserFile>$([System.IO.Path]::GetFullPath('$(MSBuildThisFileDirectory)\UserConfig.props'))</UserFile>
</PropertyGroup>
@benjaminbojko
benjaminbojko / glm_quat_angle_test.h
Last active August 24, 2017 17:06
GLM Quaternion angleAxis to angle vs roll
vector<float> degs = {60, 120, 180, 240, 300, 360, 420, 480, -60, -120, -180, -240, -300, -360, -420, -480};
// angleAxis -> angle
for (float deg : degs) {
float rad = glm::radians(deg);
glm::quat rot = glm::angleAxis(rad, glm::vec3(0, 0, 1));
std::cout << "angleAxis -> angle: " + to_string(deg) + " deg -> " + to_string(glm::degrees(glm::angle(rot))) + " deg" << std::endl;
}
// angleAxis -> roll
@benjaminbojko
benjaminbojko / AnimOperators.h
Last active July 27, 2017 00:14
Cinder Animation Operators
#pragma once
#include "cinder/Tween.h"
//==================================================
// Anim<T> + T
//
template<typename T>
inline T operator + (const ci::Anim<T> & tween, const T & value) {
@benjaminbojko
benjaminbojko / CinderProjectApp.cpp
Created December 17, 2014 23:32
Display RTSP Stream in Cinder using OpenCV
#include "cinder/app/AppNative.h"
#include "cinder/gl/Texture.h"
#include "CinderOpenCV.h"
using namespace ci;
using namespace ci::app;
static std::string const VideoStreamAddress = "rtsp://user:pass@domain.com/path/to/stream";
@benjaminbojko
benjaminbojko / LinkedTextView.h
Last active March 21, 2024 18:22
UITextView Subclass to avoid Long-Press Delays with embedded Links
//
// LinkedTextView.h
//
// Created by Benjamin Bojko on 10/22/14.
//
// The MIT License (MIT)
//
// Copyright (c) 2014 Benjamin Bojko
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
@benjaminbojko
benjaminbojko / UITextView+LayoutHelpers.h
Last active August 29, 2015 14:08
Calculate content size for UITextView
//
// UITextView+LayoutHelpers.h
//
// Created by Benjamin Bojko on 10/24/14.
// Copyright (c) 2014 Benjamin Bojko. All rights reserved.
//
#import <UIKit/UIKit.h>
@interface UITextView (LayoutHelpers)
@benjaminbojko
benjaminbojko / color-workflow-tools.md
Last active August 29, 2015 14:05
Color Workflow Tools

Color Workflow Tools

No matter how well organized or spec'ed out a PSD is, there's always that point where you have to manually bring colors from design to code. Here are a few tools that have helped me get a seamless 360° workflow for dealing with colors in OS X.

Alfred 2 Colors Workflow

Amazing workflow by Tyler Eich that allows you to preview, modify and convert colors in a bunch of different color spaces and formats (rgb, hsl, hex, ...). Great if you want to convert those hex values to RGB for CSS.

@benjaminbojko
benjaminbojko / .clang-format
Created August 5, 2014 17:34
Clang Format Settings for Xcode iOS Projects
---
BasedOnStyle: Google
PointerBindsToType: false
ObjCSpaceAfterProperty: true
ObjCSpaceBeforeProtocolList: true
ColumnLimit: 160
UseTab: Never
IndentWidth: 4
TabWidth: 4
AllowAllParametersOfDeclarationOnNextLine: false
@benjaminbojko
benjaminbojko / iOS Background Download Gotchas.md
Last active August 10, 2019 00:38
iOS Background Download Gotchas

iOS Background Download Gotchas

I've been doing some thorough investigations into setting up a solid background download process. Here are some of the gotchas I stumbled upon and wanted to capture:

Background Tasks

  • Only download and upload tasks are allowed to run in the background (no data tasks)
  • Once a download task completes, your app will have to move that task from its temporary location to a permament location (or process the data somehow); The temporary file will be deleted once the URLSession:downloadTask:didFinishDownloadingToURL: delegate method returns.

App Suspension

  • If your app is suspended, it will be re-launched whenever a background task completes
@benjaminbojko
benjaminbojko / gist:f38e88daab3a10b5ee7c
Last active August 29, 2015 14:02
[Cinder] Different Image Sizing Snippets
using namespace ci;
enum Sizing {
//! Native resolution with no scaling
Native,
//! Fit exactly by scaling x/y independently
Fit,
//! Resize to fit at least mSize while maintaining aspect ratio
Aspect,
//! Resize to fit at most mSize while maintaining aspect ratio