Related
wonder if you could help me out on the below.
I´m using Deneb to visualize small multiples in PBI and I´m not able to find out how to add text labels above/below the bar.
Does anyone know the workaround by chance?
Here´s the code that I´m using so far:
{
"data": {"values": [
{"Region":"A","Month":"1","Difference":"-0.01"},
{"Region":"A","Month":"2","Difference":"0"},
{"Region":"A","Month":"3","Difference":"-0.03"},
{"Region":"A","Month":"4","Difference":"-0.01"},
{"Region":"A","Month":"5","Difference":"-0.01"},
{"Region":"A","Month":"6","Difference":"0.05"},
{"Region":"A","Month":"7","Difference":"-0.05"},
{"Region":"A","Month":"8","Difference":"-0.03"},
{"Region":"A","Month":"9","Difference":"0.03"},
{"Region":"A","Month":"10","Difference":"-0.01"},
{"Region":"A","Month":"11","Difference":"-0.01"},
{"Region":"A","Month":"12","Difference":"0.03"},
{"Region":"B","Month":"1","Difference":"-0.02"},
{"Region":"B","Month":"2","Difference":"-0.02"},
{"Region":"B","Month":"3","Difference":"0.02"},
{"Region":"B","Month":"4","Difference":"0.03"},
{"Region":"B","Month":"5","Difference":"-0.05"},
{"Region":"B","Month":"6","Difference":"-0.02"},
{"Region":"B","Month":"7","Difference":"-0.01"},
{"Region":"B","Month":"8","Difference":"0.03"},
{"Region":"B","Month":"9","Difference":"-0.03"},
{"Region":"B","Month":"10","Difference":"-0.03"},
{"Region":"B","Month":"11","Difference":"0.01"},
{"Region":"B","Month":"12","Difference":"-0.02"},
{"Region":"C","Month":"1","Difference":"-0.05"},
{"Region":"C","Month":"2","Difference":"-0.04"},
{"Region":"C","Month":"3","Difference":"-0.03"},
{"Region":"C","Month":"4","Difference":"0"},
{"Region":"C","Month":"5","Difference":"0"},
{"Region":"C","Month":"6","Difference":"-0.02"},
{"Region":"C","Month":"7","Difference":"-0.05"},
{"Region":"C","Month":"8","Difference":"0.02"},
{"Region":"C","Month":"9","Difference":"0"},
{"Region":"C","Month":"10","Difference":"-0.03"},
{"Region":"C","Month":"11","Difference":"-0.03"},
{"Region":"C","Month":"12","Difference":"0.02"},
{"Region":"D","Month":"1","Difference":"0.05"},
{"Region":"D","Month":"2","Difference":"-0.02"},
{"Region":"D","Month":"3","Difference":"-0.05"},
{"Region":"D","Month":"4","Difference":"-0.05"},
{"Region":"D","Month":"5","Difference":"0"},
{"Region":"D","Month":"6","Difference":"-0.01"},
{"Region":"D","Month":"7","Difference":"0.02"},
{"Region":"D","Month":"8","Difference":"-0.01"},
{"Region":"D","Month":"9","Difference":"0"},
{"Region":"D","Month":"10","Difference":"-0.01"},
{"Region":"D","Month":"11","Difference":"0.01"},
{"Region":"D","Month":"12","Difference":"-0.03"}
]},
"mark": {
"type": "bar",
"stroke": "black",
"opacity": 1,
"cornerRadius": 2,
"tooltip":true
},
"width": 440,
"height": 75,
"cornerRadius": 2,
"encoding": {
"facet": {
"field": "Region",
"type": "ordinal",
"title": null,
"columns": 2
},
"x": {
"field": "Month",
"type": "ordinal",
"axis": {"labelAngle": 0}
},
"y": {
"field": "Difference",
"type": "quantitative",
"axis": {
"format": "0%",
"formatType": "pbiFormat"
}
},
"color": {
"condition": {
"test": "datum['Difference']<0",
"value": "#F78272"
},
"value": "#F2C80F"
},
"text": {
"field": "Difference",
"type": "quantitative"
}
}
}
Many thanks in advance!
*edit1: added desired output
*edit2: added dataset into the code
Desired outcome:
How's this?
{
"$schema": "https://vega.github.io/schema/vega-lite/v5.json",
"data": {
"values": [
{"Region": "A", "Month": "1", "Difference": "-0.01"},
{"Region": "A", "Month": "2", "Difference": "0"},
{"Region": "A", "Month": "3", "Difference": "-0.03"},
{"Region": "A", "Month": "4", "Difference": "-0.01"},
{"Region": "A", "Month": "5", "Difference": "-0.01"},
{"Region": "A", "Month": "6", "Difference": "0.05"},
{"Region": "A", "Month": "7", "Difference": "-0.05"},
{"Region": "A", "Month": "8", "Difference": "-0.03"},
{"Region": "A", "Month": "9", "Difference": "0.03"},
{"Region": "A", "Month": "10", "Difference": "-0.01"},
{"Region": "A", "Month": "11", "Difference": "-0.01"},
{"Region": "A", "Month": "12", "Difference": "0.03"},
{"Region": "B", "Month": "1", "Difference": "-0.02"},
{"Region": "B", "Month": "2", "Difference": "-0.02"},
{"Region": "B", "Month": "3", "Difference": "0.02"},
{"Region": "B", "Month": "4", "Difference": "0.03"},
{"Region": "B", "Month": "5", "Difference": "-0.05"},
{"Region": "B", "Month": "6", "Difference": "-0.02"},
{"Region": "B", "Month": "7", "Difference": "-0.01"},
{"Region": "B", "Month": "8", "Difference": "0.03"},
{"Region": "B", "Month": "9", "Difference": "-0.03"},
{"Region": "B", "Month": "10", "Difference": "-0.03"},
{"Region": "B", "Month": "11", "Difference": "0.01"},
{"Region": "B", "Month": "12", "Difference": "-0.02"},
{"Region": "C", "Month": "1", "Difference": "-0.05"},
{"Region": "C", "Month": "2", "Difference": "-0.04"},
{"Region": "C", "Month": "3", "Difference": "-0.03"},
{"Region": "C", "Month": "4", "Difference": "0"},
{"Region": "C", "Month": "5", "Difference": "0"},
{"Region": "C", "Month": "6", "Difference": "-0.02"},
{"Region": "C", "Month": "7", "Difference": "-0.05"},
{"Region": "C", "Month": "8", "Difference": "0.02"},
{"Region": "C", "Month": "9", "Difference": "0"},
{"Region": "C", "Month": "10", "Difference": "-0.03"},
{"Region": "C", "Month": "11", "Difference": "-0.03"},
{"Region": "C", "Month": "12", "Difference": "0.02"},
{"Region": "D", "Month": "1", "Difference": "0.05"},
{"Region": "D", "Month": "2", "Difference": "-0.02"},
{"Region": "D", "Month": "3", "Difference": "-0.05"},
{"Region": "D", "Month": "4", "Difference": "-0.05"},
{"Region": "D", "Month": "5", "Difference": "0"},
{"Region": "D", "Month": "6", "Difference": "-0.01"},
{"Region": "D", "Month": "7", "Difference": "0.02"},
{"Region": "D", "Month": "8", "Difference": "-0.01"},
{"Region": "D", "Month": "9", "Difference": "0"},
{"Region": "D", "Month": "10", "Difference": "-0.01"},
{"Region": "D", "Month": "11", "Difference": "0.01"},
{"Region": "D", "Month": "12", "Difference": "-0.03"}
]
},
"spec": {
"width": 440,
"height": 75,
"encoding": {
"x": {"field": "Month", "type": "ordinal", "axis": {"labelAngle": 0}},
"y": {
"field": "Difference",
"type": "quantitative",
"axis": {"format": "0%", "formatType": "pbiFormat"}
},
"color": {
"condition": {"test": "datum['Difference']<0", "value": "#F78272"},
"value": "#F2C80F"
}
},
"layer": [
{
"mark": {
"type": "bar",
"stroke": "black",
"opacity": 1,
"cornerRadius": 2,
"tooltip": true
}
},
{
"mark": {
"type": "text",
"dy": {"expr": "datum.Difference < 0 ? 10 : -10"}
},
"encoding": {"text": {"field": "Difference", "type": "quantitative"}}
}
]
},
"facet": {"field": "Region", "type": "ordinal", "title": null},
"columns": 2
}
Can someone explain the behavior of the following to me?
With a base class like this:
abstract class Foo
{
string[] members;
final:
this(this T)(T child)
{
import std.conv : to;
foreach (member; __traits(derivedMembers, T))
{
mixin("members ~= to!string(child." ~ member ~ ");\r\n");
}
}
void printMembers()
{
writeln(members);
}
}
I'd expect members to be populated with the values of the passed child type.
However the behavior is really weird.
The array members will be populated infinitely, which basically will cause the program to go out of memory.
If you change the mixin to this:
mixin("if (members.length < 20) members ~= to!string(child." ~ member ~ ");\r\n");
then you'll be able to see how the array is populated, but the values do not make sense in terms of how the code should work.
Example usage:
class Bar : Foo
{
int baba;
int caca;
this() { baba = 1; caca = 2; super(this); }
}
class Baz : Foo
{
int foo;
int bar;
int baz;
this() { foo = 100; bar = 200; baz = 300; super(this); }
}
void main()
{
auto b = new Bar();
auto a = new Baz();
b.printMembers();
a.printMembers();
b.printMembers();
}
The above code will produce an output like below:
["1", "2", "1", "2", "1", "2", "1", "2", "1", "2", "1", "2", "1", "2", "1", "2", "1", "2", "1", "2", "f193.Bar", "f193.Bar", "f193.Bar", "f193.Bar", "f193.Bar", "f193.Bar", "f193.Bar", "f193.Bar", "f193.Bar"]
["100", "200", "300", "100", "200", "300", "100", "200", "300", "100", "200", "300", "100", "200", "300", "100", "200", "300", "100", "200", "f193.Baz", "f193.Baz", "f193.Baz", "f193.Baz", "f193.Baz", "f193.Baz"]
["1", "2", "1", "2", "1", "2", "1", "2", "1", "2", "1", "2", "1", "2", "1", "2", "1", "2", "1", "2", "f193.Bar", "f193.Bar", "f193.Bar", "f193.Bar", "f193.Bar", "f193.Bar", "f193.Bar", "f193.Bar", "f193.Bar"]
Where I would have expected something like:
["1", "2"]
["100", "200", "300"]
["1", "2"]
Why exactly does it behave like this? It looks like a bug to me, but maybe there's a reason for the behavior?
Looking at the code I see it's because the constructor is called recursive.
The simple fix is the following:
static if (member != "__ctor") mixin("members ~= to!string(child." ~ member ~ ");\r\n");
so, i have 12 list's with Number , and i will compare it, with a Input with Number .I will that each List to compare with the input , and print the number similar with the input .
example:
input : 2 14 34 12 23 45
first list : ["2", "14", "18", "28","40", "48"]
output 2 14
my code:
w = raw_input("give number: ").split()
a1 = ["2", "14", "18", "28","40", "48"]
a2 = ["5", "9", "17", "21", "32", "49"]
a3 = ["4", "18", "19", "30", "47", "49"]
a4 = ["9", "15", "25", "28", "39", "43"]
a5 = ["8", "11", "13", "25", "39", "48"]
a6 = ["3", "12", "13", "14", "31", "33"]
a7 = ["3", "12", "14", "23", "26", "45"]
a8 = ["1", "10", "12", "15", "18", "37"]
a9 = ["6", "7", "17", "38", "41", "44"]
a10 = ["1", "7", "14", "17", "27", "35"]
a11 = ["15", "23", "25", "26", "39", "48"]
a12 = ["5", "12", "14", "30", "41", "48"]
for a,b,c,d,e,f,g,h,i,j,k,l in zip(a1, b2, c3, d4, e5, f6, g7, h8, i9, j10, k11, l12):
if a in w :
print "(1)", a
elif b in w:
print "(2)", b
elif c in w:
print "(3)", c
elif d in w:
print "(4)", d
elif e in w:
print "(5)", e
elif f in w:
print "(6)", f
elif g in w:
print "(7)", g
elif h in w:
print "(8)", h
elif i in w:
print "(9)", i
elif j in w:
print "(10)", j
elif k in w:
print "(11)", k
else:
print "(12)", a
This is what i come....
give number: 2 14 18 28
(1) 2
(1) 14
(1) 18
(1) 28
(8) 40
(12) 48
Can you Please help me.... Thanks!
People help me for this question(not here...)...very thanks them!!, The solution for my problem ... i write the solution maybe another people to need it...
bet_numbers = [
{"2", "14", "18", "28","40", "48"},
{"5", "9", "17", "21", "32", "49"},
{"4", "18", "19", "30", "47", "49"},
{"9", "15", "25", "28", "39", "43"},
{"8", "11", "13", "25", "39", "48"}, #created set Lists with curly braces {}
{"3", "12", "13", "14", "31", "33"},
{"3", "12", "14", "23", "26", "46"},
{"1", "10", "12", "15", "18", "37"},
{"6", "7", "17", "38", "41", "44"},
{"1", "7", "14", "17", "27", "35"},
{"15", "23", "25", "26", "39", "48"},
{"5", "12", "14", "30", "41", "48"},
]
drawn_numbers = set(raw_input("drawn numbers: ").split()) # build a set List
for index, numbers in enumerate(bet_numbers, start=1): #with enumerate(),enumerate each List
correct = drawn_numbers & numbers #with "identifier" add Input + numbers = (1), (2),....
if correct: #if statement without comparison because True is...
print "({}) {}".format(index, ', '.join(sorted(correct)))
#"({}) {}".format() = concatenate elements together .
# (index, ', '.join(sorted(correct))) = (1), (2),...sorted(correct),sorted the set lists output
I am creating a simple 'Bruteforce attack' for a project (not school related). Could someone please tell me which part of the code is wrong to get these errors.
The Code:
#include <string>
using namespace std;
//Password array
std::string passwordArray;
//Lowercare character array
std::string lower = { "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m",
"n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z" };
//Uppercase character array
std::string upper = { "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M",
"N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z" };
//Digits array
std::string digits = { "0", "1", "2", "3", "4", "5", "6", "7", "8", "9" };
private void setupCharArray()
{
if (ckhLower.Checked)
{
characterArray.AddRange(lower);
}
if (chkUpper.Checked)
{
characterArray.AddRange(upper);
}
if (chkDigits.Checked)
{
characterArray.AddRange(digits);
}
}
private void backgroundWorker1_DoWork(object sender, DoWorkEventArgs e)
{
brute();
}
so I try to compile this code using MinGW
g++ bruteforce.cpp -o bruteforce.exe
and I get these error messages
c:\Users\Lotty Playle\Documents>g++ bruteforce.cpp -o bruteforce.exe
bruteforce.cpp:7:66: error: in C++98 'lower' must be initialized by constructor,
not by '{...}'
bruteforce.cpp:7:66: error: could not convert '{"a", "b", "c", "d", "e", "f", "g
", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w
", "x", "y", "z"}' from '<brace-enclosed initializer list>' to 'std::string {aka
std::basic_string<char>}'
bruteforce.cpp:10:66: error: in C++98 'upper' must be initialized by constructor
, not by '{...}'
bruteforce.cpp:10:66: error: could not convert '{"A", "B", "C", "D", "E", "F", "
G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "
W", "X", "Y", "Z"}' from '<brace-enclosed initializer list>' to 'std::string {ak
a std::basic_string<char>}'
bruteforce.cpp:12:73: error: in C++98 'digits' must be initialized by constructo
r, not by '{...}'
bruteforce.cpp:12:73: error: could not convert '{"0", "1", "2", "3", "4", "5", "
6", "7", "8", "9"}' from '<brace-enclosed initializer list>' to 'std::string {ak
a std::basic_string<char>}'
bruteforce.cpp:14:1: error: expected unqualified-id before 'private'
If anyone knows what I'm doing wrong could they please show me.
L x
An array of strings should look like this: (with [])
std::string lower[] = { "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m",
"n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z" };
A std::string of characters would look like this:
std::string lower = "abcdefghijklmnopqrstuvwxyz";
Note that using a bunch of std::strings to represent characters is extremely inefficient. You should use a char array, or just work with ascii arithmetic.
I am trying to sort the below map( Clojure) on the basis of "col_nm" field, but unable to do so.
{:Mawb {:user_val "3", :col_nm "1"},
:HawbDate {:user_val "", :col_nm "3"},
:EtlBatchID {:user_val "1", :col_nm "2"}}
The output should be:
{:Mawb {:user_val "3", :col_nm "1"},
:EtlBatchID {:user_val "1", :col_nm "2"},
:HawbDate {:user_val "", :col_nm "3"} }
Can anyone help me, thanks in advance.
Try this one:
(def m {:Mawb {:user_val "3", :col_nm "1"},
:HawbDate {:user_val "", :col_nm "3"},
:EtlBatchID {:user_val "1", :col_nm "2"}})
(sort-by (comp :col_nm second) m)
=> ([:Mawb {:user_val "3", :col_nm "1"}]
[:EtlBatchID {:user_val "1", :col_nm "2"}]
[:HawbDate {:user_val "", :col_nm "3"}])