Skip to content

Instantly share code, notes, and snippets.

View richimf's full-sized avatar
:octocat:
Coding...

Ricardo Montesinos richimf

:octocat:
Coding...
View GitHub Profile
private func setup() {
self.addTarget(self, action: #selector(beginEditing), for: UIControl.Event.editingDidBegin)
self.addTarget(self, action: #selector(textDidChange), for: UIControl.Event.editingChanged)
self.addTarget(self, action: #selector(textEndEditing), for: UIControl.Event.editingDidEnd)
}
@objc func beginEditing() {
print(#function)
}
@richimf
richimf / extensions.md
Last active January 22, 2019 22:45
Coredata with Extensions

PUT YOUR DATABASE IN THE SHARED CONTAINER This method simply returns the URL of the Documents directory in the App bundle.

  lazy var applicationDocumentsDirectory: NSURL = {
    let urls = FileManager.default.urls(for: .documentDirectory, in: .userDomainMask)
    return urls[urls.count-1] as NSURL
  }()
 
@richimf
richimf / FindCopy.sh
Created January 10, 2019 17:59
Find and Copy files bash
declare -a arr=("MyClass1.swift" "MyClass2.swift" "MyClass3.swift")
## now loop through the above array
for i in "${arr[@]}"
do
echo "$i"
find /Users/richie/myapp-ios -name "$i" -exec cp '{}' /Users/richie/Desktop/${i} \;
done
@richimf
richimf / prot_disp.swift
Last active December 15, 2018 21:06
Protocol dispatching
// MARK: - Protocol definitions
protocol InputProtocol {
var a: Int { get }
var b: Int { get }
}
protocol Addition: InputProtocol {}
extension Addition {
func operation() -> Int{
return a + b
@richimf
richimf / SH_custom_command.md
Last active December 10, 2018 17:24
CopyScripts SH to terminal

Create your SH code:

#!/bin/bash
echo "Stash App Code..."
cd <YOUR_PATH>
branchName=$(git branch | grep \* | cut -d ' ' -f2)
if [[ $branchName != *"fatal"* ]]; then
echo -e "You are on branch: "$branchName
echo "Let's save your work... /o.o/"
@richimf
richimf / regex.md
Created December 3, 2018 21:02
Regular expresions in swift (notes).

Regular expresions in swift (notes).

Special characters in literal strings, precede them by a backslash \ character.

This means the standard regular expression \. will appear as \\. in Swift code.

Capturing parentheses: are used to group part of a pattern, example 3(pm|am) would match the text 3 pm as well ass 3 am. The pipe character here | acts like an OR operator.

The question mark after capturing parentheses means that whatever is inside the parentheses is optional. Nov(ember)?, input could be Nov or November.

@richimf
richimf / sum.swift
Created November 22, 2018 21:49
Sum numbers 1 to n
//You:
func sumFromOne(upto n: Int) -> Int {
var result = 0
for i in 1...n {
result += i
}
return result
}
sumFromOne(upto: 10)
@richimf
richimf / mergeunion.md
Last active April 17, 2020 17:30
Avoid merge conflicts into project.pbxproj
  1. Create a .gitattributes file:

Assuming you don’t already have one, create a file called .gitattributes in your project’s root directory.

  1. Set the merge strategy to union:

Add the following line to your .gitattributes file.

This will tell git to merge using the union strategy, meaning it’ll keep both sides (theirs and ours).

@richimf
richimf / agile.md
Created October 18, 2018 21:17
Agile

Agile

Agile: Son practicas para maximizar el valor del negocio. No necesariamente mas rápido.

Practicas Agile, 40 agile methods Scrum(Scrumbut/Scrumand), Flow, eming, XP, Crystal, DSDM, FDD, ASD, etc...

Escalar, llevar practicas de equipos mas grandes a 9 personas. Tener 8 equipos en un mismo proyecto, como escalarlo, Scrum no te dice como.

@richimf
richimf / pop.swift
Last active October 2, 2018 01:16
Protocol Oriented Programing [Networking-Error Example]
/****
Protocol Oriented Programing
Networking-Error Example
***/
import Foundation
public protocol NetworkController {
func fetchCurrentWeatherData(city: String,
completionHandler: @escaping (WeatherData?, NetworkControllerError?) -> Void) -> WeatherData?
}