Skip to content

Instantly share code, notes, and snippets.

View ttldtor's full-sized avatar
🎩
Sir Manticore

ttldtor ttldtor

🎩
Sir Manticore
View GitHub Profile
@ttldtor
ttldtor / gist:5150219
Last active December 14, 2015 21:19
Как бы хотелось вместо (1) иметь возможность делать (2) или (3).
/* 1 */
template<template <size_t> class T, size_t... Indices> struct summa;
template<template <size_t> class T, size_t Index, size_t... Indices>
struct summa<T, Index, Indices...>
{
static const decltype(T<Index>::value) value;
};
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