Skip to content

Instantly share code, notes, and snippets.

View JoeFerrucci's full-sized avatar

Joe Ferrucci JoeFerrucci

  • Instacart
  • San Francisco, CA
View GitHub Profile
@JoeFerrucci
JoeFerrucci / s3.sh
Created November 8, 2017 22:03 — forked from chrismdp/s3.sh
Uploading to S3 in 18 lines of Shell (used to upload builds for http://soltrader.net)
# You don't need Fog in Ruby or some other library to upload to S3 -- shell works perfectly fine
# This is how I upload my new Sol Trader builds (http://soltrader.net)
# Based on a modified script from here: http://tmont.com/blargh/2014/1/uploading-to-s3-in-bash
S3KEY="my aws key"
S3SECRET="my aws secret" # pass these in
function putS3
{
path=$1
@JoeFerrucci
JoeFerrucci / google_drive_create_file_example.go
Created October 30, 2017 21:43 — forked from atotto/google_drive_create_file_example.go
google drive example (v3 create file)
package main
import (
"encoding/json"
"fmt"
"io/ioutil"
"log"
"net/http"
"net/url"
"os"
@JoeFerrucci
JoeFerrucci / apns
Created December 9, 2016 02:51 — forked from fahied/apns
How to create APNS Certificates and merge into one PEM
Step 1: Create Certificate .pem from Certificate .p12
Command: openssl pkcs12 -clcerts -nokeys -out apns-dev-cert.pem -in apns-dev-cert.p12
Step 2: Create Key .pem from Key .p12
Command : openssl pkcs12 -nocerts -out apns-dev-key.pem -in apns-dev-key.p12
Step 3: Optional (If you want to remove pass phrase asked in second step)
Command : openssl rsa -in apns-dev-key.pem -out apns-dev-key-noenc.pem
Step 4: Now we have to merge the Key .pem and Certificate .pem to get Development .pem needed for Push Notifications in Development Phase of App
@JoeFerrucci
JoeFerrucci / introrx.md
Created October 3, 2016 15:27 — forked from staltz/introrx.md
The introduction to Reactive Programming you've been missing

Videos

@JoeFerrucci
JoeFerrucci / UIColorHex.swift
Created July 27, 2016 21:04
Easy UIColors using hex values, no more slower string manipulation.
extension UIColor {
convenience init(hex: Int) {
self.init(red: CGFloat((hex & 0xFF0000) >> 16) / 255.0,
green: CGFloat((hex & 0x00FF00) >> 8) / 255.0,
blue: CGFloat(hex & 0x0000FF) / 255.0,
alpha: 1.0)
}
}
@JoeFerrucci
JoeFerrucci / tableViewContentHeight.swift
Last active July 21, 2016 23:07
Finding the height of your UITableView's current content.
/////////////////////////////////////////////////////////////////////
// finding the height of your UITableView's current content:
/////////////////////////////////////////////////////////////////////
let tableView = UITableView()
func contentHeight(forTableView tableView: UITableView) -> CGFloat {
let lastSectionIndex = tableView.numberOfSections - 1
let lastRowIndex = tableView.numberOfRowsInSection(lastSectionIndex)
@JoeFerrucci
JoeFerrucci / gist:31f76ad0c22d1b43bcd968f2dcd46780
Created July 21, 2016 00:44
map a range of values to a different range of values.
private func mapValueToRange(value: CGFloat, largerRangeMin: CGFloat, largerRangeMax: CGFloat, targetRangeMin: CGFloat, targetRangeMax: CGFloat) -> CGFloat {
let largerSpan = largerRangeMax - largerRangeMin
let targetSpan = targetRangeMax - targetRangeMin
// Scaled to 0-1 range.
var scaleBy = (value - largerRangeMin) / largerSpan
if scaleBy < 0 { scaleBy = 0 }
if scaleBy > 1 { scaleBy = 1 }
@JoeFerrucci
JoeFerrucci / CopyableLabel.swift
Created May 20, 2016 17:04
CopyableLabel - a typical UILabel with "Copy" functionality.
import UIKit
class CopyableLabel: UILabel {
override init(frame: CGRect) {
super.init(frame: frame)
userInteractionEnabled = true
addGestureRecognizer(UILongPressGestureRecognizer(target: self, action: #selector(CopyableLabel.showMenu(_:))))
}
@JoeFerrucci
JoeFerrucci / JFTextStyle.swift
Created May 16, 2016 23:36
A functional wrapper around NSMutableAttributedString
/*
let myName = NSMutableAttributedString(string: " Hey, what's up!? ")
let yellowOnBlack = Styles.textBackground(.redColor(), range: NSMakeRange(2, 3)) >>> Styles.textColor(.darkGrayColor())
let label = UILabel(frame: CGRectMake(10, 50, 200, 50))
label.attributedText = yellowOnBlack(myName)
view.addSubview(label)
*/
import UIKit
import Foundation