Skip to content

Instantly share code, notes, and snippets.

Keybase proof

I hereby claim:

  • I am cocoahero on github.
  • I am cocoahero (https://keybase.io/cocoahero) on keybase.
  • I have a public key whose fingerprint is 18E8 316A 9F5F 6120 73EA DB74 8418 CCF2 7101 A733

To claim this, I am signing this object:

@cocoahero
cocoahero / Error.txt
Last active September 21, 2017 14:28
fatal error: 'try!' expression unexpectedly raised an error: Swift.DecodingError.dataCorrupted(Swift.DecodingError.Context(codingPath: [Foundation.(_JSONKey in _12768CA107A31EF2DCE034FD75B541C9)(stringValue: "Index 3", intValue: Optional(3))], debugDescription: "Cannot initialize Season from invalid String value fall", underlyingError: nil)): file /Library/Caches/com.apple.xbs/Sources/swiftlang/swiftlang-900.0.65/src/swift/stdlib/public/core/ErrorType.swift, line 181
extension SignalProducer where Value == (Data, URLResponse), Error == AnyError {
func jsonDecode<T: Decodable>(decoder: JSONDecoder = JSONDecoder()) -> SignalProducer<T, AnyError> {
return attemptMap({ data, _ in
try decoder.decode(T.self, from: data)
})
}
}
extension SignalProducer where Value: Encodable, Error == AnyError {
func jsonEncode(encoder: JSONEncoder = JSONEncoder()) -> SignalProducer<Data, AnyError> {

Keybase proof

I hereby claim:

  • I am cocoahero on github.
  • I am cocoahero (https://keybase.io/cocoahero) on keybase.
  • I have a public key whose fingerprint is 1E98 584E DC62 7645 C0B6 D5A3 5B28 7E51 482A 74CB

To claim this, I am signing this object:

@cocoahero
cocoahero / README.md
Created December 10, 2012 22:21
Android Google Maps API v2 - MapBoxOfflineTileProvider

Code Moved

The code for MapBoxOfflineTileProvider has been moved into an Android Library Project located here.

@cocoahero
cocoahero / README.md
Created December 5, 2012 01:15
Android Google Maps API v2 - MapBoxOnlineTileProvider

Code Moved

The code for MapBoxOnlineTileProvider has been moved into an Android Library Project located here.

@cocoahero
cocoahero / gist:3177433
Created July 25, 2012 17:34
OSMDroid MapQuestOSM
this.mMapView = new MapView(this, 256);
this.mMapView.setClickable(true);
this.mMapView.setMultiTouchControls(true);
this.mMapView.setTileSource(TileSourceFactory.MAPQUESTOSM);
this.mMapView.getController().setZoom(5);
@cocoahero
cocoahero / gist:3177422
Created July 25, 2012 17:33
OSMDroid MBTiles
XYTileSource MBTILESRENDER = new XYTileSource("mbtiles", ResourceProxy.string.offline_mode, 1, 20, 256, ".png", "http://example.org/");
DefaultResourceProxyImpl mResourceProxy = new DefaultResourceProxyImpl(this.getApplicationContext());
SimpleRegisterReceiver simpleReceiver = new SimpleRegisterReceiver(this.getActivity());
File f = new File(Environment.getExternalStorageDirectory(), "mymbtilesfile.mbtiles");
IArchiveFile[] files = { MBTilesFileArchive.getDatabaseFileArchive(f) };
MapTileModuleProviderBase moduleProvider = new MapTileFileArchiveProvider(simpleReceiver, MBTILESRENDER, files);
@cocoahero
cocoahero / README.md
Created July 12, 2012 17:05
Android Auto-Versioning w/ Git

It is common practice to make the android:versionCode in the AndroidManifest.xml the build number of the application. An easy build number to calculate is the number of git commits in the repo.

Instead of having to edit the manifest file manually and update the android:versionCode attribute with the build number, below is a git pre-commit hook that does it for you.

#!/usr/bin/env bash

MANIFEST="AndroidManifest.xml"

if [ -f $MANIFEST ]
@cocoahero
cocoahero / UIColor+Hexadecimal.h
Created January 17, 2012 21:17
An extension to the UIColor class for working with hexadecimal representations.
#import <UIKit/UIKit.h>
@interface UIColor (Hexadecimal)
/**
* Convenience method for creating a UIColor object from a hexadecimal
* representation.
*
* @param hexcode A color in hexadecimal represenation
* @param alpha The alpha (opacity) percentage