Skip to content

Instantly share code, notes, and snippets.

Gabriele Petronella gabro

Block or report user

Report or block gabro

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
@gabro
gabro / 0_reuse_code.js
Created Jul 6, 2016
Here are some things you can do with Gists in GistBox.
View 0_reuse_code.js
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@gabro
gabro / AssetPicker.swift
Created Nov 2, 2015
A block-based asset picker for videos, photos and files
View AssetPicker.swift
import Photos
import MobileCoreServices
class AssetPicker: NSObject, UIImagePickerControllerDelegate, UINavigationControllerDelegate, UIDocumentPickerDelegate, UIDocumentMenuDelegate {
static let sharedInstance = AssetPicker()
private lazy var cameraPicker: UIImagePickerController = {
let cameraPicker = UIImagePickerController()
@gabro
gabro / FreeConsultations.scala
Last active Sep 24, 2015
Learning the Free monad with cats
View FreeConsultations.scala
package project
import cats._
import cats.free.Free
object Main extends App {
import Algebra._
import ConsultationOp._
val c = Consultation(_id = "123", title = "A consultation")
@gabro
gabro / boom.scala
Last active Sep 4, 2015
Subtle scala quirk with implicit conversions
View boom.scala
@ "42".toInt
res0: Int = 42
@ implicit object Foo extends Function1[String, Int] {
def apply(s: String) = s.toInt
}
defined object Foo
@ "42”.toInt
// BOOM (infinite recursion)
@gabro
gabro / modalValueProducer.swift
Last active Aug 29, 2015
UIViewController producing values. Example of editing a profile section with a modal interaction, which can produce a new Patient
View modalValueProducer.swift
// Create a ViewController automatically wrapped in a UINavigationController
// returns the viewController and a Signal<Patient, NoError>
let (profileVC, signal) = EditPersonalInfoViewController.wrappedInNavigationController(patient: patient)
// observe the signal. When a new Patient is produced, update the view
// dismiss the view controller whenever the signal is completed (i.e. modifications have been saved or interaction has been canceled)
signal.observe(next: reloadViewForPatient, completed: dismissViewController)
// let the game being
self.presentViewController(profileVC, animated: true, completion: nil)
@gabro
gabro / uvc_swizzle.swift
Created Jul 17, 2015
Handle viewWillTransitionToSize across all `UIViewController`s
View uvc_swizzle.swift
// UIViewController+BackgroundStatusBar.swift
// hailadoc-ios
//
// Created by Gabriele Petronella on 7/16/15.
// Copyright (c) 2015 buildo. All rights reserved.
//
import Foundation
extension UIViewController {
@gabro
gabro / ReactiveCocoa.podspec
Created Jul 10, 2015
ReactiveCocoa v3.0-beta.9 Podspec
View ReactiveCocoa.podspec
Pod::Spec.new do |s|
s.name = "ReactiveCocoa"
s.version = "3.0-beta.9"
s.summary = "A framework for composing and transforming streams of values"
s.description = <<-DESC
ReactiveCocoa (RAC) is an Objective-C framework for Functional Reactive Programming. It provides APIs for composing and transforming streams of values.
DESC
s.homepage = "https://github.com/ReactiveCocoa/ReactiveCocoa"
s.license = "MIT"
View statusbar_snippet.swift
// let's create our status bar background view
let statusBar = UIView()
// set the navigation bar color to white (assuming `navController` is our `UINavigationController`)
navController.navigationBar.barTintColor = UIColor.whiteColor()
// turn off the autoresizing mask, since we're using autolayout
statusBarBg.setTranslatesAutoresizingMaskIntoConstraints(false)
// set a background color for the status bar
View RAC-SVProgressHUD.swift
API.cancelConsultation(consultation._id)
|> showHUDOnStart(status: "canceling consultation")
|> showHUDOnSuccessAndError
|> start()
@gabro
gabro / notify_build_result.sh
Last active Oct 22, 2015
Bambo <3 GitHub Status API
View notify_build_result.sh
#!/bin/bash
GITHUB_API=https://api.github.com
AUTH_TOKEN= # GITHUB API TOKEN HERE
REPO= # REPO NAME HERE
URL=${bamboo.buildResultsUrl}
SHA=${bamboo.repository.revision.number}
SUCCESS_DESCRIPTION="The Bamboo CI build passed"
FAILURE_DESCRIPTION="Build #${bamboo.buildNumber} failed"
You can’t perform that action at this time.