How to define vkCreateXcbSurfaceKHR in Erupted-V2? - d

I'm trying to use XCB with Vulkan bindings Erupted-V2 but I'm getting an error:
source/gfxdevicevulkan.d(231,24): Error: undefined identifier vkCreateXcbSurfaceKHR
Here's my dub.json:
{
"name": "dvulkanbase",
"targetType": "executable",
"description": "Vulkan boilerplate",
"license": "MIT",
"configurations": [
{
"name": "linux",
"platforms": ["linux"],
"versions": ["VK_USE_PLATFORM_XCB_KHR"],
"libs": [ "X11", "Xi", "Xrandr", "pthread", "Xxf86vm","GL", "GLU", "Xinerama", "Xcursor" ],
"dependencies": {
"bindbc-sdl": "~>0.19.0",
"erupted_v2": ">=1.1.71",
"xlib-d": "~>0.1.1",
"xcb-d": "~>2.1.0"
}
},
{
"name": "windows",
"platforms": ["windows"],
"versions": ["VK_USE_PLATFORM_WIN32_KHR"],
"dependencies": {
"bindbc-sdl": "~>0.19.0",
"erupted_v2": ">=1.1.71"
}
}
]
}
Here's my imports in the file that uses vkCreateXcbSurfaceKHR:
import core.stdc.string;
import erupted;
import erupted.vulkan_lib_loader;
import matrix4x4;
import std.conv;
import std.exception;
import std.stdio;
version(linux)
{
import X11.Xlib_xcb;
public import xcb.xcb;
import erupted.platform_extensions;
mixin Platform_Extensions!VK_USE_PLATFORM_XCB_KHR;
}
Here's the relevant section of the calling code:
class GfxDeviceVulkan
{
this( int width, int height, void* windowHandleOrWindow, void* display, uint window )
{
loadGlobalLevelFunctions();
VkApplicationInfo appinfo;
appinfo.pApplicationName = "VulkanBase";
appinfo.apiVersion = VK_MAKE_VERSION( 1, 0, 2 );
version(linux)
{
const(char*)[3] extensionNames = [
"VK_KHR_surface",
"VK_KHR_xcb_surface",
"VK_EXT_debug_utils",
];
}
uint extensionCount = 0;
vkEnumerateInstanceExtensionProperties( null, &extensionCount, null );
auto extensionProps = new VkExtensionProperties[]( extensionCount );
vkEnumerateInstanceExtensionProperties( null, &extensionCount, extensionProps.ptr );
uint layerCount = 0;
vkEnumerateInstanceLayerProperties( &layerCount, null );
auto layerProps = new VkLayerProperties[]( layerCount );
vkEnumerateInstanceLayerProperties( &layerCount, layerProps.ptr );
const(char*)[1] validationLayers = ["VK_LAYER_KHRONOS_validation"];
VkInstanceCreateInfo createinfo;
createinfo.sType = VkStructureType.VK_STRUCTURE_TYPE_INSTANCE_CREATE_INFO;
createinfo.pApplicationInfo = &appinfo;
createinfo.enabledExtensionCount = isDebug ? cast(uint)extensionNames.length : 2;
createinfo.ppEnabledExtensionNames = extensionNames.ptr;
createinfo.enabledLayerCount = isDebug ? validationLayers.length : 0;
createinfo.ppEnabledLayerNames = isDebug ? validationLayers.ptr : null;
enforceVk( vkCreateInstance( &createinfo, null, &instance ) );
loadInstanceLevelFunctions( instance );
version(linux)
{
auto xcbInfo = VkXcbSurfaceCreateInfoKHR(
VkStructureType.VK_STRUCTURE_TYPE_XCB_SURFACE_CREATE_INFO_KHR,
null,
0,
XGetXCBConnection( cast(xcb_connection_t*)display ),
window
);
enforceVk( vkCreateXcbSurfaceKHR( instance, &xcbInfo, null, &surface ) );
}
How to fix the error?

Related

MissingConfigVariableError while creating DataContext in Great Expectations

Unable to create DataContext with the following configuration.I am try to use a Databricks spark df datasource and in house DB as storeBackendDefaults
I get the MissingConfigVariableError exceptions
Could some explain what I am missing
import great_expectations as ge
import great_expectations.exceptions as ge_exceptions
from great_expectations.data_context.types.base import DataContextConfig, DatasourceConfig, FilesystemStoreBackendDefaults, DatabaseStoreBackendDefaults
from great_expectations.data_context import BaseDataContext
my_spark_datasource_config = DatasourceConfig(
class_name="Datasource",
execution_engine={"class_name": "SparkDFExecutionEngine"},
data_connectors={"sample_sparkdf_runtime_data_connector": {
"module_name": "great_expectations.datasource.data_connector",
"class_name": "RuntimeDataConnector",
"batch_identifiers": [
"some_key_maybe_pipeline_stage",
"some_other_key_maybe_run_id"
]
}
}
)
data_context_config = DataContextConfig(config_version = 2
,plugins_directory = None
,config_variables_file_path = None
,datasources={"my_spark_datasource": my_spark_datasource_config}
,store_backend_defaults=DatabaseStoreBackendDefaults(default_credentials = {
"drivername": "PrestoSQL",
"host": "*****",
"port": "443",
"username": "*****",
"password": "*****",
"database": "****"
}
),
anonymous_usage_statistics={"enabled": False}
)
context = BaseDataContext(project_config=data_context_config)

Number Formatting Issue with Custom Power BI Visual

Above is the card from the tutorial at https://learn.microsoft.com/en-us/power-bi/developer/custom-visual-develop-tutorial. Here is the related code for the visual.
I would like the number to be shown as a percentage value, i.e. 15.4% which is how it is formatting in the measure.
I have searched github, microsoft, google, etc. for a solution to this issue. I also skimmed all the recommended questions on Stack Overflow before posting. Any help get the number formatting to match the measures formatting would be greatly appreciated.
Here is the related code for the visual. (sorry for the length)
visual.ts
"use strict";
import "core-js/stable";
import "./../style/visual.less";
import powerbi from "powerbi-visuals-api";
import VisualConstructorOptions = powerbi.extensibility.visual.VisualConstructorOptions;
import VisualUpdateOptions = powerbi.extensibility.visual.VisualUpdateOptions;
import IVisual = powerbi.extensibility.visual.IVisual;
import EnumerateVisualObjectInstancesOptions = powerbi.EnumerateVisualObjectInstancesOptions;
import DataView = powerbi.DataView;
import * as d3 from "d3";
import VisualObjectInstanceEnumeration = powerbi.VisualObjectInstanceEnumeration;
import { VisualSettings } from "./settings";
import { rgb, RGBColor, Color } from "d3";
export class Visual implements IVisual {
private visualSettings: VisualSettings;
private svg: d3.Selection<SVGElement, any, any, any>;
private container: d3.Selection<SVGElement, any, any, any>;
private circle: d3.Selection<SVGElement, any, any, any>;
private textLabel: d3.Selection<SVGElement, any, any, any>;
private textValue: d3.Selection<SVGElement, any, any, any>;
private settings: VisualSettings;
constructor(options: VisualConstructorOptions) {
console.log('Visual constructor', options);
this.svg = d3.select(options.element)
.append('svg')
.classed('circlecard', true);
this.container = this.svg.append("g")
.classed('container', true);
this.circle = this.container.append("circle")
.classed('circle', true);
this.textValue = this.container.append("text")
.classed("textValue", true);
this.textLabel = this.container.append("text")
.classed("textLabel", true);
}
public enumerateObjectInstances(options: EnumerateVisualObjectInstancesOptions): VisualObjectInstanceEnumeration {
const settings: VisualSettings = this.visualSettings ||
VisualSettings.getDefault() as VisualSettings;
return VisualSettings.enumerateObjectInstances(settings, options);
}
public update(options: VisualUpdateOptions) {
this.settings = Visual.parseSettings(options && options.dataViews && options.dataViews[0]);
let dataView: DataView = options.dataViews[0];
let width: number = options.viewport.width;
let height: number = options.viewport.height;
this.svg.attr("width", width)
.attr("height", height);
let radius: number = Math.min(width, height) / 2.2;
this.visualSettings = VisualSettings.parse<VisualSettings>(dataView);
this.visualSettings.circle.circleThickness = Math.max(0, this.visualSettings.circle.circleThickness);
this.visualSettings.circle.circleThickness = Math.min(10, this.visualSettings.circle.circleThickness);
this.circle
.style("fill", this.visualSettings.circle.circleColor)
.style("stroke", this.visualSettings.circle.circleColor)
.style("stroke-width",this.visualSettings.circle.circleThickness)
.attr("r", radius)
.attr("cx", width / 2)
.attr("cy", height / 2);
let fontSizeValue: number = Math.min(width, height) / 5;
this.textValue
.text(dataView.single.value as string)
.attr("x", "50%")
.attr("y", "50%")
.attr("dy", "0.35em")
.attr("text-anchor", "middle")
.style("font-size", fontSizeValue + "px");
let fontSizeLabel: number = fontSizeValue / 4;
this.textLabel
.text(dataView.metadata.columns[0].displayName)
.attr("x", "50%")
.attr("y", height / 2)
.attr("dy", fontSizeValue / 1.2)
.attr("text-anchor", "middle")
.style("font-size", fontSizeLabel + "px");
}
private static parseSettings(dataView: DataView): VisualSettings {
return VisualSettings.parse(dataView) as VisualSettings;
}
/**
* This function gets called for each of the objects defined in the capabilities files and allows you to select which of the
* objects and properties you want to expose to the users in the property pane.
*
*/
}
capabilities.json
{
"dataRoles": [
{
"displayName": "Measure",
"name": "measure",
"kind": "Measure"
}
],
"objects": {
"circle": {
"displayName": "Circle",
"properties": {
"circleColor": {
"displayName": "Color",
"description": "The fill color of the circle.",
"type": {
"fill": {
"solid": {
"color": true
}
}
}
},
"circleThickness": {
"displayName": "Thickness",
"description": "The circle thickness.",
"type": {
"numeric": true
}
}
}
}
},
"dataViewMappings": [
{
"conditions": [
{ "measure": { "max": 1 } }
],
"single": {
"role": "measure"
}
}
]
}
settings.ts
"use strict";
import { dataViewObjectsParser } from "powerbi-visuals-utils-dataviewutils";
import DataViewObjectsParser = dataViewObjectsParser.DataViewObjectsParser;
export class CircleSettings {
public circleColor: string = "white";
public circleThickness: number = 2;
}
export class VisualSettings extends DataViewObjectsParser {
public circle: CircleSettings = new CircleSettings();
}
Thank you for viewing this.
One way I always handle my formats (when not possible via the interface)
is creating custom Measures that contain the format I want.
I created 2 cards to show unformatted and formatted values:
Measure formula :
Fmt_value = FORMAT(SUM('Table'[Column1]),"#,##0.0%;(#,##0.0%)")
see pictures:
Formatting Numeric values as %
Adding a Measure for Formatting
Hope this helps.

How to fix this error in my appsync while creating an array of data

I am creating an array of date and in my resolver it only return one output of date and count audited
I search throughout the google to find some answer and I found a code how to make an array of list but the problem is it didn't return well
https://imgur.com/a/1eDknYN
this is a result and the code I use it attached in the picture
#set ($tu = 0) #set ($pc = 0) #set ($fc = 0) #set ($da = [])#set ($cda = []) #foreach($item in $ctx.result.items)
#set($tu = $item.total_audits + $tu)
#set($pc = $item.passed_compliance + $pc)
#set($fc = $item.failed_compliance + $fc)
#set($date = $item.sort)
#set($count = $item.total_audits)
$util.qr($da.add("$date"))
$util.qr($cda.add("$count"))
#end
$util.toJson({"total_audits":$tu, "passed_compliance":$pc,
"failed_compliance":$fc, "daily_audit": [{"date": $da, "count": $cda}]})
here is the error
"errors": [
{
"path": [
"getAuditSummary",
"daily_audit",
0,
"date"
],
"locations": null,
"message": "Can't serialize value (/getAuditSummary/daily_audit[0]/date) : Unable to serialize `[2018-12-26, 2018-12-27, 2018-12-28]` as a valid date."
},
{
"path": [
"getAuditSummary",
"daily_audit",
0,
"count"
],
"locations": null,
"message": "Can't serialize value (/getAuditSummary/daily_audit[0]/count) : Expected type 'Int' but was 'ArrayList'."
what i want to make is it would return something like this
"daily_audit": [
{
"date": 2018-12-26,
"count": 1
}
{
"date": 2018-12-27,
"count": 4
}
{
"date": 2018-12-28,
"count": 2
}
]
This is happening because $da and $cda are arrays. So it's probably returning:
"daily_audit": [
{
"date": [2018-12-26,2018-12-27,2018-12-28],
"count": [1,4,2]
}
]
So, in your response mapping template, you can try something like:
#set ($tu = 0)
#set ($pc = 0)
#set ($fc = 0)
#set ($da = [])
#foreach($item in $ctx.result.items)
#set($tu = $item.total_audits + $tu)
#set($pc = $item.passed_compliance + $pc)
#set($fc = $item.failed_compliance + $fc)
#set($date = $item.sort)
#set($count = $item.total_audits)
$util.qr($da.add({"date":$date, "count":$count}))
#end
$util.toJson({"total_audits":$tu, "passed_compliance":$pc, "failed_compliance":$fc, "daily_audit": $da})

QJsonObject partial path from variable

I have a json object that I load:
QJsonObject json = CommonToolkit::Types::LoadJson(config);
Here is a partial of the json file content:
{
"config": {
"macos": {
"screen": {
"main": {
"height": 0,
"left": 0,
"top": 0,
"width": 0
}
},
"windows: {
}
What I do is check what os i'm running in. Using the following variable to store that os:
QString osPath;
In my test osPath = "macos"
So I want to update the applications geometry
QJsonObject jparam{
{ "height", value.height() },
{ "left", value.left() },
{ "width", value.width() },
{ "top", value.top() }
};
My problem is when I try to set jon with jparam using osPath:
json["config"][osPath]["screen"]["main"] = jparam;
The error I'm getting is:
/Users/adviner/Projects/Notes/src/Notes/data/config.cpp:87: error: type 'QJsonValueRef' does not provide a subscript operator
json["config"][osPath]["screen"]["main"] = jparam;
~~~~~~~~~~~~~~^~~~~~~
Editing a Json in Qt is not a simple task, in this case when using json["config"] you get a QJsonValueRef, this class is a helper to get other types of elements like QJsonObject, QJsonArray, int, QString, etc. by what to get the next element must be used toObject() but this value is a copy, so if you modify it, the initial element will not be modified, you have to reassign it.
QJsonObject json = CommonToolkit::Types::LoadJson(config);
QString osPath = "macos";
QJsonObject jparam{
{ "height", value.height() },
{ "left", value.left() },
{ "width", value.width() },
{ "top", value.top() }
};
// get objects
QJsonObject config_obj = json["config"].toObject();
QJsonObject osPath_obj = config_obj[osPath].toObject();
QJsonObject screen_obj = osPath_obj["screen"].toObject();
// modify param
screen_obj["main"] = jparam;
// set objects
osPath_obj["screen"] = screen_obj;
config_obj[osPath] = osPath_obj;
json["config"] = config_obj;

Determine velocity template request body property type?

I have an API Gateway that uses velocity templates as a thin wrapper to allow users to do CRUD operations on a DynamoDB table.
I'm trying to write the update operation as dynamically as possible, but where I'm stuck is with determining type from the request body's properties from within the velocity template. This is what I'm working with:
#set($body = $input.path('$'))
#set($updateExpression = "set")
#set($expressionAttributeNames = "")
#set($expressionAttributeValues = "")
#foreach($attrName in $body.keySet())
#set($updateExpression = "${updateExpression} #$attrName = :${attrName},")
#set($expressionAttributeNames = "${expressionAttributeNames}""#${attrName}"":""${attrName}""")
#set($attrValue = $input.json("$.${attrName}"))
#if($attrValue.matches("^-?\\d+$"))
#set($attrValue = """:${attrName}"": { ""N"": ${attrValue}, ")
#else
#set($attrValue = """:${attrName}"": { ""S"": """ + $util.escapeJavaScript($attrValue) + """ },")
#end
#set($expressionAttributeValues = "${expressionAttributeValues} ${attrValue}")
#if($foreach.hasNext)
#set($expressionAttributeNames = "${expressionAttributeNames}, ")
#end
#end
{
"TableName": "TABLE",
"Key": { "id": { "S": "$input.params('id')" } },
"UpdateExpression": "${updateExpression} updatedOn = :updatedOn",
"ExpressionAttributeNames": {$expressionAttributeNames},
"ExpressionAttributeValues": {
$expressionAttributeValues
":updatedOn": { "N": "$context.requestTimeEpoch" }
}
}
Edit: This would be a sample request body:
https://api/v1/endpoint/123
{
"location": {
"lat": 42,
"lon": -71
},
"rating": 4
}
This is the current transformation I get:
{
"TableName": "users",
"Key": { "gcn": { "S": "123" } },
"UpdateExpression": "set #number = :number, #location = :location, updatedOn = :updatedOn",
"ExpressionAttributeNames": {"#number":"number", "#location":"location"},
"ExpressionAttributeValues": {
":number": { "S": "1" }, ":location": { "S": "{\"lat\":26.89199858375187,\"lon\":75.77141155196833}" },
":updatedOn": { "N": "" }
}
}
I currently just have a test for checking if a value is a number...and it isn't working.
After doing some more digging I reached what I set out for. I have a dynamic Velocity Template mapping for AWS API Gateway for the purpose of updating DynamoDB items.
So far it supports strings, numbers, booleans, and string-escaped objects, as that's how my project stores them (they are not query-able). ExpressionAttributeNames exists in case you use a reserved keyword for an attribute name...like I did for 'location'.
If anyone has any improvements/enhancements please let me know, it's a beast of a script.
#set($body = $input.path('$'))
#set($updateExpression = "set")
#set($expressionAttributeNames = "")
#set($expressionAttributeValues = "")
#foreach($attrName in $body.keySet())
#set($updateExpression = "${updateExpression} #$attrName = :${attrName},")
#set($expressionAttributeNames = "${expressionAttributeNames}""#${attrName}"":""${attrName}""")
#set($attrValue = $input.json("$.${attrName}"))
#if($attrValue.toString().matches("[+-]?\d+"))
#set($attrValue = """:${attrName}"": { ""N"": ""${attrValue}"" }, ")
#elseif($attrValue.toString() == "true" || $attrValue.toString() == "false")
#set($attrValue = """:${attrName}"": { ""BOOL"": ${attrValue} }, ")
#elseif(($attrValue.toString().startsWith("{") && $attrValue.toString().endsWith("}")) ||
($attrValue.toString().startsWith("[") && $attrValue.toString().endsWith("]")) )
#set($attrValue = """:${attrName}"": { ""S"": """ + $util.escapeJavaScript($attrValue) + """ },")
#else
#set($attrValue = """:${attrName}"": { ""S"": " + $attrValue + " },")
#end
#set($expressionAttributeValues = "${expressionAttributeValues} ${attrValue}")
#if($foreach.hasNext)
#set($expressionAttributeNames = "${expressionAttributeNames}, ")
#end
#end
{
"TableName": "", ## Insert your table here.
"Key": { "gcn": { "S": "$input.params('')" } }, ## Insert your key expression here.
## Update below if `updatedOn` is not your audit attribute.
"UpdateExpression": "${updateExpression} updatedOn = :updatedOn",
"ExpressionAttributeNames": {$expressionAttributeNames},
"ExpressionAttributeValues": {
$expressionAttributeValues
":updatedOn": { "N": "$context.requestTimeEpoch.toString()" }
}
}
Sample Request Body:
{
"firstName": "John",
"isActive": true,
"_status": 1
}
Sample Transformation:
{
"TableName": "users",
"Key": {
"id": {
"S": "1"
}
},
"UpdateExpression": "set #firstName = :firstName, #isActive = :isActive, #_status = :_status, updatedOn = :updatedOn",
"ExpressionAttributeNames": {
"#firstName": "firstName",
"#isActive": "isActive",
"#_status": "_status"
},
"ExpressionAttributeValues": {
":firstName": {
"S": "John"
},
":isActive": {
"BOOL": true
},
":_status": {
"N": "1"
},
":updatedOn": {
"N": "123456789"
}
}
}