Skip to content

Instantly share code, notes, and snippets.

View coderunner's full-sized avatar

Felix Trepanier coderunner

View GitHub Profile
@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;
// 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 / 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);
}
}
@coderunner
coderunner / perdu.js
Last active November 13, 2024 20:44
demo.perdu
// https://www.perdu.com/
const titre = document.getElementsByTagName('h1')[0];
titre.innerHTML = 'Toujours perdu?';
const texte = document.getElementsByTagName('h2')[0];
texte.insertAdjacentHTML("afterend", "<button id='aide'>Aidez moi!</button>");
const message = document.getElementsByTagName('pre')[0];
@coderunner
coderunner / sv.json
Created March 12, 2022 15:53
Swedish version of coriolis npc generator... in progress.
{
"coriolisNpcGenerator": {
"settings": {
"generateName": "Generate Name",
"generateNameHint": "If enabled, a name will be generated for the NPC.",
"generateProfession": "Generate Profession",
"generateProfessionHint": "If enabled, a profession will be generated for the NPC.",
"generateCharacteristic": "Generate Characteristic",
"generateCharacteristicHint": "If enabled, a characteristic will be generated for the NPC.",
"generateActivity": "Generate Activity",
object scrap {
trait Value
case class StringValue(value: String) extends Value
case class LongValue(value: Long) extends Value
val value: Value = StringValue("test")
/**** Matching ****/
object CaseToList extends App {
trait Collapsable {
// OPTION 1
// Use reflection on the fields using the known public method of the property to access its value.
// Can be incorrect if the case class defines attributes not to be added to the list.
// Here I use the property name in the returned tuple list.
def toCollapsedList1: Seq[Any] = {
val list = for {
// ** Ensure previous timestamp match last transaction event timestamp
// before
if (tx.previous != lastTimestamp) {
throw new IOException("This transaction %s previous timestamp %s is not %s".format(
tx, tx.previous, lastTimestamp))
}
// after
@coderunner
coderunner / SalaryFunctions.java
Created January 14, 2012 03:44
Salary functions
public class SalaryFunctions {
private final float factor;
public SalaryFunctions(float factor) {
this.factor = factor;
}
public int computeBonus(Employee employee) {
return Math.round(employee.salary * factor * employee.targetBonus);
@coderunner
coderunner / SalaryFunctions.java
Created January 14, 2012 03:32
Salary functions
public class SalaryFunctions {
public int computeBonus(Employee employee, float factor) {
return Math.round(employee.salary * factor * employee.targetBonus);
}
public int getWeeklySalary(Employee employee) {
return Math.round(employee.salary / 52f);
}
}