Archive

Archive for the ‘snippet’ Category

`gem_original_require’: no such file to load — zlib (LoadError)

January 28th, 2012 No comments

You may have faced a such a error, when trying to execute gem list :

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
//lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require': no such file to load -- zlib (LoadError)
	from //lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `require'
	from //lib/ruby/site_ruby/1.8/rubygems/spec_fetcher.rb:1
	from //lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require'
	from //lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `require'
	from //lib/ruby/site_ruby/1.8/rubygems/commands/query_command.rb:3
	from //lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require'
	from //lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `require'
	from //lib/ruby/site_ruby/1.8/rubygems/commands/list_command.rb:2
	from //lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require'
	from //lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `require'
	from //lib/ruby/site_ruby/1.8/rubygems/command_manager.rb:167:in `load_and_instantiate'
	from //lib/ruby/site_ruby/1.8/rubygems/command_manager.rb:88:in `[]'
	from //lib/ruby/site_ruby/1.8/rubygems/command_manager.rb:144:in `find_command'
	from //lib/ruby/site_ruby/1.8/rubygems/command_manager.rb:131:in `process_args'
	from //lib/ruby/site_ruby/1.8/rubygems/command_manager.rb:102:in `run'
	from //lib/ruby/site_ruby/1.8/rubygems/gem_runner.rb:58:in `run'
	from /bin/gem:21

To solve this issue, move to the zlib/ folder, it should be something like this /usr/src/ruby-1.8.6-pXXX/ext/zlib/

execute the extconf.rb :

1
root@xen1:/usr/src/ruby-1.8.6-p398/ext/zlib# ruby extconf.rb

If every things are ok, you should see:

1
2
3
4
checking for deflateReset() in -lz... yes
checking for zlib.h... yes
checking for kind of operating system... Unix
creating Makefile

compile and deploy zlib by runnning both commands:

1
2
sudo make 
sudo make install

Make sure gem command is woking:

1
gem list

You should see:

1
*** LOCAL GEMS ***
Categories: how-to, snippet, Tips & Tricks Tags: , , ,

How to recursively delete .svn directories

April 20th, 2011 No comments

Just move to the directory where you want to delete, recursively, the .svn directories and type the folowing line:

rm -rf `find  . -type d -name .svn`
Categories: how-to, snippet, Tips & Tricks Tags: , ,

GTalk: Text Formatting; bold, italic and strikethrough.

July 21st, 2009 2 comments

To have more fun with GTalk (Google Talk) you can add some text formatting :
Gtalk

  • to make it bold, simply use * * (asterisk) between the text that intended to be bold in font style : i.e. *marouan* is rendred as marouan.
  • to make it italic, simply use _ _ (underscore) between the text that intended to be italic in font style: i.e. _marouan_ is rendred as marouan.
  • to make it strikethrough, simply use – - (dash) between the text that intended to be strikethrough in font style: i.e. -marouan- is rendred as marouan.

This is a stupid post but if you are addicted to Google Talk, like me, you will have more fun with GTalk using those few styling tips.

Replacing special Chars in a String c#

June 14th, 2009 No comments

I have been working on a c# french desktop application. Unfortunately iTextSharp, which is an open source java library for PDF generation written entirely in C# for the .NET platform, do not allow to print special chars (é, è, ç …etc.) properly.

Happily, I found this very useful piece of code in the Internet and I want to share it with you:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
/// <summary>
/// Delete all Accents
/// </summary>
/// <param name="txt">Source String with accents and special Char</param>
/// <returns>Source String without accents and special Char</returns>
        private static string DeleteAccentAndSpecialsChar(string OriginalText)
        {
            string strTemp = OriginalText;
            // Regex creation
            Regex regA = new Regex("[ã|à|â|ä|á|å]");
            Regex regAA = new Regex("[Ã|À|Â|Ä|Á|Å]");
            Regex regE = new Regex("[é|è|ê|ë]");
            Regex regEE = new Regex("[É|È|Ê|Ë]");
            Regex regI = new Regex("[í|ì|î|ï]");
            Regex regII = new Regex("[Í|Ì|Î|Ï]");
            Regex regO = new Regex("[õ|ò|ó|ô|ö]");
            Regex regOO = new Regex("[Õ|Ó|Ò|Ô|Ö]");
            Regex regU = new Regex("[ù|ú|û|ü|µ]");
            Regex regUU = new Regex("[Ü|Ú|Ù|Û]");
            Regex regY = new Regex("[ý|ÿ]");
            Regex regYY = new Regex("[Ý]");
            Regex regAE = new Regex("[æ]");
            Regex regAEAE = new Regex("[Æ]");
            Regex regOE = new Regex("[œ]");
            Regex regOEOE = new Regex("[Œ]");
            Regex regC = new Regex("[ç]");
            Regex regCC = new Regex("[Ç]");
            Regex regDD = new Regex("[Ð]");
            Regex regN = new Regex("[ñ]");
            Regex regNN = new Regex("[Ñ]");
            Regex regS = new Regex("[š]");
            Regex regSS = new Regex("[Š]");
            strTemp = regA.Replace(strTemp, "a");
            strTemp = regAA.Replace(strTemp, "A");
            strTemp = regE.Replace(strTemp, "e");
            strTemp = regEE.Replace(strTemp, "E");
            strTemp = regI.Replace(strTemp, "i");
            strTemp = regII.Replace(strTemp, "I");
            strTemp = regO.Replace(strTemp, "o");
            strTemp = regOO.Replace(strTemp, "O");
            strTemp = regU.Replace(strTemp, "u");
            strTemp = regUU.Replace(strTemp, "U");
            strTemp = regY.Replace(strTemp, "y");
            strTemp = regYY.Replace(strTemp, "Y");
            strTemp = regAE.Replace(strTemp, "ae");
            strTemp = regAEAE.Replace(strTemp, "AE");
            strTemp = regOE.Replace(strTemp, "oe");
            strTemp = regOEOE.Replace(strTemp, "OE");
            strTemp = regC.Replace(strTemp, "c");
            strTemp = regCC.Replace(strTemp, "C");
            strTemp = regDD.Replace(strTemp, "D");
            strTemp = regN.Replace(strTemp, "n");
            strTemp = regNN.Replace(strTemp, "N");
            strTemp = regS.Replace(strTemp, "s");
            strTemp = regSS.Replace(strTemp, "S");
            return strTemp;
 
            return strTemp;
        }

Source : http://www.codyx.org/snippet_modifie-caracteres-speciaux_154.aspx
ps : Don’t forget to import RegularExpressions in your namespace.

1
using System.Text.RegularExpressions;
Categories: snippet Tags: , ,

How to remove the blue border around an image link

April 12th, 2009 No comments

[ad#only_in_post]

You want to use an image as a link.However, a blue border appears around the image.

1
2
3
<a href="http://www.myownpercept.com/">  
  <img src="logo.png" alt="" />
</a>

This border is meant to inform users that the image is a link. Well, it’s a link but this is ugly :s and may not fit your need.
[ad#hire_me]

Solution

  1. You simply have to add a border-style, set to none, as a style to your img tag
    1
    2
    3
    
    <a href="http://www.myownpercept.com/">
      <img style="border-style: none;" src="logo.png" alt="" />
    </a>
  2. A cleaner way, that will pass the W3C validation, is by adding those lines to your CSS file :
    1
    2
    3
    
    img {
    	border-style: none;
    }
  3. A dirty old way, but works, is by adding border attribute to the img tag.
    1
    2
    3
    
    <a href="http://www.myownpercept.com/">  
      <img src="logo.png" border="0" alt="" />
    </a>

Erlang Cheat Sheet

March 18th, 2009 7 comments

I am sharing here my Erlang Cheat Sheet after some lifting :) in order to make it more useful.
Certainly, it’s not an exhaustive list of Erlang commands.
I hope you will find it useful.
ps : If there is a mistake. Please report it and I will be very thankful.

[ad#only_in_post]
Suggestions / things to be added ? are very welcome.
Erlang CheatSheet

Download: Erlang - CheatSheet (1707)

  • Update 2009-03-28: Watermark have been removed.