Archive for 'development tools'

Textmate - check your JavaScript syntax

Following the previous post, we will see today how to check the syntax for JS.

In this case we will need a bundle wrote some time ago by Andrew Dupont here. (read the article , scroll down and download the bundle). 

Install the bundle.

In this moment you are almost good to go, as the bundle is set to run just as the previous PHP check syntax, when you save the file.

I say almost good to go, because there is an warning you get from ruby,  ”Insecure world writable dir”.
So open the Bundle Editor, find Javascript tools, click on the Quick Lint command and add a -W0 ( is a zero here ) after the ruby word, like this:

ruby -W0 “$TM_BUNDLE_SUPPORT/bin/quick_lint.rb”

capture-41
Close the Bundle Editor.

This is how it looks in action:
capture-31

That’s it.

Textmate - php syntax check

A nice “hidden” feature that Textmate has, is to check the syntax of the php files you are writing, and display a popup with the result.

How to do this?

Open Bundle Editor, search for the PHP bundle, scroll down until you find the Validate syntax command.

Edit the Save setting to Current File.

Now, depending on how you want, you can alter the Activation setting or not. I set it  the same as saving the file, so each time I save the file, it makes me the syntax check.

capture-11

Close the Bundle Editor.

From now on, each time you save, a syntax check will be done, and a popup will show you the result

Like below:

capture-21

That’s all.

testing mootools apps using rhino shell

As the guys form mozilla says “The JavaScript shell provides a simple way to run scripts in batch mode or an interactive environment for exploratory programming.”
So basically you can create some tests for you app based on javascript, without needing a browser, but using rhino.
With Mootools is a little complicated, as it needs a browser environment to run, and rhino does not provide this.
The solution for this is to simulate a browser.
A great work in this direction is made by John Resig, the guy behind jQuery, here.
Only that you will need to modify a little the script, to work with Mootools

add the following lines at the very end of the env.js script

var document = window.document;
window.Element = window.DOMElement;
window.navigator.platform = “MacPPC”;

window.navigator.platform can be any platform, I used this to reflect my platform.

How to setup svn with remote working copy - my big question

Everybody know SVN and “everybody” is using it. No doubt SVN is one of the best things that happend in the last time. but for a web developer, svn can be a little frustrating - at least for me.
Let me explain:
I am on a mac, a G4 one,so I cannot afford a MAMP running on my local machine. On the other hand, I use to let clients see in real time the evolution of their projects ( is a pretty good selling advantage , by the way ;) ) so that’s why I need a remote working copy. I want to have a version controlling system but with my working copy on this server, and of course, lazy how I am, without a terminal where to write lines for commit and so on. You get my point.
On the other hand, I like the way a ftp program “caches” my transactions so my editor does not freeze every time I hit ?+S.

How this can be done? How can i accomplish this?

I would like to hear a good and practical solutions for this.
The solution I found is a nice one( of course because is mine :D ), but is very very sloooooooooow.
I mount a ftp or sftp drive with the working folder on the server on my mac, and I declare here to be the working copy. So in this way, I have a remote live working environment, and a versioning control that helps to keep my work in one piece and forget about backups - well almost.
The only drawback is that the macfuse is very slow on mac so a commit or a simple update seems to take ages - but is a good excuse for a coffee, or another coffee, and another one…..

Do you have a better solution? I would really like to speedup the process, so please let me know your thoughts

Kroppr - image cropping widget for your site

Kroppr is an unobtrusive script that enhance any site that wants to offer an image cropping tool for his visitors.

Unlike other scripts, Kroppr is able to ROTATE, zoom and move the image in the real time without using plugins - flash or java. The actual picture crop is done after the user is satisfied with his settings. In this way, the load put on the server is minimised and also the visitor’s experience.

The installation  is also very simple , being enough to add a script tag in the header’s page, and a class to the image that makes the cropping subject. More info on the Kroppr page.

How to load ioncube loader without root access

Some of coders are doing a living from selling php scripts. Nothing new here. But to protect themselves from piracy they need to encode the php code, to prevent steal, unauthorized usage and so on.

This can be accomplished using various encoders, some strong , some weak that will give them a specific amount of security, depending on what each of them is doing, form simple obfuscation to byte encoding techniques.

Two major players are Zend Guard and Ioncube encoder.

If zend has a wider spread across the hosting companies, ioncube is not that lucky, and usually you have to make a ticket to support to load the ioncube loader for you ( with or without a fee). There are cases when this cannot be done, so you might be forced to try to load this by yourself.

This can be accomplished if the ini flag enable_dl is ON - a quick phpinfo() should reveal this to you.

If you are lucky, next step is to download the loaders from ioncube site, upload it to your server and point the browser to

http://yousite.com/path/ioncube-loader-helper.php?page=install-assistant

you will find something like this:

ioncube loader

create a php.ini in the folder you need to put encoded files

and add this line to it

if you have the loader in the same folder, path woud be “./” else use the folder where you put the loader.

now point your browser to

http://yousite.com/path/ioncube-loader-helper.php

and if all is ok you should have something like this:

ioncube loader

Pretty simple, no ticket to support and no waiting to be solved.

Os X - how to create links to scripts for dock or desktop

As I promised in the previous post, I will show you how to add any script or program run normally from command line to dock or desktop and run as any other application.

For this we will use Platypus.

Platypus “can be used to create native, flawlessly integrated Mac OS X applications from interpreted scripts. Supports shell scripts, Perl, Python, PHP, Ruby, Expect, Tcl, AppleScript”.

We will use today the shell script to start the synergy application presented in the previous post

First of all we need to create a script file, to launch the synergy application

#!/bin/sh

/Applications/synergy/synergys -f –config /Applications/synergy/synergy.conf

Save this as “run_server” into the synergy folder and make it executablecapture-1.png

If you did not downloaded yet platypus, do it and install it on your mac, then start it.

Complete the fields as necessary and choose another icon if you want to. An example of how to set the parameters are in the screenshot below

picture-3.png

Hit create , save the new created tool into Application folder and you should be set :)
This is a very basic example, but you can explore more as platypus is pretty powerfool.

Let me know your thoughts.

synergy 2 - redirect your mouse and keyboard the easy way

If you are a web developer you are forced to run multiple operating systems, to check your code and design in as many browsers as possible. Well, the main problem is the IE as it always do strange things….

This can be done using a virtual machine, or multiple computers. The first case can be done using some software like VMware, VirtualBox os VirtualPC.

The second case is when you have more than one computers.

If you are like me, which i have a G4 Mac, and an HP, i think the second solution is better, as for G4 only VirtualPC works, and is in emulated mode, not virtualised, so is way too slow.

Ok, so I setup my G4 in my front, the HP in the left, mouses close, and let’s work. Well, after some time (short time) I managed to mix mouses, type on the HP keyboard wondering why my mac is not working, and so on…so is not good.

After a small search on the internet a found Synergy 2. “Synergy lets you easily share a single mouse and keyboard between multiple computers with different operating systems, each with its own display, without special hardware. It’s intended for users with multiple computers on their desk since each system uses its own monitor(s).”

It is cross-platform so it can run on Os X, windows and linux.

You have to setup a server on one computer, a client on the other, or others, and you will be able to use the main’s computer mouse and keyboard on the other one.

For Os X is a a little hard to do this as you have to configure a file, and run the software form the terminal. In a next post I’ll show how to bring this on your applications folder as any other app, being able to add it to dock or make a link to it on the desktop.

So, after I downloaded the software I put it in my application folder, I downloaded the software for windows on my HP and installed it.

the configuration file is pretty simple, the instructions on the site and on the sample config are very clear, the only thing that need to be said is that, in the config file , on the hostname for os x you have to add a “.local”, so something like “powerbook.local”

below is my config file:

section: screens
mobilegarth:
powerbook.local:
end

section: links
mobilegarth:
right = powerbook.local
powerbook.local:
left = mobilegarth
end

section: aliases

end

section: options
switchDelay = 350
end

mobilegarth is the HP.

after this you need to start the terminal, and run

/Applications/synergy/synergys –config synergy.conf -f

the “-f” will keep the application in front, so you can see what messages it returns.

All this being set, go to windows computer, start the synergy client, put the server name “powerbook” in this case and this should be all.

Moving the mouse on the left side of the screen will trigger the switch , and your mouse and keyboard will work on the other computer, until you come back on the right side this time, to your main computer.

As i said before, in one of the next posts, i will show you how to setup a “shortcut” to run this as any other normal application, without the need of terminal.

Let me know your thoughts.

Textmate tricks- open ftp files in tabs,keybindings changes and codebrowser

After searching through editors for Os X, that can go as close as possible to Quanta, my former editor in linux, before I switched to mac, and not founding anything close - or better said close to my habits - I finished choosing 3 editors - Coda, skEdit, and TextMate.

Coda is nice, but I miss auto-completion, as I was used with , skEdit does a really good job, but I miss a codebrowser panel , and again the auto-completion.

Well, now it comes TextMate.

I wanted for it a codebrowser - i need to see my functions, classes and variables - so i used this plugin TmCodeBrowser . Is not a real panel, but I moved it to the right side of the screen, set normal panel and visible on launch, resized the main window until it touch the edge of codebrowser, and seems ok.

What was very unpleasant for me, was that without a project, files were opening in individual windows. I like my desktop clear, so a file tabs solution would be nice. To fix this, in conjunction with using an external ftp manager - I use ForkLift - I had to create a project, and set to it the folder used by ForkLift to cache it’s files

~/Library/Caches/com.binarynights.ForkLift/

save the project, and take care to have it opened before opening a remote file.

Another thing was the autocomplete feature TextMate it has. I would like to have a classical dropdown, but i think this is the way it reach the speed it has in presenting a suggestion. For a >7000 lines source code, on my G4, other apps become slow, so I get used with this behaviour. What I did not get used with is that key Esc is binded to do operation. Is far, is small and almost always i was pressing the ` key. So I edited the

/Applications/TextMate.app/Contents/Resources/KeyBindings.dict - don’t forget to back-up -

and added this line -

“~ ” = “nextCompletion:”;

that means alt(option) key with spacebar will perform the completion.

I am sure lot of other tricks exist to make TextMate an easier and more pleasant companion for new users of mac, so if you know some, please share.

Thanks.

web development on OS X

There is some long time since i posted, but i had a very limited time in last month. Meanwhile I managed to buy myself a mac, I always wanted one. So now i’m in a little kind of dilema. What tools to use for webdeveloping ?

My area is PHP, Javascript - Mootools at most, xhtml,CSS, and some design.

So, for design part, I choosed CS2, for the server side I choosed MAMP - for windows users is almost the same with WAMP, it installs php,apache with a mouse click..(well, almost), for ftp I use ForkLift which is pretty close to Krusader, even with less, lot less features

But, the main problem for me remains the editor.

I come from linux world, where I spent a lot of time…so Quanta is what I really miss, with Krusader as file manager, and all the little add-ons like Kdiff for example, that allowed me to make some operations in a very easy and time productive way.

I have tried lot of editors

Textmate - all the people say it rocks, but i did not manage to find a code browser for it, or i did - some extention, but did not like’it. And autocomplete I had to press escape several times until i get what i need, instead of opening a dropdown near the cursor, too choose from. Maybe if any of you know how to do this, or knows a good “noob” tutorial for textmate, it will convince me.

I tried others like Smultron, Webscripter, KomodoEdit - which is pretty nice, but is too much resources eater - my mac is a g4, 1.33 -, Aptana, same problem as KomodoEdit,and some others i don’t remember right now

What i choosed are skEdit, and Coda, but i like skEdit more, as is less heavy for the system than Coda.

Maybe a more experimented mac user, can suggest a better setup, for people like me, who are trying to use a mac fr web development.

Thanks