Skip to content

Instantly share code, notes, and snippets.

View MaisaMilena's full-sized avatar
🖖

Maisa MaisaMilena

🖖
View GitHub Profile
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(

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

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:

function sum(n) {
  if (n == 0) {
    return 0
  } else {
    return n + sum(n - 1) 
  }
}

console.log(sum(10000))
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

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 git@github.com:user/repo.git
  • HTTPS: git clone https://github.com/user/repo.git
# 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:
- Criar um contador pra fazer várias ações dentro da habilidade. Ex: clico 4x o botão e acontece algo.
- Testar a criação de um elemento que fica muito tempo no jogo
- Um clone repetir ação do personagem original
- Adicionar efeitos de fear
- Dentro de um input ter um contador pra: acumular energia, fazer um efeito extra (no primeiro clique faz X coisas no segundo outra)
- trava aleatoriamente 3 direçoes do jogador inimigo
1: cria um caminho que jogadores inimigos não podem passar.
2: cria uma marca no chão onde inverte os comandos dos jogadores inimigos fazendo andar pros lados errados.
3: buffa os aliados, deixando mais rapidos
// ## Kaelin
//
// A simple, blockhain-enabled MOBA implemented in Formality-Core.
//
// Kaelin aims to capture some of the spirit of a MOBA, inluding map awareness,
// micro and macro strategies, resource control, team-fights, skillshots and so
// on, while aiming blockchain-compatible by being very lightweight (the entire
// game state has only 8192 bits) and based on ~20 second turns. This allows it
// to run on state-channels and use Ethereum for conflict resolution.
//
import Nat@0
import Base
fold : {N : Ind2, ~A : Type, ~B : Type, id : !(A -> B), op : !(B -> B -> B)} -> ! {arr : Array(A, $ind2_depth(N))} -> B
dup op = op
dup id = id
let moti = {n} Array(A, $ind2_depth(n)) -> B
let step = {~n, a, b, arr}
get [x, y] = arr
op(a(x), b(y))