Skip to content

Instantly share code, notes, and snippets.

View ttldtor's full-sized avatar
🎩
Sir Manticore

ttldtor ttldtor

🎩
Sir Manticore
View GitHub Profile
if (!String.prototype.format) {
String.prototype.format = function() {
var me = this;
function replacer4Array(a) {
return me.replace(/{(\d+)}/g, function(match, number) {
var n = parseInt(number, 10);
if (isNaN(n) || typeof a[n - 1] === "undefined") {
return match;
QWebView *MuWebView::createWindow(QWebPage::WebWindowType type) {
Q_UNUSED(type)
QWebView* webView = new QWebView;
QWebPage* webPage = new QWebPage(webView);
webView->setWindowModality(Qt::ApplicationModal);
webView->setAttribute(Qt::WA_DeleteOnClose, true);
webView->setPage(webPage);
#include <iostream>
#include <iomanip>
#include <fstream>
#include <vector>
#include <chrono>
#include <utility>
#include <cmath>
const size_t records_number = 1000000;
const size_t check_status_chunk_size = records_number / 100;
import std.stdio;
import std.net.curl;
import std.regex;
import std.conv;
version(Windows) {
import std.windows.charset;
}
QLineEdit[hasErrorData=true] {
border-radius: 6px;
border: 2px solid #9A4745;
}
ui->adminLoginEdit->setProperty("hasErrorData", "true");
object StringUtils {
implicit class StringImprovements(val s: String) {
import scala.util.control.Exception._
def toIntOpt = catching(classOf[NumberFormatException]) opt s.toInt
def toLongOpt = catching(classOf[NumberFormatException]) opt s.toLong
}
}
void TERPConnector::asyncRequest(const QString &url, const QString &requestData, const QString &successfulDataType, std::function<void(QJsonObject)> onSuccess,
std::function<void(QJsonObject)> onError, std::function<void(QJsonObject)> onTimeout, int requestTimeout) {
QSharedPointer<QNetworkAccessManager> nam = QSharedPointer<QNetworkAccessManager>(new QNetworkAccessManager);
QUrl requestUrl(url_.toString() + url);
if (nam
/*&& nam_->networkAccessible() == QNetworkAccessManager::Accessible*/) {
#ifdef DEBUG
qDebug() << "asyncRequest: url = " << requestUrl.toString() << ", data = " << requestData << ", succDataType = " << successfulDataType
<< ", requestTimeout = " << requestTimeout;
const QString vsrc = R"SHADER(
#include "shaders/shader.glsl"
)SHADER";
import shapeless._
// A pair of ordinary case classes ...
case class Address(street : String, city : String, postcode : String)
case class Person(name : String, age : Int, address : Address)
// Some lenses over Person/Address ...
val nameLens = lens[Person] >> 'name
val ageLens = lens[Person] >> 'age
val addressLens = lens[Person] >> 'address
import core.atomic;
alias atomic_count = long;
void increment(ref shared atomic_count a, long b) {
atomicOp!"+="(a, b);
}
unittest {
import core.thread;