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 core.atomic; | |
alias atomic_count = long; | |
void increment(ref shared atomic_count a, long b) { | |
atomicOp!"+="(a, b); | |
} | |
unittest { | |
import core.thread; |
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
struct unspecified_bool_type_t {}; | |
typedef void (*unspecified_bool_type)(unspecified_bool_type_t); | |
static void unspecified_bool_true(unspecified_bool_type_t) {} | |
/// Operator returns non-null if there is a non-success error code. | |
operator unspecified_bool_type() const { | |
if (value_ == 0) | |
return 0; |
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 std.c.string; | |
import std.conv; | |
string formatError(int err, string prefix = "") { | |
version(Posix) { | |
char[512] buf; | |
const(char)* cs; | |
version (linux) { | |
cs = strerror_r(err, buf.ptr, buf.length); |
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
const A& foo() { | |
static A instance; | |
return instance; | |
} |
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 std.stdio; | |
import core.thread; | |
class A { | |
void opCall(int i) const shared { | |
write(i); | |
} | |
}; | |
shared(const A) foo() { |
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.concurrent._ | |
import scala.concurrent.ExecutionContext.Implicits.global | |
import scala.concurrent.duration._ | |
object Main extends App { | |
val futures = 1 to 1000 map { i => Future { i } } | |
val seq = Future.sequence(futures) | |
seq.onSuccess { case i => println(i) } | |
// just because ideone will kill main thread otherwise |
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 org.mucode.scim | |
import scalafx.Includes._ | |
import scalafx.application.JFXApp | |
import scalafx.event.ActionEvent | |
import scalafx.scene.Scene | |
import scalafx.scene.layout.BorderPane | |
object Application extends JFXApp { |
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 QtQuick 2.0 | |
import Mu 1.0 | |
Item { | |
id: pingPoint | |
property string address: "127.0.0.1" | |
property var status: Pinger.None | |
property int roundtripTime: -1 |
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 org.mucode.smerp.api | |
import scalikejdbc._, async._, FutureImplicits._ | |
import org.joda.time.DateTime | |
import scala.concurrent._ | |
case class Call( | |
id: Long, | |
companyId: Long, |
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 std.string; | |
import std.algorithm; | |
import std.array; | |
import std.format; | |
string stripMargin(string s, char marginChar = '|') { | |
return s.splitLines.map!(line => line.stripLeft.chompPrefix("" ~ marginChar)).join("\n"); | |
} |