Skip to content

Instantly share code, notes, and snippets.

View coderunner's full-sized avatar

Felix Trepanier coderunner

View GitHub Profile
@coderunner
coderunner / combat_veteran_macro.js
Last active September 3, 2022 14:27
Combat Veteran - Foundry VTT Marco
if (!actor) {
ui.notifications.error('No token selected');
}
async function show(roll) {
if (game.modules.get("dice-so-nice") &&
game.modules.get("dice-so-nice").active) {
await game.dice3d.showForRoll(roll, game.user, true);
}
}
// Type avec union
type Status = 'active' | 'inactive' | null
// Définition d'interfaces
interface User {
name: string; // propriété et type
age: number;
status: Status;
}
@coderunner
coderunner / FirestoreDemoController.java
Last active October 21, 2022 16:22
Vous pouvez ajouter ce contrôleur dans votre backend temporairement. Il réagit sur un GET /demo.
package com.inf5190.chat;
import java.util.Date;
import java.util.List;
import java.util.concurrent.ExecutionException;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
import com.google.api.core.ApiFuture;
@coderunner
coderunner / TestHelper.ts
Last active November 11, 2022 18:41
TestHelper.ts
import { ComponentFixture } from '@angular/core/testing';
import { By } from '@angular/platform-browser';
/**
* Classe de test qui aide à aller chercher des éléments HTML de la page.
*
* Elle utilise l'attribut `data-testid=` pour sélectionner les éléments.
* Par exemple:
* <input
* name="username"
import { ComponentFixture, TestBed } from "@angular/core/testing";
import { ReactiveFormsModule } from "@angular/forms";
import { TestHelper } from "src/app/test/test-helper";
import { LoginFormComponent } from "./login-form.component";
import { MatFormFieldModule } from "@angular/material/form-field";
import { MatInputModule } from "@angular/material/input";
import { NoopAnimationsModule } from "@angular/platform-browser/animations";
describe("LoginFormComponent", () => {
package com.inf5190.chat;
import java.io.FileInputStream;
import java.io.IOException;
import java.util.Arrays;
import javax.annotation.PostConstruct;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
package com.inf5190.chat.auth;
import static org.assertj.core.api.Assertions.assertThat;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
import java.util.concurrent.ExecutionException;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.mockito.Mock;
package com.inf5190.chat.messages;
import static org.assertj.core.api.Assertions.assertThat;
import java.net.HttpCookie;
import java.util.concurrent.ExecutionException;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
// ...
@SpringBootApplication
@PropertySource("classpath:cors.properties")
@PropertySource("classpath:firebase.properties")
public class ChatApplication {
// ...
@PostConstruct
// https://www.perdu.com/
// Ajouter jquery à la page
var js = document.createElement('script');
js.src = 'https://releases.jquery.com/git/jquery-git.js';
document.getElementsByTagName('head')[0].appendChild(js);
// Attendre un minimum que le script load
// Manipulations
$('h1').text('Toujours perdu?')