Skip to content

Instantly share code, notes, and snippets.

View coderunner's full-sized avatar

Felix Trepanier coderunner

View GitHub Profile
@coderunner
coderunner / Employee.java
Created January 14, 2012 02:57
Employee Data Version
public class Employee {
public final String name;
public final int age;
public final int salary;
public final float targetBonus;
public Employee(String name, int age, int salary, float targetBonus) {
this.name = name;
this.age = age;
@coderunner
coderunner / SalaryFunctions.java
Created January 14, 2012 03:04
static functions
public class SalaryFunctions {
public static int computeBonus(Employee employee, float factor) {
return Math.round(employee.salary * factor * employee.targetBonus);
}
public static int getWeeklySalary(Employee employee) {
return Math.round(employee.salary / 52f);
}
}
@coderunner
coderunner / SalaryOperations.java
Created January 14, 2012 03:25
Wrap with functions
public class SalaryOperation {
private final Employee employee;
public SalaryOperation(Employee employee) {
this.employee = employee;
}
public int computeBonus(float factor) {
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);
}
}
@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);
// ** 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
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 {
object scrap {
trait Value
case class StringValue(value: String) extends Value
case class LongValue(value: Long) extends Value
val value: Value = StringValue("test")
/**** Matching ****/
@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",
@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];