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 / 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 {
@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 / 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!)
@arjan
arjan / controller.ex
Last active Aug 29, 2015
Twitter authorization controller
View controller.ex
defmodule TestApp.TwitterController do
use Phoenix.Controller
# Routing configuration:
#
# scope "/twitter", TestApp do
# pipe_through :browser_session
# get "/:lang/authorize", TwitterController, :authorize
# get "/redirect", TwitterController, :authorize_return
@MarcDiethelm
MarcDiethelm / Contributing.md
Last active Jan 23, 2020
How to contribute to a project on Github
View Contributing.md

This text now lives at https://github.com/MarcDiethelm/contributing/blob/master/README.md. I turned it into a Github repo so you can, you know, contribute to it by making pull requests.


Contributing

If you want to contribute to a project and make it better, your help is very welcome. Contributing is also a great way to learn more about social coding on Github, new technologies and and their ecosystems and how to make constructive, helpful bug reports, feature requests and the noblest of all contributions: a good, clean pull request.

@strickyak
strickyak / gist:4201971
Created Dec 4, 2012
How to simulate classes and virtual methods in Golang.
View gist:4201971
/*
How to simulate classes and virtual methods in Go.
*/
package main
import . "fmt"
type A struct {
// Set My to outermost object (most derived class) after constructing.
@damianb
damianb / app.js
Created Dec 2, 2012
nodejs app - expressjs 3.0 + socket.io v9 + passport + redis
View app.js
var express = require('express'),
passport = require('passport'),
LocalStrategy = require('passport-local').Strategy,
connect = require('connect'),
http = require('http'),
path = require('path'),
util = require('util'),
fs = require('fs'),
redis = require('redis'),
cookie = require('cookie'),
@jodell
jodell / nah_xcode_uncrustify.rb
Created Feb 20, 2012 — forked from mnem/nah_xcode_uncrustify.rb
Script file to be run as an Xcode 4 behaviour which uncrustifies the project source using reasonable Objective-C formatting defaults. Alternatively, you can run it and pass a path to uncrustify.
View nah_xcode_uncrustify.rb
#!/usr/bin/env ruby
###########################################################################
# Script to be called as an Xcode 4 behaviour which will attempt to
# uncrustify all source files in the open project.
#
# (c) Copyright 2012 David Wagner.
#
# Complain/commend: http://noiseandheat.com/
#
#*************************************************************************#
You can’t perform that action at this time.