Skip to content

Instantly share code, notes, and snippets.

View keynmol's full-sized avatar
🏠
choosing the lowest hill to die on

Anton Sviridov keynmol

🏠
choosing the lowest hill to die on
View GitHub Profile
@keynmol
keynmol / README.md
Last active June 9, 2017 16:13
Scrape Tax Calculator for Gross vs. Net income information

Requirements:

  • Scraping: curl, ack, python
  • Visualisation: R, tidyverse packages, scales

Scrape

echo "Gross;Net" > data.csv; 
python -c 'RANGE=(20000, 200000); STEPS=40; [print(int(RANGE[0] + i*(RANGE[1] - RANGE[0])/STEPS)) for i in range(1, STEPS)]' | \ 
@keynmol
keynmol / README.md
Created August 7, 2020 12:42
Running DynamoDB local from inside of the Ammonite script (OS X)
  1. You'll need platform-dependent binaries for SQLite4Java (that's what local dynamo is using under the hood): https://bitbucket.org/almworks/sqlite4java/src/master/
  2. put them in native-libs folder at the root of your project
  3. In your script you'll need to set
System.setProperty("sqlite4java.library.path", "native-libs")
  1. When you run it first, it won't work. You need to skip Catalina's notarization:
@keynmol
keynmol / README.md
Created February 8, 2021 12:52
A script to dump bytecode in plaintext

This is a simple script to help me see the bytecode when plaing with Scala 3.

All it does is parallelises the calls to javap command that should available if you have JDK installed.

Installation

Just Ammonite - https://ammonite.io/

It's excellent.

@keynmol
keynmol / summary.md
Created November 27, 2021 09:00
Advent of code Scala Native 0.4.0 vs 0.4.1
Command Mean [ms] Min [ms] Max [ms] Relative
./day1-0.4.0 ../inputs/day1 688.7 ± 10.2 672.6 735.2 1.00
./day1-0.4.1 ../inputs/day1 965.6 ± 11.8 946.5 1035.4 1.40 ± 0.03
Command Mean [ms] Min [ms] Max [ms] Relative
:--- ---: ---: ---: ---:
./day2-0.4.0 ../inputs/day2 14.0 ± 0.7 13.3 19.7 1.00
./day2-0.4.1 ../inputs/day2 15.4 ± 0.3 14.7 16.8 1.10 ± 0.06
Command Mean [ms] Min [ms] Max [ms] Relative
:--- ---: ---: ---: ---:
@keynmol
keynmol / cJSON.scala
Created December 30, 2021 15:42
Scala Native 3 bindings for CJSON
package cJSON_test
import scala.scalanative.unsafe.*
import scala.scalanative.unsigned.*
import scalanative.libc.*
object predef:
abstract class CEnum[T](using eq: T =:= Int):
given Tag[T] = Tag.Int.asInstanceOf[Tag[T]]
extension (t: T) def int: CInt = eq.apply(t)
@keynmol
keynmol / nuklear.scala
Created December 30, 2021 15:49
Scala Native 3 bindings for Nuklear.h
package lib_nuklear
import scala.scalanative.unsafe.*
import scala.scalanative.unsigned.*
import scalanative.libc.*
object predef:
abstract class CEnum[T](using eq: T =:= Int):
given Tag[T] = Tag.Int.asInstanceOf[Tag[T]]
extension (t: T) def int: CInt = eq.apply(t)
package libvulkan
import scala.scalanative.unsafe.*
import scala.scalanative.unsigned.*
import scalanative.libc.*
object predef:
abstract class CEnum[T](using eq: T =:= Int):
given Tag[T] = Tag.Int.asInstanceOf[Tag[T]]
@keynmol
keynmol / SDL-native.c
Created March 16, 2022 12:52
SDL bindings automatically generated
#include <string.h>
void __sn_wrap_libsdl_SDL_GameControllerGetBindForAxis(SDL_GameController * gamecontroller, SDL_GameControllerAxis axis, SDL_GameControllerButtonBind *____return) {
SDL_GameControllerButtonBind ____ret = SDL_GameControllerGetBindForAxis(gamecontroller, axis);
memcpy(____return, &____ret, sizeof(SDL_GameControllerButtonBind));
}
void __sn_wrap_libsdl_SDL_GameControllerGetBindForButton(SDL_GameController * gamecontroller, SDL_GameControllerButton button, SDL_GameControllerButtonBind *____return) {
SDL_GameControllerButtonBind ____ret = SDL_GameControllerGetBindForButton(gamecontroller, button);
@keynmol
keynmol / README.md
Last active May 11, 2022 11:44
Scala 3 nightly bisector

This script does the following:

  1. Downloads the listing of Scala 3 nightly versions from https://repo1.maven.org/maven2/org/scala-lang/scala3-compiler_3/
  2. Parses and sorts them in a really silly way
  3. Runs binary search, invoking scala-cli with a given file and different versions, until it hits the earliest version where the file fails to compile

E.g. if you have a file like this (from scala/scala3#15160):

example.sc

@keynmol
keynmol / build.sbt
Created July 2, 2022 10:40
Try Doobie modernised
libraryDependencies ++= Seq(
"org.xerial" % "sqlite-jdbc" % "3.36.0.3",
"org.tpolecat" %% "doobie-core" % "1.0.0-RC2",
"org.tpolecat" %% "doobie-hikari" % "1.0.0-RC2", // HikariCP transactor.
"org.tpolecat" %% "doobie-specs2" % "1.0.0-RC2", // Specs2 support for typechecking statements.
"org.tpolecat" %% "doobie-scalatest" % "1.0.0-RC2", // ScalaTest support for typechecking statements.
)