Skip to content

Instantly share code, notes, and snippets.

View boundsj's full-sized avatar

Jesse Bounds boundsj

View GitHub Profile
@boundsj
boundsj / python_env_mac.md
Last active February 6, 2016 13:07
Setting up a Python environment: Mac

Creating an Agile Python Environment: Mac

This gist assumes you are on a Mac. It also assumes that you already have Python and pip installed and that you are most likely using Python version 2.7.x. If your environment differs you may have to work a little harder to get things sorted but hopefully the gist of the gist (agile Python) will still be useful for you. If you are on a windows machine, this is probably not the gist you are looking for.

We will take the minimum amount of steps nessessary to set up a complete set of tools that are fully controllable from the command line. Use your text editor or IDE of choice for creating the spec and implementation files. Note that some IDEs (i.e. PyCharm) make some of what we cover below a lot easier (i.e. debugging) but it is probably still useful to understand what is going on behind the scenes.

We will create a simple application that pulls down Guido van Rossum's twitter feed and prints out some of his latest perls of wisdo

@boundsj
boundsj / SomeViewController.m
Created November 4, 2013 05:03
JavaScriptCore, Objective-C calln' javascripts
#import "ViewController.h"
@import JavaScriptCore;
@interface ViewController ()
@property (nonatomic, strong) JSContext *context;
@end
@implementation ViewController
@boundsj
boundsj / pckit.sh
Last active December 27, 2015 10:49
Add PivotalCoreKit as a submodule
# bash -c "$(curl -fsSL https://gist.github.com/boundsj/7314358/raw/be3e7f29f6d69b067bf9696fa4ebbaab07c62c82/pckit.sh)"
EXTERNALS="Externals"
if [ ! -d $EXTERNALS ]; then
mkdir Externals
fi
git submodule add https://github.com/pivotal/PivotalCoreKit.git Externals/PivotalCoreKit
git submodule init
@boundsj
boundsj / gist:9245097
Created February 27, 2014 05:52
protips
remember to change framework search paths for cedar specs to $(SRCROOT)/Specs/Frameworks to work on CI (i.e. travis)
@boundsj
boundsj / MyTextView.h
Created June 9, 2014 13:55
Subclass with Internal Delegate and Message Forwarding
#import <UIKit/UIKit.h>
@interface MyTextView : UITextView
@end
@boundsj
boundsj / TapableTextView.m
Last active August 29, 2015 14:05
Tappable Attributed UITextView
// in a tap gesture recognizer handler in view controller
// assuming you have a text view in controller called "myTextView"
- (void)myTextViewTapped:(UITapGestureRecognizer *)recognizer {
// get tap location in view in question
CGPoint location = [recognizer locationInView:self.myTextView];
// adjust location for text view's offsets
location.x -= self.myTextView.textContainerInset.left;
location.y -= self.myTextView.textContainerInset.top;
### Keybase proof
I hereby claim:
* I am boundsj on github.
* I am boundsj (https://keybase.io/boundsj) on keybase.
* I have a public key whose fingerprint is 8C6A AF5D 5922 5BF4 45A2 1278 54F0 7E43 1D15 92FF
To claim this, I am signing this object:
@boundsj
boundsj / force_touch_annotations.md
Last active August 4, 2016 16:14
Force touch annotations

Since an MGLAnnotationView is a UIView you can use familiar APIs to manipulate it. For example, on devices that support 3D touch, you can transform the view as a function of the touch force.

override func touchesMoved(touches: Set<UITouch>, withEvent event: UIEvent?) {
    super.touchesMoved(touches, withEvent: event)

    if let touch = touches.first {
        let normalizedForce = touch.force / touch.maximumPossibleForce * 2.5
        self.transform = CGAffineTransformMakeScale(1 + normalizedForce, 1 + normalizedForce)
    }
@boundsj
boundsj / earthquake_clusters.md
Last active September 21, 2016 01:27
earthquake clusters
    NSURL *url = [NSURL URLWithString:@"https://www.mapbox.com/mapbox-gl-js/assets/earthquakes.geojson"];
    MGLSource *source = [[MGLSource alloc] initWithSourceIdentifier:@"source"];
    MGLSymbolStyleLayer *symbolLayer = [[MGLSymbolStyleLayer alloc] initWithLayerIdentifier:@"place-city-sm" source:source];
    
    NSDictionary *options = @{MGLGeoJSONClusterOption: @(YES),
                              MGLGeoJSONClusterRadiusOption: @10,
                              MGLGeoJSONClusterMaximumZoomLevelOption: @15};
    
    MGLGeoJSONSource *geoJSONSource = [[MGLGeoJSONSource alloc] initWithSourceIdentifier:@"earthquakes" URL:url options:options];
@boundsj
boundsj / style_vector_layer.md
Created September 7, 2016 18:08
style_vector_layer
- (void)mapViewDidFinishLoadingMap:(MGLMapView *)mapView
{
    [self.mapView setStyleURL:[MGLStyle darkStyleURLWithVersion:9]];
    
    NSURL *url = [[NSURL alloc] initWithString:@"mapbox://mapbox.mapbox-terrain-v2"];
    MGLVectorSource *vectorSource = [[MGLVectorSource alloc] initWithSourceIdentifier:@"terrain-data" URL:url];
    [self.mapView.style addSource:vectorSource];
    
    MGLBackgroundStyleLayer *backgroundLayer = [[MGLBackgroundStyleLayer alloc] initWithLayerIdentifier:@"background"];