scripting

Can script.readyState be trusted to detect the end of dynamic script loading?

走远了吗. 提交于 2019-12-17 15:23:25
问题 I use dynamic script loading to reduce the duration of the initial page load. To ensure that the functions and objects defined by a script are accessible, I need to ensure that the script has been fully loaded. I have developed my own Javascript library to this end, and thus did quite a lot of research on the subject, studying how it's done in different libraries. During a discussion related to this issue, Kyle Simpson, the author of LABjs, stated that: LABjs (and many other loaders) set both

Python: checking if point is inside a polygon

廉价感情. 提交于 2019-12-17 15:22:25
问题 I have a class describing a Point (has 2 coordinates x and y) and a class describing a Polygon which has a list of Points which correspond to corners (self.corners) I need to check if a Point is in a Polygon Here is the function that is supposed to check if the Point in in the Polygon. I am using the Ray Casting Method def in_me(self, point): result = False n = len(self.corners) p1x = int(self.corners[0].x) p1y = int(self.corners[0].y) for i in range(n+1): p2x = int(self.corners[i % n].x) p2y

Python script header

假装没事ソ 提交于 2019-12-17 15:14:55
问题 The typical header should be #!/usr/bin/env python But I found below also works when executing the script like $python ./my_script.py #!/usr/bin/python #!python What's difference between these 2 headers? What could be the problem for 2nd one? Please also discussing the case for python interpreter is in PATH or not. Thanks. 回答1: First, any time you run a script using the interpreter explicitly, as in $ python ./my_script.py $ ksh ~/bin/redouble.sh $ lua5.1 /usr/local/bin/osbf3 the #! line is

Monitor Drive. Using VB Script

僤鯓⒐⒋嵵緔 提交于 2019-12-17 14:55:39
问题 I want to monitor a drive for file changes, using VBScript. I have the below code. It works fine for InstanceCreationEvent and InstanceDeletionEvent . But InstanceModificationEvent is not happening. From googling I got to know we need to use CIM_DataFile instead of CIM_DirectoryContainsFile to monitor InstanceModificationEvent . I am not sure how to modify the code. Can anyone help. FYI: One script should monitor all the folders and subfolders in a drive. PS: Any suggestion to improve the

WinSCP time based file download

て烟熏妆下的殇ゞ 提交于 2019-12-17 14:14:36
问题 I would like to write WinSCP script to download a file that is placed onto the remote server every morning between 4-4:30am. Is there a way to do this with time-stamping? I want to pseudocode: get file.txt where timestap<1 hour from 4 am 回答1: First, I assume your file does not have fixed name (contrary to your question with fixed name file.txt ). If not, please explain, why do you need timestamp-based solution. Anyway, you can use a file mask with a time constraint: get "*.txt>2014-07-19 4:00

Number of tokens limit in a FOR command in a Windows batch script

自古美人都是妖i 提交于 2019-12-17 14:06:09
问题 I was trying to process a text file in a Windows batch script and I ran into something that looks like a limitation to 31 tokens in a FOR loop. I isolated the issue in the code below: @ECHO OFF SET DATA=01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 FOR /F "tokens=31* delims= " %%i IN ("%DATA%") DO ( ECHO [%%i] ECHO [%%j] ) ECHO. FOR /F "tokens=32* delims= " %%i IN ("%DATA%") DO ( ECHO [%%i] ECHO [%%j] ) The output is: [31] [32 33 34

Bundle python script and dependencies into a single file

百般思念 提交于 2019-12-17 13:04:54
问题 I have a few script that had their own copy of a some functions, so I extracted these functions to a module and had the scripts import the function. These script are to be copied over to a bunch of linux servers and executed. When the scripts worked standalone, I would simply copy the files over to the servers and execute "python ". I have a central management server that will copy and run the scripts on the different servers. I've done some reading on python eggs, but could use some advice

Bundle python script and dependencies into a single file

半世苍凉 提交于 2019-12-17 13:03:50
问题 I have a few script that had their own copy of a some functions, so I extracted these functions to a module and had the scripts import the function. These script are to be copied over to a bunch of linux servers and executed. When the scripts worked standalone, I would simply copy the files over to the servers and execute "python ". I have a central management server that will copy and run the scripts on the different servers. I've done some reading on python eggs, but could use some advice

Batch File input validation - Make sure user entered an integer

安稳与你 提交于 2019-12-17 12:26:21
问题 I'm experimenting with a Windows batch file to perform a simple operation which requires the user to enter a non-negative integer. I'm using simple batch-file techniques to get user input: @ECHO OFF SET /P UserInput=Please Enter a Number: The user can enter any text they want here, so I would like to add some routine to make sure what the user entered was a valid number. That is... they entered at least one character, and every character is a number from 0 to 9. I'd like something I can feed

Batch File input validation - Make sure user entered an integer

て烟熏妆下的殇ゞ 提交于 2019-12-17 12:25:52
问题 I'm experimenting with a Windows batch file to perform a simple operation which requires the user to enter a non-negative integer. I'm using simple batch-file techniques to get user input: @ECHO OFF SET /P UserInput=Please Enter a Number: The user can enter any text they want here, so I would like to add some routine to make sure what the user entered was a valid number. That is... they entered at least one character, and every character is a number from 0 to 9. I'd like something I can feed