Skip to content

Instantly share code, notes, and snippets.

View gerson's full-sized avatar

Gerson Villanueva gerson

  • Barranquilla, Colombia
View GitHub Profile
// MARK: - Adding a header to a single request
func doRequestWithHeaders1() {
let headers: HTTPHeaders = [
"X-Mashape-Key": MY_API_KEY,
"Accept": "application/json"
]
Alamofire.request("https://mashape-community-urban-dictionary.p.mashape.com/define?term=smh", headers: headers)
.responseJSON { response in
debugPrint(response)
@gerson
gerson / gist:b0caa88cfe9b75ca51c75d5c19d7982c
Created July 13, 2017 13:58 — forked from snikch/gist:3661188
Find the current top view controller for your iOS application
- (UIViewController *)topViewController{
return [self topViewController:[UIApplication sharedApplication].keyWindow.rootViewController];
}
- (UIViewController *)topViewController:(UIViewController *)rootViewController
{
if (rootViewController.presentedViewController == nil) {
return rootViewController;
}
@gerson
gerson / xcode-build-bump.sh
Created August 3, 2016 15:42 — forked from sekati/xcode-build-bump.sh
Xcode Auto-increment Build & Version Numbers
# xcode-build-bump.sh
# @desc Auto-increment the build number every time the project is run.
# @usage
# 1. Select: your Target in Xcode
# 2. Select: Build Phases Tab
# 3. Select: Add Build Phase -> Add Run Script
# 4. Paste code below in to new "Run Script" section
# 5. Drag the "Run Script" below "Link Binaries With Libraries"
# 6. Insure that your starting build number is set to a whole integer and not a float (e.g. 1, not 1.0)
//: Playground - noun: a place where people can play
import UIKit
/*
Swift es "type-safe" y usa "type-inference", lo cual significa que te ayudara mientras estas codeando.
Ejemplo si estas esperando un String evita que le envies un Int, de la misma
manera funciona cuando esperas un "no Optional" string y envias un "Optional" string.
*/
//Ex:
@gerson
gerson / install-comodo-ssl-cert-for-nginx.rst
Created February 8, 2016 22:54 — forked from bradmontgomery/install-comodo-ssl-cert-for-nginx.rst
Steps to install a Comodo PositiveSSL certificate with Nginx.

Setting up a SSL Cert from Comodo

I use Namecheap.com as a registrar, and they resale SSL Certs from a number of other companies, including Comodo.

These are the steps I went through to set up an SSL cert.

Purchase the cert

@gerson
gerson / Sublime Text License Key.md
Created October 17, 2015 21:08
Sublime Text 2 License Key, Sublime Text 3 License Key, Sublime Text Full Version.

Sublime Text 2 & 3 License Key, Sublime Text Full Version

Sublime Text License Key

How to activate license key

  1. Go to menu Help > Enter License.
  2. Copy the license key below and paste it into the textbox > Click the Use License button.
  3. Enjoy! 👍
@gerson
gerson / gist:1353362
Created November 9, 2011 22:35
Tracking facebook friends with me app permission
def suggested_rivals_facebook
friend_user_ids = []
if authentications.size > 0 && authentications.map(&:provider).include?("facebook")
auth = authentications.where(:provider => 'facebook').map.first
friends_application = FbGraph::Query.new("SELECT uid FROM user WHERE is_app_user=1 and uid IN (SELECT uid2 FROM friend WHERE uid1 = #{auth.uid})").fetch("#{auth.access_token}")
friends_application.collect! {|par| par["uid"].to_s}
friend_user_ids = User.where("authentications.provider" => "facebook").any_in("authentications.uid" => friends_application).not_in("_id" => rivals.map(&:competitor)).map
end
friend_user_ids
end