Skip to content

Instantly share code, notes, and snippets.

View ttldtor's full-sized avatar
🎩
Sir Manticore

ttldtor ttldtor

🎩
Sir Manticore
View GitHub Profile
import core.atomic;
alias atomic_count = long;
void increment(ref shared atomic_count a, long b) {
atomicOp!"+="(a, b);
}
unittest {
import core.thread;
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;
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);
const A& foo() {
static A instance;
return instance;
}
import std.stdio;
import core.thread;
class A {
void opCall(int i) const shared {
write(i);
}
};
shared(const A) foo() {
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
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 {
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
package org.mucode.smerp.api
import scalikejdbc._, async._, FutureImplicits._
import org.joda.time.DateTime
import scala.concurrent._
case class Call(
id: Long,
companyId: Long,
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");
}