Skip to content

Instantly share code, notes, and snippets.

View plokhotnyuk's full-sized avatar

Andriy Plokhotnyuk plokhotnyuk

View GitHub Profile
@non
non / seeds.md
Last active July 10, 2024 20:34
Simple example of using seeds with ScalaCheck for deterministic property-based testing.

introduction

ScalaCheck 1.14.0 was just released with support for deterministic testing using seeds. Some folks have asked for examples, so I wanted to produce a Gist to help people use this feature.

simple example

These examples will assume the following imports:

@cvogt
cvogt / foo.scala
Created February 1, 2018 18:43
versioned serializers in scala
case class Foo( bar: Bar )
case class Bar( bar: Baz )
case class Baz( bar: Booyah )
case class Booyah( i: Int, s: String )
object V1Serializers{
implicit def FormatFoo[Foo] = ...
implicit def FormatBar[Bar] = ...
implicit def FormatBaz[Baz] = ...
implicit def FormatBooyah[Booyah] = ...
@mrrooijen
mrrooijen / intel-microcode-update.md
Created January 18, 2018 06:25
How to update Intel microcode on Ubuntu.

Verify the microcode version prior to updating:

dmesg | grep microcode

Update your package list and install the following packages:

apt update
apt install microcode.ctl intel-microcode

Reboot and run the following command again to verify the new microcode is in effect:

Quick Tips for Fast Code on the JVM

I was talking to a coworker recently about general techniques that almost always form the core of any effort to write very fast, down-to-the-metal hot path code on the JVM, and they pointed out that there really isn't a particularly good place to go for this information. It occurred to me that, really, I had more or less picked up all of it by word of mouth and experience, and there just aren't any good reference sources on the topic. So… here's my word of mouth.

This is by no means a comprehensive gist. It's also important to understand that the techniques that I outline in here are not 100% absolute either. Performance on the JVM is an incredibly complicated subject, and while there are rules that almost always hold true, the "almost" remains very salient. Also, for many or even most applications, there will be other techniques that I'm not mentioning which will have a greater impact. JMH, Java Flight Recorder, and a good profiler are your very best friend! Mea

@eed3si9n
eed3si9n / sbt-plugin-ranking-2017-08-05.md
Last active June 8, 2018 09:15 — forked from xuwei-k/sbt-plugin-ranking-2014-02-25
List of sbt plugins sorted by GitHub stars. This was generated using https://gist.github.com/eed3si9n/ea4ceef0c5e5c07d6e62c87bea029f88, then augmented by hand.

Revisiting Tagless Final Interpreters

Tageless Final interpreters are an alternative to the traditional Algebraic Data Type (and generalized ADT) based implementation of the interpreter pattern. This document presents the Tageless Final approach with Scala, and shows how Dotty with it's recently added implicits functions makes the approach even more appealing. All examples are direct translations of their Haskell version presented in the Typed Tagless Final Interpreters: Lecture Notes (section 2).

The interpreter pattern has recently received a lot of attention in the Scala community. A lot of efforts have been invested in trying to address the biggest shortcomings of ADT/GADT based solutions: extensibility. One can first look at cats' Inject typeclass for an implementation of [Data Type à la Carte](http://www.cs.ru.nl/~W.Swierstra/Publications/DataTypesA

@apangin
apangin / HighResolutionTimer.java
Created October 3, 2016 23:04
Java HighResolutionTimer hack for Windows
import javax.sound.midi.MidiDevice;
import javax.sound.midi.MidiUnavailableException;
import javax.sound.midi.spi.MidiDeviceProvider;
public class HighResolutionTimer {
private static final MidiDevice midiDevice = getMidiOutDevice();
private static MidiDevice getMidiOutDevice() {
MidiDeviceProvider provider = new com.sun.media.sound.MidiOutDeviceProvider();
MidiDevice.Info[] info = provider.getDeviceInfo();
@alirobe
alirobe / reclaimWindows10.ps1
Last active June 10, 2025 00:59
This Windows 10 Setup Script turns off a bunch of unnecessary Windows 10 telemetery, bloatware, & privacy things. Not guaranteed to catch everything. Review and tweak before running. Reboot after running. Scripts for reversing are included and commented. Fork of https://github.com/Disassembler0/Win10-Initial-Setup-Script (different defaults). N.…
###
###
### UPDATE: For Win 11, I recommend using this tool in place of this script:
### https://christitus.com/windows-tool/
### https://github.com/ChrisTitusTech/winutil
### https://www.youtube.com/watch?v=6UQZ5oQg8XA
### iwr -useb https://christitus.com/win | iex
###
### OR take a look at
### https://github.com/HotCakeX/Harden-Windows-Security
@nornagon
nornagon / 1-intro.md
Last active November 17, 2024 22:16
How to make a Minecraft (1.8) mod

How to make a Minecraft mod

Minecraft mods, especially mods which change the client, are by and large written with Forge. If you visit their website, you'll be greeted abruptly by a mysterious message at the top of an SMF forum, with no clear path towards actually... making a mod. I'm documenting here the steps I went through to get started, in the hopes of helping the next person have an easier time of it.

I'll be using Scala for this guide, but it should be fairly easy to adapt these instructions to any JVM language (e.g. clojure or if you're feeling masochistic, Java). I'm also developing on OS X, so some of the commands will be a little different if you're on Linux or Windows. I'm assuming you have some proficiency with your operating system, so I won't go into details about how to adapt those commands to your system.

Background

Minecraft doesn't have an official mod API (despite early [promises](http://notch.t

@paulp
paulp / functions.scala
Created September 20, 2015 12:34
Implicit classes translating scala lambdas into java.util.function classes.
package psp
package jtos
import java.{ util => ju }, ju.{ stream => jus, function => juf }, jus._
import scala.annotation.unchecked.{ uncheckedVariance => uV }
object generated {
implicit final class BiConsumer[-T1, -T2](f: (T1, T2) => Unit) extends juf.BiConsumer[T1 @uV, T2 @uV] { def accept(x1: T1, x2: T2): Unit = f(x1, x2) }
implicit final class BiFunction[-T1, -T2, +R](f: (T1, T2) => R) extends juf.BiFunction[T1 @uV, T2 @uV, R @uV] { def apply(x1: T1, x2: T2): R = f(x1, x2) }
implicit final class BinaryOperator[T](f: (T, T) => T) extends juf.BinaryOperator[T] { def apply(x1: T, x2: T): T = f(x1, x2) }