Skip to content

Instantly share code, notes, and snippets.

import Combine
import Foundation
import XCTest
class LocalFileSystemLoader {
typealias LoadResult = Result<Data?, Error>
private let url: URL
init(url: URL) {
self.url = url
import Combine
import Foundation
import UIKit
class PubisherFactory {
func make() -> AnyPublisher<String, Error> {
let localCache = LocalCache()
return localCache
.makeAnyCachePublisher()
import UIKit
class ViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
let textLayer = makeTextLayer()
let animation = makeTextLayerAnimation()
view.layer.addSublayer(textLayer)
@lfcj
lfcj / HaciendoFiguras.swift
Last active July 17, 2021 13:01
Primeras figuras usando UIBezierPath
import PlaygroundSupport
import UIKit
class Subclase: UIView {
var bezierPath: UIBezierPath?
override func draw(_ rect: CGRect) {
// let figura = dibujaRectangulo(altura: 200, ancho: 100)
// let figura = dibujaCirculo(ancho: 100, altura: 100)
// let figura = dibujaTriangulo()
@lfcj
lfcj / BigTable.swift
Last active May 27, 2019 08:06
Table showing up all students subjects and scores
import UIKit
// Instead of having matrices of Student data, it's better to have the logic divided in structs
struct Student {
let subjects: [Subject]
let tests: [Test]
}
struct Subject {
import Foundation
//import UIKit
import AppKit
struct ColorTheme {
let name: NSColor
let lastName: NSColor
}
let colorTheme = ColorTheme(name: .red, lastName: .yellow)
import UIKit
import WebKit
class ViewController: UIViewController {
lazy var webView: WKWebView = {
let mySVGImage = "<svg height=\"190\"><polygon points=\"100,10 40,180 190,60 10,60 160,180\" style=\"fill:lime;stroke:purple;stroke-width:5;fill-rule:evenodd;\"></svg>"
let preferences = WKPreferences()
preferences.javaScriptEnabled = false
let configuration = WKWebViewConfiguration()
@lfcj
lfcj / DecodeWebPUsingThreads.swift
Created October 5, 2018 08:06
Tries to decode a webp image using the configuration offered by the WebP framework - Something odd with the colorspace.
private class func webPImage(from data: NSData) -> UIImage? {
var width: Int32 = 0
var height: Int32 = 0
var config = WebPDecoderConfig()
guard
WebPGetInfo(data.bytes.assumingMemoryBound(to: UInt8.self), data.length, &width, &height) > 0,
WebPInitDecoderConfig(&config) != 0
else {
return nil
import UIKit
class ViewController: UIViewController, UITableViewDelegate, UITableViewDataSource {
var tableView: UITableView!
override func viewDidLoad() {
super.viewDidLoad()
tableView = UITableView(frame: CGRect(x: 0, y: 0, width: view.frame.width, height: view.frame.height))
tableView.register(MyCell.self, forCellReuseIdentifier: "cell")
{
"Altavista": {
"apartamento": "20",
"casa": "34",
"comunas": {}
},
"Barbosa": {
"apartamento": "2500000",
"casa": "1200000",
"comunas": {}