Skip to content

Instantly share code, notes, and snippets.

View MaisaMilena's full-sized avatar
🖖

Maisa MaisaMilena

🖖
View GitHub Profile
# This is a basic workflow to help you get started with Actions
name: CI
# Controls when the action will run. Triggers the workflow on push or pull request
# events but only for the master branch
on:
push:
branches: [ master ]
pull_request:

How to setup Gitwatch

Gitwatch is a bash script to watch a file or folder and commit changes to a git repo. I found it while looking for how to automatically commit and push files that changed in a certain folder. Gitwatch is great but I had some trouble finding enough information on how to set it up.

Let's go to the point.

  1. First of all, you will need a git environment configured. The way I recommend to avoid having problems on the next steps is to clone the repository you will be working on using SSH. You can try using HTTP but will probably face the Terminal/Console asking for your Github username and password every time Gitwatch needs to do a push.
  • SSH: git clone [email protected]:user/repo.git
  • HTTPS: git clone https://github.com/user/repo.git
Mons.map_source: List(List(String))
[
[
"w2pgpgpgpgpgpgpgpgpgpgpgpgpgpgpgpgpgpgpgpgpgpgpgpgpgpgpgpgpgpgpgpgpgpgpgpgpgpgpgpgpgpgpgpgpgpgpgpgpgpgpgpgpgpgpgpgpgpgpgpgpgpgpgpgpgpg",
"w2S0.g.g.g.g.g.g.g.g.g.g.g.g.g.g.g.g.g.g.g.g.g.g.g.g.g.g.g.g.g.g.g.g.g.g.g.g.g.g.g.g.g.g.g.g.g.g.g.g.g.g.g.g.g.g.g.g.g.g.g.g.g.g.g.gpg",
"w2S0.g.g.g.g.g.g.g.g.g.g.g.g.g.g.g.g.g.g.g.g.g.g.g.g.g.g.g.g.g.g.g.g.g.g.g.g.g.g.g.g.g.g.g.g.g.g.g.g.g.g.g.g.g.g.g.g.g.g.g.g.g.g.g.gpg",
"w2S0.g.g.g.g.g.g.g.g.g.g.g.g.g.g.g.g.g.g.g.g.g.g.g.g.g.g.g.g.g.g.g.g.g.g.g.g.g.g.g.g.g.g.g.g.g.g.g.g.g.g.g.g.g.g.g.g.g.g.g.g.g.g.g.gpg",
"w2S0.g.g.g.g.g.g.g.g.g.g.g.g.g.g.g.g.g.g.g.g.g.g.g.g.g.g.g.g.g.g.g.g.g.g.g.g.g.g.g.g.g.g.g.g.g.g.g.g.g.g.g.g.g.g.g.g.g.g.g.g.g.g.g.gpg",
"w2S0.g.g.g.g.g.g.g.g.g.g.g.g.g.g.g.g.g.g.g.g.g.g.g.g.g.g.g.g.g.g.g.g.g.g.g.g.g.g.g.g.g.g.g.g.g.g.g.g.g.g.g.g.g.g.g.g.g.g.g.g.g.g.g.gpg",
"w2S0.g.g.g.g.g.g.g.g.g.g.g.g.g.g.g.g.g.g.g.g.g.g.g.g.g.g.g.g.g.g.g.g.g.g.g.g.g.g.g.g.g.g.g.g.g.g.g.g.g.g.g.g.g.g.g.g.g.g
function sum(n) {
  if (n == 0) {
    return 0
  } else {
    return n + sum(n - 1) 
  }
}

console.log(sum(10000))

Se você é desenvolvedor Swift muito provavelmente já usou o tipo Result em algum código. Result é um um Generic Enumeration, e nos auxiliara lidar com requisições que podem dar certo - nos trazendo um valor de retorno, ou errado, resultando em um erro.

Ao realizar operações é bem comum que tenhamos no mínimo dois outputs; if-else, is nil or not e success-failure são bem familiares. Você já parou pra pensar no porquê essa estrutura funciona tão bem?

No caso success-failure, tem uma definição tal que:

Filtering a Date attribute for a CoreData Entity can be very confusing. The documentation didn't help me to solve this, but ChatGPT got me into the right track. Here is my solution:

 /// Creates a predicate to fetch a `key` attribute in a certain `date`
 func makeFetchRequestPredicate(for key: String, on date: Date) -> NSPredicate {
    let calendar = Calendar.current
    let components = calendar.dateComponents([.year, .month, .day], from: date)

    let currentDay: CVarArg = calendar.date(from: components)! as CVarArg
 let nextDay: CVarArg = calendar.date(byAdding: .day, value: 1, to: calendar.date(from: components)!)! as CVarArg
import Foundation
public protocol Logger: AnyObject {
static func info(_ message: String, file: StaticString, function: StaticString)
static func event(_ message: String, file: StaticString, function: StaticString)
static func error(_ message: String, file: StaticString, function: StaticString)
}
final class Sentinel: Logger {
static func info(