Skip to content

Instantly share code, notes, and snippets.

View ducaale's full-sized avatar

Mohamed Daahir ducaale

  • eduMe
  • London, UK
View GitHub Profile
@ducaale
ducaale / resumake-logo.js
Created October 14, 2022 10:37
Generate Resumake logo using vercel/satori
import fs from 'fs/promises'
import satori from 'satori'
let html = {
type: 'div',
props: {
style: {
height: '100%',
width: '100%',
display: 'flex',
@ducaale
ducaale / App.fsx
Last active June 7, 2021 19:14
(WIP) Can we implement react-hooks using FSharps's computation expressions?
// a good reference on how react-hooks work https://youtu.be/KJP1E-Y-xyo
// Also see brisk reconciler https://github.com/briskml/brisk-reconciler
let useTimer() = hook {
let! (now, setNow) = useState(0)
do! useEffect1 (fun () ->
let interval = setInterval 1_000 (fun () -> n+1 |> setNow)
fun () -> interval.clear()
) []
@ducaale
ducaale / cli-tools-i-use.md
Last active May 12, 2021 13:11
Cli tools I use
@ducaale
ducaale / ppxes-I-would-to-see-in-reasonml.re
Created October 3, 2020 23:47
PPXes I would like to see in OCaml/Reasonml
let add = (a, b) => a + b;
// modules with test attribute will be stripped from source in production mode
// running `esy test` should find and run all the functions inside test modules
[@test]
module Test {
[@desciption "1 + 1 is equal to 2"]
let test_1 = () => {
Assert.areEqual(2, add(1, 1));
}
@ducaale
ducaale / notes-on-brisk-reconciler.md
Last active September 30, 2020 08:11
Notes on using brisk-reconciler in OCaml

There are two ways to declare a component in brisk-reconciler:

  1. By using a normal function
let%component counterButtons = () => {
  let%hook (count, setCount) = Hooks.state(0);

  <view>
    <button title="Decrement" onPress={() => setCount(count => count - 1)} />
    <text text={"Counter: " ++ str(count)} />
@ducaale
ducaale / opamx.sh
Last active September 10, 2020 21:53
WIP: A convenience wrapper for opam. Inspired by https://khady.info/opam-npm.html
# inspired by https://khady.info/opam-npm.html
USAGE="A convenience wrapper for opam
USAGE:
opamx [options] [command]
OPTIONS:
-h, --help Print help information
// Given a list of sets [set1, set2, set3, ... setn], and a window with start and end such that (end - start) is constant.
// What is the fastest way to get all possible aggregates of the sets by moving start and end by 1 each time?
//
// example:
// const data = [set1, set2, set3, set4, set5, set6, set7, set8, set9];
// const windowSize = 4
// const [s, e] = [0, windowSize]
//
// in this case, our result should be:
// const result = [
@ducaale
ducaale / 1d_2d.js
Last active December 29, 2022 17:09
I am tired of having to solve this again and again
const gridToLine = (x, y, width, height) => {
return (y * width) + x;
}
const lineTogrid = (a, width, height) => {
const x = a % width;
const y = a / width;
return [x, y]
}
@ducaale
ducaale / piping-experiments.js
Last active July 7, 2020 20:41
Using ES6 Proxies to turn methods into pipe friendly functions
// .babelrc
// {"plugins": [["@babel/plugin-proposal-pipeline-operator", { "proposal": "minimal" }]]}
const pipeable = (class_) => new Proxy({}, {
get: (target, prop) => (
(prop in class_.prototype)
? (...args) => (receiver) => class_.prototype[prop].call(receiver, ...args)
: class_[prop].bind(class_) // https://stackoverflow.com/a/30819436/5915221
)
});
#[derive(Debug)]
struct User {
name: String,
email: String,
sign_in_count: u64,
active: bool,
}
impl Default for User {
fn default() -> Self {