Skip to content

Instantly share code, notes, and snippets.

@jonnyhopper
jonnyhopper / xcode_copyfiles.py
Created June 2, 2017 11:36
Insert a PBXCopyFilesBuildPhase into an xcode project
import re
import sys
import uuid
# generate a 24 character uid for the project file
def new_uid():
return uuid.uuid1().hex[:24].upper()
def add_copyfiles_phase( project_path, file_path, file_name ):
with open (project_path, 'r') as projfile:
@jonnyhopper
jonnyhopper / quadratic_bezier.cpp
Created May 30, 2017 20:00
How to make a quadratic bezier curve in like 4 lines, less if you put it all on one line and don't write the comments
// Assuming you have a 2d or 3d point datatype
// and a value t in 0..1, which is your point on the curve
point bezier_points[3] = { ... };
point q0 = lerp( t, bezier_points[0], bezier_points[1] );
point q1 = lerp( t, bezier_points[1], bezier_points[2] );
point b = lerp( t, q0, q1 );
@jonnyhopper
jonnyhopper / PoinyOnPolygonEdge.cpp
Created December 8, 2016 09:29
Find the point along an edge of a regular polygon, given an angle
v2 PointOnPolygonEdge( v2 centre, float angle, float radius, int num_sides )
{
// the midpoint on the polygon edge
const float apothem = radius * cosf( PI / (float)num_sides );
const float segment_angle = TWO_PI / (float)num_sides;
// find min segment vertex, rotated by half a segment
const float min_segment = segment_angle * ( 0.5f + (int)( angle / segment_angle ) );
// get a lerp that goes from 0 ... 1 ... 0 at vertex ... apothem ... vertex
@jonnyhopper
jonnyhopper / installation.rst
Last active May 4, 2016 14:29 — forked from UnderGreen/installation.rst
Installation instruction for Kallithea

Setting up Kallithea on Ubuntu Server 12.04

Preparation

  1. Install Ubuntu Server.
  2. Update Ubuntu with the commands: