AppleScript to download files from HTTP server, mutating the URL? - http

I've never messed with AppleScript so this is only a concept to me. Can this work?
Bungie, the game designer, is hosting a ton of PNGs for Halo Reach in systematically named files and directories. IE:
http://www.bungie.net/images/reachstats/commendations/onyx/onyx_large_precision_multiplayer.png
Change two instances of the same word, and you generate another version of the image. Change "onyx" to "iron", "bronze", "silver" or "gold" and you get a corresponding image, like so:
http://www.bungie.net/images/reachstats/commendations/gold/gold_large_precision_multiplayer.png
Would an AppleScript be able to take an input URL, find and change the instances of the words in the URL, and then download the associated file to a directory? Today is my birthday (Oct 27th! hence the XXVII) and if this will work I would be super excited if someone could make this!
Thanks for all of your kind answers!

This works:
set the destination_file to ((path to desktop as string) & "picture.jpg") as file specification
set thisImageSRC to "http://www.bungie.net/images/reachstats/commendations/gold/gold_large_precision_multiplayer.png"
tell application "URL Access Scripting"
download thisImageSRC to destination_file replacing yes
end tell
String manipulation is done completely with changing Applescript's text item delimiters. So to get the components of the URL into a list, you need to do the following:
set oldDelims to AppleScript's text item delimiters
set AppleScript's text item delimiters to "/"
set theUrlComponents to (every text item of theURL) as list
set AppleScript's text item delimiters to oldDelims
Add salt to taste, but I agree with the first commenter that there are better languages to do this. Applescript would be my last choice here.

Related

Make basic Math in Draw.io (diagrams.net)

I want to make some basic math stuff like Sum in Diagrams.net (old Draw.io).Is it possible ?
Exemple : I create a new parameter on a shape, like "Elec : T16" and make several copy on this shape. Is it possible to have a Text which can give me the total of the shape with this parameter ?
Best Regards.
I search a lot in the Diagrams.net blog but anything relevent.
This is not supported.
Regards,
I also wanted to do something similar and while it doesn't seem possible to do it completely in the software (as of v20.3.0), I did find a bit of a workaround: If you add properties to the shape data, then do File > Export As > XML, the properties will be there in the XML data. You can then count them one of two ways:
Open the XML file with a text editor like Notepad++, do a find on the value you want to count. If you choose "Find All" it will tell you how many times it appears.
Use a programming language like Python to read through the file and count the instances of that value.
Example:
I created a red circle in a new diagram, edited the text to say "RedCircle" and used Edit Data to add a property called TestValue, to which I assigned a value of 1. When I exported to XML it contained this element:
<object label="RedCircle" TestValue="1" id="6byQ5fOap-RXn7mFit_J-1">
Notes
When you export, make sure you turn off the Compressed option, this will create an unusable file.
Don't use Save As > XML, this will also use compression.
Diagrams.net natively saves in a compressed XML format, with only slight differences between that and the other compressed XML options, but it seems happy to also read in the exported uncompressed XML. I didn't test but if you go the programming route and want to take it a step further, it seems you could have the program update the value of a given "counter" element with the count, then open the XML file in diagrams.net to see the updated value and save it as a native .drawio file or publish in whatever format you like.
Edit: I discovered that under File > Properties you can turn off the compression on the actual .drawio file. If you do that you can just work from this file instead of exporting, but you might want to check the size of your file with and without it.
I'm sure a plugin could be created to do all of that within the app itself, but the other methods are enough for me at this point.
Hope this helps you!

Is it possible to search some word in js files only of certain project?

I am using Brackets and Atom for front-end development.
I am trying to achieve this:
1. Search the certain work Ex: "Testing"
2. That word is in so many files which are html,javascript and others.
3. I want only *.js files to display the results.
There are 100s of files, it is difficult to manually do it.
What I'm trying to achieve?
I want to search all Regex written for the form validation in this project.
Yes, it is.
First ctrl + shift + F
In the first input box (Find in Project), enter the word you want to search.
In the last input box(File/Directory Pattern), enter Projectname,*.js
Note: ProjectName is case sensitive.

TinyButStrong magnet tag shows in output docx

Hi my colleague and I has been trying to get the TinyButStrong plugin openTBS to create some docx files.
We have a live system which creates some RTF files, with data from MySQL. We want to change this to docx, use openTBS. A couple of super users then in Word manage the templates.
We have a problem with creating the files, as we need to remove a line, if data isn't present.
If we in the Word template do
<w:p>[*fieldname*;magnet=w:p]*some kind of text*</w:p>
it hiddes the line if fieldname contains no data, and if if contains data, it will show the line. GREAT :-)
The problem is, that it also shows <w:p> and </w:p> when it contains data, and we don't like that.
How do we get it to stop showing these tags?
The TBS parameter ope=minv is done for thus purpose: it performs the magnet behavior but keep the field invisible (minv stands for magnet invisible).
So the solution is:
<w:p>[*fieldname*;magnet=tbs:p;ope=minv]*some kind of text*</w:p>
By the way, magnet=tbs:p is better than magnet=w:p because your template stays compatible when converted to another other format (LibreOffice).

Atom doesn't replace on auto complete

I don't know if this is a bug or something wrong i am doing but when ever i type something and press enter to select from the auto complete menu it leaves whatever is written before... or specifically the # symbol for now
here a picture demonstration
enter image description here
enter image description here
So more to the question, Atom does replace whatever you type if you chose to auto-complete in contrary to what Brent said below. In an html file try typing dv or btn and select to auto-complete you'll then see that it replaces what you've typed. So this behavior is only (as far as i am concerned) replicable with symbols
From the Autocomplete section of the Atom Flight manual:
By default, the autocomplete system will look through the current open file for strings that match what you're starting to type.
If you've typed in part of a keyword that Atom doesn't recognize, and then autocomplete the rest of the phrase, Atom will not erase what you've previously typed. I used to do this a bunch when I first started using Atom. The solution is simple: just type the part of the keyword that Atom recognizes before auto-completing the rest of it. So in the case of your first example image, you just have to start typing the phrase media and then press enter; no need to include the preceding # symbol. This ultimately means that you just have to type less to get your desired code, which I think is pretty sweet.

What fields does SDL Tridion 2011 search use?

I have never had practical success when using the search feature in Tridion (SDL Tridion 2011). I am looking at a list of components. I enter some of the text for one those component's name and the search does not find it. I have to use the exact name of the component for it to find it.
What fields does it search using my criteria?
Is there a wild card symbol I can use or a setting to make it a "contains" query?
The Search Indexer should index all fields of every components as well as text in binaries (PDFs, MS Word Docs etc). I have a running instance of SDL Tridion 2011 and can confirm that it does in fact give results from both binary and normal component content.
I am not entirely sure of the inner workings of the newer SolR version of Tridion, but I imagine that Titles and Full text are indexed separately.
It could be that your indexer is not actually running properly, I have seen the service appear to be in the running state, but not actually processing messages in the Search Queue. Try opening the Purge Queue tool (Normally located at "C:\Program Files (x86)\Tridion\bin\TcmPurgeQueue.exe"), and see if there are lots of messages waiting in the Search Queue. If there are, it may be that items are not being processed properly, try hitting refresh and see if the number is going down.
For a wildcard, you should just be able to use a '*'. I just tested putting the string "Rampusplong" in a component filed, and can confirm that searching for "Rampusplong" or "Rampus*" or "*ampusplo*" return my result, but "Rampus" returns no results.
Yes, * for wild cards as Chris mentions. See some reserved word options below (source: the SDL Welcome "Getting to Know SDL Tridion" help pages) for other options to try.
identifier (e.g. tcm:19-123-8)
search operators
AND
OR
NOT
IN (e.g. "someword IN title", where title is the component's XML)
exact phrases delimited with " (e.g. "Mad cookie")
wildcards
* for wildcard, multiple characters (I've sometimes needed this on supposed full matches)
? for single
special characters
+ - ! ( ) { } [ ] ^ " ~ * ? : \
(help file doesn't say much more except to escape with double quotes)
reserved words (escape with \ regardless of capitalization)
CONTAINS
NEAR
SENTENCE
PARAGRAPH
PHRASE
IN
MATCHES
STARTS
SUBSTRING
ENDS
AND
OR
NOT
You can also search in multimedia as well as metadata, schema, and the other visible search options by clicking on the advanced search (down arrow next to search).
At least in older versions (R5.3 specifically and possibly 2009), I've seen items outside of regular creation (via VBScript) skip getting indexed. Re-index if that's the case, but not sure with 2011.

Resources