Skip to content

Instantly share code, notes, and snippets.

Greg Pardo gregpardo

Block or report user

Report or block gregpardo

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@gregpardo
gregpardo / UIImage+CropTransparent.swift
Last active Jul 19, 2019
Swift Image Crop Out Transparent Pixels (Swift 2.0)
View UIImage+CropTransparent.swift
extension UIImage {
func imageByCroppingTransparentPixels() -> UIImage {
let rect = self.cropRectForImage()
return cropImage(toRect: rect)
}
func cropRectForImage(image:UIImage) -> CGRect {
let imageAsCGImage = image.CGImage
let context:CGContextRef? = self.createARGBBitmapContext(imageAsCGImage!)
@gregpardo
gregpardo / RxSwift+NVActivityIndicatorView.swift
Last active Feb 1, 2019
rx_animating extension for NVActivityIndicatorView
View RxSwift+NVActivityIndicatorView.swift
extension NVActivityIndicatorView {
public var rx_animating: AnyObserver<Bool> {
return UIBindingObserver(UIElement: self) { indicator, animating in
if (animating) {
indicator.startAnimation()
} else {
indicator.stopAnimation()
}
}.asObserver()
}
@gregpardo
gregpardo / RxSwift+Realm.swift
Last active Dec 25, 2016
Simple extension on results object for swift realm
View RxSwift+Realm.swift
extension Realm {
public func rx_objectForPrimaryKey<T: Object>(type: T.Type, key: AnyObject) -> Observable<T?> {
return self.objects(type)
.filter("%K = %@", self.schema[type.className()]!.primaryKeyProperty!.name, key)
.rx_result
}
}
extension Results where T: Object {
View Alamofire+RxSwiftObjectMapper.swift
extension Alamofire.Request {
func processMap<N>(map:(AnyObject)->N?) -> Observable<N> {
return Observable.create { observer in
self.responseData { response in
let result = response.result
if result.isSuccess {
guard let o = map(result.value!) else{
View Realm+CascadingDeletions.swift
import Foundation
import RealmSwift
protocol CascadingDeletable {
var cascadingDeletions: [AnyObject?] { get }
}
extension Realm {
func delete<T: AnyObject>(cascading: List<T>) where T: CascadingDeletable {
View keybase.md

Keybase proof

I hereby claim:

  • I am gregpardo on github.
  • I am gregpardo (https://keybase.io/gregpardo) on keybase.
  • I have a public key ASCr1RWL0WaB70EP4-gFGOn7td5QHkVFTyFizFXNbH-kbgo

To claim this, I am signing this object:

View taxjar-example-request.js
taxjar.taxForOrder({
from_street: '480 N Orange Ave',
from_city: 'Orlando',
from_state: 'FL',
from_zip: '32801',
from_country: 'US',
line_items: [
{
id: 1,
quantity: 1,
View taxjar-example-response.json
{
"order_total_amount": 10,
"shipping": 0,
"taxable_amount": -2.5,
"amount_to_collect": -0.16,
"rate": 0.065,
"has_nexus": true,
"freight_taxable": true,
"tax_source": "destination",
"jurisdictions": {
You can’t perform that action at this time.