Skip to content

Instantly share code, notes, and snippets.

View phated's full-sized avatar
💰
Sponsor my open source work! https://github.com/sponsors/phated

Blaine Bublitz phated

💰
Sponsor my open source work! https://github.com/sponsors/phated
View GitHub Profile
@phated
phated / rollup.config.js
Created January 21, 2021 17:57
Neat little Rollup script for generating a CJS version of an ESM module.
import fs from "fs";
import { builtinModules as builtin } from "module";
const pkg = JSON.parse(fs.readFileSync("./package.json"));
export default {
input: "./src/index.js",
output: {
file: "build/index.cjs",
format: "cjs",
@phated
phated / rip-doom.js
Last active December 31, 2020 23:34
class Plugin {
async render(container) {
container.style.width = '200px';
container.style.height = '150px';
container.innerHTML = `<iframe width="100%" height="100%" src="https://www.youtube.com/embed/videoseries?list=OLAK5uy_nEMsrf6n4MS_by9gYHYx8vEyMK6PJbJog" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>`;
}
destroy() { }
}
@phated
phated / map-export.js
Last active August 19, 2021 20:10
Dark Forest Map Export
function exportMap() {
// This requires the React Devtools to be installed in your browser.
// Download them from https://chrome.google.com/webstore/detail/react-developer-tools/fmkadmapgofadopljbjfkapdkoienihi?hl=en
// And then make sure to close your inspector & reload the Dark Forest client
// It seems like React Devtools has a hard time starting up, so try all the "reboot" tricks you can think of
// Once you do all of the above, make sure to load up the game, and copy-paste this script into your developer tools console
let container = document.querySelector('[class^=AppContainer] > div > div');
__REACT_DEVTOOLS_GLOBAL_HOOK__.reactDevtoolsAgent.selectNode(container);
@phated
phated / abstract.md
Last active March 12, 2019 23:06
Better Application Development in ReasonML

Better Application Development in ReasonML

With the introduction of Redux, The Elm Architecture, and ReasonReact’s reducerComponents, finite-state machines have become a popular way to develop front-end applications. Most of the libraries rely on a global state atom and don’t maintain a stack of states. Things like state transitions and reflecting the state in the URL are often an afterthought. They’re added as imperative side-effects, which become an unsustainable mess as the codebase grows.

If we focus on the URL from the beginning, we can evolve our finite-state machine by leveraging the browser’s History API, which maintains a stack of previous/next states for us.

In this talk, we’ll explore how Reason’s type system can be leveraged to ensure we are always thinking about our state transitions so they can be properly reflected in our URL.

@phated
phated / ReasonReact.re
Created February 8, 2019 21:03
Random ReasonReact ideas
[@react.decorate]
let component = (fn) => {
let make = fn;
let props = [@bs.obj] someHowGetArguments
(make, props);
};
@phated
phated / Emotion.re
Created October 5, 2018 22:48
Experimenting with a Reason API for Emotion
open BsReactNative;
[@bs.deriving abstract]
type style = {
[@bs.optional]
color: string,
[@bs.optional]
fontSize: float,
[@bs.optional]
margin: float,
undefined is not a function (evaluating 'window.addEventListener('message', idleTick, false)')
<unknown>
schedule.development.js:366:26
<unknown>
schedule.development.js:15:2
loadModuleImplementation
require.js:214:12
guardedLoadModule
require.js:148:36
_require
@phated
phated / non-shitty-http.go
Created April 27, 2018 03:05
Abusing funcMap and text/template
package main
import (
"errors"
"io/ioutil"
"log"
"net/http"
"os"
"text/template"
)

Trying to solve this problem but I think I lack some knowledge of pull-streams (still a newbie).

I have a single source and a single sink (I don't actually control these), my goal is to feed the source into multiple through streams and then combine the results of each of them and pass into the sink. The order doesn't matter.

       / through A \
source - through B - sink
       \ through C /
@phated
phated / styles.css
Created September 4, 2016 06:30 — forked from pburtchaell/styles.css
VH and VW units can cause issues on iOS devices. To overcome this, create media queries that target the width, height, and orientation of iOS devices.
/**
* VH and VW units can cause issues on iOS devices: http://caniuse.com/#feat=viewport-units
*
* To overcome this, create media queries that target the width, height, and orientation of iOS devices.
* It isn't optimal, but there is really no other way to solve the problem. In this example, I am fixing
* the height of element `.foo` —which is a full width and height cover image.
*
* iOS Resolution Quick Reference: http://www.iosres.com/
*/