This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
proxmox / local / CT Templates | |
------------------------------ | |
Download from URL: https://images.linuxcontainers.org/images/openwrt/23.05/amd64/default/20240316_11%3A57/rootfs.tar.xz | |
SHA-256: d6df8e1abeb24965146e22186b7aa767e3d42fac7fd71be0805cbc0c82377917 | |
proxmox console | |
--------------- | |
pct create 201 /var/lib/vz/template/cache/openwrt-20240316.tar.xz --arch amd64 --hostname openwrt --rootfs local-lvm:201 --memory 1024 --cores 2 --ostype unmanaged --unprivileged 1 --net0 name=eth0 --net1 name=eth1 --storage local-lvm |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Base64 encode | |
val text = "This is plaintext." | |
val bytesEncoded = java.util.Base64.getEncoder.encode(text.getBytes()) | |
// Base64 decode | |
val textDecoded = new String(java.util.Base64.getDecoder.decode(bytesEncoded)) | |
println(textDecoded) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
System Information | |
------------------- | |
Manufacturer: HP | |
Product Name: HP ENVY x360 Convertible 15-ee0xxx |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import com.typesafe.config.Config | |
implicit class ImplicitConfigHelper(val c: Option[Config]) extends AnyVal { | |
import scala.reflect.ClassTag | |
import scala.util.control.NonFatal | |
import ImplicitConfigHelper._ | |
implicit def valueOf[T : ClassTag](prop: String)(implicit ev: ClassTag[T]) : T = | |
ev.runtimeClass match { // you need stable identifiers here | |
case String_ => c.get.getString(prop).asInstanceOf[T] | |
case Int_ => c.get.getInt(prop).asInstanceOf[T] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import scala.reflect.runtime.universe._ | |
import scala.reflect.api | |
def runtimeTypeTagOf(name: String, parent: ClassLoader, url: java.net.URL): TypeTag[_] = | |
runtimeTypeTagOf(name, parent, Seq(url)) | |
def runtimeTypeTagOf(name: String, parent: ClassLoader, urls: Seq[java.net.URL]): TypeTag[_] = | |
runtimeTypeTagOf(name, new java.net.URLClassLoader(urls.toArray, parent)) | |
def runtimeTypeTagOf(name: String, cl: ClassLoader): TypeTag[_] = { | |
val c = Class.forName(name, true, cl) | |
val mirror: Mirror = runtimeMirror(cl) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import reflect.runtime.universe._ | |
import reflect.ClassTag | |
def typeTag2ClassTag[T: TypeTag]: ClassTag[T] = { | |
ClassTag[T]( typeTag[T].mirror.runtimeClass( typeTag[T].tpe ) ) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
val lines = | |
Seq( | |
"Item,Qty,Price", | |
"Banana,1,0.50") | |
val text = lines.mkString("\n") | |
val stream: java.io.InputStream = new java.io.ByteArrayInputStream(text.getBytes(java.nio.charset.StandardCharsets.UTF_8.name)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// QUICK EXAMPLE FOR THE IMPATIENT | |
/** This trait provides ability to instantiate a generic class */ | |
trait Makeable[T] { | |
def make: T | |
} | |
/** This typeclass which allows making an instance of type `T` */ | |
class Make[T: Makeable] { | |
def make(): T = implicitly[Makeable[T]].make |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package object spark { | |
import org.apache.spark.sql.types.StructType | |
implicit class StructTypeExtension(schema: StructType) { | |
import org.apache.spark.sql.types.StructField | |
implicit def similar(other: StructType): Boolean = _similar(schema, other) | |
implicit val fieldOrdering: Ordering[StructField] = Ordering.by(field => field.name) | |
private final def _similar(_this: StructType, _other: StructType): Boolean = |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// NOTE: This trickery below allows us to obtain the type of | |
// fields of a case class, so that we can play with generic | |
// pattern matching on field types. | |
// The post below is somewhat related. | |
// See also: http://www.alessandrolacava.com/blog/scala-case-classes-in-depth/ | |
import scala.reflect.runtime.universe._ |
NewerOlder