Skip to content

Instantly share code, notes, and snippets.

View benjaminbojko's full-sized avatar

Benjamin Bojko benjaminbojko

View GitHub Profile
@benjaminbojko
benjaminbojko / .jsbeautifyrc
Last active August 29, 2015 13:56
JS Beautify Settings
{
// Details: https://github.com/victorporof/Sublime-HTMLPrettify#using-your-own-jsbeautifyrc-options
// Documentation: https://github.com/einars/js-beautify/
"html": {
"brace_style": "collapse", // "expand", "end-expand", "expand-strict"
"indent_char": " ",
"indent_scripts": "keep", // "separate", "normal"
"indent_size": 2,
"max_preserve_newlines": 10,
"preserve_newlines": true,
@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
@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 / 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 / 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 / gist:4028025
Created November 6, 2012 22:18
Flip and Reload a single UIView
/// based on http://stackoverflow.com/questions/347721/how-do-i-apply-a-perspective-transform-to-a-uiview
[UIView animateWithDuration:0.3f delay:0.0f options:UIViewAnimationOptionBeginFromCurrentState|UIViewAnimationOptionCurveEaseIn animations:^{
CATransform3D rotationAndPerspectiveTransform = CATransform3DIdentity;
rotationAndPerspectiveTransform.m34 = 1.0 / -500;
rotationAndPerspectiveTransform = CATransform3DRotate(rotationAndPerspectiveTransform, M_PI_2, 0.0f, 1.0f, 0.0f);
[self.view.layer setTransform:rotationAndPerspectiveTransform];
} completion:^(BOOL finished) {
// REFRESH YOUR VIEW HERE
@benjaminbojko
benjaminbojko / gist:3751079
Created September 19, 2012 17:50
Convert NodeJS JSON Date String to Objective C Date
// Modified version of an Apple Docs example that accomodates for the extra milliseconds used in NodeJS/JS dates
// https://developer.apple.com/library/ios/#documentation/Cocoa/Conceptual/DataFormatting/Articles/dfDateFormatting10_4.html#//apple_ref/doc/uid/TP40002369-SW1
- (NSDate *)dateForRFC3339DateTimeString:(NSString *)rfc3339DateTimeString {
NSDateFormatter *rfc3339DateFormatter = [[NSDateFormatter alloc] init];
[rfc3339DateFormatter setDateFormat:@"yyyy'-'MM'-'dd'T'HH':'mm':'ss'.'SSS'Z'"];
[rfc3339DateFormatter setTimeZone:[NSTimeZone timeZoneForSecondsFromGMT:0]];
// Convert the RFC 3339 date time string to an NSDate.
@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 / 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 / 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>