Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

yoblanco

macrumors newbie
Original poster
Dec 10, 2011
26
0
That's the question. Is there any webpage along the internet where you can ask for some program? (It's pretty simple, I know how to do it with MATLAB in less than 4 minutes)
The perfect solution would be an .html document which let's you paste some text and then processes it.
But Applescript, or even Automator could work.

In short, if you could tell me a website where I can ask for a little program in .html, Applescript or Automator, I would really appreciate it :D

Thank you!

PS: the text contains "words" with three numbers separated by commas, colons or dots (e.g., 13.16.30, for the example A.B.C). On other place I need to input a different (global) number (D). And then the "application" or script should take that text, and that number, select the words with that pattern A.B.C or A:B:C, and for each of those words, give you links like:

Code:
www.web.com/someplace/inside/placeA/index.php?option1=B&option2=C&option3=D

where the number D is global (so should have a place to input it, different fron the whole text).

PS2: in MATLAB I know how to do it if the text contains only those kind of words. So if it's difficult to "select" them from a whole text, you could think that the text contains only those words.
 
Last edited:

ArtOfWarfare

macrumors G3
Nov 26, 2007
9,560
6,059
Just use sed if all you want is a find & replace with a regex pattern (which is what it seems you want to me.)
 

yoblanco

macrumors newbie
Original poster
Dec 10, 2011
26
0
Thanks for the fast answer.

The reason why I would really like it to be an .html (or something that runs from any web browser) is that I need it everywhere and on different machines. And if I get that, then put it in Dropbox and use it wherever I want.
But I know nothing about .html or some "web language", even less about forums about that subject. And that's basically what I'm asking.

In second place, if the html solution doesn't come up, then I think some applescript would work.

Thank you for the answer, and that could really work in a machine with sed installed, but not everywhere :S
 

ArtOfWarfare

macrumors G3
Nov 26, 2007
9,560
6,059
Thanks for the fast answer.

The reason why I would really like it to be an .html (or something that runs from any web browser) is that I need it everywhere and on different machines. And if I get that, then put it in Dropbox and use it wherever I want.
But I know nothing about .html or some "web language", even less about forums about that subject. And that's basically what I'm asking.

In second place, if the html solution doesn't come up, then I think some applescript would work.

Thank you for the answer, and that could really work in a machine with sed installed, but not everywhere :S

sed is a part of every OS X, Unix, and Linux distribution (I think.) For Windows, you can install sed as part of many different packages, as mentioned here:

http://stackoverflow.com/questions/127318/is-there-any-sed-like-utility-for-cmd-exe

Don't reinvent the wheel. If you're not a programmer, then here's something you need to know about them: good programmers are lazy. If a good solution already exists and they can't make a better one in a reasonable timeframe (IE, in less time than it would take to just use the existing solution), they use it. sed is likely better than anything anyone else is going to come up with anytime soon. So use it.
 

yoblanco

macrumors newbie
Original poster
Dec 10, 2011
26
0
@ArtOfWarfare It's okey, I will look into sed. I wrote "man sed" in my terminal and gave me nothing. That's why I wrote about installing it. I have done it again just now and it works... I don't know what I wrote before.

@960design considering that I'm a begginer in MATLAB and took me 6 minutes to do it, I hope that in a place where people know how html works it could be done for free.

By the way, the main question remains. Any html forum or community where this small request could fit and be done? If not, any AppleScript one?

The problem with the applescript is that I should be in a Mac and that it couldn't be done automatically in a new computer. The optimal solution is an html file (which I would put in Dropbox) and then, in any machine with internet, open that webpage, paste a text, write the number D, click a button and have a bunch of links.

----------

@ArtOfWarfare It's okey, I will look into sed. I wrote "man sed" in my terminal and gave me nothing. That's why I wrote about installing it. I have done it again just now and it works... I don't know what I wrote before.

@960design considering that I'm a begginer in MATLAB and took me 6 minutes to do it, I hope that in a place where people know how html works it could be done for free.

By the way, the main question remains. Any html forum or community where this small request could fit and be done? If not, any AppleScript one?

The problem with the applescript is that I should be in a Mac and that it couldn't be done automatically in a new computer. The optimal solution is an html file (which I would put in Dropbox) and then, in any machine with internet, open that webpage, paste a text, write the number D, click a button and have a bunch of links.
 

yoblanco

macrumors newbie
Original poster
Dec 10, 2011
26
0
Mmm... I don't really think this fits there (it's not a question since I know nothing, it's more like a request). I have been for some time in that (nice) place, and the reason to come here to ask is that I think this question is not really appropriate there.

Thank you.
 

chown33

Moderator
Staff member
Aug 9, 2009
10,747
8,421
A sea of green
I had some free time this afternoon, so I cobbled together something from parts of older projects I have.

It's in 3 parts (HTML, CSS, JavaScript) because that's how the original parts were written.

I make no claims that any of the parts are optimal, exemplary, instructive, or comprehensible to anyone at any skill level. For better or for worse, it's the way the original parts were written.

There may still be some cruft in any or all parts.

FWIW, JavaScript is a reasonably capable language for doing string processing. It's worth learning it for those features alone, so when similar situations arise (and I suspect they will), one has the skills to modify this, or to toss it out and write something better.

The awk language is probably more capable than JavaScript when it comes to solving problems like this. Except for the "It has to run everywhere" constraint, this could probably be done as an awk one-liner. FWIW, awk is a much simpler and smaller (more focused) language than JavaScript.

Released into the public domain. Do what you will with any or all of it.
 

Attachments

  • app-in-3-parts.zip
    3.5 KB · Views: 73

yoblanco

macrumors newbie
Original poster
Dec 10, 2011
26
0
That's perfect. I wasn't really expecting anything here, but to get an address of a forum. But instead I got it. Thank you.

It needs some tweaks, but I can NOW go to StackOverflow, just to ask small questions.

Thank you!

EDIT: Well I say what the problem is here so may be you can solve it.
The links are right, but the ideal is to have clickable links (and even better if they automatically open in a NEW TAB).
And just to say, if all the fonts were Lucida that could be great :p
 
Last edited:

chown33

Moderator
Staff member
Aug 9, 2009
10,747
8,421
A sea of green
The links are right, but the ideal is to have clickable links (and even better if they automatically open in a NEW TAB).

I'm not quite sure what you want.

Do you want the list of clickable links in a new tab? Or do you want each link in the list of clickable links to open a new tab when clicked? Or maybe both?


Please provide a complete list of what you want. Adding features piecemeal makes it harder to estimate the amount of work, and takes longer to create because adding things you don't want still requires writing code.

Describe the complete process you want a user to experience. That is, step through the user experience. Example of current behavior:
  1. User enters a value for D.
  2. User enters or pastes in a series of lines containing triplets.
  3. User presses "Process" button.
  4. The textarea below the "Process" button is cleared, and the contents is replaced by a series of lines with the replacement strings given in the first post.
So change step 4 (or any other steps) so it describes exactly what should happen. If there are additional steps in the user experience, such as clicking newly produced links, be sure to describe exactly what happens for those.

http://www.mikeash.com/getting_answers.html


And just to say, if all the fonts were Lucida that could be great :p
Open the app.css file in a text editor (TextEdit.app will work; TextWrangler (google for free download) would be better). Then delete this line:
Code:
  font-family:monospace;
Save the file, then reload the html page in your browser.

You can make additional changes to the CSS file to alter the styling. Any decent reference or tutorial on CSS should provide info. The CSS I used is pretty basic stuff.

If you use TextEdit.app to edit the CSS file, make sure it's being saved as plain text, not rich text. That's one reason for using TextWrangler; it's primarily for editing plain text.
 

yoblanco

macrumors newbie
Original poster
Dec 10, 2011
26
0
I want clickable links. And, the perfect thing would be that when I click on them they open a new tab (in front), I explain later.

And thanks for the monospace tip, I will edit the .CSS (with TextMate, which is the editor I'm familiar with).

Here it is the workflow.

  1. User collects info from a source, and writes down the triplets on a .txt file (or in a mail or wherever). And calculates the D number. This has nothing to do with the program, but just to add info.
  2. User enters a value for D.
  3. User enters or pastes in a series of lines containing triplets.
  4. User presses "Process" button.
  5. The textarea below the "Process" button is cleared, and the contents is replaced by a series of lines with the replacement strings given in the first post.
  6. The user visit each of those links and do a small business there.
  7. And it's over. The next time, with new data, the user goes through another list of triplets and a different number D.

The idea of this programs is to make it easy to visit each of those links. Instead of clicking and writing on a webpage, you write those triplets, calculate the D number, click process and there you have the links automatically.
The next (and, I think, last) step is to make those links clickable. As the user has to go into all of them, to save more time, the point 6. of the list could be expanded (and detailed) like this
  1. User clicks on first link.
  2. New tab is opened and automatically placed on screen (I mean, the tab should be opened in front).
  3. User do a small business there.
  4. User presses CMD + W to close that tab and go back to the list of links (the "app").
  5. And then the second link, and all the same for all the rest of generated links.

I hope I made myself clear.
Thank you really much for your attention.
 

chown33

Moderator
Staff member
Aug 9, 2009
10,747
8,421
A sea of green
  1. User collects info from a source, and writes down the triplets on a .txt file (or in a mail or wherever). And calculates the D number. This has nothing to do with the program, but just to add info.
  2. User enters a value for D.
  3. User enters or pastes in a series of lines containing triplets.
  4. User presses "Process" button.
    [*]The textarea below the "Process" button is cleared, and the contents is replaced by a series of lines with the replacement strings given in the first post.
    [*]The user visit each of those links and do a small business there.
  5. And it's over. The next time, with new data, the user goes through another list of triplets and a different number D.
If the area below the "Process" button contains links, then it won't contain a textarea. Those are two completely different things.


What should each clickable link look like?

A link consists of text content and an href. The text content appears in blue and is underlined (by default) to indicate it's a clickable link. The href is the target URL of the link. Examples:
Exactly what should appear as the text content of each link?


And for my own curiousity, please explain why your 6-minute MATLAB solution is unsatisfactory. Is it because you don't have MATLAB everywhere? Some other reason?
 

yoblanco

macrumors newbie
Original poster
Dec 10, 2011
26
0
Doesn't matter if the text content and the href are the same.
But I think it's better to have the text content as the triplets.

And, yes, as you say, then it isn't a "textarea".

MATLAB is unsatisfactory because I don't have it anywhere, and, even at home, I need to open MATLAB to process a .txt file. With an .html, I just need to open it in the browser (which is almost always open), and it isn't necessary a .txt (can be a copied text).
 
Last edited:

chown33

Moderator
Staff member
Aug 9, 2009
10,747
8,421
A sea of green
Doesn't matter if the text content and the href are the same.
But I think it's better to have the text content as the triplets.

New version attached.

The "open in new tab" feature is not guaranteed to work in every browser. There is a standardized way to request it in CSS3, but that may or may not be implemented by any given browser. There are also non-standardized ways that appear in different browsers. See the "app.js" source for links to discussion on this issue on stackoverflow.com.

Stackoverflow links:
http://stackoverflow.com/questions/15551779/open-link-in-new-tab
http://stackoverflow.com/questions/6296013/how-can-i-open-a-link-in-new-tab-and-not-new-window

The CSS3 way (Working Draft version):
http://www.w3.org/TR/2004/WD-css3-hyperlinks-20040224/

Still in the public domain. Do what you will with any or all of it.
 

Attachments

  • appv2-in-3-parts.zip
    4.3 KB · Views: 94

yoblanco

macrumors newbie
Original poster
Dec 10, 2011
26
0
That's it. I guess there's nothing more. I've been trying it and works ideally (with my MATLAB solution I just got an .html with the links, with the same href as the text content, and with no spacing...). This is beautiful, well organized, and, of course, useful. If I find something more I will tell you.

Thank you very much!
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.