server-side scripting – If the content is retrieved from wget, there may be a problem if I do not know the content type in the HTTP response.

The content-type is used by browsers to find out how the content is displayed. Browsers must choose the presentation method based on the content type. Rendering simple text is very different from rendering HTML.

wget Performs the same action on all files: they are stored on the hard disk. In my experience, it does not pay attention to the Content-Type Header, it only saves the file. Most file systems have no other mechanism to store metadata about the file than the file name and permissions. The content type is not even saved.

The only exception could be Mac OS. Mac's file systems can store far more metadata about files than other file system references. I have never used wget on the Mac, but it is possible that the content type will be saved there as a file metadata. This would then affect which program opens the file with the default action.

Of course, other file systems will usually guess based on the file extension .html, Since this is also wrong, the systems may behave the same way as the application types selected to open the saved file.

If you use the UUID with a specific script or application, it probably does not matter to you what the operating system would choose as the default editor and viewer for the file. I can not imagine that your use case on Windows, Mac or Linux will cause unforeseen problems.

server-side scripting – If the content is retrieved from wget, there may be a problem if the HTTP response does not specify the correct content type.

It's a question too wget, I have a simple file uuid.html in the document root, which contains a single line 54da5638-099d-4cf3-9319-c436fcb81334, I get the line in a shell script content=$(wget localhost/uuid.txt -O -), My server, Apache, assigns the content type automatically text/html to the output document in the response returned to wget. Is it reliable to consider that wget completely ignores the content type in the response header to determine what is returned and assigned? $content? I know that Apache would set the content type to text/plain in the response header, if I used another extension for the file. That's not the question. Does the content type need to be specified in the HTTP response header? is a similar question, but the context is different: you think the request is being made by a browser. Of course I also checked if it works on my server. The question is, is this reliable regardless of the environment?

Scripting – WolframScript does not simplify the output

I am trying to multiply a matrix and a vector (imported from a CSV) into Tungsten script to speed up a process that is usually done with Mathematica notebooks. However, this is the first time that I use Wolfram script, and it seems that it does not simplify my answers. For example, I tried the simplest example:

value1 = Import(file1.csv, "Table");
value2 = Import(file2.csv, "Table");

value1 = value1((1))((1)); //value1 = Sqrt(2)
value2 = value2((1))((1)); //value2 = Sqrt(3)

Print(FullSimplify(Evaluate(value1 * value2))) //should be Sqrt(2)*Sqrt(3) = Sqrt(6)

This gives sqrt (6) in the normal notebook, but sqrt (2) * sqrt (3) as output on the command line with tungsten script.

I tried FullSimplify, Simplify, Evaluate, etc., but nothing seems to simplify the answer in Wolframscript.

The matrices and vectors that I eventually try to multiply are much more complicated, so I'm trying to find a solution to this simple case. I wonder if it has anything to do with the sqrt function?

Thank you in advance!

scripting – How to turn an algorithm into a function

I have written a script that allows me to determine the different local minima of a record. Two arguments are needed: the dataset list and an x ​​coordinate value, which tells the script from where to look for the minima. However, I want to make this a feature so I can call it multiple times in the same notebook without having to keep writing it. Is that possible? I tried to define it as a normal function

f[x_,y_]:= script...

But it did not work. Also … as a bonus … is it possible to save this function in a personal directory from where I can access it in several notebooks without having to write them in each one of them?

Here is my script, if it helps.

Many thanks for your help.

MinCoordinates0 = {{0, 0}};
SweepStartingPoint = 1;
MinPointsCounter = 0;

i = Position[list,Nearest[list[[All, 1]],SweepStartingPoint][[1]]][[1]][[1]]; 

While[i < Length[list] - 1,
  If[list[[i + 1, 2]] <= list[[i + 2, 2]] && 
   list[[i + 1, 2]] <= list[[i, 2]], {MinPointsCounter=MinPointsCounter + 1, 
MinCoordinates0 = 
Join[MinCoordinates0, {{list[[i + 1, 1]], list[[i + 1, 2]]}}]}]; 
i++]

MinCoordinates = 
Table[{MinCoordinates0[[k, 1]], MinCoordinates0[[k, 2]]}, {k, 2, 
Length[MinCoordinates0]}];

Print[MinCoordinates // MatrixForm]
MinPoints = Range[MinPointsCounter];

j = 1;

While[j <= Length[MinPoints], 
 MinPoints[[j]] = 
Graphics[{Red, 
Disk[{MinCoordinates[[j, 1]], MinCoordinates[[j, 2]]}, 0.04]}]; j++]

Show[ListLinePlot[list], MinPoints]

The two arguments of my future function in this script are "SweepStartingPoint" and "list", where the first is the point where the search starts and list is the nx2 record, where n is the number of lines.

Scripting – After a unity tutorial. Why are these textures tiling instead of just overlapping?

It might be helpful to provide all the details. So here they are and here's the YouTube tutorial that triggered my question: https://www.youtube.com/watch?v=vAfZ5gFaThI

So there is a prefab of the background tile named "tile background". This prefab has the default settings, except that "Pixels Per Unit" is set to 512 and that a script called "BackgroundTile" is appended, which has not even been opened. It is only for the other script for referencing.

An empty object named "Board" has been created whose tile-ready element is the tile background. It also has a script, Board.cs, whose content can be found here: https://pastebin.com/CPbmAUh9
The width is set to 4. The height is set to 7.
Otherwise the camera position is X: 1.5, Y: 3 and the aspect ratio is 9:16.

My question is this: Why is Vector2 (i, j) interpreted as it runs, putting the sprites side by side rather than placing the sources of the sprites in a 4×7 pixel grid in which they almost completely overlap? There is no place where their positions are multiplied by the size of the tiles, right? Halving the pixels per unit does not even halve the height of the board – it stays constant and looks really strange even though the board has no set dimension attributes. What's going on here?

Edit: damn it, I forgot to put the link

scripting – The PowerShell function parameter becomes zero in the try block

I'm putting together a Powershell zip-in-transit script called via a function, but it keeps saying that the path after creating the zip file is zero. After running the script in ISE, I then start from the CLI:

Move-Stuff c:logs HASTNAME

It compresses the files in the first parameter I specified, but then returns the error:
Any ideas? After all, what I can say is that you get $ beforeHash, which fails

The argument can not be set to the parameter & # 39; Path & # 39; be tied because it is zero.

Here is the full script:

function Move-Stuff {
                param(
                        (Parameter(Mandatory))
                        #(string)$Path,
                        (string)$Path, 

                        (Parameter(Mandatory))
                        (string)$DestinationPath
                     )
     try {
             echo "The path is set to $Path"
             ## Zip up the folder
             echo "Zipping stuff"
             $zipFile = Compress-Archive -Path $Path -DestinationPath "$Path($(New-Guid).Guid).zip" -CompressionLevel Optimal # -PassThru
             echo "The path is set to $Path"
             echo "$Path($(New-Guid).Guid).zip"

             ## Create the before hash
             echo "Before Hash"
             echo "The path is set to $Path"
             echo "$zipFile"
             echo "$zipFile.FullName"
             Write-Host "zipfile:" $zipFile
             Write-Host "zipfile full name:" $zipFile.FullName
             echo "$Path($(New-Guid).Guid).zip"
             $beforeHash = (Get-FileHash -Path $zipFile.FullName).Hash
             echo "$beforeHash"
             echo "After Hash"
             echo "The path is set to $Path"

             ## Transfer to a temp folder
             echo "Starting Transfer"
             $destComputer = $DestinationPath.Split('')(2)
             $remoteZipFilePath = "\$destComputerc$Temp"

             Start-BitsTransfer -Source $zipFile.FullName -Destination $remoteZipFilePath

             ## Create a PowerShell remoting session
             echo "Starting PSSession"
             $destComputer = $DestinationPath.Split('')(2)
             $session = New-PSSession -ComputerName $destComputer
             echo "PSSession Created"

             ## Compare the before and after hashes
             ## Assuming we're using the c$ admin share
             $localFolderPath = $DestinationPath.Replace("\$destComputerc$",'C:')
             $localZipFilePath = $remoteZipFilePath.Replace("\$destComputerc$",'C:')
             $afterHash = Invoke-Command -Session $session -ScriptBlock { (Get-FileHash -Path "$using:localFolderPath$localZipFilePath").Hash }
             if ($beforeHash -ne $afterHash) {
             throw 'File modified in transit!'
             }

             ## Decompress the zip file
             Invoke-Command -Session $session -ScriptBlock { Expand-Archive -Path "$using:localFolderPath$localZipFilePath" -DestinationPath $using:localFolderPath }
             } catch {
             $PSCmdlet.ThrowTerminatingError($_)
             } finally {
             ## Cleanup
             #Invoke-Command -Session $session -ScriptBlock { Remove-Item "$using:localFolderPath$localZipFilePath" -ErrorAction Ignore }
             #Remove-Item -Path $zipFile.FullName -ErrorAction Ignore
             #Remove-PSSession -Session $session -ErrorAction Ignore
     }
 }