Skip to content

Instantly share code, notes, and snippets.


Vlad Patryshev vpatryshev

View GitHub Profile
View terminology.pdf
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View gist:826504
// Clone just one branch
mkdir $BRANCH
git init
git remote add -t $BRANCH -f origin $REMOTE_REPO
git checkout $BRANCH
// Aliases and stuff
git config --global "Luis Uribe"
vmarquez / TxMapTest.scala
Last active Nov 28, 2021
A mini STM if you will. I've made a'Transactional' map that mutates in a referentially transparent way.
View TxMapTest.scala
import java.util.concurrent.atomic.AtomicReference
import java.util.concurrent.CountDownLatch
import scala.concurrent.Future
import scala.concurrent.ExecutionContext
object TxMapTest {
* Example Usage
* We want to show two threads working with the same data source having both of their effects succeed
alvinj /
Last active Jun 22, 2021
A shell script to create an SBT project directory structure
# Name: sbtmkdirs
# Version: 1.5
# Purpose: Create an SBT project directory structure with a few simple options.
# Author: Alvin Alexander,
# License: Creative Commons Attribution-ShareAlike 2.5 Generic
jaytaylor / EnvHacker.scala
Created Aug 21, 2014
Setting environment variables in Scala JVM
View EnvHacker.scala
trait EnvHacker {
* Portable method for setting env vars on both *nix and Windows.
* @see
def setEnv(newEnv: Map[String, String]): Unit = {
try {
val processEnvironmentClass = Class.forName("java.lang.ProcessEnvironment")
val theEnvironmentField = processEnvironmentClass.getDeclaredField("theEnvironment")
kristopherjohnson /
Last active Aug 15, 2020
Translation of classic Lunar Lander game from FOCAL to Rust
//! Translation of
//! <>
//! by Jim Storer from FOCAL to Rust.
use std::error::Error;
use std::io;
use std::io::prelude::*;
use std::marker::{Send, Sync};
use std::process;
use std::str::FromStr;
tmyymmt / HexBytesUtil.scala
Created Sep 15, 2012
hex2bytes and bytes2hex fixed
View HexBytesUtil.scala
object HexBytesUtil {
def hex2bytes(hex: String): Array[Byte] = {
hex.replaceAll("[^0-9A-Fa-f]", "").sliding(2, 2), 16).toByte)
def bytes2hex(bytes: Array[Byte], sep: Option[String] = None): String = {
sep match {
case None =>"%02x".format(_)).mkString
case _ =>"%02x".format(_)).mkString(sep.get)
retronym / config.scala
Last active May 9, 2018
Styles of config propagation: Manual, Implicits, DynamicVariable, Reader
View config.scala
package scalaz.example
object Reader extends App {
* Manual propagation of the environment (in the example, `contextRoot`.)
object Config0 {
def fragment1(contextRoot: String) = <a href={contextRoot + "/foo"}>foo</a>
View LinVect.scala
object LinVect {
type K = Double
trait NAT[N] { val nat: Int }
def NAT[N: NAT]: NAT[N] = implicitly
def nat[N: NAT]: Int = NAT[N].nat
trait NAT_10
implicit object NAT_10 extends NAT[NAT_10]
zraffer / CAT.scala
Created Nov 6, 2016
sample of abuse of Java/Scala type system for simulate given formal system
View CAT.scala
package cat
object CAT {
// system traits
sealed trait Type[Self <: Type[Self]]
sealed trait Of[Self <: Of[Self, T], T <: Type[T]]
// types
case class Ob()