Skip to content

Instantly share code, notes, and snippets.

<?php
class ConjugatedGradient {
private readonly float $tolerance;
private readonly int $maxIterations;
public function __construct(float $tolerance = 1e-6, int $maxIterations = 1000) {
$this->tolerance = $tolerance;
$this->maxIterations = $maxIterations;
}
export class ConjugatedGradient {
private readonly tolerance: number;
private readonly maxIterations: number;
constructor(tolerance: number = 1e-6, maxIterations: number = 1000) {
this.tolerance = tolerance;
this.maxIterations = maxIterations;
}
minimize(
// :(
<?php
class Company {
public const WorkerEmployeeType = 0;
public const SupervisorEmployeeType = 1;
public const ManagerEmployeeType = 2;
// more code...
}
// :(
export class EmployeeType {
public static readonly WorkerEmployeeType: number = 0;
public static readonly SupervisorEmployeeType: number = 1;
public static readonly ManagerEmployeeType: number = 2;
}
////////////////////////////////////////
// :(
public static class EmployeeType
{
public const int WorkerEmployeeType = 0;
public const int SupervisorEmployeeType = 1;
public const int ManagerEmployeeType = 2;
}
////////////////////////////////////////777
// :(
public static final int WORKER_EMPLOYEE_TYPE = 0;
public static final int SUPERVISOR_EMPLOYEE_TYPE = 1;
public static final int MANAGER_EMPLOYEE_TYPE = 2;
////////////////////////////////////////777
// :)
@trikitrok
trikitrok / Employee.ts
Last active March 22, 2025 12:32
Wrap Class example
//////////////////////////////////////////////////
// Step 1: Identify the change point
export class Employee {
public timeCards: TimeCard[];
public payPeriod: Date[];
public date: Date;
public payRate: number;
public payDispatcher: PayDispatcher;
@trikitrok
trikitrok / Employee.ts
Created March 22, 2025 12:24
Wrap Method version 2 example
// We also want to keep the original behavior (paying without logging)
//////////////////////////////////////////////////
// Step 1: Identify the change point
export class Employee {
public timeCards: TimeCard[];
public payPeriod: Date[];
public date: Date;
public payRate: number;
@trikitrok
trikitrok / Employee.ts
Created March 22, 2025 11:59
Wrap Method V1 example
//////////////////////////////////////////////////
// Step 1: Identify the change point
export class Employee {
public timeCards: TimeCard[];
public payPeriod: Date[];
public date: Date;
public payRate: number;
public payDispatcher: PayDispatcher;
@trikitrok
trikitrok / QuarterlyReportGenerator.ts
Created March 22, 2025 11:50
Sprout Class example
//////////////////////////////////////////////////
// Step 1: Identify the change point and determine the sprouted class interface
export class QuarterlyReportGenerator {
public readonly beginDate: Date;
public readonly endDate: Date;
public readonly database: Database;
constructor() {
// constructor with multiple side effects