Skip to content

Instantly share code, notes, and snippets.

View albertopeam's full-sized avatar
😄

Alberto Penas Amor albertopeam

😄
View GitHub Profile
@albertopeam
albertopeam / UITableView+beginRefreshing.swift
Created February 21, 2025 11:04 — forked from mttcrsp/UITableView+beginRefreshing.swift
Extension that allows programmatic pull to refresh
import UIKit
public extension UITableView {
public func beginRefreshing() {
// Make sure that a refresh control to be shown was actually set on the view
// controller and the it is not already animating. Otherwise there's nothing
// to refresh.
guard let refreshControl = refreshControl, !refreshControl.isRefreshing else {
return
@albertopeam
albertopeam / sendRawTransaction.js
Created October 30, 2021 19:20 — forked from raineorshine/sendRawTransaction.js
Sends a raw transaction with web3 v1.2.2, ethereumjs-tx v2.1.1, and Infura
const Web3 = require('web3')
const Tx = require('ethereumjs-tx').Transaction
// connect to Infura node
const web3 = new Web3(new Web3.providers.HttpProvider('https://mainnet.infura.io/INFURA_KEY'))
// the address that will send the test transaction
const addressFrom = '0x1889EF49cDBaad420EB4D6f04066CA4093088Bbd'
const privateKey = new Buffer('PRIVATE_KEY', 'hex')
@albertopeam
albertopeam / URLRequest.swift
Created March 30, 2020 13:06 — forked from peterprokop/URLRequest.swift
Print NSURLRequest in cURL format (Swift 3)
//
// URLRequest.swift
//
// Created by Peter Prokop on 17/08/2017.
import Foundation
public extension URLRequest {
/// Returns a cURL command for a request
@albertopeam
albertopeam / UIViewControllerPreview.swift
Created January 22, 2020 12:49 — forked from mattt/UIViewControllerPreview.swift
Generic structures to host previews of UIView and UIViewController subclasses.
import UIKit
#if canImport(SwiftUI) && DEBUG
import SwiftUI
struct UIViewControllerPreview<ViewController: UIViewController>: UIViewControllerRepresentable {
let viewController: ViewController
init(_ builder: @escaping () -> ViewController) {
viewController = builder()
}
@albertopeam
albertopeam / DynamicInit.swift
Created July 16, 2019 15:07 — forked from Ben-G/DynamicInit.swift
Dynamically create instance based on type in Swift
protocol Initializable {
init()
}
class A : Initializable {
var content:String
required init() {
content = "TestContent"
}
@albertopeam
albertopeam / presentation.md
Created March 12, 2017 00:03 — forked from szimek/presentation.md
HTTP caching in Rails

HTTP caching

Kinds of caches

  • Browser
  • Proxy
  • Gateway

TODO Difference between proxy and gateway caches.