Showing posts with label REBOL. Show all posts
Showing posts with label REBOL. Show all posts

23 February, 2009

OS X - Running Scripts As Apps

I had a need to run a REBOL script as an application on my Mac. I was tired of constantly opening Terminal, navigating to the right directory, and typing "rebol script.r" every time I wanted to run my script. This post contained my solution. It describes how to open the current folder you're looking at in Finder in the Terminal, but the same principals worked for my problem. 

I created a workflow in Automator with a single "Run Applescript" step. Basically, the Applescript ended up looking like this.
on run {input, parameters} 
 tell application "Terminal"
activate
tell window 1
do script "rebol ~/REBOL/var/script.r"
end tell
end tell

return input
end run
Voila, I exported the workflow as an application via "Save As..." in the file menu in Automator, and running the program opened Terminal and launched my script. Problem solved. It's not the cleanest solution, but it works.

This is applicable to any script you want to run. Python, Ruby, REBOL, whatever you want. You could specify anything in the "do script..." line. You could even whip together an app that prompts you for what script you want to run, and then passes it in as a variable to the Run Applescript step in the workflow. The possibilities abound.

04 June, 2008

Blog Post Date

Here's a little program I wrote a few weeks ago. It's still beta, maybe still alpha, and I'm working out the kinks. Pretty much, you enter the URLs of your blog(s) at the top of the script, and it scrapes out the blog title and the date of your last post. Judging by the screenshot, I don't post very often.

I wrote it because I wanted one place I could look to see if it was time to post again, and in some cases, how egregiously vacant I can be at times. What do you think? Is this useful? What are your thoughts?

20 March, 2008

Calculating Image Aspect Ratios

Ever wonder how programs like Photoshop or The GIMP calculate image aspect ratios? No? Me neither. But, I was recently tasked with crunching such numbers, and I found the answer to be quite interesting. One thing I really hate is when somebody has incorrectly specified the height and width properties of an image. It's always too tall or too wide, and looks quite atrocious. In the past, I've just opened up The GIMP real quick, created a blank image the size of my original, and then used the Scale Image function to see my new dimensions. Now, thanks to my newly-acquired knowledge, I won't have to go through all that rigamarole. 

Basically, it's a simple math formula:

The product of the means is equal to the product of the extremes.
Where b and c are the means, and a and d are the extremes.

So (b * c) / a = d, or
(768 * 800) / 1024 = 600 

In the example above, all the black numbers are known. You know the dimensions of your original image (1024x768), and you know your desired width (800). We only need to calculate the desired height (600). This simple formula works with basic 4:3 ratios like the example above, but also works on any ratio you give it:
(720 * 467) / 1080 = 311
(with a little rounding)

I haven't explained the formula in its original algebraic format, simply because it makes more sense to me this way. Sorry, math purists! 

So, even though I can do these ratios with just a calculator, a friend (who wishes to remain anonymous) and I created a simple REBOL function and then a GUI version that does all the work for you. You can download those here (Right-click, "Save As..." to download the scripts):
If you use and/or like these scripts, let me know; I always like feedback.

13 June, 2005

REBOL/View 1.3

YES! It's finally here! REBOL/View 1.3 has been released! They've added a bunch of cool stuff. I think my favorite thing is the new AGG (Anti-Grain Graphics) draw dialect. You can do soooo much cool stuff with it. I haven't done much with it yet but, believe me; I will. They have made some changes on the Desktop too. It handles a little better now.

They currently only have 1.3 for Windows XP. The Mac and Linux versions should come soon. Check it out!

See it here

15 December, 2004

It continues...

Well, a new day begins. Nothing exciting happening today. Oh well. Anyway, on to REBOL. I
must make clear before going any further that it's pronounced like "rebel" not "reebol". As I said yesterday, you should look at http://www.rebol.com and read all about it. I haven't tried any other languages but, from what I've heard it's really good for a lot of things compared to other languages. If you want to buy a book on REBOL, there are only two in english at this point. One is the "Official Guide to REBOL" and the other is "REBOL for Dummies". There is at least one other book also but, it's in french. (if you're from France or speak french, check out
http://www.rebolfrance.com) I haven't read the "REBOL for Dummies" book yet and I am working on the "Official Guide" at the moment. I am also working on starting a rebsite (REBOL website) for the very very beginning people. If I get it up and running I'll post the link on here so you can look at that if you are interested. Now, don't go getting the impression that I'm a REBOL master or anything. I am quite the opposite. You can ask me all the questions you want and I'll try to answer them, but no garunteees.
Changing the subject. Does anyone know of a cheap or free HTML generator? Something like
Frontpage or Dreamweaver but, a lot cheaper. There is no way I could afford either of the above. I really want to make an actual website but, I've tried HTML and well, quite frankly, I don't like it. Too many unnecessary tags and, well I'm not going to go through everything I don't like about it. Anyway, if you know of somewhere I could download or purchase something like this please let me know. It would be much appreciated. The download couldn't be too big though. (stupid dial-up) Changing the subject again. Is anyone an Oingo Boingo fan? As I write this "Good for your Soul" is playing in the backround. Some of you might think I'm a little weird but, I really like 'em. Danny Elfman is incredible. He's written too many soundtracks to count. He also wrote all the music for "The Nightmare After Christmas". Incase any of you haven't seen it, it's the stop-motion animation. You know where they have to take 24 pictures for every second of film? Insane. He's also the singing voice of Jack in that too. Amazing. I am very compatible in my music listening ability. Sometimes I listen to classical piano, sometimes opera (very rarely), rock, Oingo Boingo (they don't classify as any of the above.), and everything inbetween. The only thing I probably never listen to would be rap. I just can't stand the stuff.
Once again, the subject is changing. :) Have you read "Eragon" by Christopher Paolini? If you picked it up at the library once and then set it back down because of the dust jacket quote,
you made a big mistake. The liner notes don't make it sound very good but it's incredible. It's
book one in the Inheritance Series. It's going to be a trilogy. If you are at all interested you
should check the book out at the library and look at http://www.alagaesia.com. The amazing thing is he graduated from high school at fifteen and published his first book (Eragon) at nineteen! I'm pretty sure he's twenty-one now. That's kind of an inspiration for me. It show's me that I can do anything I want at any age. I guess I couldn't join a retirement home at thirty though so...
Well I guess that's all for now. Anyway, check REBOL out, listen to Oingo Boingo, read
"Eragon", and well, keep checking on this blog! :) Later!

09 December, 2004

In the beginning...

Well it's begun. This is the first entry in the blog of, well, me. But you can already see that so, let's move on. Okay. If anyone would like to criticize me on my blogging technique please do. I am completely brand new to this so, some advice would be much appreciated. I'm really in to computers. I like gaming even though I wouldn't be classified as a gamer, I'm learning programming in REBOL (for all of you who haven't heard of it, see below), I listen to all types of music (from rock to classical), I read lot of books (mostly science fiction/fantasy) and well, blog!

Anyway, about REBOL. You really should check it out if you are a programmer or would like to become one. You can look at
http://www.rebol.com and download the free version. You should also look at the X-Internet and IOS if you own a small buisness or something like one. It's another file transfer system besides all the FTP stuff. Even though there is no free version of that, you still might want to look into it.

Well I'd better get offline. (incredibly slow dial-up) As I said before, please criticize me all you want. I need it. Thanks in advance,
REBOLyte

 
 
Copyright © 2015 James Irwin.
Clear by BloggerThemes Design by Diovo.com, with serious alterations by the author.