Skip to content

Instantly share code, notes, and snippets.

View shrynx's full-sized avatar
🤦‍♂️
github statuses are stupid. waiting for github stories

shrynx shrynx

🤦‍♂️
github statuses are stupid. waiting for github stories
View GitHub Profile
@noelbundick
noelbundick / README.md
Created October 14, 2021 16:15
Optimizing Rust container builds

Optimizing Rust container builds

I'm a Rust newbie, and one of the things that I've found frustrating is that the default docker build experience is extremely slow. As it downloads crates, then dependencies, then finally my app - I often get distracted, start doing something else, then come back several minutes later and forget what I was doing

Recently, I had the idea to make it a little better by combining multistage builds with some of the amazing features from BuildKit. Specifically, cache mounts, which let a build container cache directories for compilers & package managers. Here's a quick annotated before & after from a real app I encountered.

Before

This is a standard enough multistage Dockerfile. Nothing seemingly terrible or great here - just a normal build stage, and a smaller runtime stage.

@mscharley
mscharley / Generator.re
Last active January 19, 2022 02:45
Example of using JavaScript generators in ReasonML.
/* Note, this is only for library interop code. This is *not* a good way to do things in pure Reason code. */
module type GeneratorType {
type value('a);
type t('a);
type fn('a) = unit => t('a);
let valueGet: value('a) => option('a);
let doneGet: value('a) => bool;
@gaearon
gaearon / prepack-gentle-intro-1.md
Last active May 3, 2024 12:56
A Gentle Introduction to Prepack, Part 1

Note:

When this guide is more complete, the plan is to move it into Prepack documentation.
For now I put it out as a gist to gather initial feedback.

A Gentle Introduction to Prepack (Part 1)

If you're building JavaScript apps, you might already be familiar with some tools that compile JavaScript code to equivalent JavaScript code:

  • Babel lets you use newer JavaScript language features, and outputs equivalent code that targets older JavaScript engines.
@sebmarkbage
sebmarkbage / Infrastructure.js
Last active October 1, 2024 04:42
SynchronousAsync.js
let cache = new Map();
let pending = new Map();
function fetchTextSync(url) {
if (cache.has(url)) {
return cache.get(url);
}
if (pending.has(url)) {
throw pending.get(url);
}
@evancz
evancz / data-interchange.md
Last active October 31, 2024 12:01
Why do I have to write JSON decoders in Elm?

A vision for data interchange in Elm

How do you send information between clients and servers? What format should that information be in? What happens when the server changes the format, but the client has not been updated yet? What happens when the server changes the format, but the database cannot be updated?

These are difficult questions. It is not just about picking a format, but rather picking a format that can evolve as your application evolves.

Literature Review

By now there are many approaches to communicating between client and server. These approaches tend to be known within specific companies and language communities, but the techniques do not cross borders. I will outline JSON, ProtoBuf, and GraphQL here so we can learn from them all.

@lexi-lambda
lexi-lambda / Main.hs
Last active July 5, 2023 18:01
Minimal Haskell implementation of Complete and Easy Bidirectional Typechecking for Higher-Rank Polymorphism
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
module Language.HigherRank.Main
( Expr(..)
, EVar(..)
, Type(..)
, TVar(..)
, TEVar(..)
, runInfer
) where
@developit
developit / factory-loader.md
Created March 25, 2017 18:24
factory-loader

Factory Loader

This is a tiny webpack loader that invokes a given module with another as an argument.

What's that useful for? Dependency Injection! Maybe this is how we can solve the VDOM fragmentation issue.

Example

Here's a library-agnostic VDOM component. Notice that it doesn't import react/preact/inferno/whatever - instead, it takes the VDOM library as an argument.

@stagfoo
stagfoo / pinky.scss
Last active March 5, 2017 09:04
Really small and Simple Sass Grid system
[class*='col-'] {
//Aligns the columns next to each other
width: 100%;
float:left;
min-height: 1px;
}
// an extend only class for clearfixing
%clearfix {
*zoom: 1;
&:before,
@CrowdHailer
CrowdHailer / actor.js
Last active March 23, 2021 10:43
Implementing actors in JavaScript.
// Turns out this was not too difficult.
// By using the event loop as a global mail box ordering is even guaranteed for messages between only two actors.
// TODO would like to try and put one actor in a web worker to get some real parallism
// TODO would like to handle errors and have the concept of a deceased actor while a reference to an actor still exists. Probably involves creating an actor system like in Scala. Eurgh.
var actor = {
send: function(message) {
var self = this;
console.log("sending to:", self);
setTimeout(function(){
@btroncone
btroncone / rxjs_operators_by_example.md
Last active November 7, 2024 09:19
RxJS 5 Operators By Example