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
@shrynx
shrynx / README.md
Created March 16, 2024 22:34 — forked from noelbundick/README.md
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.

@shrynx
shrynx / GADTs.md
Last active February 24, 2021 08:48
GADTs: A primer

GADTs: A primer

Sketch link

This post assumes you are familiar with Algebraic Data Types (sum types/variants/tagged unions and product types: records, tuples, etc) and comfortable reading type signatures. For a brush up on ADTs and specifically on sum types/variants, refer Reason's documentation and rauschmayer's blog on variants in Reason. Also while you are at it, a quick look on phantom types wouldn't hurt 🙂.

@shrynx
shrynx / halftone-cartesian.pde
Created March 24, 2020 21:50 — forked from desandro/halftone-cartesian.pde
Half-ton halftones Processing sketch
// options
String imagePath = "img/desandro-avatar.jpg";
float res = 10; // resolution, dot density
float zoom = 3.0; // proportion to zoom image
boolean isAdditive = true; // true = RGB, false = CMY
float offsetAngle = 1; // affects dot pattern
/*
0 = no patter
0.05 = slight offset
1 = slight offset
@shrynx
shrynx / beads.clj
Created April 23, 2019 21:07 — forked from adicirstei/beads.clj
Beads on vector fields source
(ns gen-art.beads
(:require [clojure2d.core :refer :all]
[fastmath.core :as m]
[fastmath.random :as r]
[fastmath.fields :as f]
[fastmath.vector :as v]
[clojure2d.color :as c]
[clojure2d.extra.utils :as ut]
[clojure2d.pixels :as p])
(:import [fastmath.vector Vec2]) )
module type Res = {type t;};
module Make = (R: Res) => {
include R;
type state =
| NotAsked
| Loading
| NetworkError
| DecodingError

Keybase proof

I hereby claim:

  • I am shrynx on github.
  • I am shrynx (https://keybase.io/shrynx) on keybase.
  • I have a public key ASDZMy6G_oMiX_f3Ckv281Z_VlsvbvrNtESV7pCiDEX1wQo

To claim this, I am signing this object:

state = {
everySecond: 0,
every5Second: 0,
random: 0,
};
incrementEverySecond = () => {
this.setState(({ everySecond }) => ({ everySecond: everySecond + 1 }));
};
@shrynx
shrynx / react simple context demo.js
Last active May 10, 2018 01:01
simple demo of react's context api
const CounterContext = React.createContext(0);
class CounterProvider extends React.Component {
state = { count: 0 };
incrementCount = () => {
this.setState(({ count }) => ({ count: count + 1 }));
};
componentDidMount() {
setInterval(this.incrementCount, 1000);
}
@shrynx
shrynx / macOSOpenURLInChrome.js
Created March 8, 2018 11:23
open url in chrome on macOS and reuse already open tab if possible.
#!/usr/bin/env osascript -l JavaScript
const Chrome = Application('Chrome');
// although there is ES6 support , but "run" function
// can't use fat arrow functions.
// https://github.com/JXA-Cookbook/JXA-Cookbook/wiki/ES6-Features-in-JXA#arrow-functions
function run(args) {
const url = args[0];
const tabData = findTabForUrl(url);
@shrynx
shrynx / cloudSettings
Last active June 8, 2020 06:36
Visual Studio Code Settings Sync Gist
{"lastUpload":"2020-06-08T06:36:34.305Z","extensionVersion":"v3.4.3"}