I use the following command to launch a JS script: C:\Windows\System32\cscript.exe /nologo //E:{16d51579-a30b-4c8b-a276-0ff4dc41e755} in order to use the latest Chakra engine.
In my script, the command WScript.Echo( ScriptEngineMajorVersion() + "." + ScriptEngineMinorVersion() + "." + ScriptEngineBuildVersion()); outputs 11.0.19326.
I know this increases performance, and I thought I'd be also able to use the latest XMLHttpRequest instead of the good old Microsoft.XMLHTTP (I need responseURL) but it looks like I am not.
Is there a solution?
My guess is, the way you're loading the Chakra engine it's loading an invisible IE instance. But according to this MDN compatibility table there is no version of Internet Explorer that supports responseURL.
edit: don't use JScript
Through much testing, attempting to load Edge's Chakra engine into Windows Script Host, I can land on no permutation that works. Creating an htmlfile COM object and forcing compatibility using x-ua-compatible, attempting the same with an HTA application (both natively and again with an htmlfile COM object), attempting to create a MSXML2.ServerXMLHTTP.6.0 object, no Windows Script Host hack I can conceive will expose the .responseURL property of an XMLHttpRequest object.
Best bet would be to pick a different language. In PowerShell you could do something like this:
$req = [Net.WebRequest]::Create("https://youtu.be/")
$resp = $req.GetResponse()
$resp.ResponseURI.AbsoluteURI
... which would print
https://www.youtube.com/?feature=youtu.be
And if you need the equivalent of .responseText, just add the following:
$reader = new-object System.IO.StreamReader $resp.GetResponseStream()
$responseText = $reader.ReadToEnd()
If you want to parse $responseText using DOM methods...
$htmlfile = new-object -COM htmlfile
$htmlfile.IHTMLDocument2_writeln($responseText)
$buttons = $htmlfile.getElementsByTagName("button")
You can see the original revision of this answer for an example of what doesn't work.
Related
I have defined one global variable in a Pre-request Script.
I want to compare this global variable with variable present in the response.
As the warning message says, you're running a very old version of Postman and it's probably the chrome extension.
This is now several major versions behind and the pm.* functionality is not included in that old version of the chrome extension.
Download the native application and start using the newest version of Postman. By not doing this, you're missing out on so many new features.
As #Danny mentioned, it is recommended to update to the latest version.
Now to your question, if you want to compare the global variable with workkard_number present in response, you need to first parse the response and get the workkard_number in it, which you can then compare with your global variable. You could try something like this in your test script:
var jsonData = JSON.parse(responseBody);
var responseWorkkardNumber = jsonData.wokkard_number;
You can retreive the workkard_number in the response like this(assuming that your response is a json with "workkard_number" as a key in it. Then you can compare it as follows:
tests["workkard_numbers are equal"] = responseWorkkardNumber === globals.workkard_number;
or
tests["workkard_numbers are equal"] = responseWorkkardNumber === pm.globals.get("workkard_number");
Also note - "Warning - Environment and global variables will always be stored as strings. If you're storing objects/arrays, be sure to JSON.stringify() them before storing, and JSON.parse() them while retrieving." - https://www.getpostman.com/docs/v6/postman/environments_and_globals/manage_environments
I've searched much time about IntelliJ IDEA 12 and the xdebug.file_link_format configuration value.
I found nothing which works...
Using protocols like "idea", "intellij", "txmt", or other protocols doesn't work.
I found nothing about a plugin which register the IntelliJ protocol...
Is it possible to use the xdebug file links with IntelliJ IDEA or PhpStorm?
Yes and No.
No -- there is no proper built-in support for this. Watch this ticket for details: http://youtrack.jetbrains.com/issue/IDEA-65879
Yes -- you may find some workaround, at very least the aforementioned ticket has recipes for Mac OS (using AppleScript) or via Remote Call etc.
Update: as of PhpStorm 8 you may use:
xdebug.file_link_format = "phpstorm://open?file=%f&line=%l"
Not out of the box, but it is possible to get the links to work. I have this working with Windows 7, Firefox and PhpStorm 10 - in this example, I'm using the protocol phpstorm://, but this will work regardless of the name.
create a custom protocol handler: Any executable will do, here I have modified a WScript from https://pla.nette.org/en/how-open-files-in-ide-from-debugger . Save as run-editor.js :
// note: edit the path, with backslashes escaped
var editor = '"c:\\Program Files (x86)\\JetBrains\\PhpStorm 143.434\\bin\\PhpStorm.exe" nosplash --line %line% "%file%"';
var url = WScript.Arguments(0);
var match = /^phpstorm:\/\/open\/\?file=(.+)&line=(\d+)$/.exec(url);
if (match) {
var file = decodeURIComponent(match[1]).replace(/\+/g, ' ');
var command = editor.replace(/%line%/g, match[2]).replace(/%file%/g, file);
var shell = new ActiveXObject("WScript.Shell");
shell.Exec(command.replace(/\\/g, '\\\\'));
}
create the protocol in registry: create the following as editor.reg and import to Registry. Note that you again need to double-escape the path to the above file, and set it to wherever yours is saved:
REGEDIT4
[HKEY_CLASSES_ROOT\phpstorm]
#="URL:phpstorm Protocol"
"URL Protocol"=""
[HKEY_CLASSES_ROOT\phpstorm\shell\open\command]
#="wscript \"C:\\path\\to\\run-editor.js\" \"%1\""
enable the protocol in Firefox:
in about:config, create a "logical value" named
network.protocol-handler.expose.phpstorm and set it to false
open one such link in Firefox, e.g. phpstorm://open?file=somefile.html&line=123 - it should open in PhpStorm.
Per the comment from #gapple, this will make Xdebug link to the file/link in PhpStorm:
xdebug.file_link_format = "phpstorm://open?file=%f&line=%l"
I tested this in PhpStorm 10 on Mac and it works great.
You need to ad to the php.ini file in the [xdebug] section the following line:
xdebug.file_link_format = "phpstorm://open?file=%f&line=%l"
Then restart your web server (Apache for me on Mac)
The REST API is probably the best option now:
http://localhost:63342/api/file%f:%l
Wrapping in a javascript protocol and AJAX request allows the permission approval to be saved so you don't have to approve every time you click:
javascript: var r = new XMLHttpRequest; r.open('get', 'http://localhost:63342/api/file%f:%l');r.send()
API specs:
https://www.develar.org/idea-rest-api/
My issue seems to be related to permissions, but I am not sure how to solve it.
In the FeatureActivated event of one of my features I am calling out to a class I created for managing webconfig entries using the SPWebConfigModification class. The class reads up an xml file that I have added to the mapped Layouts folder in the project.
When I deploy the .wsp to my Sharepoint server everything gets installed fine, but when the FeatureActivated event runs it throws a 503 error when attempting to access the xml file.I am deploying the .wsp remotely using a powershell script and I have the powershell, the iisapp pool and the owstimer.exe all using the same domain administrative user.
I assumed the issue was that the FeatureActivated event code was being run within the scope of the OWSTIMER.exe so changed the logon of the service to a domain user that has administrative access to the server to see if that would solve the problem, but no matter what I am getting the 503.
I have traced out the URL to the xml file and pasted that into IE and I am getting back the xml without issue from the server once its copied.
Can anyone give me any idea where to look to figure out why the FeatureActivated event code can't seem to get to the XML file on the server?
Below is the code in my class that is being called from the FeatureActivated event to read the xml.
_contentservice = ContentService;
WriteTraceMessage("Getting SPFeatureProperties", TraceSeverity.Medium, 5);
_siteurl = properties.Definition.Properties["SiteUrl"].Value;
_foldername = properties.Definition.Properties["FolderName"].Value;
_filename = properties.Definition.Properties["FileName"].Value;
_sitepath = properties.Definition.Properties["SitePath"].Value;
WriteTraceMessage("Loading xml from layouts for configuration keys", TraceSeverity.Medium, 6);
xdoc = new XDocument();
XmlUrlResolver resolver = new XmlUrlResolver();
XmlReaderSettings settings = new XmlReaderSettings();
StringBuilder sb = new StringBuilder();
sb.Append(_siteurl).Append("_layouts").Append("/").Append(_foldername).Append("/").Append(_filename);
WriteTraceMessage("Path to XML: " + sb.ToString(), TraceSeverity.Medium, 7);
WriteTraceMessage("Credentials for xml reader: " + CredentialCache.DefaultCredentials.ToString(), TraceSeverity.Medium, 8);
resolver.Credentials = CredentialCache.DefaultCredentials; //this the issue might be here
settings.XmlResolver = resolver;
xdoc = XDocument.Load(XmlReader.Create(sb.ToString(), settings));
I finally punted on this issue because I discovered that while adding the -Force switch to the Enable-SPFeature command did use a different process to activate the feature when adding a solution it did not work when updating a solution. Ultimately I just changed my XDocument.Load() to use a TextReader instead of a URI. The xml file will always be available when deploying the WSP because it is part of the package so there is no reason to use IIS and a webrequest to load up the xml.
I need to embed some resource in a pure compiled dll written in php using phalanger.
These are txt files tha I set in visual studio as "Embedded Resource".
My problem is that I cannot use the Assembly class to get the resource using GetManifestResourceStream.
I tried code like this:
use System\Reflection\Assembly
$asm = Assembly::GetExecutingAssembly(); //this gives me mscorlib instead of my dll
$str = $asm->GetManifestResourceStream("name");
My question is: how do I get access to embedded resources in phalanger?
Many thanks
I'm not sure, why Assembly::GetExecutingAssembly() returns an incorrect value. Anyway to workaround the $asm value, use following code:
$MyType = CLRTypeOf MyProgram;
$asm = $MyType->Assembly;
Then you can access embedded resources as you posted
$asm->GetManifestResourceStream("TextFile1.txt");
or you can include standard resource file (.resx) into your project, and use \System\Resources\ResourceManager
$this->manager = new \System\Resources\ResourceManager("",$asm);
$this->manager->GetObject("String1",null);
Just note, currently there can be just one .resx within Phalanger project
This question is old, but the part of the Phalanger code (Php.Core.Emit.AddResourceFile() method) responsible for this hasn't changed since this was asked. I faced the same problem and solved it in (almost) non-hacky way. You have to provide alternative name (/res:/path/to/filename,alternative-name) for this to work though.
$asm = clr_typeof('self')->Assembly;
$resourceStream = $asm->GetManifestResourceStream("filename");
$reader = new \System\Resources\ResourceReader($resourceStream);
$type = $data = null;
$reader->GetResourceData("alternative-name", $type, $data);
// and still there are 4 excess bytes
// representing the length of the resource
$data = \substr($data, 4);
$stream = new IO\MemoryStream($data);
// after this $stream is usable as you would expect
Straightforward GetManifestResourceStream() (as suggested by Jakub) does not work because Phalanger does not use System.Reflection.Emit.ModuleBuilder.DefineManifestResource() (like I think it should when supplied with unrecognized file format). It uses ModuleBuilder.DefineResource() which returns ResourceWriter instead, that only really suited for .resources files. And this is what dictates the requirement to use ResourceReader when you need to read your resource.
Note: This answer applies to Phalanger master branch at the time of writing and prior versions since circa 2011. Noted because it looks like a bug (especially the need to use both original and alternative names).
I'm Stuck the following problem: How can I link a PDF Document to a Record in a Data Grid using Visual Studio LightSwitch 2011 and Visual Basic?
Any help would be awesome, thanks!
Here's the simplest way to do this: add a custom command to the Command Bar of the Data Grid Row for your Data Grid. In this example I'm calling the command Open PDF File. Then add this code to Execute code for the command:
partial void OpenPDFFile_Execute()
{
const string LOCAL_SERVER_PDF_DIR = #"\\MyServer\PDFs\";
const string WEB_SERVER_PDF_DIR = "http://myweb.server/PDFs/";
const string PDF_SUFFIX = ".pdf"; //assumes you do not include the extension in the db field value
if (AutomationFactory.IsAvailable)
{
//if the AutomationFactory is available, this is a desktop deployment
//use the shell to open a PDF file from the local network
dynamic shell = AutomationFactory.CreateObject("Shell.Application");
string filePath = LOCAL_SERVER_PDF_DIR + this.PDFFiles.SelectedItem.FileName + PDF_SUFFIX;
shell.ShellExecute(filePath);
}
else
{
//otherwise this must be a web deployment
//in order to make this work you must add a reference to System.Windows.Browser
//to the Client project of your LS solution
var uri = new Uri(WEB_SERVER_PDF_DIR + this.PDFFiles.SelectedItem.FileName + PDF_SUFFIX);
HtmlPage.Window.Navigate(uri, "_blank");
}
}
You will need to add the following imports to the top of your user code file to make this code compile:
using System.Runtime.InteropServices.Automation;
using System.Windows.Browser;
I should mention that you need a directory to server the PDFs up from. This example is flexible with respect to deployment, because it handles both desktop and web configurations. Since you'll need to set up the PDF directoy, you may want to just handle one configuration option to simply things (or you could expose the same PDF directory over http and as a local network share).
You may also want to present this as a true link instead of a button. In order to do this, you'll need a custom SilverLight control. In any case, I would recommend implementing the PDF link using a button first. You can then move this same code to a link event handler as a separate project if that is worth spending time on.