Skip to content

Instantly share code, notes, and snippets.

View programaker's full-sized avatar

Marcelo da Silva Gomes programaker

View GitHub Profile
@xuwei-k
xuwei-k / Sudoku.scala
Created September 7, 2024 11:32
sudoku
import scala.compiletime.ops.boolean.&&
type Sudoku[A <: Tuple] = A match {
case (
_1_1 *: _1_2 *: _1_3 *: _1_4 *: _1_5 *: _1_6 *: _1_7 *: _1_8 *: _1_9 *:
_2_1 *: _2_2 *: _2_3 *: _2_4 *: _2_5 *: _2_6 *: _2_7 *: _2_8 *: _2_9 *:
_3_1 *: _3_2 *: _3_3 *: _3_4 *: _3_5 *: _3_6 *: _3_7 *: _3_8 *: _3_9 *:
_4_1 *: _4_2 *: _4_3 *: _4_4 *: _4_5 *: _4_6 *: _4_7 *: _4_8 *: _4_9 *:
_5_1 *: _5_2 *: _5_3 *: _5_4 *: _5_5 *: _5_6 *: _5_7 *: _5_8 *: _5_9 *:
_6_1 *: _6_2 *: _6_3 *: _6_4 *: _6_5 *: _6_6 *: _6_7 *: _6_8 *: _6_9 *:
sealed trait Expr
case class Const(d: Double) extends Expr
case class Var(a: String) extends Expr
case class Times(l: Expr, r: Expr) extends Expr
case class Plus(l: Expr, r: Expr) extends Expr
@johnynek
johnynek / dotty_list.scala
Last active September 7, 2024 15:14
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]]]
}
@alexandredantas
alexandredantas / tf_monad.scala
Created July 29, 2019 17:17
custom monads for tagless final
import scalaz.std.list._
import zio.IO
import scalaz.{ Applicative, Monad }
import scala.util.Try
package object types{
type ThrowableSafeResult[+T] = IO[Throwable, T]
implicit val ioMonadInstance: Monad[ThrowableSafeResult] = new Monad[ThrowableSafeResult] {
@douglascayers
douglascayers / github-copy-labels.sh
Last active December 22, 2023 08:16
Export and import GitHub labels between projects by running bash script with jq and curl. Uses GitHub REST API. Requires personal access token.
# This script uses the GitHub Labels REST API
# https://developer.github.com/v3/issues/labels/
# Provide a personal access token that can
# access the source and target repositories.
# This is how you authorize with the GitHub API.
# https://help.github.com/en/articles/creating-a-personal-access-token-for-the-command-line
GH_TOKEN="YOUR_TOKEN"
# If you use GitHub Enterprise, change this to "https://<your_domain>/api/v3"
@douglascayers
douglascayers / github-export-labels.js
Last active September 14, 2023 15:30
Export and import GitHub labels between projects by running JavaScript in the browser console to automate clicks.
/**
* Inspired by @MoOx original script: https://gist.github.com/MoOx/93c2853fee760f42d97f
* Adds file download per @micalevisk https://gist.github.com/MoOx/93c2853fee760f42d97f#gistcomment-2660220
*
* Changes include:
* - Get the description from the `title` attribute instead of `aria-label` (doesn't exist anymore)
* - Use style.backgroundColor and parse the rgb(...) to hex (rather than regex parsing of 'style' string)
* - Downloads labels to a JSON file named after the webpage to know which GitHub repo they came from.
*
* Last tested 2019-July-27:
@alexandredantas
alexandredantas / zio-environment-setup.scala
Last active July 22, 2019 21:10
Setting up ZIO environment with custom traits
import zio.clock.Clock
import zio.console.Console
import zio.system.System
import zio.random.Random
import zio.blocking.Blocking
import com.typesafe.config.Config
import zio.Task
import com.typesafe.config.ConfigFactory
import scala.collection.JavaConverters
@adrianobrito
adrianobrito / magnofy.js
Created February 20, 2019 13:33
Magnofy caraio
const charMap = {
'á' : "'a",
'Á' : 'A',
'ã' : 'a] ',
'Ã' : 'A]',
'â' : '^a',
'Â' : '^A',
'à' : '`a',
'À' : "`A",
'é' : "'e",
@gustavompo
gustavompo / atividadenovacilo.js
Created August 22, 2018 21:56
atividadenovacilo.js
[{url: "https://emoji.slack-edge.com/T6CU2169Z/100sual/b3a1531ff45f2acd.jpg", name: ":100sual:"}
,{url: "https://emoji.slack-edge.com/T6CU2169Z/1_don%2527t_pick_up_the_phone/8dd1f635352780e8.png", name: ":1_don't_pick_up_the_phone:"}
,{url: "https://emoji.slack-edge.com/T6CU2169Z/1hokage/9e66cda3a2ecf310.jpg", name: ":1hokage:"}
,{url: "https://emoji.slack-edge.com/T6CU2169Z/2_don%2527t_let_him_in/eb898e174fa62821.png", name: ":2_don't_let_him_in:"}
,{url: "https://emoji.slack-edge.com/T6CU2169Z/2hokage/63f4935ed5608b8c.gif", name: ":2hokage:"}
,{url: "https://emoji.slack-edge.com/T6CU2169Z/3_don%2527t_be_his_friend/68b9721a15ed8aeb.png", name: ":3_don't_be_his_friend:"}
,{url: "https://emoji.slack-edge.com/T6CU2169Z/3hokage/765b9b0f9d994981.jpg", name: ":3hokage:"}
,{url: "https://emoji.slack-edge.com/T6CU2169Z/4hokage/39a0745cfb994d6c.jpg", name: ":4hokage:"}
,{url: "https://emoji.slack-edge.com/T6CU2169Z/5hokage/0e9dcea089de5b8b.jpg", name: ":5hokage:"}
,{url: "https://emoji.slack-edge.com/T6CU2169Z/6hokag