Skip to content

Instantly share code, notes, and snippets.

View hedefalk's full-sized avatar

Viktor Hedefalk hedefalk

View GitHub Profile
#!/bin/sh
# btsync service
# Replace with linux users you want to run BTSync clients for
BTSYNC_USERS="mendel"
DAEMON=/usr/bin/btsync
start() {
for btsuser in $BTSYNC_USERS; do
HOMEDIR=`getent passwd $btsuser | cut -d: -f6`
config=$HOMEDIR/.sync/config.json
@hedefalk
hedefalk / DateParsers.scala
Created June 21, 2011 15:57
DateParsers.scala
trait DateParsers extends RegexParsers {
def dateTime(pattern: String): Parser[DateTime] = new Parser[DateTime] {
val dateFormat = DateTimeFormat.forPattern(pattern)
val dateParser = dateFormat.getParser
def jodaParse(text: CharSequence, offset: Int) = {
val mutableDateTime = new MutableDateTime
val newPos = dateFormat.parseInto(mutableDateTime, text, offset);
(mutableDateTime.toDateTime, newPos)
}
@hedefalk
hedefalk / eclipse.ini
Created May 5, 2011 14:46
eclipse.ini
-startup
../../../plugins/org.eclipse.equinox.launcher_1.1.1.R36x_v20101122_1400.jar
--launcher.library
../../../plugins/org.eclipse.equinox.launcher.cocoa.macosx.x86_64_1.1.2.R36x_v20101019_1345
-showsplash
org.eclipse.platform
--launcher.XXMaxPermSize
256m
--launcher.defaultAction
openFile
implicit def bindableText(text: Text): Target[String] = {
new Target[String] {
def bind(value: Signal[String]) = observe(value) { newValue =>
if (!text.isFocusControl) // don't update the text that's editing
text.setText(newValue)
true // keep observing
}
}
}
object Temperature {
implicit def unboxText2Double(s: String) = if (s != "") java.lang.Double.parseDouble(s) else 0.0
implicit def convertDouble2String(d: Double) = d.toString
val fahrenheit = new Var[String]("0")
val celsius = new Var[String]("0")
val calcCelsius = Signal {
((5.0 / 9.0) * (fahrenheit() - 32)) toString
}
text bind signal
implicit def bindableText(text: Text): Target[String] = {
new Target[String] {
def bind(value: Signal[String]) = observe(value) { newValue =>
text.setText(newValue)
true // keep observing
}
}
}
// outer scope
val myOutputSignal = Var[String]("")
// setup
textbox(signal)
def textbox(output: Var[String])(setups: (Text => Any)*)(parent: Composite) = {
val text = new Text(parent, SWT.BORDER)
text setText (output.now)
text emitTo output
setupAndReturn(text, setups)
}
text(_ emitTo signal)