Dota 2 Plugin (Values end up being assigned to all units) - javascript

Here is my Code
http://pastebin.com/RXUNxcct
What i would like to know is, how i can use my list to only affect the listed units?

If I understand correctly, here is some pseudocode:
I would first put both sets into two lists or arrays. One array/list for the total heroes, and one for the "to be buffed" heroes. I would then check each element of the total heroes list, and see if the current hero that you are working with (through a for-loop, perhaps?) is in the "to be buffed" list. If so, buff it.
Let me know if this helps you.

Related

Tracking Conversion Value on GTM without Data Layer on Ecommerce

how are you doing? Hope you're fine.
My name is Thiago. I'm a brazilian enterpreneur that runs a Marketing Agency.
It's been a very long while since I'm in need of help with a very specific matter.
I'll try to explain it here the clearest and easiest as possible.
I'd like to ask sorry for any bad english in advanced. =D
So, the thing is, conversion is a big game changing, whatever it's on Facebook or Google.
Setting up conversions it self isn't that hard, when you have an ecommerce platform that comes with a data layer already setup.
Most of my clients doesn't have an ecommerce with a Data Layer.
I was following the Measure School youtube tutorial to install Active Campaign Tracking, and by doing this I add a template in my Google Tag Manager that almost soved the problem, but the code is note quite working.
And that's where I need help. =D (sorry for the long story kkk)
The Custom Variable "Purchase Function" code is this:
function() {
var price = str.split("Adicionar R$ ", "{{Click Text}}",[1])
return price
}
It's returning unedefined.
I'll add some prints showing the whole process with the most details as possible.
0 - Adding Product to Cart
1 - Product Price in Button Click Text
2 - Purchase Price Not Working
3 - GTM Price Function
I really need help making this Custom Variable "Purchase Price" works.
Thanks a lot.
You are using the split function wrong (for starters, you apply it to a variable str which is undefined. Also, wrong number of parameters and wrong parameters).
Look at the documentation for split here: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/split
Your function should look something like this:
function() {
// splits Click Text by whitespace an returns an array
var parts = {{Click Text}}.split(" ");
// pop removes the last part from the array and returns it
// numerical index might not work if there is more than one whitespace in the click text
price = parts.pop();
return price;
}

Firebase: best way to order and filter multiple childs

So as we know firebase won't let order by multiple childs. I'm looking for a solution to filter my data so at the end I will be able to limit it to 1 only. So if I won't to get the lowest price it will be something like that:
ref.orderByChild("price").limitToFirst(1).on...
The problem is that I also need to filter it by dates (timestamp)
so for that only I will do:
.orderByChild("timestamp").startAt(startValue).endAt(endValue).on...
So for now that's my query and then I'm running on all results and checking for that one row that has the lowest price. my Data is pretty big and contains around 100,000 rows. I can changed it however I want.
for the first query that gets the lowest price but all timestamps causes that the returned row might be the lowest price but not in my dates range. However this query takes ONLY 2 seconds compared to the second one which takes 20 including my code to get the lowest price.
So, what are your suggestions on how to do it best? I know I can make another index which contains the timestamp and the price but those are different data values and it makes it impossible.
full data structure:
country
store
item
price,
timestamp
just to make it even more clear, I have 2 inner loops which runs over all countries and then over all stores. so the real query is something like that:
ref.child(country[i]).child(store[j]).orderByChild("timestamp").startAt(startValue).endAt(endValue).on...
Thanks!

Performance of an ordered list in Firebase

If I want to maintain an ordered list in Firebase, it seems like the best way to do it is to manually assign a priority to each item in my list. That means if I insert or remove an item from the list, I have to update the priorities of all the items following it. For an item at the beginning of the list, this means updating every item in the list. Is there a better performing data structure or algorithm to use in this case?
You can create an ordered list by setting the priority of elements appropriately. Items in a list are ordered lexigraphically by priority, or if the priority can be parsed to a number, by numeric value.
If you want to insert items into the middle of an existing list, modifying the priorities of the existing items would work, but would be horribly inefficient. A better approach is just to pick a priority between the two items where you want to insert the value and set that priority for the new item.
For example, if you had element 1 with priority "a", and element 2 with priority "b", you could insert element 3 between the two with priority "aa" (or "aq", "az", etc).
In our experience, most times when you create an ordered list, you don't necessarily know the position in the list you want to insert the item beforehand. For example, if you're creating a Leader Board for a game, you don't know in advance that you want to place a new score 3rd in the list, rather you know you want to insert it at whatever position score 10000 gets you (which might happen to be third). In this case, simply setting the priority to the score will accomplish this. See our Leader Board example here:
https://www.firebase.com/tutorial/#example-leaderboard
The Ruby gem ranked_model has an interesting approach to this problem. It uses a position integer like many other "acts as list" implementations, but it doesn't rely on re-writing all the integers on each position move. Instead, it spaces the integers widely apart, and so each update may only affect one or two rows. Might be worth looking through the readme and code to see if this approach could fit here.

How to Parameterize the values in ajax TruClient scripts

This is the scenario -
There is a search criterion giving me 100 search results (100 Links).
I want the virtual users to click on any of those links ramdomly.
Can you please help me how manage this situation?
Perhaps this is useful to you? http://h30499.www3.hp.com/t5/LoadRunner-Support-Forum/Ajax-True-Client-parameterization-problem/td-p/5607543#.UDxLONYaNN9
Your path is through correlating the links into an array, picking a random offset into the array and then a web_url to head to the link in question....
Have a look at the help for the functions
web_reg_save_param()
web_reg_save_param_ex()
and especially the "Ord=All"/"Ordinal=All" parts in the help.
Then when you have captured the relevant data into an array you can use
lr_paramarr_random("TheArrayName");
to get a random value from the array.
The answer depends on whether or not every listbox element is a valid selection. If the first element of the listbox is instructional ("Please select...", etc.), you need a snippet of code:
Option 1: (when a “Please select” is present)
In the step's 'Arguments' section, Set Ordinal to:
var objectIndex = Math.floor((object.length-1)*Math.random())+2;
objectIndex;
Option 2: (when a “Please select” is not present)
In the step's 'Arguments' section, Set Ordinal to “0”.
Generate a random number in runtime and put that variable in the Ord= parameter. E.g.
a = Rand(1,100)
lr_save_param("{myrandval}",a);
Web_custome_request("",
"",
"",
"Ord={myrandval}",
LAST);

jQuery "Autocomplete" plugin is messing up the order of my data

I'm using Jorn Zaefferer's Autocomplete plugin on a couple of different pages. In both instances, the order of displayed strings is a little bit messed up.
Example 1: array of strings: basically they are in alphabetical order except for General Knowledge which has been pushed to the top:
General Knowledge,Art and Design,Business Studies,Citizenship,Design and Technology,English,Geography,History,ICT,Mathematics,MFL French,MFL German,MFL Spanish,Music,Physical Education,PSHE,Religious Education,Science,Something Else
Displayed strings:
General Knowledge,Geography,Art and Design,Business Studies,Citizenship,Design and Technology,English,History,ICT,Mathematics,MFL French,MFL German,MFL Spanish,Music,Physical Education,PSHE,Religious Education,Science,Something Else
Note that Geography has been pushed to be the second item, after General Knowledge. The rest are all fine.
Example 2: array of strings: as above but with Cross-curricular instead of General Knowledge.
Cross-curricular,Art and Design,Business Studies,Citizenship,Design and Technology,English,Geography,History,ICT,Mathematics,MFL French,MFL German,MFL Spanish,Music,Physical Education,PSHE,Religious Education,Science,Something Else
Displayed strings:
Cross-curricular,Citizenship,Art and Design,Business Studies,Design and Technology,English,Geography,History,ICT,Mathematics,MFL French,MFL German,MFL Spanish,Music,Physical Education,PSHE,Religious Education,Science,Something Else
Here, Citizenship has been pushed to the number 2 position.
I've experimented a little, and it seems like there's a bug saying "put things that start with the same letter as the first item after the first item and leave the rest alone". Kind of mystifying. I've tried a bit of debugging by triggering alerts inside the autocomplete plugin code but everywhere i can see, it's using the correct order. it seems to be just when its rendered out that it goes wrong.
Any ideas anyone?
max
EDIT - reply to Clint
Thanks for pointing me at the relevant bit of code btw. To make diagnosis simpler i changed the array of values to ["carrot", "apple", "cherry"], which autocomplete re-orders to ["carrot", "cherry", "apple"].
Here's the array that it generates for stMatchSets:
stMatchSets = ({'':[#1={value:"carrot", data:["carrot"], result:"carrot"}, #3={value:"apple", data:["apple"], result:"apple"}, #2={value:"cherry", data:["cherry"], result:"cherry"}], c:[#1#, #2#], a:[#3#]})
So, it's collecting the first letters together into a map, which makes sense as a first-pass matching strategy. What i'd like it to do though, is to use the given array of values, rather than the map, when it comes to populating the displayed list. I can't quite get my head around what's going on with the cache inside the guts of the code (i'm not very experienced with javascript).
SOLVED - i fixed this by hacking the javascript in the plugin.
On line 549 (or 565) we return a variable csub which is an object holding the matching data. Before it's returned, I reorder this so that the order matches the original array of value we were given, ie that we used to build the index in the first place, which i had put into another variable:
csub = csub.sort(function(a,b){ return originalData.indexOf(a.value) > originalData.indexOf(b.value); })
hacky but it works. Personally i think that this behaviour (possibly coded more cleanly) should be the default behaviour of the plugin: ie, the order of results should match the original passed array of possible values. That way the user can sort their array alphabetically if they want (which is trivial) to get the results in alphabetical order, or they can preserve their own 'custom' order.
What I did instead of your solution was to add
if (!q && data[q]){return data[q];}
just above
var csub = [];
found in line ~535.
What this does, if I understood correctly, is to fetch the cached data for when the input is empty, specified in line ~472: stMatchSets[""] = []. Assuming that the cached data for when the input is empty are the first data you provided to begin with, then its all good.
I'm not sure about this autocomplete plugin in particular, but are you sure it's not just trying to give you the best match possible? My autocomplete plugin does some heuristics and does reordering of that nature.
Which brings me to my other answer: there are a million jQuery autocomplete plugins out there. If this one doesn't satisfy you, I'm sure there is another that will.
edit:
In fact, I'm completely certain that's what it's doing. Take a look around line 474:
// loop through the array and create a lookup structure
for ( var i = 0, ol = options.data.length; i < ol; i++ ) {
/* some code */
var firstChar = value.charAt(0).toLowerCase();
// if no lookup array for this character exists, look it up now
if( !stMatchSets[firstChar] )
and so on. So, it's a feature.

Categories