Skip to content

Instantly share code, notes, and snippets.

View texastoland's full-sized avatar
:octocat:
Getting my open source groove back

Texas Toland texastoland

:octocat:
Getting my open source groove back
View GitHub Profile
@texastoland
texastoland / fibonacci.re
Created October 12, 2023 21:44
Naive Fibonacci, tail recursive, and memoized mutual recursive variants in Reason
module Performance {
external now: unit => float = "performance.now"
}
module BigInt {
type t
type op = (t, t) => t
;[@mel.send] external toString: t => string = "toString"
import 'util/styles'
def log do console.log $1 and $1
class Todo
@observable text\string
@observable done\boolean
tag todos
@observable todos\Todo[] = []
@texastoland
texastoland / observePosts.js
Created August 24, 2023 20:38
Apply renderPosts if views/likes/etc. satisfy configurable thresholds
const observePosts = () => {
const timeline = document.querySelector("[data-testid=primaryColumn]")
const observer = new MutationObserver((...args) =>
observePosts.listen(...args),
)
observer.observe(timeline, {
childList: true,
subtree: true,
})
return observer
@texastoland
texastoland / App.res
Last active July 7, 2023 04:25
Elm style in ReScript compared to TypeScript
// https://rescript-lang.org/try?version=v11.0.0-beta.1&code=ALBWGcA8GEHsDsBmBLA5gCgN4DcCmAncZBALgAIAWAGjIFtYATXcgIgEMBXAF1lra+QBjFgF8AlACgJsAA654ZAFLgJ9BhwA2uMgEEyAXiXgAdDvz42ATwBMqxpu0AlA2Ue42grhK1c6bGc6G6GzmVjT48kz4YgYAfGQhFpYAtLE6xnwy6BHwUWKpjsaJVlJclnJkvoaYyOAAYmzwgpbkAEawsBo0grAc8FzkyP00ArS44OTFlgA8ACL8uMZcsSJSPmRDyFVkNfWNzeSIbBrguN29-eQADCPIYxNkANoAuqveuL4cMgwLLuhquC6dHAqBi+nimAkZDI4AA7ltBAALYGoHZQsgAHzIAGIACqwVCoLRxHbGMkAoG1BpNFpkACEFOMVP2llW0Kx2OgGiEAGs4ujoetRuMXIzheBUul-HJcuh5lxFnwebh0GJJNDoZgyRlGIDzn0BnRdRpjD0DWQANRkACMt3ubLIqzewAiHi4pt4MgQ8i86yV2iCYIh6PWWGZNP1w0qd3GIhoDFqMn4SLBZC+PwVBWMHFObnUggI6E2XEkIY+ZEQsHwfG26D6RwjFZZQbIRb2NLIAH4mx3yPXm1nwFx8ENUFJodM+ENYgKyNMZDONRrpkMZNxZ0uynIAPr6FhI3CCHntSAsMgHo+4Bj6XbU5oiMgIaCIxqoXA37ckvEEom4VIJ8Aky4JEHSXAB6RclznDQ2FaQEIRYO9LEfbg1y4TsWEHYdRwfaYwJguCNEgicwIXWdplabgeAUJ9uSPD8vy5Xl-0TZNEREYiNUhKCNXWGQNA4CwNBcM1+gMfRDGtLsyBYM9WHAFgN148tRO2VTUgASX6JZYAAZWw+Axx46FK2rfh0FUmgAAMmMvBgyAAEkwVSH2FJz+ME44RCs9UoNAucwMorhqM46ZOk4zVxVSTJHHQYV+WM6DkAiqDMFMmt0CUnjhVSeVFjfLhc
@texastoland
texastoland / App.svelte
Created June 19, 2023 18:32
Reactivity in Vue compared to Svelte
<script>
let isFancy = true
let count = 0
let times = []
// ❎ functions need $: to update
$: format = (unfancy, fancy) => (isFancy ? fancy : unfancy)
</script>
<p>
@texastoland
texastoland / list-classes.ts
Created June 24, 2021 06:26
Linked list comparison between TypeScript and ReScript
export abstract class List<T> {
readonly isEmpty: boolean
constructor(readonly length: number) {
this.isEmpty = !length
}
*[Symbol.iterator](): Generator<T, void, void> {
for (let xs = this as List<T>; xs instanceof NonEmptyList; xs = xs.rest)
yield xs.first
}
}
@texastoland
texastoland / align.js
Created July 1, 2018 05:31
My first OSS circa 2008
/**
* @author jtoland
*/
Ext.ux.extendMixin('Ext.ux.layout.AlignLayout', Ext.layout.ContainerLayout, function( $super ) { return {
monitorResize:true,
parseMargins : function( val ) {
if (typeof val == 'string') { return arguments.callee.call(null, val.split(' ')); }
@texastoland
texastoland / tree.ml
Created June 24, 2018 18:17
HKT in OCaml/Reason with functors
(** `Tree` abstracts over differnet kinds of trees *)
module Tree = struct
(** `BasicType` is what tree implementations provide *)
module type BasicType = sig
type _ children
(* polymorphic variant easier to use in implementations *)
type 'a tree = [ `Leaf of 'a | `Branch of 'a children ]
val flatten : 'a tree -> 'a list
end