Skip to content

Instantly share code, notes, and snippets.

View anthonycastelli's full-sized avatar

Anthony anthonycastelli

View GitHub Profile
@anthonycastelli
anthonycastelli / UINavigationBariOS7.m
Last active December 23, 2015 16:38
Bright blurred UINavigationBar's in iOS 7
// Huge thanks to @stroughtonsmith for discovering this
CALayer *navBar = [CALayer layer];
[navBar setBackgroundColor:[UIColor blueColor] CGColor];
[navBar setFrame:CGRectMake(0, -20, 320, 64)]; // Navigation Bars are 44 points and the statusbar is 20 points
[navBar setOpacity:0.70];
[self.navigationController.navigationBar.layer insertSublayer:navBar atIndex:1];
@anthonycastelli
anthonycastelli / UIImage+Snapshot.m
Created October 14, 2013 02:01
Snapshotting on iOS
+ (UIImage *)snapshotView:(UIView *)view {
UIGraphicsBeginImageContextWithOptions(view.frame.size, NO, [[UIScreen mainScreen] scale]); //0
[view drawViewHierarchyInRect:view.frame afterScreenUpdates:YES];
UIImage *snapshot = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
return snapshot;
}
+ (UIImage *)snapshot {
CGSize imageSize = CGSizeZero;

Keybase proof

I hereby claim:

  • I am anthonycastelli on github.
  • I am anth (https://keybase.io/anth) on keybase.
  • I have a public key whose fingerprint is 8899 4C18 86B5 4780 34D4 F9B9 6034 348C AADD C434

To claim this, I am signing this object:

@anthonycastelli
anthonycastelli / gist:7e8a8cdf7ac3a21e86a6
Created October 12, 2014 23:25
Child View Controllers
- (void)replaceViewController:(UIViewController *)replacementViewController {
// Load the new view controller
[self addChildViewController:replacementViewController];
[replacementViewController.view setFrame:self.view.bounds];
[self.view addSubview:replacementViewController.view];
[replacementViewController didMoveToParentViewController:self];
// Get rid of the old one
[self.selectedViewController willMoveToParentViewController:nil];
[self.selectedViewController.view removeFromSuperview];
@anthonycastelli
anthonycastelli / renamer.py
Last active August 29, 2015 14:14
Batch rename movie files
# To run this script, simply call
# $ python renamer.py "/path/to/folder" "S01" " - "
# This will take a file with a divider in it and add
# the appropriate formatting to work better with
# Plex Media Server.
# i.e. "Season 1 Episode 21 Episode Name.mp4" would become
# "S01E21 Episode Name.mp4"
import os
import sys
@anthonycastelli
anthonycastelli / resizer.py
Created February 10, 2015 21:01
iOS 8 Icons
import os
import sys
import numpy
from PIL import Image
if len(sys.argv) < 3:
print('You must specifiy an image and an output folder')
print('i.e. "resizer.py image.png output_folder_name')
sys.exit(1)
Verifying I am +anth on my passcard. https://onename.com/anth
// You'll need this https://gist.github.com/jorgenisaksson/76a8dae54fd3dc4e31c2
extension NSBezierPath {
func toCGPath () -> CGPath? {
if self.elementCount == 0 {
return nil
}
let path = CGPathCreateMutable()
var didClosePath = false
init() {
print("•", RLMRealm.default().configuration.fileURL?.path)
var config = Realm.Configuration(
// Set the new schema version. This must be greater than the previously used
// version (if you've never set a schema version before, the version is 0).
schemaVersion: 1,
// Set the block which will be called automatically when opening a Realm with
// a schema version lower than the one set above
@anthonycastelli
anthonycastelli / Fluent+Date.swift
Created April 15, 2017 02:18
Fluent+Date.swift
//
// Fluent+Date.swift
//
//
// Created by Anthony Castelli on 12/10/16.
//
//
import Foundation
import Fluent