Git-svn, an SVN client that works like Git
Who are using Git as the version control may face in a situation where there is no option but to use SVN. In that case you will have to learn SVN commands to continue. But the most important thing you are not getting the facility of using git over SVN. “git-svn” can help you in that case. Many of you who are using git may already know about it. But this post is for those who don’t know and for those who knows but haven’t tried till now. Here are the basic commands for manipulation:
– To install it run:
$ yum install git-svn
– To clone a repo just replace the “svn co”/”svn checkout” phrase with “git svn clone” phrase. e.g.
$ git svn clone http://path/to/trank [project-name]
or
$ git svn clone svn+ssh://path/to./trunk [project-name]
$ cd project-name
Now you can use all the git commands like you normally do for a git repository including git add, git rm, git checkout, git commit. One thing to notice, git commit will commit your changes a git does normally. But to commit it in SVN repository you have to use:
$ git svn dcommit
This will commit all of your commit(s) that you have done using git in SVN repo as separate SVN commit(s).
To update your local version with server run:
$ git svn rebase
So clone, rebase and commit – these are the three times that you need to interact with SVN repo. Other things before dcommit can be handled by your favorite GIT.
So have a try. Its really coooool!!
Installing Ruby On Rails in Fedora
Posted by jhalak in Linux, Ruby On Rail on June 16, 2011
After noticing the struggle to install Ruby on Rail in Fedora by some of my dear fellows near me and having a lot of push talk by our branch manager I am going to post the way that I used to install Ruby on Rails in Fedora. Of course you can find help online, but none of them are straight forward and many time you can fall in a situation like “now what to do” if you are a novice in ROR like me. (Actually I know the installation only. hehe…). Hope you find it useful.
# yum install rubygem-rails ruby-mysql =========================================================================================== Package Arch Version =========================================================================================== Installing: ruby-mysql i686 2.8-4.fc12 rubygem-rails noarch 1:2.3.4-2.fc12 Installing for dependencies: ruby-irb i686 1.8.6.399-6.fc12 ruby-rdoc i686 1.8.6.399-6.fc12 rubygem-actionmailer noarch 1:2.3.4-2.fc12 rubygem-actionpack noarch 1:2.3.4-3.fc12 rubygem-activerecord noarch 1:2.3.4-2.fc12 rubygem-activeresource noarch 1:2.3.4-2.fc12 rubygem-activesupport noarch 1:2.3.4-2.fc12 rubygem-rack noarch 1:1.0.0-3.fc12 rubygem-rake noarch 0.8.7-2.fc12 rubygems noarch 1.3.7-1.fc12 Transaction Summary ============================================================================================= Install 12 Package(s) # yum install rubygem-sqlite3-ruby # yum install rubygem-mongrel* # yum install rubygem-json ========================================================================================== Package Arch Version ========================================================================================== Installing: rubygem-json i686 1.1.7-3.fc12 Installing for dependencies: ruby-atk i686 0.19.4-1.fc12 ruby-cairo i686 1.10.0-3.fc12 ruby-gdkpixbuf2 i686 0.19.4-1.fc12 ruby-glib2 i686 0.19.4-1.fc12 ruby-gtk2 i686 0.19.4-1.fc12 ruby-pango i686 0.19.4-1.fc12 rubygem-cairo i686 1.10.0-3.fc12 Transaction Summary =========================================================================================== Install 8 Package(s) # yum install rubygem-git (the following will not be needed if first command dont install these) # yum install rubygem-actionmailer rubygem-activerecord rubygem-activesupport APACHE CONFIGURATION: --------------------------- # yum install ruby-devel # gem install passenger # passenger-install-apache2-module This will create an .so file in: /usr/lib/ruby/gems/1.8/gems/passenger-X.X.X/ext/apache2/mod_passenger.so and the shell will tell you to add some code in httpd.conf and create virtual host. e.g. Edit the httpd.conf and at the eld of LoadModules section add the lines: LoadModule passenger_module /usr/lib/ruby/gems/1.8/gems/passenger-3.0.5/ext/apache2/mod_passenger.so PassengerRoot /usr/lib/ruby/gems/1.8/gems/passenger-3.0.5 PassengerRuby /usr/bin/ruby VHOST: ServerName relvurvey.jlk DocumentRoot /opt/www/relativesolutions-survey/public RailsEnv production ## Don't forget to edit the /etc/hosts file to reflect your newly created domain in conf ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ ++++++++++++++++++++++++ Troubleshooting +++++++++++++++++++++++++++++++ ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1) Application error.... The best way to locake the problem is to run the dispach.cgi. This will detect the problems that is causing problem running the application. # cd to/public # ./dispach.cgi Error A) /usr/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require': no such file to load -- pdfkit (LoadError) from /usr/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `require' from ./../config/environment.rb:12 from ./dispatch.cgi:3:in `require' from ./dispatch.cgi:3 Sol: gem install pdfkit 2) Internal Server Eroor...: >> Your log file may not be writable by the web server. (log/*) >> Your database configuration may not be correct. (config/database.yml) >> May be you need to restart the apache server if you are in middle of any erver configuration. But have a try with it anyway.
Install ImageMagick in fedora with yum
The easiest way to install imageMagick in Fedora is from yum and PECL.
$ yum install ImageMagick
$ yum install ImageMagick-devel
$ yum install php-devel
$ yum install php-pear
$ pecl install imagick
Then add “extension=imagick.so” to php.ini
Restart apache
Magento Installation Troubleshooting
In fedora Core 9 the during installing Magento I faced some problems. This can be solved by many ways b googling. But I did everything after googling. That didn’t work for me. Then I do the following thing and that worked:
Problem: There was two extension of PHP were missing — mcrypt and dom.
Solution:
At first I updated yum:
$ yum update
Then I removed the php-mcrypt rpm:
# rpm -e php-mcrypt
Then I again installed mcrypt with yum:
#yum install php-mcrypt
And also installed php-dom:
#yum install php-dom
Then after restarting the apache I could proceed to the istallation step of magento where I stucked.
Problem: After installation of Magento in localhost I could not logged in to its admin panel.
Solution: After googling I found that you have to use the IP addressof your locall server instead of localhost. I mman you have to browse:
http://192.168.0.1/magento instead of http://localhost/magento
Image doesn’t show after cutting from PSD / JPEG in IE6
Problem: In most cased you are delivered a PSD file to convert it to HTML. After slicing you find that the images that you cut is working in all browsers but not in IE6.
Cause: The image is in CMYK mode.
Solution: Change the mode to RGB. To do it go to: image > mode and then select RGB Color.
Opacity doesn’t work in IE
opacity attribute of CSS doesn’t work for IE. if there is a class difined as:
.myclass{
opacity: 0.5;
}
then it will work all browser other than IE. To make this class functional in IE also you have to add:
.myclass{
opacity: 0.5;
filter: Alpha(opacity='50')
}
Transperant png doesn’t show in IE.
In many cases we need to use transparent png image as background. But in IE, png files don’t show as transparent. To fix this problem follow the following procedure:
1) Say, the div in which u want ti use transparent image has a class named “trans_bg_class”. The class is defined as:
.trans_bg_class{
height:50px;
width:100px
background:url(images/transparent_image.png) repeat;
}
2) Now add another class named “trans_bg_class_IE”
.trans_bg_class_IE{
height:50px;
width:100px
filter: progid : DXImageTransform.Microsoft.AlphaImageLoader(src='../images/transparency_page.png', sizingMethod='scale');
}
3) Create a javascript file named “transbgIEfix.js” and write the following code in it:
var arVersion = navigator.appVersion.split("MSIE")
var version = parseFloat(arVersion[1])
if ((version >= 5.5) && (document.body.filters)){
var x = document.getElementsByTagName('div');
for (var i=0;i<x.length;i++)
{
if (x[i].className == 'trans_bg_class'){
x[i].setAttribute('className', 'trans_bg_class_IE');
}
}
}
4) Now add the javascript file in the head section of your HTML page as below:
<!--[if lt IE 7.]> <script defer type="text/javascript" src="transbgIEfix.js"></script> <![endif]-->
That is all. Now browse the page with IE and you will see the div with transperent image.
HTML mail doesn’t show in Microsoft Outlook
I have sent HTML mail with PHP but it shows in evolution / thunderbird in Linux but not in Outlook Express in Windows. To solve the problem use the following code:
$boundary = “_e5YKJHKJHKH098090871893712893″;
$message = “–$boundary\n”;
$message .= “Content-disposition: inline\n”;
$message .= “Content-type: text/html\n\n”;
$message .= “<html>\n”;
$message .= “<head>\n”;
$message .= “<title>Your title</title>\n”;
$message .= “</head>\n”;
$message .= “<body>\n”;
$message .= “\n”;
$message .= “<TABLE width=600 border=0 cellpadding=4 cellspacing=1 bgcolor=#878676>\n”;
$message .= “ <TR>\n”;
$message .= “ <TD bgcolor=white nowrap>Your text</TD>\n”;
$message .= “ </tr>\n”;
$message .= “</TABLE>\n”;
$message .= “</body>\n”;
$message .= “</html>\n”;
$message .= “\n–$boundary–\n”;
$headers = ‘From:’ .$author. “\r\n” . ‘Reply-To:’ .$author;
$headers .= “\nContent-type: multipart/alternative; boundary=\”$boundary\”\nMime-Version: 1.0″;
if (mail($mailto, $subject , $message, $headers)) echo “Mail sent successfully”;
else echo “Something problem !!!!!!!!!!!!!!!!”;
Writing / Building widget: a simple approach
1) There will be three files for this widget
1) style.css
2) script.js
3) widget.php
style.css : This file contains your all styles regurding to view the page. Below is a sample of this page code:
#someId{
border:1px solid #000000;
}
.someclass{
background-color: #cccccc;
}
script.js : this file contains your all javascript codes. Below is a sample of this page code:
function someFunction(){
// do something
}
widget.php: This is the main file that contains all of your html as well as php codes for the widget. Below is a sample of this page code:
document.write(‘ <link rel=”stylesheet” href=”http://www.yourdomain.com/style.css” type=”text/css” /> ‘);
document.write(‘ <script language=”javascript” src=”http://www.yourdomain.com/script.js”></script>’);
document.write(‘ <div id=”someid0″ class=”someclass”> ‘);
document.write(‘ <div id=”tab”> ‘);
document.write(‘ <ul> ‘);
document.write(‘ <li><span id=”someid1″ style=”padding-left:3px;” onClick=”return someFunction1();”>ABCD</span></li> ‘);
document.write(‘ </ul> ‘);
document.write(‘ </div>’);
document.write(‘ <div class=”someclass2″>’);
document.write(‘ <div id=”someId4″ style=”display:block” class=”someclass”> ‘);
document.write(‘ <?php
$db_host = “yourhostname”;
$db_user = “yourdbusername”;
$db_pass = “yourdbpassword”;
$db_name = “yourdbname”;
$db_table_prifix = “yourdbtableprefix”;
if (($conn = mysql_connect($db_host, $db_user, $db_pass)) != NULL){
if (mysql_select_db($db_name,$conn)){
$get_post_sql = “YOUR QUERY “;
$get_post_res = mysql_query($get_post_sql);
while ($row = mysql_fetch_array($get_post_res, MYSQL_ASSOC)){
?> ‘);
document.write(‘ <div class = “dataDiv”> ‘);
document.write(‘ <div class = “topdata”> ‘);
document.write(‘ <a href=”http://anydomain/index.php?Id=<?php echo $row["col1"]; ?>” target=”_blank”> ‘);
document.write(‘ <?php
echo $row["col2"].”…”;
echo “</a>”;
echo “</div>”;
?> ‘);
document.write(‘ <?php
echo “</div>”;
}
mysql_close($conn);
}
}
else echo “No database connection”;
?> ‘);
document.write(‘ </div>’);
document.write(‘ </div>’);
document.write(‘ </div> ‘);
document.write(‘</div> ‘);
Now in any HTML file inside the body tag add the following line:
<script type=”text/javascript” src = “http://www.yourdomain.com/widget.php”> </script>
Thats all. Open this HTML file with any web browser. You will see the widget.
How to upload large files in PHP
Problem: File upload error (the uploaded file exceeds the upload_max_filesize directive in php.ini)
Solution:
1) To update the php.ini file set
upload_max_filesize = 20M (your desired size)
post_max_size = 20M (your desired size)
max_execution_time = 3000 (your desired time)
2) Add the following lines in the .htaccess file in the root directory of the server:
php_value upload_max_filesize 20M
php_value post_max_size 20M
php_value max_execution_time 200
php_value max_input_time 200
3) In the php file including the following codes:
<?php ini_set(“memory_limit”,”64M”); ?>
<?php ini_set(“post_max_size”,”20M”); ?>
<?php ini_set(“upload_max_filesize”,”20M”); ?>
In HTML file from where the file will be uploaded:
<form ……………………….>
<input type=”hidden” name=”MAX_FILE_SIZE” value=”200000000″>
<input type=”file” …………………>
</form>
The choice depends upon the situation.