脚本

getting more information from phantomjs “SyntaxError: Parse error” message

匿名 (未验证) 提交于 2019-12-03 02:29:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I have a long script that was not written by me. When i run it I get: phantomjs file.js SyntaxError: Parse error i checked out the manual and --help, and the best i could came up with was: phantomjs --debug=yes file.js (irrelevant debug statement from CookieJar) SyntaxError: Parse error Is there any better way to get at least a line number? or any hint at all? 回答1: Run the file with node . If there is a parse error it will report it. If the file is valid, then node will also try to run it, which will fail if your script depends on something

How load and use/call dynamically JavaScript

匿名 (未验证) 提交于 2019-12-03 02:29:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I need to dynamically load a JavaScript file and then access its content. File test.js test = function () { var pub = {} pub.defult_id = 1; return pub; }() In this case it works: <!DOCTYPE html> <html> <head> <script type="text/javascript" src="/test.js"></script> </head> <body> <script type="text/javascript"> console.log(test.defult_id); </script> </body> </html> But I need to load it dynamically, and that way it does not work: <!DOCTYPE html> <html> <head> </head> <body> <script type="text/javascript"> function loadjs(file) { var script =

How to get a timer in a Powershell messagebox?

匿名 (未验证) 提交于 2019-12-03 02:29:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I'm trying to display a timer in my message box that I created with PS Forms. I would like something like that: " Your PC will be shutdown in 10 sec" after 1 sec. "Your PC will be shutdown in 9 sec" "Your PC will be shutdown in 8 sec" and so on. Hope you can help me. 回答1: I don't see a way of refreshing the text in a message box. If I had to do this I would probably pop up another form with a label and use a timer that refreshes the text of the label on each tick. Here is a code example to use a potential starting point: Add-Type

“bad variable name” using “read var”

匿名 (未验证) 提交于 2019-12-03 02:29:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I am getting confused about Linux shells. It may be that I oversee something obvious as a Linux noob. All I want is the following script to run: #!/bin/bash echo "Type some Text:" read var echo "You entered: "$var Here is the situation: Installed Ubuntu Server 14.04 in a VirtualBox on windows Installed it with this packages A SAMBA mounted on /media/buff The script is on /media/buff/ShellScript/test.sh made executable by "sudo chmod a+x /media/buff/ShellScript/test.sh" The rest is default I am using PSPad on windows to edit the script file I

Best way to store a large python dictionary in a file

匿名 (未验证) 提交于 2019-12-03 02:29:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I have a python script (script 1) which generate a large python dictionary. This dictionary has to be read by an another script (script 2). Could any one suggest me the best way to write the python dictionary generated by script 1 and to be read by script 2. In past I have used cPickle to write and read such large dictionaries. Is there a beter way to do this? 回答1: shelve will give you access to each item separately, instead of requiring you to serialize and deserialize the entire dictionary each time. 回答2: If you want your dictionary to be

placing PHP Variables inside javascript file

匿名 (未验证) 提交于 2019-12-03 02:29:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: As per title. I have a piece of jQuery that looks like the following $("<div class='creditCardDetails' id='usercurrentccbox'> <div class='creditCard'> <div class='cardChoice'> <span>Choose Card Type</span> <input name='cctype' type='radio' value='V' class='lft-field' id='visa' /> <label for='visa'></label> <input name='cctype' type='radio' value='M' class='lft-field' id='mastercard' /> <label for='mastercard'></label><input name='cctype' type='radio' value='A' class='lft-field' id='amex' /> <label for='amex'></label> </div> <!--cardChoice-->

Reference javax.script.ScriptEngine in android or evaluate a javascript expression

匿名 (未验证) 提交于 2019-12-03 02:28:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: Is it possible to reference the javax.script.ScriptEngine library when developing an android application? If not is there anyway possible to evaluate a javascript expression in android? 回答1: javax.script.ScriptEngine is not a default part of android, but you could easily jar up any libraries you need(assuming the size is reasonable, I'm not sure) and include them in your project. 回答2: For the classes javax.script.ScriptEngine, javax.script.ScriptEngineFactory and so on, you can add the jsr223.jar to your Android project: just copy the .jar

Unity: How to dynamically attach an unknown script to a GameObject (custom editor)

匿名 (未验证) 提交于 2019-12-03 02:28:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I'm currently making a system for the Unity Editor (custom inspector and custom windows) that will automate and make things easier for the artists working on the game we're making, but I've hit a brick wall. I'm trying to find a way to dynamically add, through an editor Textfield input and a GUI button, an unknown script to a gameobject in the scene. The artist/programmer will type the name of the script in the textfield and it will search and add to a gameobject, but I don't know how to proceed with this, specially since some functions of

Specify command line arguments like name=value pairs for shell script

匿名 (未验证) 提交于 2019-12-03 02:27:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: Is it possible to pass command line arguments to shell script as name value pairs, something like myscript action=build module=core and then in my script, get the variable like $action and process it? I know that $1....and so on can be used to get variables, but then won't be name value like pairs. Even if they are, then the developer using the script will have to take care of declaring variables in the same order. I do not want that. 回答1: In the Bourne shell, there is a seldom-used option ' -k ' which automatically places any values

Drag and drop onto Python script in Windows Explorer

匿名 (未验证) 提交于 2019-12-03 02:27:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I would like to drag and drop my data file onto a Python script and have it process the file and generate output. The Python script accepts the name of the data file as a command-line parameter, but Windows Explorer doesn't allow the script to be a drop target. Is there some kind of configuration that needs to be done somewhere for this work? 回答1: Sure. From a mindless technology article called "Make Python Scripts Droppable in Windows" , you can add a drop handler by adding a registry key: Here’s a registry import file that you can use to