Skip to content

Instantly share code, notes, and snippets.

View andru255's full-sized avatar
🇵🇪
:)

Andrés Muñoz andru255

🇵🇪
:)
View GitHub Profile
@andru255
andru255 / gist:87883eb800bf772fe940b9249600f75b
Created September 17, 2021 14:13
Reset a file from a hash
~ git checkout <commit hash> file
// source: https://stackoverflow.com/questions/215718/how-can-i-reset-or-revert-a-file-to-a-specific-revision
@andru255
andru255 / fancy-tabs-demo.html
Created October 28, 2020 15:19 — forked from ebidel/fancy-tabs-demo.html
Fancy tabs web component - shadow dom v1, custom elements v1, full a11y
<script>
function execPolyfill() {
(function(){
// CustomElementsV1.min.js v1 polyfill from https://github.com/webcomponents/webcomponentsjs/tree/v1/src/CustomElements/v1.
/*
Copyright (c) 2016 The Polymer Project Authors. All rights reserved.
This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
@andru255
andru255 / SectionedTableViewAdapter.swift
Created February 15, 2019 15:30 — forked from AlexanderZ-aFrogleap/SectionedTableViewAdapter.swift
Generic UITableView adapter with sections
//: Playground - noun: a place where people can play
import UIKit
protocol SectionModel {
var count: Int { get }
func cell(at: Int) -> UITableViewCell
func selected(at: Int)
}
@andru255
andru255 / README.md
Last active November 24, 2018 18:47
basicAuthGenerator.sh

BasicAuthGenerator.sh corre en linux/iOS

Descargar y luego habilitarles permisos de ejecución:

~ sudo chmod +x basicAuthGenerator.sh

~ ./basicAuthGenerator.sh nombre password
let patternEmail = "[\\w0-9\\.]+@[\\w.]+"
let raw = "1 2 foo@bar.com, jhon@haha.con"
let replaceWith = "xxx"
let text = raw.replace(pattern: patternEmail, with: replaceWith) // example
struct ReplacerPlusResult {
let textReplaced: String
var rangesApplied: [Range<String.Index>]
}
@andru255
andru255 / index.md
Created September 3, 2018 23:08
1st day - basic 4th

Agenda

  • Focus
  • Rules
  • Score
  • Topics of the day -> Holiday and Travel partner

Focus

  • More vocabulary
  • Less grammar
@andru255
andru255 / example.swift
Last active September 1, 2018 18:43
disable shadow and ink effect on material chip component
guard let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "locationChip", for: indexPath) as? MDCChipCollectionViewCell else {
return MDCChipCollectionViewCell()
}
let item = handler?.getRegisteredItems()[indexPath.row]
cell.chipView.titleLabel.text = item?.display
cell.alwaysAnimateResize = false
// Estableciendo la fuente personalizada
cell.chipView.titleFont = UIFont(name: "gothambook", size: 14)
@andru255
andru255 / UISearchBar.swift
Created August 27, 2018 16:53
UISearchBar with UIActivityIndicator source: https://stackoverflow.com/a/45905342
import UIKit
extension UISearchBar {
public var textField: UITextField? {
let subViews = subviews.flatMap { $0.subviews }
guard let textField = subViews.first(where: { $0 is UITextField }) as? UITextField else {
return nil
}
return textField
}
class BooksTests: QuickSpec {
override func spec() {
describe("Book") {
let adapter = NetworkAdapter()
let mockFinder = MockBookFinder(adapter: adapter)
it("MockBookFinder.searchBy success") {
var wasSuccess = false
mockFinder.searchBy(author: "jhon doe", success: { data in
wasSuccess = true
class MockBookFinder: BookFinderProtocol {
private var adapter: NetworkAdapter
private var totalSearch: Int
public init(adapter: NetworkAdapter){
self.adapter = adapter
self.totalSearch = 0
}
public func searchBy(author: String, success:((_ data:[BookModel?]) -> Void )? = nil, fail: FailCallback = nil) {
let dataFake:[BookModel] = [