|
|
|
Sunday, 08 January 2012 11:56 |
require 'zip/zip'
require 'zip/zipfilesystem'
include Zip
def compress(ppath)
ppath.sub!(%r[/$],'')
archive = File.join('./',File.basename(ppath))+'.zip'
FileUtils.rm archive, :force=>true
Zip::ZipFile.open(archive, 'w') do |zipfile|
Dir["#{ppath}/**/**"].reject{|f|f==archive}.each do |file|
zipfile.add(file.sub(ppath+'/',''),file)
end
end
end
# usage
temp = "./some_folder"
begin
compress(temp) # pack folder
FileUtils.remove_dir(temp,true) # remove non empty folder, which is packed
end
 Read more: |
|
|
Monday, 19 December 2011 01:00 |
Trim: remove whitespace from the start and end(both sides) of the string.
LTrim: remove start whitespace of the string.
RTrim: remove end whitespace of the string.
Rather than using a clumsy loop, use a simple, elegant regular expression.
String.prototype.trim = function() {
return this.replace(/^\s+|\s+$/g,"");
}
String.prototype.ltrim = function() {
return this.replace(/^\s+/,"");
}
String.prototype.rtrim = function() {
return this.replace(/\s+$/,"");
}
Example:-
// example of using trim, ltrim, and rtrim
var myString = " hello my name is imdadhusen ";
alert("*"+myString.trim()+"*");
alert("*"+myString.ltrim()+"*");
alert("*"+myString.rtrim()+"*");
 Read more: |
|
Thursday, 15 December 2011 00:24 |
Remove any image that is contained within a link will be given large blue border
this will automatically remove borders from every hyperlink from entire page, if it contains image inside.
 Read more: |
|
|
Tuesday, 21 September 2010 07:00 |
 | About Absolute Shisen-Sho
A traditional Chinese game whose origins have been lost in the mists of time, but is said to have been inspired by Mahjong. The principle of the game is simple enough: you have a grid of tiles arranged on a wooden board; your goal is to match pairs of tiles and remove them all… the catch, is that you can only remove a pair of tiles if they can be connected by a vertical or horizontal line with no more than two 90-degree bends.
These simple rules have entranced people the world over. To avoid frustration when no more moves are possible, Absolute Shisen-Sho also gives you some super powers to use when you are stuck: Zap will remove a random pair of tiles; Cheat will remove any pair you select, even if you couldn’t normally remove it; and Hint will find a pair (if any remain). |
Read more: |
|
Friday, 27 August 2010 07:00 |
 | About PegIt
A unique and challenging logic puzzle game. Originally inspired by the classic board game “Peg Solitaire.” The object of the Peg Solitaire game is to remove all the Pegs by jumping one peg over another. In this game, the Pegs are replaced with little yellow-haired people known as “PegIts”. The PegIts can leapfrog over each other, use Trampolines, Springboards, Teleports, and all manner of crazy objects to remove each other from the game! |
Read more: |
|
|
|
|
|
|
|