Skip to content

Instantly share code, notes, and snippets.

@mbuff24
mbuff24 / InheritedAnimationDurationOverride.swift
Created October 4, 2016 15:18
Overriding inherited animation speed in tvOS
override func didUpdateFocus(in context: UIFocusUpdateContext, with coordinator: UIFocusAnimationCoordinator) {
super.didUpdateFocus(in: context, with: coordinator)
let duration = UIView.inheritedAnimationDuration * 2
UIView.animate(withDuration: duration, delay: 0, options: [.overrideInheritedDuration, .overrideInheritedCurve], animations: { [weak self] in
self?.layoutIfNeeded()
}, completion: nil)
}
@mbuff24
mbuff24 / Playground.swift
Created September 1, 2016 19:26
Copying a swift struct with a reference type property
//: Playground - noun: a place where people can play
import UIKit
class Person: CustomDebugStringConvertible {
let name: String
init(name: String) {
self.name = name
}
//: Playground - noun: a place where people can play
import UIKit
import XCPlayground
import QuartzCore
extension UIImage {
class func imageWithLabel(label: UILabel) -> UIImage {
UIGraphicsBeginImageContextWithOptions(label.bounds.size, false, 0.0)
import java.io.*;
import java.util.*;
public class Solution {
static class Operation {
public int a;
public int b;
public int k;
@mbuff24
mbuff24 / crush.js
Created December 28, 2015 23:15
Naive javascript solution for Algorithmic Crush -- https://www.hackerrank.com/contests/w4/challenges/crush
String.prototype.splitSpacesAsInts = function() {
return this.split(" ").map(function(aNum) { return parseInt(aNum); });
};
function processData(input) {
var lines = input.split("\n");
var first = lines[0].splitSpacesAsInts();
var n = first[0];
var m = first[1];
var ops = lines.slice(1).map(function(line) { return line.splitSpacesAsInts(); });
//http://maven.apache.org/guides/getting-started/maven-in-five-minutes.html
mvn archetype:generate -DgroupId=com.mycompany.app -DartifactId=my-app -DarchetypeArtifactId=maven-archetype-quickstart -DinteractiveMode=false
@mbuff24
mbuff24 / allow_public_read.json
Created November 25, 2014 03:01
Allow public read access to s3 bucket (S3 tab -> Edit bucket policy -> paste in textarea -> money!)
{
"Version":"2012-10-17",
"Statement":[{
"Sid": "AddPerm",
"Effect": "Allow",
"Principal": "*",
"Action": ["s3:GetObject"],
"Resource": [
"arn:aws:s3:::bucket-name/*"
]
@mbuff24
mbuff24 / ffmpeg_ec2.txt
Created November 18, 2014 15:52
Installing ffmpeg on ec2
INSTALLING FFMPEG ON EC2
I just received this excellent how-to from AWS Support and it worked for me on my Amazon Linux AMI release 2013.09. It would probably work this way for any Linux distribution
1. SSH into your instance and become root
sudo su -
2. Go to the the /usr/local/bin directory
cd /usr/local/bin
# Treebank Parser tag definitions
# https://www.ling.upenn.edu/courses/Fall_2003/ling001/penn_treebank_pos.html
#
# Triplet Extraction paper
# http://ailab.ijs.si/dunja/SiKDD2007/Papers/Rusu_Trippels.pdf
import json
ADJECTIVE_TYPES = ["JJ", "JJR", "JJS"]
NOUN_TYPES = ["NN", "NNP", "NNPS", "NNS"]
@mbuff24
mbuff24 / gist:f2b473f1c76b798ae644
Created October 10, 2014 20:17
Making a capture style button with a UIView and 2 CALayers
class MainController: UIViewController {
@IBOutlet weak var captureButton: UIView?
let BORDER_WIDTH:CGFloat = 4
let RADIUS_MULTIPLIER:CGFloat = 0.5
let BUTTON_COLOR = UIColor.redColor().CGColor
let BUTTON_PRESSED_COLOR = UIColor.whiteColor().CGColor
let INNER_BUTTON_OFFSET = 0.4