Ubuntu 10.4: How to place the window close button on the right again

Ubuntu 10.4 is live. I’ve been using Ubuntu for around 4 to 5 years, and I am a pretty happy user.

From my point of view, the big problem I found on this release (which I just installed 5 minutes ago) is that they changed the window buttons from the right to the left side of the window. I think 95% of the users are used to the buttons on the right side, and I don’t see the point on moving them to the left.

Anyway, I don’t like it, so I searched around, and I’ve found a quick and easy solution.

Press Alt+F2, then type gconf-editor and press enter. That’s for opening the configuration editor.

Once on this editor, in the item tree at the left, you have to look for this path  app -> metacity -> general and you doubleclick on the field named  button_layout.

Then, you have only to change the value field and put this:

menu:minimize,maximize,close

You save the changes, and voila!! all the windows reconfigured again!

Now all the windows show the minimize, maximize and close buttons on the right again ;)


http_build_query implemented in Python

I implemented a function in Python that mimics http_build_query function.

##
# Mimics the behaviour of http_build_query PHP function
# This method can be useful for sending data to flash applications
##################################################
def http_build_query(params, topkey = ''):
  from urllib import quote
 
  if len(params) == 0:
    return ""
 
  result = ""
 
  # is a dictionary?
  if type (params) is dict:
    for key in params.keys():
      newkey = quote (key)
      if topkey != '':
        newkey = topkey + quote('[' + key + ']')
 
      if type(params[key]) is dict:
        result += http_build_query (params[key], newkey)
 
      elif type(params[key]) is list:
        i = 0
        for val in params[key]:
          result += newkey + quote('[' + str(i) + ']') + "=" + quote(str(val)) + "&"
          i = i + 1
 
      # boolean should have special treatment as well
      elif type(params[key]) is bool:
        result += newkey + "=" + quote (str(int(params[key]))) + "&"
 
      # assume string (integers and floats work well)
      else:
        result += newkey + "=" + quote (str(params[key])) + "&"
 
  # remove the last '&'
  if (result) and (topkey == '') and (result[-1] == '&'):
    result = result[:-1]
 
  return result

If you find the code useful, feel free to use it in any kind of software product, be it commercial or not :)

, ,

Manso Trick: Detect the Operating System in PHP

There could be a lot of reasons to detect the OS in PHP, and I’m pretty aware that these reasons could open a discussion by themselves. Anyway, it could be useful to do some tweaks or optimizations, to run one commands or anothers, or simply  it can be useful as additional information for webmasters, developers or operations department.

Anyway, we are all grown ups, so you know what you are doing. Now, imagine you need to know this. There are several ways (the more creative you are, the more ways you will find). The first way, and most simple and complete, is by using the php_uname function. The php_uname is similar to the unix command uname, and with this function we can know the  operating system, the version of the OS, the release number, the host name, and the hardware architecture  (i386, amd64, …). It has all that you need ;)

On the other hand, if you don’t want to use this pretty command, you can directly use the PHP_OS constant, which only includes the operating system name, but in most cases will be enough (it is equivalent to call php_uname(‘s’)).

Now you can try these two examples:

echo php_uname() . "\n";
echo PHP_OS . "\n";

The funny thing is that probably you would never need to know the OS, so you can skip the whole post :P

, , ,

Uploading a stalled file using scp

If you were copying/uploading a file using SCP, and the connection got lost… bad news, you cannot continue uploading it using SCP. This command will upload it again from the beginning, so if the file was 2GB, and you already uploaded 1 and a half gigs, you are f***… in trouble

The good news is that there is a “trick” to continue uploading, the trick is named rsync:

rsync -rsh=ssh --partial --progress <src-path> <dest-path>

or, the short format:

rsync -rsh=ssh -P <src-path> <dest-path>

Hope you find it useful, as I did ;)

, ,

Photoshop: Content-Aware Fill

Impressive video about one of the coming features of photoshow, with just a click of the mouse.

You can go directly to the minute 2:50 to watch how it removes a tree out of the scene in just a click.

It is amazing the things that can be done…

Seen at John Nack on Adobe

,

[SOLVED] Uploadify and session problems

Uploadify is a wonderful plugin for jQuery that allows you to upload several files at once,  it does the uploads transparently  using flash (take a look at the demo on this link).

In fact, the great advantage I see is not to be able to upload several files at once, this can be done by javascript with no extra plugins, the great advantage is the progress bar it shows to the user, which is great for obvious usability reasons (user looking a screen where nothing happens… not good :p).

Apart of uploading files, you can also upload any other variables or data (take a look to scriptData). This can be really useful if you want, for example,to send the data in another form at the same time a file is being uploaded.

The great disadvantage of uploadify, is that each file is sent in a separate request. This means that if you are uplading 30 files, each file is sent in a separate HTTP request. Please note that the problem here is not the speed, because you can easily make uploadify sends several files at once, in parallel, the problem appears if you have to send form data on the first request only… The fact that are different requests makes things a little more difficult to handle on the server, but anyway, this only happens on specific cases…

Anyway, I recently used uploadify in a project where users should be logged in, in order to upload files. The thing is, when I first tried uploadify, it didn’t work… files were being apparently uploaded, but they were not stored in the server. I tried again and again, and the same problem… Finally I discovered why.

Uploadify does not send cookies, and because of that, it cannot send session information on the request, so the server does not know that the user sending the files is registered, it thinks it’s an annonymous user. The good thing, is that once I realiced what was the problem, the solution was quite simple.

The solution to keep the session using uploadify is the same as when the client cannot store cookies. Basically is just adding session name and identifier at the end of the URL, as a GET request.

In PHP, adding session to the URL would be something like:

$url = $url . '?' . session_name() . '=' . session_id();

Once I did that, the application was working with uploadify ;)

, , , ,

New web for playing Flash games

I’ve been thinking of making a games website for a while. I’ve finally decided to go ahead and do a website with Flash games.

The truth is, that lately I’ve been really busy with lots of things that have nothing to do with games, but this Saturday I needed to disconnect and  work on something totally different (to dissestress myself :p), so I though on a challenge.  I told myself: “Let’s see if I am able to do a complete website of games before the end of the weekend”

I’m proud to announce NextGameGen, the new website where you can play tons of games for FREE.

I’ve made myself the whole website (even the part that upload and introduces games in the system) between Saturday and Sunday. I dedicated 4 hours on Saturday afternoon, 4 hours on Sunday morning, and 8 hours on Sunday afternoon/night. Quite intensive programming session ;)

The truth is that I’m very happy with the result. In just 16 hours a complete website of games from scratch. I only dedicated 45 minutes extra today, to add a couple of buttons to allow Sharing games in Facebook, twitter & friends, add some ads and fixing  a couple of bugs.

I know there are things that can be improved, and that there are a couple of bugs (invisible to the human eye), but the website is fully functional, so if you want, you can play right now!

The site even recommends some games according to the game you are playing to (although the algorithm is far from being perfect right now).

Now its time to grow the visits of the website. I’m planning to use ShareUsers, which is a FREE service to do automatic link exchange, and to get lots and lots of free traffic from different webs (more about this in another post).

That’s all I have to say. You can try and play some nice games, and I’m here waiting from any feedback or criticism about the games web ;)

, , , ,

MansoGrover: difference between FIXME and TODO

Hello there, this is your old pal Grover, and today I’m going to talk to you about the difference between a FIXME and a TODO in a comment.

  • FIXME: should be used when is a hack, a hardcoded constant, variable, function or something critical, and something that should be removed before the next release. Usually FIXMEs are used to do a fast prototyping, or to move forward in the software product.
  • TODO: should be used when explaining some improvments or when you have to do a (usually complex) change, or you are too lazy to do it in that particular moment.

Remember, if it is something critical, and the software could not be released without that code or fix, then use a FIXME; on the other hand, if the change will not affect the proper behaviour of the program, and you are comfortable in leaving the code as it is, then use TODO.

, ,

Click effect for jQuery

Today I’ve been playing for a while with javascript. The truth is that I haven’t found what I was looking for, but let’s assume that this is because I’m a programmer and not a designer.

Anyway, what I was trying to do is to create some kind of click effect. Ok, let me try again. What I wanted to do, is that when someone clicked on a link, that some kind of circle/rectangle/whatever expanded disappearing. Let’s try with an example. Have you seen those TV ads for games for the Wii? At the beginning there are like three or four circles that disappear. Something like that, but less sophisticate is what I wanted to do.

After trying several things, even after playing with images, I come up with a solution that is quite aproximated, although still needs something extra I don’t know how to do.

The example has two interesting parts.

The first part is where the effect is associated to the elements of class ‘clickable-round’. When you click on any ‘clickable-round’ element, a circle will appear and diffuminate:

$('.clickable-round').click (function (event) {
 $(event.currentTarget).jSimulateClick (event.pageX - 1, event.pageY - 1, 'round');
});

The other interesting fragment associated the event to the elements that contain the class ‘clickable-square’. When you click on any of those elements, the effect will be quite similar to the previous one, but instead of drawing a circle, a square that will go from one pixel to the width and height of the clicked object will appear.

$('.clickable-square').click (function (event) {
  $(event.currentTarget).jSimulateClick (event.pageX - 1, event.pageY - 1);
});

If you want to play with the plugin, my advice is that you start playing with the border width, border color, the duration, or even the size of the circle/rectangle…

You can use this javascript for any personal or commercial application, or do whatever you want with it.

Finally, I would appreciate any comment for improving the effect.

, , ,

jQuery 1.4.1 is out

Some weeks after the release of jQuery 1.4, now the first bug fix release for this fantastic javascript framework is out.

The new version fixes several bugs, and includes some improvements.

Download jQuery 1.4.1 and have a look at the release notes.


prev posts prev posts