scripting

Validation detected dangerous client input - post from TinyMCE in ASP.NET

我们两清 提交于 2019-12-19 18:53:05
问题 I get this error when I post from TinyMCE in an ASP.NET MVC view. Error: Request Validation has detected a potentially dangerous client input value, and processing of the request has been aborted From googling, it says to just add a validateRequest in the Page directive at the top which I did, but I STILL get this error. As you can see, below is my code in the view: <%@ Page validateRequest="false" Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc

Ruby - Read file in batches

社会主义新天地 提交于 2019-12-19 17:40:47
问题 I am reading a file that is 10mb in size and which contains some id's. I read them into a list in ruby. I am concerned that it might cause memory issues in the future, when the number of id's in file might increase. Is there a effective way of reading a large file in batches? Thank you 回答1: there's no universal way. 1) you can read file by chunks: File.open('filename','r') do |f| chunk = f.read(2048) ... end disadvantage: you can miss a substring if it'd be between chunks, i.e. you look for

Collecting the data for a partiulcar process from PMU for every 1 milli second

时光怂恿深爱的人放手 提交于 2019-12-19 11:58:49
问题 I would like to access the Hardware performance counters for a particular PID for every 1 milli second and save the output to a text file. The below code collects the data of all the processes running in the system in parallel for a certain duration and then outputs it to a text file. #!/bin/sh #set -x ps -ef | awk '{printf($2)"\n";}' > out.txt sed '1d' out.txt > tmp IFS=$'\n' while read tmp do 3>results-$tmp perf stat -p $tmp --log-fd 3 sleep 5 > /dev/null & done <tmp In order to collect the

KornShell Sort Array of Integers

拈花ヽ惹草 提交于 2019-12-19 10:57:52
问题 Is there a command in KornShell (ksh) scripting to sort an array of integers? In this specific case, I am interested in simplicity over efficiency. For example if the variable $UNSORTED_ARR contained values "100911, 111228, 090822" and I wanted to store the result in $SORTED_ARR 回答1: Is it actually an indexed array or a list in a string? Array: UNSORTED_ARR=(100911 111228 090822) SORTED_ARR=($(printf "%s\n" ${UNSORTED_ARR[@]} | sort -n)) String: UNSORTED_ARR="100911, 111228, 090822" SORTED

Applescript to make new folder

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-19 10:53:17
问题 I Want to make a new Folder command in apple script Why dosent this script work? tell application "Finder" activate end tell tell application "System Events" tell process "Finder" tell menu bar 1 tell menu bar item "File" tell menu "File" click menu item "New folder" end tell end tell end tell end tell end tell 回答1: You can do it more directly with AppleScript: tell application "Finder" set p to path to desktop -- Or whatever path you want make new folder at p with properties {name:"New

Applescript to make new folder

試著忘記壹切 提交于 2019-12-19 10:53:17
问题 I Want to make a new Folder command in apple script Why dosent this script work? tell application "Finder" activate end tell tell application "System Events" tell process "Finder" tell menu bar 1 tell menu bar item "File" tell menu "File" click menu item "New folder" end tell end tell end tell end tell end tell 回答1: You can do it more directly with AppleScript: tell application "Finder" set p to path to desktop -- Or whatever path you want make new folder at p with properties {name:"New

Is there a language-independent way to add a function to JSR223 scripting bindings?

流过昼夜 提交于 2019-12-19 09:57:21
问题 The JSR223 Bindings class allows you to expose arbitrary Java objects to scripting languages. But they have to be objects. I would like to define a function quit() that can be called from the scripting environment that turns into quitObject.run() in Java. But JSR223 doesn't define the concept of a function object. Is there a language-independent way to do the following in Javascript, namely to take a Runnable() and create a function in the scripting environment? static private Object

Checking duplicates in terminal?

拥有回忆 提交于 2019-12-19 09:53:45
问题 The following code prints me a long list of files with hashes and file names md5sum *.java I have tried unsuccessfully to list the lines where identical hashes occur, so that I can then remove identical files. How can you filter and delete identical files which have same content? 回答1: This should work: md5sum *.java | sort | uniq -d -w32 This tells uniq to only compare the first 32 character, which is only the md5 sum, not the filenames. EDIT: If -w isn't available, try: md5sum *.java | awk '

How do gnuplot margins work in multiplot mode?

限于喜欢 提交于 2019-12-19 05:52:50
问题 I am a bit confused about gnuplot margins. First of all I have no idea what units these things are pointing to. Are they pointing to the canvas coordinates OR are they a fraction of the canvas coordinates. Do they behave the same in gnuplot mode and multiplot mode? My problem arises when plotting some data in multiplot mode. I am plotting to the screen (wtx terminal). Let's just say I am bungling things badly - I get plots off the canvas, or very small unreadable plots. Without margins the

How do gnuplot margins work in multiplot mode?

女生的网名这么多〃 提交于 2019-12-19 05:52:06
问题 I am a bit confused about gnuplot margins. First of all I have no idea what units these things are pointing to. Are they pointing to the canvas coordinates OR are they a fraction of the canvas coordinates. Do they behave the same in gnuplot mode and multiplot mode? My problem arises when plotting some data in multiplot mode. I am plotting to the screen (wtx terminal). Let's just say I am bungling things badly - I get plots off the canvas, or very small unreadable plots. Without margins the