Skip to content

Instantly share code, notes, and snippets.

@exocode
exocode / xfs-on-hetzner.yml
Last active January 27, 2024 06:33
Create xfs partitions on Hetzner via cloud-init. It keeps root disk available again after rebooting. Simply change your desired sizes and filesystem to use it for your needs.
#cloud-config
resize_rootfs: false
disk_setup:
/dev/sda:
table_type: 'mbr'
layout:
- 25
- 75
overwrite: true
@tuxdna
tuxdna / Example.scala
Last active October 31, 2018 22:39
Examples: sealed families of singleton objects extending functions
sealed trait Transformer[P, Q] {
protected def transform(x: P): Q
def apply(x: P): Q = transform(x)
}
object Int2StringTransformer extends Transformer[Int, String] {
def transform(x: Int): String = x.toString
}
object List2SetTransformer extends Transformer[List[_], Set[_]] {
@davegurnell
davegurnell / TypeclassDemo.scala
Created October 6, 2015 14:53
Example of the type class pattern in Scala
object TypeclasseDemo {
// The parts of the type class pattern are:
//
// 1. the "type class" itself -- a trait with a single type parameter;
//
// 2. type class "instances" for each type we care about,
// each marked with the `implicit` keyword;
//
// 3. an "interface" to the type class -- one or more methods
@mottyc
mottyc / kafka-service-script
Last active January 10, 2022 07:07
Kafka service script (copy to file: /etc/init.d/kafka)
#! /bin/sh
# /etc/init.d/kafka: start the kafka daemon.
# chkconfig: - 80 20
# description: kafka
KAFKA_HOME=/usr/share/kafka
KAFKA_USER=root
KAFKA_SCRIPT=$KAFKA_HOME/bin/kafka-server-start.sh
KAFKA_CONFIG=$KAFKA_HOME/config/server.properties
import scala.language.higherKinds // lol
trait Functor[F[_]] {
def fmap[A, B](f: A => B): F[A] => F[B]
}
trait Apply[F[_]] {
def ap[A, B](f: F[A => B]): F[A] => F[B]
}
@benevans
benevans / artifactory.sh
Created September 25, 2014 10:46
Artifactory start script for supervisord
#!/bin/bash
# Artifactory start script for supervisord
# Derived from http://serverfault.com/questions/425132/controlling-tomcat-with-supervisor
ARTHOME=$HOME/artifactory-3.3.1
function shutdown() {
echo "$(date): Shutting down Artifactory"
$ARTHOME/bin/artifactory.sh stop
}
@cvogt
cvogt / gist:9239494
Last active September 9, 2019 01:30
Slick app architecture cheat sheet
// Please comment in case of typos or bugs
import scala.slick.driver.H2Driver._
val db = Database.for...(...)
case class Record( ... )
class Records(tag: Tag) extends Table[Record](tag,"RECORDS"){
...
def * = ... <> (Record.tupled,Record.unapply)
// place additional methods here which return values of type Column

Hi, looking for scalac flags?

This gist has been upgraded to a blog post here.

@milessabin
milessabin / gist:6185537
Created August 8, 2013 15:18
shapeless records ... current state of play ...
Welcome to Scala version 2.10.2 (Java HotSpot(TM) 64-Bit Server VM, Java 1.7.0_21).
Type in expressions to have them evaluated.
Type :help for more information.
scala> import shapeless._ ; import SingletonTypes._ ; import Record._
import shapeless._
import SingletonTypes._
import Record._
scala> :paste
@krishnanraman
krishnanraman / zipcodes of wealthy elite
Last active December 20, 2015 06:09
Where do the WEALTHY WELL EDUCATED ELITE live ?
/*
Goal: Use Scalding to datamine the 2010 US Census data (kindly provided by @ElonAzoulay & @hmason), to find
Where do the WEALTHY WELL EDUCATED ELITE live ?
WEALTHY == house value quarter million, household income 150k
WELL EDUCATED == sort by edu, edu = (10 * Phd + 5 * MS + 1 * BS) score
*/
import com.twitter.scalding._
import cascading.tuple.Fields
import cascading.tap.SinkMode