Skip to content

Instantly share code, notes, and snippets.

View romyilano's full-sized avatar
😎
improving

Romy romyilano

😎
improving
View GitHub Profile
//
// ExtensionURLRequest.swift
//
// Created by Abhishek Maurya on 16/07/20.
// Copyright © 2020. All rights reserved.
//
import Foundation
extension URLRequest {
@romyilano
romyilano / combineSample.swift
Created January 23, 2024 22:41
ways of doing core location in the different async frameworks
// super rusty on combine
// https://brightdigit.com/tutorials/combine-corelocation-publishers-delegates/
class CLLocationManagerPublicist: NSObject, CLLocationManagerCombineDelegate {
...
let locationSubject = PassthroughSubject<[CLLocation], Never>()
func locationPublisher() -> AnyPublisher<[CLLocation], Never> {
return locationSubject.eraseToAnyPublisher()
}
func locationManager(_: CLLocationManager, didUpdateLocations locations: [CLLocation]) {
@romyilano
romyilano / appleWatchStateTransition.md
Last active January 17, 2024 02:03
Apple watchOS state transition

Handling Common State Transitions

The watch is a little different from the phone but has the same states

  1. not running
  2. inactive
  3. active
  4. background
  5. suspended
@romyilano
romyilano / mermaid.md
Last active January 16, 2024 23:44
Drawing mermaid state machine diagrams

Add a space in a state name

stateDiagram
    classDef yourState font-style:italic,font-weight:bold,fill:white

    yswsii: Your state with spaces in it
 [*] --&gt; yswsii:::yourState
@romyilano
romyilano / documentation.md
Last active September 28, 2023 23:16
swift memory review
  • arrays and variable-size collections use copy-on-write optimization
  • multiple copies of an array share the same storage
@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
@romyilano
romyilano / skew.swift
Created April 10, 2022 19:49
Creating a skew in SpriteKit
// https://stackoverflow.com/a/43532815/1492368
extension SKSpriteNode {
func addSkew(value: CGFloat = -1){
var effectNode = SKEffectNode()
effectNode.shouldRasterize = true
effectNode.shouldEnableEffects = true
effectNode.addChild(SKSpriteNode(texture: texture))
@romyilano
romyilano / rottentomatoes.json
Created July 7, 2015 00:14
rottentomatoes.json
{
"movies": [
{
"id": "771324839",
"title": "Jurassic World",
"year": 2015,
"mpaa_rating": "PG-13",
"runtime": 123,
"critics_consensus": "",
"release_dates": {
@romyilano
romyilano / merge2Images.m
Created December 21, 2012 22:03
Merge 2 Images into one image / iOS
// source
// http://stackoverflow.com/questions/9257992/how-to-combine-merge-2-images-into-1
- (UIImage*)imageByCombiningImage:(UIImage*)firstImage withImage:(UIImage*)secondImage {
UIImage *image = nil;
CGSize newImageSize = CGSizeMake(MAX(firstImage.size.width, secondImage.size.width), MAX(firstImage.size.height, secondImage.size.height));
if (UIGraphicsBeginImageContextWithOptions != NULL) {
UIGraphicsBeginImageContextWithOptions(newImageSize, NO, [[UIScreen mainScreen] scale]);
} else {
UIGraphicsBeginImageContext(newImageSize);