Is it possible to create dummy bidders to test header bidding? - prebid.js

I am a developer curious about header bidding. I don't have demand partners. But I want to test the solution I build. Is it possible to create dummy bidders? Is there any open source code that can mimic a bidder?

You can use appnexus's dummy bidder used in their examples on prebid.org.
It's also available on jsfiddle
Here's the complete configuration:
var adUnits = [{
code: 'div-gpt-ad-1460505748561-0',
sizes: [[300, 250], [300,600]],
bids: [{
bidder: 'appnexus',
params: {
placementId: '10433394'
}
}]
},{
code: 'div-gpt-ad-1460505661639-0',
sizes: [[728, 90], [970, 90]],
bids: [{
bidder: 'appnexus',
params: {
placementId: '10433394'
}
}]
}];
Of course you could also take some else's live configuration, but the owners won't be happy to see your dummy bids

Related

GROQ: Query one-to-many relationship with parameter as query input

I have a blog built in NextJS, backed by Sanity. I want to start tagging posts with tags/categories.
Each post may have many categories.
Category is a reference on post:
defineField({
name: 'category',
title: 'Category',
type: 'array',
of: [
{
type: 'reference',
to: [
{
type: 'category',
},
],
},
],
}),
This is my GROQ query:
*[_type == "post" && count((category[]->slug.current)[# in ['dogs']]) > 0] {
_id,
title,
date,
excerpt,
coverImage,
"slug": slug.current,
"author": author->{name, picture},
"categories": category[]-> {name, slug}
}
The above works, when it is hardcoded, but swapping out 'dogs' with $slug for example will cause the query to fail. (Where $slug is a param provided)
*[_type == "post" && count((category[]->slug.current)[# in [$slug]]) > 0]
{
$slug: 'travel'
}
How do I make the above dynamic?
Returns all documents that are storefronts // within 10 miles of the user-provided currentLocation parameter ; // For a given $currentLocation geopoint
I can't believe it. Rookie mistake. I needed to pay more attention in the Sanity IDE. (To be fair there was a UI bug that hid the actual issue)
The param should not contain the $. E.g the following works in the GROQ IDE.
{
slug: 'travel'
}

Is there a way to run the supplied prisma query as a raw sql query?

I have been stuck with this and similar dilemmas for a while now and can't seem to find an acceptable solution. Prisma currently doesn't allow for upsertMany in it's queries, or in my case a nested upsertMany. I have found some accepted solutions and the most popular one is using $transaction from prisma to write a loop of upserts which doesn't work for me as each query contains up to 200 items to upsert (currently testing 100 items takes roughly 10sec to run so it really isn't an acceptable solution). Prisma offers the ability to use $queryRaw to use a raw SQL query which may offer a more acceptable solution. I've supplied the code to their currently accepted solution as well as the query (that isn't currently possible) that I'm hoping someone could help me turn into a raw sql query or a better solution.
Their accepted solution:
prisma.$transaction(data.map((d) =>
prisma.MODEL.upsert({
where:{
id: d.id
},
update:{
foo:d.foo,
},
create:{
foo: d.foo,
bar: d.bar
},
}),
),
);
How I would need to implement it as I would like to create one MODEL with a related array of MODELS and another array of related MODELS:
let transactionOne = prisma.$transaction(
arrayOne.map((d)=>
prisma.MODEL.upsert({
where:{
id: d.id,
},
update:{
foo: d.foo,
},
create:{
foo: d.foo,
bar: d.bar,
},
}),
)
);
let transactionTwo = prisma.$transaction(
arrayTwo.map((d)=>
prisma.MODEL.upsert({
where:{
id: d.id,
},
update:{
foo: d.foo,
},
create:{
foo: d.foo,
bar: d.bar,
},
}),
)
);
let data = await prisma.MODEL.create({
data:{
foo: foo,
bar: bar,
example:{
connect: transactionOne.map((a)=>({id: a.id})),
},
exampleTwo:{
connect: transactionTwo.map((b)=>({id: b.id})),
},
},
});
My example above like mentioned before takes just over 10 seconds with 100 items and may possibly require 200 items so 20 seconds per call. Is there an easier way to make this faster or like I said a way to create a raw SQL query with the same results?
Thanks for any help!

How to display RadDataForm Valueproviders with key value pair

I resolve most of my problem only few left out of which this one is preventing me to submit the form. I am using Nativescript + vue and without Typescript. how to display the Valueproviders with array list? Here is the code
https://play.nativescript.org/?template=play-vue&id=2oWObE
There was the problem with your data type. As per the documentation Array should have key and label properties. But still if you want id and name then you should try like below.
'valuesProvider': {
key: 'id',
label: 'name',
items: [
{ id: 1121, name: 'Shanghai' },
{ id: 3651, name: 'Lagos' },
{ id: 5213, name: 'Moscow' },
{ id: 6214, name: 'São Paulo' },
{ id: 6985, name: 'Sydney' }
]
};
https://docs.nativescript.org/vuejs/ns-ui/DataForm/dataform-editors-providers
Anyway, I tried that and that was not working for me either then searched for it and relaised that there is an open feature request to support the valuesProvider for picker from JSON metadata. You can vote to support the same feature.
https://github.com/NativeScript/nativescript-ui-feedback/issues/369
Solution
Just get you cityList out of vue data and map your data
https://play.nativescript.org/?template=play-vue&id=2oWObE&v=6
more detailed version with groups
https://play.nativescript.org/?template=play-vue&id=rqK7wO&v=3

Trying to create a yadcf filter for a column with images

I need to create a filter on a tipical columns created with images: each field is an image with this format:
<img src='http://lab.onclud.com/psm/blackcircle.png' class='notasg'>
I've created a fiddle example here: fiddle
An explication:
there are only 2 diferents status: [assigned/not assigned] although there are 4 diferents images (black, red, yellow and green).
Only black image correspond to not assigned status. The others three ones (red, yellow and green) correspond to assigned status.
As you could see, I've tried to differentiate those status by class HTML tag in img elements (notasg/asgn).
Thanks in advance.
PD:
I'm getting data from a json, so I can't put:
<td data-search="notassigned">
directly on HTML code. As a solution, I've used createdCell (columnDefs option) as you could see on the next updated to create data-search attribute on td element fiddle.
In this one, as you could test, your previously created filter doesn't work. I've tried some solutions, but no one has worked.
Please help me again on this one. Thanks in advance.
You can make use of the datatables HTML5 data-* attributes, and then tell yadcf to rely on this dt feature with the use of html5_data
So your td will look something like
<td data-search="assigned"><img src='http://lab.onclud.com/psm/redcircle.png' class='asgn'></td>
and yadcf init will look like
var oTable = $('#example').DataTable();
yadcf.init(oTable, [
{
column_number: 0,
html5_data: 'data-search',
filter_match_mode: 'exact',
data: [{
value: 'assigned',
label: 'Assigned'
}, {
value: 'notassigned',
label: 'Not assigned'
}]
}]);
Notice that I used filter_match_mode: 'exact', because I used data-search="notassigned" and data-search="assigned", and since the assigned word included inside notassigned I had to tell yadcf to perform an exact search, this can be avoided if you will use unique search term in your data-search= attribute,
See working jsfiddle
Another solution as introduced by kthorngren from datatables forum is to use the following dt init code
var oTable = $('#example').DataTable({
columnDefs: [{
targets: 0,
render: function(data, type, full, meta) {
if (type === 'filter') {
return full[0].search('asgn') >=1 ? "assigned" : full[0].search('notasg') >= 1 ? "notassigned" : data
} else {
return data
}
}
}],
});
and yadcf init (removed html5_data)
yadcf.init(oTable, [
{
column_number: 0,
filter_match_mode: 'exact',
data: [{
value: 'assigned',
label: 'Assigned'
}, {
value: 'notassigned',
label: 'Not assigned'
}]
}
]);
third option - look here

Amazon Product API not respecting ResponseGroups

I'm trying to get all products priced between 12.50 and 11.50. I'm using Node-APAC for my requests to the Amazon Product API. Here's my code for a request:
exports.search = function(req, res){
OperationHelper = require('apac').OperationHelper;
var opHelper = new OperationHelper({
awsId: process.env.AMZ_ACCESS_KEY_CODE,
awsSecret: process.env.AMZ_SECRET_ACCESS_KEY,
assocId: process.env.AMZ_ASSOCIATE_ID
});
opHelper.execute('ItemSearch', {
'SearchIndex': 'All',
'Keywords': ' ',
'MaximumPrice': 12.50,
'MinimumPrice': 11.50,
'ResponseGroup': 'Medium'
}, function(error, results) {
res.send(results);
});
};
The response does not limit the results to a Medium ResponseGroup. You can see some of the full response here (It's huge). Here's the structure:
{
ItemSearchResponse: {
$: {...},
OperationRequest: [...],
Items: [
{
Request: [...],
TotalResults: [...],
TotalPages: [...],
MoreSearchResultsUrl: [...],
Item: [
{
ASIN: [...],
DetailPageURL: [...],
ItemLinks: [...],
SmallImage: [...],
MediumImage: [...],
LargeImage: [...],
ImageSets: [...],
ItemAttributes: [...],
OfferSummary: [...]
},
{...},
{...},
{...},
{...}
]
}
]
}
}
It is not returning what the documentation says should be included in the Medium ResponseGroup. It's returning a bunch of other stuff which is unnecessary. Any help is appreciated!
Note: It's also returning products that don't fit the price range. These problems may be related. Any tips there would be helpful.
As per the Amazon Product Advertising doc for the ItemSearch operation, MinimumPrice (resp. MaximumPrice) "specifies the minimum (resp. maximum) price of the items to return. Prices are in terms of the lowest currency denomination, for example, pennies, for example, 3241 represents $32.41.".
So if you change the values for the following two parameters:
'MaximumPrice': 12.50,
'MinimumPrice': 11.50,
with
'MaximumPrice': 1250,
'MinimumPrice': 1150,
the price filtering should work. As for the ResponseGroup, I would suggest you to pass "Small,OfferSummary" (as per my answer to your question "How to specify what Amazon Product API returns").