Skip to content

Instantly share code, notes, and snippets.

@AHaliq
AHaliq / main.ml
Created Mar 31, 2021
export ocaml function to call from js
View main.ml
let global_nctx = ref Kernel.Context.empty
let global_ectx = ref Kernel.Context.empty
let js_run_repl str =
match String.(compare str "quit") with
| 0 -> "bye"
| _ ->
match String.(compare str "reset") with
| 0 ->
global_nctx := Kernel.Context.empty;
@AHaliq
AHaliq / comp
Created Jan 7, 2021
Compound Stake
View comp
rate[x_] := rated[x*365]
rated[x_] :=
If[x < 7, 1.5,
If[x < 30.4167, 3, If[x < 365/2, 5, If[x < 365, 17, 30]]]]
f[ip_, r_, p_, t_, n_] :=
If[t <= 0, ip,
If[t < p, ip + ip*r*t - rate[t],
f[ip + (ip * r * p) - rate[p] - rate[0]*n, r, p, (t - p), n + 1]]]
g[ip_, r_, t_] := ip + ip*r*t - rate[t]
init := 10000
View CreateInputCommand.java
// NOTE read Responses.java first itll make more sense
public class CreateInputCommand implements ResponseFunc {
private String front = "";
private String back = "";
// handle types??
@Override
public boolean funcCall(String i, State s) {
if (s.state == StateEnum.CREATE_STATE_FRONT) {
front = i;
View Responder.java
// my motivation to use enum is so you dont need to create new objects everytime a command is executed
// instead you simply call a static method. and to iterate through a list of static methods we use enums.
// So this is a typical enum u encounter all the time
enum MyEnum {
A, B, C;
}
// However enums are capable of having properties and methods!
// if u define a method in an enum all enums will have it
// e.g.
@AHaliq
AHaliq / Response.java
Created Oct 9, 2019
My dukes responses
View Response.java
package com.core;
import com.core.savedata.SaveFile;
import com.util.datetime.DateTime;
import com.util.datetime.DateTimeParse;
import java.util.stream.IntStream;
import com.util.Printer;
import com.tasks.Deadline;
import com.tasks.DoableTask;
View Responder.java
package com.core;
public enum Response {
BYE("(?i)^b(ye)?\\s*", (i, s) -> {
Printer.printString("Bye. Hope to see you again soon!");
s.toExit = true;
s.lastError = false;
return true;
}),
RESPONDER_NAME("regex", (commandInput, programState) -> {
@AHaliq
AHaliq / CodeCard.java
Last active Oct 4, 2019
Classes to model flashcards
View CodeCard.java
abstract class CodeCard implements FlashCard {
protected String question;
protected String output;
public JavascriptCard(String q, String o) {
question = q;
output = o;
}
abstract render...
@AHaliq
AHaliq / ex2.c
Last active Oct 3, 2019
CS2106 Lab3 ex2 Haliq
View ex2.c
/*************************************
* Lab 3 Exercise 2
* Name: Abdul Haliq
* Student No: A0125431U
* Lab Group: B-08
*************************************/
#include <pthread.h>
#include "rw_lock.h"
@AHaliq
AHaliq / sketch.js
Last active Dec 10, 2019
Coding Train Challenge #125, fourier series implemented in functional style with waves in terms of amplitude, frequency and range
View sketch.js
let STAGE_WIDTH = 800;
const STAGE_HEIGHT = 400;
const L_BORDER = 25;
const COLBG = 220;
const COL1 = 100;
const COL2 = 195;
const PIVOTRADI = 10;
const LINEGAP = 5;
let UNITRADI = 50;
let DW;