Skip to content

Instantly share code, notes, and snippets.

View bfollington's full-sized avatar
😈
scheming

Ben Follington bfollington

😈
scheming
View GitHub Profile
@bfollington
bfollington / contributions.py
Created November 12, 2023 23:56
Contribution Graph for Directory
import calendar
from datetime import datetime, timedelta
from pathlib import Path
import platform
def create_ascii_art_grid():
# Get the current year
current_year = datetime.now().year
start_date = datetime(current_year, 1, 1).date() # Convert to date
end_date = datetime(current_year, 12, 31).date() # Convert to date
I am attesting that this GitHub handle bfollington is linked to the Tezos account tz1XHjbFVsAqp1J2gS9wbMXXMTv1cbh4F915 for tzprofiles
sig:edsigtwzLSLDr9RMKL4ZiKHp1hWgZ9ix9DvBWWF934p4RhYjcGenFgbnrGM7grWK5qXysPv9onXRzAeXBtVPXVRdTHod4td52hX
@bfollington
bfollington / ExampleUse.cs
Last active January 26, 2021 03:07
Simple object pooling solution
public static class ExampleUse {
public static void Example(ObjectPoolingSystem pool) {
pool.Get(ObjectPoolType.SelectFx, fx => {
fx.transform.position = new Vector3(1, 1, 1);
});
}
}
@bfollington
bfollington / release.sh
Created January 9, 2021 06:42
Release cljs build in itch compatible format
# run `lein uberjar` before releasing
echo "preparing..."
mkdir -p ./dist/js
mkdir -p ./dist/css
mkdir -p ./dist/assets
echo "copying files..."
cp ./target/cljsbuild/public/js/app.js ./dist/js/app.js
cp -r ./resources/public/css ./dist
(defn contains-in?
[m ks]
(not= ::absent (get-in m ks ::absent)))
(defn update-in-if-contains
[m ks f & args]
(if (contains-in? m ks)
(apply (partial update-in m ks f) args)
m))
@bfollington
bfollington / ping-urls.clj
Last active September 12, 2020 10:03
Check response time from a list of URLs every second
(ns cursive-test.core
(:require [clj-http.client :as client])
(:require [clojure.core.async :as async]))
; setup async pipelines
(def publisher (async/chan))
(def publication
(async/pub publisher #(:topic %)))
@bfollington
bfollington / workflow.fs
Last active July 22, 2020 04:48
Imagining a workflow DSL
module Sketch
type Step =
| VSI
| BusinessAddress
| Offer
| AccountHolder
| BusinessDetails
| Identity
| Concessions
import React, { ChangeEvent } from "react";
import "./App.css";
import { RecoilRoot, atom, useRecoilState } from "recoil";
const useRecoilReducer = <S, A>(
reducer: (s: S, a: A) => S,
recoilState: any
) => {
const [state, setState] = useRecoilState(recoilState);
const dispatch = (a: A) => {
@bfollington
bfollington / structural-typing.ts
Created April 27, 2020 04:18
A quick demo of structural typing and JS object semantics in TS
type User = { name: string, email: string }
type Admin = { name: string, role: string }
// Let's say hi to a user!
const greet1 = (u: User) => console.log(`Hi, ${u.name}`)
// What if we want to greet an Admin though... We can't re-use this
// What about taking a page out of C#'s book and use an interface?
interface INamed { name: string }
@bfollington
bfollington / App.tsx
Last active April 29, 2022 07:20
useReducer + @reduxjs/toolkit
import React, { useReducer } from "react";
import { messages, initialMessagesState } from "./slices/messages";
const App: React.FC = () => {
const [messageList, dispatch] = useReducer(
messages.reducer,
initialMessagesState
);
return (