Skip to content

Instantly share code, notes, and snippets.

View felipericieri's full-sized avatar
:octocat:
Coding

Felipe Ricieri felipericieri

:octocat:
Coding
View GitHub Profile
@masuhara
masuhara / RainbowGradient.swift
Last active May 6, 2018 20:33
Rainbow color gradient written in Swift2.2
func insertGradientLayer(view: UIView) {
let color1 = UIColor.redColor()
let color2 = UIColor(red: 255, green: 165, blue: 0, alpha: 1.0)
let color3 = UIColor.yellowColor()
let color4 = UIColor(red: 0, green: 128, blue: 0, alpha: 1.0)
let color5 = UIColor.cyanColor()
let color6 = UIColor.blueColor()
let color7 = UIColor.purpleColor()
let fromColors = [color1.CGColor, color2.CGColor, color3.CGColor, color4.CGColor, color5.CGColor, color6.CGColor, color7.CGColor]
let toColors = fromColors.reverse()
@dautermann
dautermann / UIImage+Colorize.swift
Last active August 30, 2018 13:08 — forked from fabb/UIImage+Colorize.swift
Colorize / tint a UIImage (Swift 3 compatible)
import UIKit
extension UIImage {
// colorize image with given tint color
// this is similar to Photoshop's "Color" layer blend mode
// this is perfect for non-greyscale source images, and images that have both highlights and shadows that should be preserved
// white will stay white and black will stay black as the lightness of the image is preserved
func tint(tintColor: UIColor) -> UIImage? {
@dedecej
dedecej / arc.swift
Created October 6, 2017 08:58
Reference counting demo
import Foundation
// Retain count of object
var object = NSObject()
CFGetRetainCount(object)
let nextObject = object
@skreutzberger
skreutzberger / sen_swiftbe_dev.md
Last active December 2, 2019 15:07
Senior Swift Backend Developer (Freelance, 100% Remote)

Senior Swift Backend Developer (Freelance, 100% Remote)

I am searching experienced backend developers (freelance, remote) with a ❤️ for Swift for Moonshot Energy, the world’s first AI-driven renewable energy company located in Germany. Moonshot Energy is financially backed by Innogy SE, one of Europe's largest energy providers.

At Moonshot you will play a major role in making the world greener, the future brighter and energy distribution smarter by using latest technologies like server-side Swift, microservices, artificial intelligence 🤖 and machine learning and new interfaces like chatbots and dialog-based systems (NLP).

Since our team is working on European timezones it would be good if you would live in the EU or if you are an early bird living in US-East 🇪🇺🇺🇸.

Your job:

  • build our internal microservices
@kishikawakatsumi
kishikawakatsumi / UIScrollView+UIPageControl.swift
Created April 29, 2018 15:21
UIScrollView + UIPageControl with RxSwift
import RxSwift
import RxCocoa
fileprivate extension Reactive where Base: UIScrollView {
fileprivate var currentPage: Observable<Int> {
return didEndDecelerating.map({
let pageWidth = self.base.frame.width
let page = floor((self.base.contentOffset.x - pageWidth / 2) / pageWidth) + 1
return Int(page)
})
@natecook1000
natecook1000 / CalculatorView.swift
Last active June 6, 2022 01:00
An IBInspectable Calculator Construction Set
// CalculatorView.swift
// as seen in http://nshipster.com/ibinspectable-ibdesignable/
//
// (c) 2015 Nate Cook, licensed under the MIT license
/// The alignment for drawing an String inside a bounding rectangle.
enum NCStringAlignment {
case LeftTop
case CenterTop
case RightTop
@LemonSpike
LemonSpike / .lldbinit
Last active February 14, 2023 15:29
Xcode LLDB Snippets
command alias 🚽 expression -l objc -- (void)[CATransaction flush]
command alias porvc e -l swift -- UIApplication.shared.keyWindow?.rootViewController?.value(forKey: "_printHierarchy")
@lucasecf
lucasecf / StreamingExample.swift
Last active February 24, 2023 23:16
Example of how to use the streaming feature of the iOS MultipeerConnectivity framework
/*
For this Gist, we have two sides: sender and receiver. The same user can be a sender and a receiver, but I will separate this
two roles to be more clear.
This gist assumes thatyou already have a MCSession created, and the peers are connected,
*/
@benvium
benvium / retrofit-custom-error-handling.java
Created August 29, 2014 19:45
Fairly simply Retrofit custom error handling example. Is set up so that you don't need to do much work in the 'failure' handler of a retrofit call to get the user-visible error message to show. Works on all endpoints. There's lots of exception handling as our server folks like to keep us on our toes by sending all kinds of random stuff..!
// on error the server sends JSON
/*
{ "error": { "data": { "message":"A thing went wrong" } } }
*/
// create model classes..
public class ErrorResponse {
Error error;
import Foundation
extension String
{
var length: Int {
get {
return countElements(self)
}
}