Skip to content

Instantly share code, notes, and snippets.

View WolfDan's full-sized avatar
❄️
halcyon days

WolfDan

❄️
halcyon days
View GitHub Profile
@patmaddox
patmaddox / mk_image.sh
Last active February 1, 2023 01:41
FreeBSD ZFS-on-Root (GCP)
#!/bin/sh
set -e
set -x
# Adapted from https://www.daemonology.net/blog/2019-02-16-FreeBSD-ZFS-AMIs-now-available.html
# Note: You need to run this on an instance with read/write access to Google Compute
# Alternatively, you can run the gcloud commands from somewhere with privileges
disk=da1
@joeytrapp
joeytrapp / FileBtn.re
Created April 10, 2019 17:54
ReasonReact 0.7.0 ref example
[@react.component]
let make = (~className="", ~onSelect, ~children) => {
let fileInputRef: ReactDOMRe.Ref.currentDomRef =
React.useRef(None->Js.Nullable.fromOption);
let key = React.useRef(1);
let handleInputChange =
React.useCallback0(event => {
let files = ReactEvent.Form.target(event)##files;
@kkazuo
kkazuo / VirtualList.re
Created March 21, 2019 15:05
ReasonReact binding of react-virtualized/List
[@bs.module "react-virtualized"]
external reactClass: ReasonReact.reactClass = "List";
[@bs.deriving abstract]
type cellProps = {
index: int,
isScrolling: bool,
isVisible: bool,
key: string,
style: ReactDOMRe.Style.t,
@tmbb
tmbb / release.exs
Created December 2, 2018 15:10
A script to automatie releases of elixir packages.
defmodule Releaser.VersionUtils do
@doc """
Some utilities to get and set version numbers in the `mix.exs` file
and to programatically transform version numbers.
Maybe the `bump_*` functions should be in the standard library?
This script doesn't support pre-release versions or versions with build information.
"""
@version_line_regex ~r/(\n\s*@version\s+")([^\n]+)("\n)/
@jaredly
jaredly / App.re
Last active January 1, 2021 17:34
ReasonReact Context API Example
module StringContext =
Context.MakePair({
type t = string;
let defaultValue = "Awesome";
});
let component = ReasonReact.statelessComponent("Tree");
let make = _children => {
@fedme
fedme / Run Visual Studio Code for Linux from WSL.md
Last active November 8, 2023 09:33
Run Visual Studio Code for Linux from WSL on Windows 10

Run Visual Studio Code for Linux from WSL

Thanks a lot to mredbishop and others for their insturctions posted here. This is just a recap of what they figured out.

This process was tested on WSL Ubuntu 18.04.

Install VcXsrv on Windows

  1. Dowload the VcXsrv installer from https://sourceforge.net/projects/vcxsrv/
  2. Install the software on Windows

Add VS Code repositories

@tvaliasek
tvaliasek / main.js
Created June 5, 2018 20:09
electron axios stream download with progress
import {ipcMain} from 'electron'
const fs = require('fs')
const axios = require('axios')
/* ... */
ipcMain.on('downloadFile', function (event, data) {
const filePath = data.filePath
const item = data.item
@joshnuss
joshnuss / udp_server.exs
Last active June 17, 2024 11:45
Fault tolerant UDP Server in Elixir
# to run:
# > elixir --no-halt udp_server.exs
# to test:
# > echo "hello world" | nc -u -w0 localhost 2052
# > echo "quit" | nc -u -w0 localhost 2052
# Let's call our module "UDPServer"
defmodule UDPServer do
# Our module is going to use the DSL (Domain Specific Language) for Gen(eric) Servers
use GenServer
@schinns
schinns / App.re
Created February 23, 2018 20:51
Simple ReasonReact Router Example
let component = ReasonReact.statelessComponent("App");
let make = (_children) => {
...component,
render: (_self) =>
<div className="app">
<View.Nav></View.Nav>
<Router.WithRouter>
...(
(~currentRoute) =>
switch currentRoute {
@jswny
jswny / Flexible Dockerized Phoenix Deployments.md
Last active July 3, 2023 05:25
A guide to building and running zero-dependency Phoenix (Elixir) deployments with Docker. Works with Phoenix 1.2 and 1.3.

Prelude

I. Preface and Motivation

This guide was written because I don't particularly enjoy deploying Phoenix (or Elixir for that matter) applications. It's not easy. Primarily, I don't have a lot of money to spend on a nice, fancy VPS so compiling my Phoenix apps on my VPS often isn't an option. For that, we have Distillery releases. However, that requires me to either have a separate server for staging to use as a build server, or to keep a particular version of Erlang installed on my VPS, neither of which sound like great options to me and they all have the possibilities of version mismatches with ERTS. In addition to all this, theres a whole lot of configuration which needs to be done to setup a Phoenix app for deployment, and it's hard to remember.

For that reason, I wanted to use Docker so that all of my deployments would be automated and reproducable. In addition, Docker would allow me to have reproducable builds for my releases. I could build my releases on any machine that I wanted in a contai