Skip to content

Instantly share code, notes, and snippets.

@cameroncooke
cameroncooke / AppAPNSender.class.php
Created December 12, 2012 17:38
Apple Push Notification message sender
<?php
/**
* Basic Apple Push Notification sender
*
* @package default
* @author Cameron Cooke (Brightec Ltd)
**/
class AppAPNSender
{
@cameroncooke
cameroncooke / keyboard.m
Last active October 16, 2015 18:36
The (not so) ultimate UIScrollView keyboard appearance and disappearance implementation
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@cameroncooke
cameroncooke / BTFormSheetViewController.h
Last active September 18, 2015 14:18
On iPad allows you to present a view controller in a form sheet with regular/regular traits
//
// BTFormSheetViewController.h
//
// Created by Cameron Cooke on 18/09/2015.
// Copyright © 2015 Brightec. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
@cameroncooke
cameroncooke / UIViewController+AutoRotation.m
Last active November 1, 2021 23:34
Propagates shouldAutorotate and supportedInterfaceOrientations calls to UITabBarController, UINavigationController and UISplitViewController.
//
// By Cameron Cooke at Brightec Ltd.
//
// Based on code from Stack Overflow: http://stackoverflow.com/a/15023156/248848
//
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
@cameroncooke
cameroncooke / unsign-xcode.sh
Last active October 20, 2016 09:51
Unsign Xcode 8+ so that 3rd party plug-ins can be used again
# Install unsign
wget https://github.com/steakknife/unsign/archive/master.zip ~/Downloads
cd ~/Downloads
unzip unsign-master.zip
cd unsign-master
make
cp ./unsign /usr/local/bin
# Copy Xcode
@cameroncooke
cameroncooke / navigation_bar_hide.swift
Created July 6, 2017 07:21
Hides navigation bar for current controller and shows it smoothly on push and hides it on pop.
override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
if let navigationController = navigationController,
presentedViewController == nil {
navigationController.setNavigationBarHidden(true, animated: true)
}
}
@cameroncooke
cameroncooke / gist:13dac92bf35045e8095272dbdf34ba95
Created April 28, 2018 11:40
List top 10 .swift files sorted by number of lines
find . -type f -name "*.swift" -exec wc -l {} + | sort -nr | head
@cameroncooke
cameroncooke / nsscreencast_downloader.rb
Created August 22, 2018 21:32
Downloads videos from nsscreencast (requires paid account)
# Using this script downloads ALL the videos in NSScreencast.
# Usage: `EMAIL=your email PASSWORD=your password.`
require 'HTTParty'
require 'Nokogiri'
require 'pry'
require "mechanize"
require "parallel"
class Scraper