Is it valid to set both page level setTargeting and slot level setTargeting in DFP gpt tag? - google-ad-manager

I want to use both Page level setTargeting and adSlot level Targeting in DFP gpt adtag.
Example:-
googletag.cmd.push(function() {
googletag.defineSlot('/xxxxxxxx/xxxx.co.in/technology', [[728,90],[970,90],[970,250]], 'div-gpt-ad-1')
.addService(googletag.pubads())
.setTargeting('test',['refresh']);
googletag.pubads().enableSingleRequest(),
googletag.pubads().collapseEmptyDivs(),
googletag.pubads().enableAsyncRendering(),
googletag.enableServices();
googletag.pubads().setTargeting('interests', 'sports');
});
will both the target go to apply or only one?

Short answer: Yes. You can combine slot-level and page-level targeting.

Related

angular-calendar - how to programmatically navigate

I am using https://github.com/mattlewis92/angular-calendar and I would like to navigate programmatically (Next, Previous, Today).
I know the directives (e.g. mwlCalendarPreviousView, mwlCalendarNextView) but I would like to navigate via an API call.
How can I achieve this?
TIA
Changing viewDate "date", example with Moment and MonthView:
// Next
this.viewDate = moment(this.viewDate ).add(1, 'months').toDate();
// Previous
this.viewDate = moment(this.viewDate ).add(-1, 'months').toDate();

Using ApplescriptObjC to convert color spaces of an image using NSColorSpace and iccProfileData

I have some code that will change an images colorspace from RGB to a GenericCMYK profile. I would like to be able to use an ICC Profile to convert the image to a CMYK colorspace. There is a way to do this in Photoshop, but the process takes too much of a users time when you are dealing with 100's of images, I am trying to create an AppleScript droplet that will do this for them.
I have already looked at the page for NSColorspace and there looks like there is a way to do this. I just have no idea how to convert this Objective-C into ApplescriptObjC. Here are the two references to the ICC Profiles in NSColorSpace:
init?(iccProfileData: Data)
Initializes and returns an NSColorSpace object given an ICC profile.
var iccProfileData: Data?
The ICC profile data from which the receiver was created.
Here is the code I have thanks to Shane at Macscripter.net:
set theImage to (current application's NSImage's alloc()'s initWithContentsOfURL:theInput)
set imageRep to (theImage's representations()'s objectAtIndex:0)
set targetSpace to current application's NSColorSpace's genericCMYKColorSpace()
set bitmapRep to (imageRep's bitmapImageRepByConvertingToColorSpace:targetSpace renderingIntent:(current application's NSColorRenderingIntentPerceptual))
set theProps to (current application's NSDictionary's dictionaryWithObjects:{1.0, true} forKeys:{current application's NSImageCompressionFactor, current application's NSImageProgressive})
set jpegData to (bitmapRep's representationUsingType:(current application's NSJPEGFileType) |properties|:theProps)
set colorSpace to bitmapRep's colorSpaceName() as text
(jpegData's writeToURL:theOutput atomically:true)
I just need to figure out how to include the ICC Profile as a part of the CMYK conversion process that happens I believe on this line of code:
set targetSpace to current application's NSColorSpace's genericCMYKColorSpace()
Can anyone give me some guidance on this?
Thanks!
You are looking at the NSColorSpace documentation in Swift. AppleScriptObjC is an Objective-C bridge, so it makes more sense viewing the documentation in Objective-C (the language can be set in the page header), where your snippet becomes
set targetSpace to current application's NSColorSpace's alloc's initWithICCProfileData:iccData
where iccData is the ICC profile data you are going to use.

Setting cmask / inv in perf_event

I'm trying to manually use performance measurements with linux/perf_event.h. As a reference: I do it similarly as described in ozlabs.org/~anton/junkcode/perf_events_example1.c
I would like to read some specific performance counter event, for example I would like to have the event
UOPS_ISSUED.ANY with Cmask=1 and Inv = 1 (count stalled cycles).
So then I have attr.type=PERF_TYPE_RAW and attr.config=0x010E. But where can I then specify Cmask and Inv?
Cmask and Inv are architecture specific attributes. I assume you are using x86. Then the attributes are in the structure x86_pmu_config in arch/x86/kernel/cpu/perf_event.h
You can use the macro X86_CONFIG, defined in the same file, to create the adequate value for attr.config . For example:
X86_CONFIG(.event=0xb1, .umask=0x3f, .inv=1, .cmask=1);
as described in this link.

Is it possible to get $_COOKIE with TypoScript?

In TypoScript exists the possibility to get the environment variable HTTP_COOKIE_VARS (which is deprecated):
10 = TEXT
10.data = global : HTTP_COOKIE_VARS | some_cookie
I got this from the documentation.
But on my server (PHP 5.3) this variable is empty! I suppose this is because this environment variable is deprecated. Now I am running out of options, without using an extension, user function or user condition.
Maybe you have an idea! Thanks in advance.
this should do the job (at least with TYPO3 4.5 and PHP 5.3.8):
10 = TEXT
10.data = global:_COOKIE|some_cookie
10.wrap = <h2>Cookie: |</h2>
Unfortunately, there is no built-in functionality for the $_COOKIE variable.
You can however write a hook which implements the tslib_content_getDataHook interface and register it via
$TYPO3_CONF_VARS['SC_OPTIONS']['tslib/class.tslib_content.php']['getData'][] = 'path/to/your/class.user_cookiehook.php';
[request.getCookieParams()['some_cookie'] == 'some_value']
Your Code
[end]

Create registry entry to associate file extension with application in C++

I would like to know the cleanest way of registering a file extension with my C++ application so that when a data file associated with my program is double clicked, the application is opened and the filename is passed as a parameter to the application.
Currently, I do this through my wix installer, but there are some instances where the application will not be installed on ths user's computer, so I also need the option of creating the registry key through the application.
Additionally, will this also mean that if the application is removed, unused entries in the registry will be left lying around?
Your basic overview of the process is found in this MSDN article. The key parts are at the bottom of the list:
Register the ProgID
A ProgID (essentially, the file type registry key) is what contains your important file type properties, such as icon, description, and context menu items including applications used when the file is double clicked. Many extensions may have the same file type. That mapping is done in the next step:
Register the file name extension for the file type
Here, you set a registry value for your extension, setting that extension's file type to the ProgID you created in the previous step.
The minimum amount of work required to get a file to open with your application is setting/creating two registry keys. In this example .reg file, I create a file type (blergcorp.blergapp.v1) and associate a file extension (.blerg) with it.
Windows Registry Editor Version 5.00
[HKEY_CURRENT_USER\Software\Classes\blergcorp.blergapp.v1\shell\open\command]
#="c:\path\to\app.exe \"%1\""
[HKEY_CURRENT_USER\Software\Classes\.blerg]
#="blergcorp.blergapp.v1"
Now, you probably want to accomplish this programmatically. To be absolutely kosher, you could check for the existence of these keys, and change your program behavior accordingly, especially if you're assuming control of some common file extension. However, the goal can be accomplished by setting those two keys using the SetValue function.
I'm not positive of the exact C++ syntax, but in C# the syntax looks something like this:
Registry.SetValue(#"HKEY_CURRENT_USER\Software\Classes\blergcorp.blergapp.v1\shell\open\command", null, #"c:\path\to\app.exe \"%1\"");
Registry.SetValue(#"HKEY_CURRENT_USER\Software\Classes\.blerg", null, "blergcorp.blergapp.v1");
Of course you could manually open each sub key, manually create the ProgID and extension subkey, and then set the key value, but a nice thing about the SetValue function is that if the keys or values don't exist, they will automatically be created. Very handy.
Now, a quick word about which hive to use. Many file association examples online, including ones on MSDN, show these keys being set in HKEY_CLASSES_ROOT. I don't recommend doing this. That hive is a merged, virtual view of HKEY_LOCAL_MACHINE\Software\Classes (the system defaults) and HKEY_CURRENT_USER\Software\Classes (the per-user settings), and writes to any subkey in the hive are redirected to the same key in HKEY_LOCAL_MACHINE\Software\Classes. Now, there's no direct problem doing this, but you may run into this issue: If you write to HKCR (redirected to HKLM), and the user has specified the same keys with different values in HKCU, the HKCU values will take precedence. Therefore, your writes will succeed but you won't see any change, because HKEY_CURRENT_USER settings take precedence over HKEY_LOCAL_MACHINE settings.
Therefore, you should take this into consideration when designing your application. Now, on the flip side, you can write to only HKEY_CURRENT_USER, as my examples here show. However, that file association setting will only be loaded for the current user, and if your application has been installed for all users, your application won't launch when that other user opens the file in Windows.
That should be a decent primer for what you want to do. For further reading I suggest
Best Practices for File Association
File Types and File Association, especially
How File Associations Work
And see also my similar answer to a similar question:
Associating file extensions with a program
This is a two step process:
1. Define a program that would take care of extension: (unless you want to use existing one)
1.1 create a key in "HKCU\\Software\\Classes\\" for example
"Software\\Classes\\YourProgramName.file.ext"
1.2 create subkey "Software\\Classes\\YourProgramName.file.ext\\DefaultIcon"
1.2.1 set default value ("") to your application full path to get
icon from resources
1.3 create a subkey "Software\\Classes\\YourProgramName.file.ext\\Shell\\OperationName\\Command"
OperationName = for example Open, Print or Other
1.3.1 set default value ("") to your application full path +optional runtime params (filename)
2.Associate file extension with program.
2.1 create a key HKCU\\Software\\Classes\\.ext - here goes your extension
2.2 set default value to the program definition key
("YourProgramName.file.ext")
Below is part of the program written in c# which associate file extension. It is not c++ but i think it is simple enought to explain itself and AFAIK it is verv simmilar if not identical to the code in c++
1.
RegistryKey keyPFCTExt0 = Registry.CurrentUser.OpenSubKey("Software\\Classes\\PFCT.file.enc", true);
if (keyPFCTExt0 == null)
{
keyPFCTExt0 = Registry.CurrentUser.CreateSubKey("Software\\Classes\\PFCT.file.enc");
keyPFCTExt0.CreateSubKey("DefaultIcon");
RegistryKey keyPFCTExt0ext = Registry.CurrentUser.OpenSubKey("Software\\Classes\\PFCT.file.enc\\DefaultIcon", true);
keyPFCTExt0ext.SetValue("", Application.ExecutablePath +",0");
keyPFCTExt0ext.Close();
keyPFCTExt0.CreateSubKey("Shell\\PFCT_Decrypt\\Command");
}
keyPFCTExt0.SetValue("", "PFCT.file.enc");
keyPFCTExt0.Close();
2.
RegistryKey keyPFCTExt1 = Registry.CurrentUser.OpenSubKey("Software\\Classes\\PFCT.file.enc\\Shell\\PFCT_Decrypt\\Command", true);
if (keyPFCTExt1 == null)
keyPFCTExt1 = Registry.CurrentUser.CreateSubKey("Software\\Classes\\PFCT.file.enc\\Shell\\PFCT_Decrypt\\Command");
keyPFCTExt1.SetValue("", Application.ExecutablePath + " !d %1"); //!d %1 are optional params, here !d string and full file path
keyPFCTExt1.Close();
I don't know why people keep saying that HKEY_CURRENT_USER\Software\Classes\<.ext>'s Default value (which will redirect you into another (software-created) class.
It does work, but it will be overridden by
HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\<.ext>\UserChoice
And I believe Microsoft recommends the second practice- because it's what the built-in "open with" is doing. The value of Progid" key is equal to default value of HKEY_CURRENT_USER\Software\Classes\<.ext> in this case.
I found the following while trying to manipulate associations using C#:
hkcu\software\microsoft\windows\currentVersion\explorer\fileexts.reg\userchoice -> for user specific settings. The values in the openWithProgIds
key point to the keys in the hkcr.
hkcr\xfile\shell\open\muiVerb value or hkcr\xfile\shell\open\command\default value -> affects open handler. This is the value that contains the path to a program.
hkcr\ .x -> affects context menu (new x) among other things related to the menus.
I don't know the C++ code, but given these info you must be able to manipulate the registry using the registry API.