Skip to content

Instantly share code, notes, and snippets.

Avatar
💭
married

Vlad Patryshev vpatryshev

💭
married
View GitHub Profile
View gist:5491536
22:06 ~/Projects/Kepler_5923/sandbox (ticket/5923)$ cat Macros.scala
import language.experimental.macros
import scala.reflect.macros.Context
trait Iso[T, U] {
def to(t : T) : U
// def from(u : U) : T
}
object Iso {
@tmyymmt
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).toArray.map(Integer.parseInt(_, 16).toByte)
}
def bytes2hex(bytes: Array[Byte], sep: Option[String] = None): String = {
sep match {
case None => bytes.map("%02x".format(_)).mkString
case _ => bytes.map("%02x".format(_)).mkString(sep.get)
@alvinj
alvinj / sbtmkdirs.sh
Last active Jun 22, 2021
A shell script to create an SBT project directory structure
View sbtmkdirs.sh
#!/bin/bash
#------------------------------------------------------------------------------
# Name: sbtmkdirs
# Version: 1.5
# Purpose: Create an SBT project directory structure with a few simple options.
# Author: Alvin Alexander, http://alvinalexander.com
# License: Creative Commons Attribution-ShareAlike 2.5 Generic
# http://creativecommons.org/licenses/by-sa/2.5/
#------------------------------------------------------------------------------
@retronym
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>