Found today the resource ajaxload.info, you can generate your custom ajaxload spinners there.
The guys did pretty well I should say. There are lots of patterns, you can choose a transparent background and custom colors.
Nice stuff.
Wednesday, April 16, 2008
Tuesday, April 15, 2008
Displaying GIT Branch Name In Your Console
So, if you had been taken the gateway drug of GIT recently, then you probably feel the sake of branches and there's a little trick for you dear fellow.
Put (or change) the following stings in your ~/.bashrc file and you'll get a nice enhancement on your console prompt which will show your current git-branch when you're in a directory which is under git.
This is quite handy when you use the branches feature actively.
Put (or change) the following stings in your ~/.bashrc file and you'll get a nice enhancement on your console prompt which will show your current git-branch when you're in a directory which is under git.
function git_branch {
git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/(\1) /'
}
PS1='\[\033[0;37m\][\[\033[01;36m\]\W\[\033[0;37m\]] \[\033[0;32m\]$(git_branch)\[\033[00m\]\$ '
This is quite handy when you use the branches feature actively.
Sunday, April 13, 2008
Rescue data from a reiserfs partition
Couple of days ago, I met a situation, when my /home partition, which was on reiserfs filesystem, all the sudden, got dead. It was not able to restore the partition with reiserfs utils, it didn't want to mount anymore, info said there only 563 Kb of 60 Gb data left. Not good.
I've spent a day rescuing the data, and managed to get back 99% of it (i belive), so now I share the experience.
The rule number one in such a situation is to calm down. Sit down, take a blank sheet of paper, a pencil and then in a nice friendly characters write the phrase "DON'T PANIC".
I'm serious, it's pretty easy to get jumpy and overreactive when "all of yours" suddenly getting disappeared. And surrely it's easy to broke something down completely. So, don't touch anything until you get back to the cool consciousness.
The second thing you need, is a complete copy of your damaged partition. For that you'll need another free partition with exact same size. If you have such space on another hard drive, create it there, or think about baying another one.
Once you have your new partition for the backup. You need to boot up on some kind of live-cd with a linux environment. I've used the ubuntu 7.10 live-cd, it's quite handy, understand most of the modern hardware, contains the gparted util, have a web-browser etc. So it's stuffed pretty good for our purpose.
When you have your live cd booted up, you may copy the partitions. There's a builtin prgramm called 'dd', which allows you to copy block devices byte by byte, one to another. So you run it like that.
Where the '/dev/old' and '/dev/new' are your damaged and backup partitions. The optional attribute 'conv=noerror' tells the commad to skip reading errors.
Optionally you may unlock the 'universe' repository and install the 'dd_rescue' prgramm, which I belive, a wrapper for the 'dd' command and provides some more resuce oriended functionality.
The main point is to create an exact copy of the aviable data from the damaged partition.
And note, depends on the conditions, this may take quite a long time. My 60G partition was copied in about 7 hours.
That's it. Once you have a copy block. You run the 'reiserfsck' on the _copy_ partition like that.
Note the '-S' option. This tells the reiserfsck programm to scan the whole partition for the aviable data. It's important, don't miss it up.
This operation usually is quite fast. Depends on the size of your data, and its condition this will take some minutes.
After the reiserfsck pargamm have finished, mount your new partition and take a look how is it going. If your partition was not damaged too hard, most of the data and directories structure will be on the right places. And there will be the 'lost+found' directory, take a look in it too, there will be lots of directories and subdirectories named with numbers. The util put there the files which were recovered but which former place was not found. And you may find there some files which you have deleted recently. So browse throw the directories, you may find some valuable data there too.
This is pretty much it. In really it's qute a simple stuff. Just don't get scary, some bad blocks on your hard drive is not a big problem, most of your data usually safe untill the harddrive any-working.
I've spent a day rescuing the data, and managed to get back 99% of it (i belive), so now I share the experience.
The rule number one in such a situation is to calm down. Sit down, take a blank sheet of paper, a pencil and then in a nice friendly characters write the phrase "DON'T PANIC".
I'm serious, it's pretty easy to get jumpy and overreactive when "all of yours" suddenly getting disappeared. And surrely it's easy to broke something down completely. So, don't touch anything until you get back to the cool consciousness.
The second thing you need, is a complete copy of your damaged partition. For that you'll need another free partition with exact same size. If you have such space on another hard drive, create it there, or think about baying another one.
Once you have your new partition for the backup. You need to boot up on some kind of live-cd with a linux environment. I've used the ubuntu 7.10 live-cd, it's quite handy, understand most of the modern hardware, contains the gparted util, have a web-browser etc. So it's stuffed pretty good for our purpose.
When you have your live cd booted up, you may copy the partitions. There's a builtin prgramm called 'dd', which allows you to copy block devices byte by byte, one to another. So you run it like that.
$ sudo dd conv=noerror if=/dev/old of=/dev/new
Where the '/dev/old' and '/dev/new' are your damaged and backup partitions. The optional attribute 'conv=noerror' tells the commad to skip reading errors.
Optionally you may unlock the 'universe' repository and install the 'dd_rescue' prgramm, which I belive, a wrapper for the 'dd' command and provides some more resuce oriended functionality.
The main point is to create an exact copy of the aviable data from the damaged partition.
And note, depends on the conditions, this may take quite a long time. My 60G partition was copied in about 7 hours.
That's it. Once you have a copy block. You run the 'reiserfsck' on the _copy_ partition like that.
$ sudo reiserfsck --rebuild-tree -S /dev/new
Note the '-S' option. This tells the reiserfsck programm to scan the whole partition for the aviable data. It's important, don't miss it up.
This operation usually is quite fast. Depends on the size of your data, and its condition this will take some minutes.
After the reiserfsck pargamm have finished, mount your new partition and take a look how is it going. If your partition was not damaged too hard, most of the data and directories structure will be on the right places. And there will be the 'lost+found' directory, take a look in it too, there will be lots of directories and subdirectories named with numbers. The util put there the files which were recovered but which former place was not found. And you may find there some files which you have deleted recently. So browse throw the directories, you may find some valuable data there too.
This is pretty much it. In really it's qute a simple stuff. Just don't get scary, some bad blocks on your hard drive is not a big problem, most of your data usually safe untill the harddrive any-working.
Sunday, April 6, 2008
Wish that thing in Ruby
class Array
def ||<<(i)
<< i unless include? i
end
end
Think, that would be logically appropriate, in similar to the ||= operation
Sunday, March 30, 2008
Idea about restful_authentication plugin
If you're using the restful_authentication plugin with your rails projects, there's a simple idea which might be interesting to you.
Idea as I said pretty simple. Rename the users_controller which the plugin generates to profiles_controller, and sequentially change the routes declaration
The reason is simple as well. With the controller you actually manage the user's profile (the registration process for example), not the users collection in really. For administration purposes you may need more standard CRUD controller for the User unit later. And you will extend the existing controller, then you may run into some ugly constructions in it pretty soon.
But with such a simple renaming you'll keep the things more clear and reusable.
Idea as I said pretty simple. Rename the users_controller which the plugin generates to profiles_controller, and sequentially change the routes declaration
# from
map.resources :users
# to
map.resource :profile
The reason is simple as well. With the controller you actually manage the user's profile (the registration process for example), not the users collection in really. For administration purposes you may need more standard CRUD controller for the User unit later. And you will extend the existing controller, then you may run into some ugly constructions in it pretty soon.
But with such a simple renaming you'll keep the things more clear and reusable.
Tuesday, March 25, 2008
Another Work Is Done
With love and proud another piece of work been done and now on the air.
Met http://www.redstarpoker.com! Some pretty basic but loverly done rails work.
And don't blame me on the main menu with images, that's all the communists, they like such stuffs.
Met http://www.redstarpoker.com! Some pretty basic but loverly done rails work.
And don't blame me on the main menu with images, that's all the communists, they like such stuffs.
Monday, March 24, 2008
Creating element event handlers with RJS
If you're working with rails and ajax you probably familiar with the
So, that's cool. But sometimes you might want to use RJS to write some events handling for say a form element. For example you've got a select box which switches different blocks on/off depends on what you choose and you need to wire the 'onchange' event with some logic. In a such case you can pass the :onchange value of the html_options argument in the 'select' helper method. The problem is that it applies a string, not a block where you can put in your RJS stuffs.
And the problem is solvable. There's another helper method which actually applies a block of rjs code and returns a string of compiled javascript code. It's name
it's a little bit hacky, I've used this 'page << ' stuff and it's not probably a good rjs example. But I want to show the idea only. Whenever you need a javascript string and wish to write it in RJS, you can use the 'update_page' method and have it on.
link_to_function helper. And especially with its ability to apply a block where you can put some RJS code. Sometimes it's pretty handy. Especially if you're not much javascript guru or just don't want to get dirty with it.So, that's cool. But sometimes you might want to use RJS to write some events handling for say a form element. For example you've got a select box which switches different blocks on/off depends on what you choose and you need to wire the 'onchange' event with some logic. In a such case you can pass the :onchange value of the html_options argument in the 'select' helper method. The problem is that it applies a string, not a block where you can put in your RJS stuffs.
And the problem is solvable. There's another helper method which actually applies a block of rjs code and returns a string of compiled javascript code. It's name
update_page. The link_to_function method calls it internally. For example you want to switch some blocks depend on a chosen language. This might look like that.
<%= select nil, nil, Language.to_options, {}, :onchange => update_page{ |page|
Language.all.each do |lang|
page << %{$("block-in-langage-#{lang.id}")[this.value == '#{lang.id}' ? 'show' : 'hide']();}
end
} %>
it's a little bit hacky, I've used this 'page << ' stuff and it's not probably a good rjs example. But I want to show the idea only. Whenever you need a javascript string and wish to write it in RJS, you can use the 'update_page' method and have it on.
Subscribe to:
Posts (Atom)