Skip to content

Instantly share code, notes, and snippets.

View vigoo's full-sized avatar

Daniel Vigovszky vigoo

View GitHub Profile
@vigoo
vigoo / RowCountController.scala
Created February 16, 2014 10:53
Binding table's row count to a label with ScalaFX
package scalafxml.demo.rowcount
import scalafx.Includes._
import scalafxml.core.macros.sfxml
import scalafx.scene.control.{TableColumn, Label, TableView}
import scalafx.event.ActionEvent
import scalafx.application.JFXApp
import scalafxml.core.{DependenciesByType, FXMLView}
import scalafx.scene.Scene
import scalafx.beans.property.StringProperty
@vigoo
vigoo / TestController.scala
Created April 27, 2014 11:38
scalafxml TableColumn test
package scalafxml.demo
import scalafx.application.JFXApp
import scalafx.Includes._
import scalafx.scene.control.TableView
import scalafx.scene.control.TableColumn
import scalafxml.core.{FXMLView, DependenciesByType}
import scalafxml.core.macros.sfxml
import scalafx.scene.Scene
import scalafx.beans.property.StringProperty
@vigoo
vigoo / Main.hs
Created June 6, 2014 10:14
Trying to run git with shelly
{-# LANGUAGE OverloadedStrings #-}
import Shelly
import Data.Text as T
default (T.Text)
main = shelly $ do
git "pull" []
last_commit <- git "log" ["--oneline", "-n 1"]
echo $ append "Last commit in this repo was: " last_commit
@vigoo
vigoo / ScalaFXScheduler
Created August 21, 2014 07:02
RxScala scheduler for ScalaFX
package io.github.vigoo.rx.schedulers
import java.util.{TimerTask, Timer}
import java.util.concurrent.TimeUnit
import rx.Scheduler.Worker
import rx.Subscription
import rx.functions.Action0
import rx.lang.scala.Scheduler
import rx.subscriptions.{Subscriptions, BooleanSubscription, CompositeSubscription}
@vigoo
vigoo / prox_1_1.scala
Created November 20, 2019 15:31
prox 1/1
class Process[Out, Err, OutResult, ErrResult,
IRS <: RedirectionState, ORS <: RedirectionState, ERS <: RedirectionState](
val command: String,
val arguments: List[String],
val workingDirectory: Option[Path],
val inputSource: ProcessInputSource,
val outputTarget: ProcessOutputTarget[Out, OutResult],
val errorTarget: ProcessErrorTarget[Err, ErrResult],
val environmentVariables: Map[String, String])
extends ProcessNode[Out, Err, IRS, ORS, ERS] {
@vigoo
vigoo / prox_1_2.scala
Created November 20, 2019 15:38
prox 1/2
/** Phantom type representing the redirection state of a process */
sealed trait RedirectionState
/** Indicates that the given channel is not redirected yet */
trait NotRedirected extends RedirectionState
/** Indicates that the given channel has already been redirected */
trait Redirected extends RedirectionState
@vigoo
vigoo / prox_1_3.scala
Created November 20, 2019 15:59
Prox 1/3
val p1: Process[NotRedirected, NotRedirected, NotRedirected] = ???
val p2: Process[NotRedirected, Redirected, NotRedirected] = p1 > (home / "tmp" / "out.txt")
val p3 = p2 > (home / "tmp" / "another.txt") // THIS MUST NOT COMPILE
@vigoo
vigoo / prox_1_4.scala
Created November 20, 2019 16:00
Prox 1/4
implicit class ProcessNodeOutputRedirect[
IRS <: RedirectionState,
ERS <: RedirectionState,
PN <: Process[IRS, NotRedirected, ERS]](process: PN) {
def >[To](to: To)(implicit target: CanBeProcessOutputTarget[To]): Process[IRS, Redirected, ERS] = ???
}
@vigoo
vigoo / prox_1_5.scala
Created November 20, 2019 16:01
Prox 1/5
sealed trait ProcessNode[Out, Err, IRS <: RedirectionState, ORS <: RedirectionState, ERS <: RedirectionState]
@vigoo
vigoo / prox_1_6.scala
Created November 20, 2019 16:02
prox 1/6
class PipedProcess[Out, Err, PN1Out,
PN1 <: ProcessNode[_, _, _, _, _],
PN2 <: ProcessNode[_, _, _, _, _],
IRS <: RedirectionState, ORS <: RedirectionState, ERS <: RedirectionState]
(val from: PN1, val createTo: PipeConstruction[PN1Out] => PN2)
extends ProcessNode[Out, Err, IRS, ORS, ERS] {
// ...
}