Skip to content

Instantly share code, notes, and snippets.

View he9lin's full-sized avatar

Lin He he9lin

View GitHub Profile

Understanding Comparative Benchmarks

I'm going to do something that I don't normally do, which is to say I'm going to talk about comparative benchmarks. In general, I try to confine performance discussion to absolute metrics as much as possible, or comparisons to other well-defined neutral reference points. This is precisely why Cats Effect's readme mentions a comparison to a fixed thread pool, rather doing comparisons with other asynchronous runtimes like Akka or ZIO. Comparisons in general devolve very quickly into emotional marketing.

But, just once, today we're going to talk about the emotional marketing. In particular, we're going to look at Cats Effect 3 and ZIO 2. Now, for context, as of this writing ZIO 2 has released their first milestone; they have not released a final 2.0 version. This implies straight off the bat that we're comparing apples to oranges a bit, since Cats Effect 3 has been out and in production for months. However, there has been a post going around which cites various compar

@swlaschin
swlaschin / NewsDomainDtoExample.fsx
Last active November 17, 2019 07:18
Demonstrates DTO validation for a news feed domain
(*
Demonstrates DTO validation for a news feed domain
*)
// "result.fsx" comes from https://github.com/swlaschin/DmmfWorkshop/blob/master/src/E-ModelingErrors/Result.fsx
#load "result.fsx"
module Domain =
type DocumentId = DocumentId of int
type EmailAddress = EmailAddress of string
@swlaschin
swlaschin / effective-fsharp.md
Last active March 8, 2024 03:10
Effective F#, tips and tricks

Architecture

  • Use Onion architecture

    • Dependencies go inwards. That is, the Core domain doesn't know about outside layers
  • Use pipeline model to implement workflows/use-cases/stories

    • Business logic makes decisions
    • IO does storage with minimal logic
    • Keep Business logic and IO separate
  • Keep IO at edges

@dadhi
dadhi / Env.fsx
Created March 11, 2019 12:51
An F# toy example of Scala ZIO Environment
module EnvDemo
open System
open System.IO
[<Struct>]
type Nothing =
private
| Nothing
@chrismccord
chrismccord / upgrade.md
Last active April 7, 2023 12:03
Phoenix 1.2.x to 1.3.0 Upgrade Instructions

If you want a run-down of the 1.3 changes and the design decisions behidn those changes, check out the LonestarElixir Phoenix 1.3 keynote: https://www.youtube.com/watch?v=tMO28ar0lW8

To use the new phx.new project generator, you can install the archive with the following command:

$ mix archive.install https://github.com/phoenixframework/archives/raw/master/phx_new.ez

Bump your phoenix dep

Phoenix v1.3.0 is a backwards compatible release with v1.2.x. To upgrade your existing 1.2.x project, simply bump your phoenix dependency in mix.exs:

@aaronlevin
aaronlevin / events.hs
Last active December 3, 2023 13:03
LambdaWorld 2016 & Typelevel Summit 2017 (Copenhagen): Type-Level DSLs // Typeclass induction
-- Our goal is to create a type describing a list of events. This is our
-- type-level DSL.
-- We will then use typeclass resolution to "interpret" this type-level DSL
-- into two things:
-- 1. A comma-separated list of events
-- 2. A method that, when given an event name and a payload, will try to parse
-- that event type with the payload. A form of dynamic dispatching
--
-- To model a list of types we will use tuples. You can imagine the list of
-- types "Int, String, Char" to look like:
@ahmadshah
ahmadshah / randomizer.ex
Created September 1, 2016 10:28
Random string in elixir
defmodule Randomizer do
@moduledoc """
Random string generator module.
"""
@doc """
Generate random string based on the given legth. It is also possible to generate certain type of randomise string using the options below:
* :all - generate alphanumeric random string
* :alpha - generate nom-numeric random string
@syafiqfaiz
syafiqfaiz / how-to-copy-aws-rds-to-local.md
Last active February 21, 2024 06:00
How to copy production database on AWS RDS(postgresql) to local development database.
  1. Change your database RDS instance security group to allow your machine to access it.
    • Add your ip to the security group to acces the instance via Postgres.
  2. Make a copy of the database using pg_dump
    • $ pg_dump -h <public dns> -U <my username> -f <name of dump file .sql> <name of my database>
    • you will be asked for postgressql password.
    • a dump file(.sql) will be created
  3. Restore that dump file to your local database.
    • but you might need to drop the database and create it first
    • $ psql -U <postgresql username> -d <database name> -f <dump file that you want to restore>
  • the database is restored
(*
ParserLibrary_v1.fsx
Version 1 of the code for a parser library.
Related blog post: http://fsharpforfunandprofit.com/posts/understanding-parser-combinators/
*)
open System
@henrik
henrik / deploying_phoenix_on_dokku.md
Last active April 14, 2024 00:32
Deploying Elixir's Phoenix Framework on Dokku.

Deploying Phoenix on Dokku

Worked 2015-09-08 for Phoenix 1.0.1 on Dokku 0.3.25.

These instructions assume you've set up Dokku. If not, go find a tutorial for that part. My notes for setting it up on Digital Ocean.

On your local machine, in the app's repo

Create a Dokku app: