脚本

跨域解决方案之JSONP

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-03 10:25:48
跨域解决方案之JSONP 同源策略 JSONP介绍 JSONP基本原理 添加请求参数 小练习:百度搜索提示 同源策略 同源策略(Same origin policy)是一种约定,它是浏览器最核心也最基本的安全功能,如果缺少了同源策略,则浏览器的正常功能可能都会受到影响。可以说Web是构建在同源策略基础之上的,浏览器只是针对同源策略的一种实现。 同源策略,它是由Netscape提出的一个著名的安全策略。 现在所有支持JavaScript 的浏览器都会使用这个策略。所谓同源是指,域名,协议,端口相同。 例如: http://www.baidu.com 和 http://www.baidu.com:8080 二者是不同源的。http://www.baidu.com和https://www.baidu.com 同样是不同源的。 当请求不同源的数据的时候,浏览器就会在控制台报出一个异常,并且提示拒绝访问。同源策略是浏览器的行为,是为了保护本地数据不被JavaScript代码获取回来的数据污染,因此拦截的是客户端发出的请求回来的数据接收,即请求发送了,服务器响应了,但是无法被浏览器接收。 JSONP介绍 JSONP(JSON with Padding)是JSON的一种“使用模式”,可用于解决主流浏览器的跨域数据访问的问题。由于同源策略,一般来说位于 server1.example.com

Running Powershell script as scheduled task

匿名 (未验证) 提交于 2019-12-03 10:24:21
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 由 翻译 强力驱动 问题: I am using the powershell script below to open several word documents, update the form fields in them, and then close them. First, I'll note that if this script is run from the command line or by right clicking the file and selecting Run with Powershell basically doing it manually in any way, it will execute just fine. However, if I try to run this as a scheduled task, one of two things happen. I have tried several different forms of syntax for this, but all produce one of the same two results. Either A) The script says it started

Load a Javascript file, but cancel if it takes too long?

匿名 (未验证) 提交于 2019-12-03 10:24:21
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: Anyone have a good way to load a JS file but cancel loading it if it takes too long? I'm thinking something like this, hypothetically: <script type="text/javascript" cancel_after="2000" src="myfile.js"></script> The script is code that needs to get loaded in the head, because it replaces elements on the page, and so the browser needs to block while loading it. But in case the server takes too long to respond, I'd like to be able to have the browser proceed without loading the script. 回答1: Use a preloader. I personally prefer yepnope , where

Tcl Output redirection from stdout to a file

匿名 (未验证) 提交于 2019-12-03 10:24:21
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I know this question has been asked several times here. I have looked at the responses, but couldn't figure out the way it worked.Can you please help me understand. Here it goes: I'm trying to source a tcl script on the tclsh command line, and I want to redirect the output of that script into a file. $ source my_script.tcl The script my_script.tcl is something like this: set output_file final_result set OUT [open $output_file w] proc calculate{} { <commands> return $result } foreach value [calculate] { puts $output_file "$value" } This

Create custom elements v1 in ES5, not ES6

匿名 (未验证) 提交于 2019-12-03 10:24:21
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: Right now, if you follow the exact specifications of v1 of the custom elements spec , it's not possible to use custom elements in browsers that don't support classes. Is there a way to create v1 custom elements without using the class syntax so that they are fully functional in Chrome, FireFox and IE11. Also, since IE11 doesn't have native support for custom elements, I'm assuming we will probably need to use some pollyfills, so what polyfills or libraries do we need in order to make this work in IE11? I've messed around with Polymer 2,

How to convert a GNU linker Script ld to Scatter File (ARM)

匿名 (未验证) 提交于 2019-12-03 10:24:21
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I would like to migrate from GCC to the new ARM COMPILER 6. But I'm not able to well convert the Gnu liker script (ld) to the equivalent of ARM Scatter file. The Original Code is as following: arm-none-eabi-ld -T link.ld test.o shared/bootcode.o shared/vertors.o -o test.elf Where link.ld script is as following ENTRY(bootcode) SECTIONS { . = 0x00000000; /* Code starts with vectors, then bootcode, then other code */ .text : { *vectors.o(vectors) *bootcode.o(boot) *(.text) /* remainder of code */ } =0 .data : { *(.data) } .bss : { *(.bss) } /*

[-f: Command not found, Bash script does file exist [duplicate]

匿名 (未验证) 提交于 2019-12-03 10:24:21
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: This question already has an answer here: Why should there be a space after '[' and before ']' in Bash? 4 answers I'm having an issue with a script that I am trying to program. Narrowed down and simplified code and it gives an error that command is not found. If i do "test -f file" in command line it returns nothing, not command not found PATH=$1 #!/bin/bash DIR=$1 if [[-f $PATH]]; then echo expression evaluated as true else echo expression evaluated as false fi exit Here is the actual more complicated script I'm trying to run verify() { if

Jenkins job not seeing console output

匿名 (未验证) 提交于 2019-12-03 10:24:21
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: First, I'm not the admin, so there might be something config-wise that's not correct, leading to this issue. I can configure the one job I have access to configure and that is all. I am performing a Windows build, using a combination of shell scripts (using git-bash.exe) and Windows batch file. The sole jenkins build script is a shell script containing only: #!c:\Program Files\Git\git-bash.exe $WORKSPACE/builds/step1.sh |& tee $WORKSPACE/build_output.log (My git-bash.exe version is '4.3.42(5)-release' and the |& shorthand appears to be

Ruby script to telnet switch

匿名 (未验证) 提交于 2019-12-03 10:24:21
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I've created the following ruby script that telnet to Cisco devices, that telnet to Cisco devices and run command 'show int status err'. require 'net/telnet' C3550_20_PterraEst = "192.168.244.20" #Enter the IP address here USER = "user" #Enter username here PASS = "password" #Enter password here ENABLE = "password" #Enter enable password here print "Selezionare il piano [0-1-2-All]: "; # get the input from the console, val1 = gets; tn = Net::Telnet::new("Host" => C3550_20_PterraEst, "Timeout" => 5, "Prompt" => /Username/ ) tn.cmd("\n#{USER}"

Calling a Python script from Javascript, both local files

匿名 (未验证) 提交于 2019-12-03 10:24:21
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 由 翻译 强力驱动 问题: I'm trying to run a python script from a local javascript file (part of a locally running HTML/javascript program). I've been googling this for hours and found a lot of solutions, none of which actually work for me. Here is the javascript: $ . ajax ({ type : "POST" , url : "test.py" , data : { param : " " } }). done ( function ( o ) { alert ( "OK" ); }); The test.py file is in the same folder as the script/html file. here is the script: #!/usr/bin/python import os filepath = os . getcwd () def MakeFile ( file_name ): temp_path =