Skip to content

Instantly share code, notes, and snippets.

View olgusirman's full-sized avatar

olgusirman olgusirman

View GitHub Profile
@Andrea-Scuderi
Andrea-Scuderi / .swift
Created September 3, 2019 10:23
CombineAPIDemo
import Combine
import Foundation
enum APIError: Error {
case invalidBody
case invalidEndpoint
case invalidURL
case emptyData
case invalidJSON
case invalidResponse
@luismachado
luismachado / FadeScrollView.swift
Created June 23, 2017 13:53
Custom UIScrollView with fade effect
//
// FadeScrollView.swift
//
// Created by Luís Machado on 23/06/2017.
// Copyright © 2017 Luis Machado. All rights reserved.
//
import UIKit
class FadeScrollView: UIScrollView, UIScrollViewDelegate {
import UIKit
typealias JSON = [String : Any]
fileprivate let imageCache = NSCache<NSString, UIImage>()
extension NSError {
static func generalParsingError(domain: String) -> Error {
return NSError(domain: domain, code: 400, userInfo: [NSLocalizedDescriptionKey : NSLocalizedString("Error retrieving data", comment: "General Parsing Error Description")])
}
}
@romyilano
romyilano / appleSearchBarSample.swift
Last active June 15, 2022 17:14
Various search bar implementations. Including an RxSwift / reactive swift version too
//https://developer.apple.com/library/content/samplecode/TableSearch_UISearchController/Introduction/Intro.html
// MARK: - UISearchResultsUpdating
func updateSearchResults(for searchController: UISearchController) {
// Update the filtered array based on the search text.
let searchResults = products
// Strip out all the leading and trailing spaces.
let whitespaceCharacterSet = CharacterSet.whitespaces
exec > /tmp/${PROJECT_NAME}_archive.log 2>&1
UNIVERSAL_OUTPUTFOLDER=${BUILD_DIR}/${CONFIGURATION}-universal
if [ "true" == ${ALREADYINVOKED:-false} ]
then
echo "RECURSION: Detected, stopping"
else
export ALREADYINVOKED="true"
@lopspower
lopspower / README.md
Last active April 16, 2024 05:46
Hexadecimal color code for transparency

Hexadecimal color code for transparency

Twitter

How to set transparency with hex value ?

For example, you want to set 40% alpha transparence to #000000 (black color), you need to add 66 like this #66000000.

Download This sample on Google Play Store

@emaloney
emaloney / guard-closure.md
Last active August 1, 2023 00:24
A simplified notation for avoiding the weak/strong dance with closure capture lists

Simplified notation for avoiding the [weak self]/strongSelf dance with closures

  • Proposal: TBD
  • Author: Evan Maloney
  • Status: Draft
  • Review manager: TBD

Introduction

Frequently, closures are used as completion callbacks for asynchronous operations, such as when dealing with network requests. It is quite common to model these sorts of operations in such a way that an object instance represents a request/response transaction, for example:

@jkotchoff
jkotchoff / generate_twitter_bearer_token.rb
Last active April 27, 2023 23:10
Send Tweets to the Twitter API with an OAuth1 token
# Generate and use an oauth2 bearer token for the Twitter API in Ruby
#
# For Application-Only authentication to the twitter API, a 'bearer token'
# is required to authenticate agains their endpoints for rate limiting
# purposes.
#
# This script generates a bearer token by posting to twitter and then it
# uses that token to poll their API.
#
# Note, the base 64 encoded consumer credentials for the bearer token needs
@squarism
squarism / iterm2.md
Last active April 13, 2024 18:03
An iTerm2 Cheatsheet

Tabs and Windows

Function Shortcut
New Tab + T
Close Tab or Window + W (same as many mac apps)
Go to Tab + Number Key (ie: ⌘2 is 2nd tab)
Go to Split Pane by Direction + Option + Arrow Key
Cycle iTerm Windows + backtick (true of all mac apps and works with desktops/mission control)
@AliSoftware
AliSoftware / struct_vs_inheritance.swift
Last active March 27, 2024 11:57
Swift, Struct & Inheritance: How to balance the will of using Struct & Value Types and the need for Inheritance?
// #!Swift-1.1
import Foundation
// MARK: - (1) classes
// Solution 1:
// - Use classes instead of struct
// Issue: Violate the concept of moving model to the value layer
// http://realm.io/news/andy-matuschak-controlling-complexity/