Skip to content

Instantly share code, notes, and snippets.

View doc-han's full-sized avatar

Farhan Y. doc-han

View GitHub Profile
@doc-han
doc-han / mixpanel-chrome.ts
Last active November 13, 2024 23:11
Want to use the Mixpanel client in a browser extension service_worker?
type ProperyValueTypes = string | number | undefined;
const TRACKER_ENDPOINT = "https://api.mixpanel.com/track?ip=1"; // MIXPANEL
const DISTINCT_ID_KEY = "t_distinct_id";
const DEVICE_ID_PREFIX = "$device:";
interface IDInfo {
$user_id?: string;
$device_id: string;
}
@doc-han
doc-han / filler_game.elm
Last active December 24, 2023 22:29
Filler Game
-- FILLER GAME
import Html exposing (Html, text, div, h3, ol, li, p)
import Html.Attributes exposing (style)
import Html.Events exposing (onClick)
import Array exposing (Array)
import Browser
import Random
import Task
import Set exposing (Set)
@doc-han
doc-han / pixel_art_canvas.elm
Last active December 19, 2023 10:47
Simple Pixel Art Canvas with elm
-- Pixel Art Editor
import Html exposing (text, Html, div, input)
import Browser
import Array exposing (Array)
import Html.Attributes exposing (..)
import Html.Events exposing (onInput, onClick, onMouseOver, onMouseUp, onMouseDown)
main =
Browser.sandbox {init=init, update=update, view=view}
@doc-han
doc-han / tic-tac-toe.elm
Last active December 19, 2023 10:47
Simple TIC-TAC-TOE Game in Elm
-- TIC-TAC-TOE
import Browser
import Array exposing (Array)
import Html exposing (text, Html, div, h2, button)
import Html.Attributes exposing (style)
import Html.Events exposing (onClick)
main =
Browser.sandbox {init=init, update=update, view=view}
@doc-han
doc-han / get_nth_item_in_list.elm
Created December 15, 2023 00:30
Get the nth item in a List - learning ELM
getIndexVal: List a -> Int -> a -> a
getIndexVal list index defVal =
if index > 0 then
case List.tail list of
Nothing ->
defVal
Just jlist ->
getIndexVal jlist (index - 1) defVal
else
case List.head list of
function sumFunc(val){
if(!arguments[0]) return this.sum;
const sum = (this.sum || 0) + val;
return (val) => sumFunc.bind({sum})(val);
}
// This function will perform sum operation on the chain of parameters passed to it.
const ans = sumFunc(1)(2)(3)(4)(5)(6)(7)();
console.log(ans) // 28