Skip to content

Instantly share code, notes, and snippets.

View hardlianotion's full-sized avatar

Etuka Onono hardlianotion

View GitHub Profile
@quelgar
quelgar / typed_errors.md
Last active January 16, 2024 09:36
Every Argument for Static Typing Applies to Typed Errors

Every Argument for Static Typing Applies to Typed Errors

Think of all the arguments you've heard as to why static typing is desirable — every single one of those arguments applies equally well to using types to represent error conditions.

An odd thing I’ve observed about the Scala community is how many of its members believe that a) a language with a sophisticated static type system is very valuable; and b) that using types for error handling is basically a waste of time. If static types are useful—and if you like Scala, presumably you think they are—then using them to represent error conditions is also useful.

Here's a little secret of functional programming: errors aren't some special thing that operate under a different set of rules to everything else. Yes, there are a set of common patterns we group under the loose heading "error handling", but fundamentally we're just dealing with more values. Values that can have types associated with them. There's absolutely no reason why the benefits of static ty

@dacr
dacr / zio-learning-json-2-cheat-sheet.sc
Last active May 25, 2024 10:20
ZIO learning - playing with json - zio-json cheat sheet / published by https://github.com/dacr/code-examples-manager #862c2592-c58c-4541-817b-eaf9da4c762e/8f61a19ede84238b6a1614dbdcf2aed8cfac5751
// summary : ZIO learning - playing with json - zio-json cheat sheet
// keywords : scala, zio, learning, json, pure-functional, @testable
// publish : gist
// authors : David Crosson
// license : Apache NON-AI License Version 2.0 (https://raw.githubusercontent.com/non-ai-licenses/non-ai-licenses/main/NON-AI-APACHE2)
// license-url :
// id : 862c2592-c58c-4541-817b-eaf9da4c762e
// created-on : 2021-12-30T10:57:55+01:00
// managed-by : https://github.com/dacr/code-examples-manager
// run-with : scala-cli $file
@johnynek
johnynek / dotty_list.scala
Last active January 12, 2020 13:43
Implementation of linked list using dotty features (opaque type, union types, extension methods, type lambda).
// unfortunately
// opaque type Fix[F[_]] = F[Fix[F]]
// won't work (no recursion in opaque type), but this implementation is safe, but scary due to asInstanceOf
object FixImpl {
type Fix[F[_]]
inline def fix[F[_]](f: F[Fix[F]]): Fix[F] = f.asInstanceOf[Fix[F]]
inline def unfix[F[_]](f: Fix[F]): F[Fix[F]] = f.asInstanceOf[F[Fix[F]]]
}

Advance the support of Scala.js in Dotty, a tutorial

Dotty contains preliminary support for Scala.js under the flag -scalajs. Or rather, it contains the infrastructure for preliminary support. It is far from being actually usable, but this is where you can help!

This small tutorial walks you through a few steps that you can do to further the support of Scala.js in Dotty. Even if you do not typically contribute to a compiler, this can be your chance. It is not very difficult, given that there already exists an extensive test suite, as well as a working implementation for scalac.

@Yyukan
Yyukan / http4szio.scala
Created March 1, 2019 07:45
Http4s example with ZIO
import cats.effect
import scalaz.zio._
import scalaz.zio.interop.catz._
import org.http4s._
import org.http4s.dsl.io._
import org.http4s.implicits._
import org.http4s.server.Router
import org.http4s.server.blaze.BlazeServerBuilder
import scalaz.zio.clock.Clock
@dwalend
dwalend / Http4sClientTest.scala
Last active June 21, 2021 16:02
http4s client that can work through a client-side https proxy
package net.shrine.utilities.http4sclienttest
import cats.effect.IO
import io.netty.handler.ssl.{SslContext, SslContextBuilder}
import org.asynchttpclient.Dsl
import org.asynchttpclient.netty.ssl.InsecureTrustManagerFactory
import org.asynchttpclient.proxy.ProxyServer
import org.http4s.client.Client
import org.http4s.client.asynchttpclient.AsyncHttpClient
import org.http4s.headers.Accept
@agrcrobles
agrcrobles / android_instructions_29.md
Last active June 2, 2024 05:54 — forked from patrickhammond/android_instructions.md
Setup Android SDK on OSX with and without the android studio

Hi, I am a fork from https://gist.github.com/patrickhammond/4ddbe49a67e5eb1b9c03.

A high level overview for what I need to do to get most of an Android environment setup and maintained on OSX higher Catalina and Big Sur with and without Android Studio been installed.

Considering the SDK is installed under /Users/<your_user>/Library/Android/sdk folder which is the Android Studio preferred SDK location, but it works fine under /usr/local/share/android-sdk as well, which is a location pretty much used on CI mostly.

Prerequisites:

https://github.com/shyiko/jabba instead ?

@joepie91
joepie91 / vpn.md
Last active July 24, 2024 17:46
Don't use VPN services.

Don't use VPN services.

No, seriously, don't. You're probably reading this because you've asked what VPN service to use, and this is the answer.

Note: The content in this post does not apply to using VPN for their intended purpose; that is, as a virtual private (internal) network. It only applies to using it as a glorified proxy, which is what every third-party "VPN provider" does.

  • A Russian translation of this article can be found here, contributed by Timur Demin.
  • A Turkish translation can be found here, contributed by agyild.
  • There's also this article about VPN services, which is honestly better written (and has more cat pictures!) than my article.
@fehu
fehu / cached recursion
Last active September 18, 2019 20:33
cached recursion function for Scala, it's performance comparison with Y combinator for calculating fibonacci numbers
def cachedRec[A, B](rec: (A => B) => (A => B)): A => CachedRecResult[A, B] = {
val cache = mutable.HashMap.empty[A, B]
// fixed-point combinator
def YY(f: (A => B) => (A => B)): A => B = {
a => cache.getOrElse(a, {
val b = rec(YY(rec))(a)
cache += a -> b
b
})
}