Показаны сообщения с ярлыком php. Показать все сообщения
Показаны сообщения с ярлыком php. Показать все сообщения

VIM. Great tool for programmer

VIM is a great instrument for programmer. It's fast, stable, has a lot functionality. But there is one thing you should know before you start: VIM is extremely shortcut oriented text-editor.

I was a fan of jEdit, but it is very unstable. A lot of plugins are crashing time after time. So I decided to find something else. IDE's like NetBeans and Eclipse are very slow. I've used Emacs and it was interesting. But it wasn't mine. That's why I've tried VIM.

I'm using it about 6 month and I can say, that my happiness is growing day after day.

Plugins, that you have to try:
rails - awesame plugin for Ruby on Rails
matchit - aotocomplete html tags with "Cntrl"+ "Shift" + "_"
autotag - quick updating ctags file after each file write

that's all :)
VIM has all you need out of box. When I'm saying "all you need", I don't mean "all you want" or "all you expected from VIM". There is a VIM Way. It's quite differ from IDE.

Here is my config ~/.vimrc:



Kohana v2.3.4. Image resizing. Transparency losing

I've found interesting bug in Kohana's Image module: sometimes it losing transparency while resizing images. The point was that sometimes imagecopyresized was used.

Let's take a look at system/libraries/drivers/Image/GD.php, Image_GD_Driver#resize:

//...
// Test if we can do a resize without resampling to speed up the final resize
if (false && $properties['width'] > $width / 2 AND $properties['height'] > $height / 2)
{
  // Presize width and height
  $pre_width = $width;
  $pre_height = $height;

  // The maximum reduction is 10% greater than the final size
  $max_reduction_width  = round($properties['width']  * 1.1);
  $max_reduction_height = round($properties['height'] * 1.1);

  // Reduce the size using an O(2n) algorithm, until it reaches the maximum reduction
  while ($pre_width / 2 > $max_reduction_width AND $pre_height / 2 > $max_reduction_height)
  {
    $pre_width /= 2;
    $pre_height /= 2;
  }

  // Create the temporary image to copy to
  $img = $this->imagecreatetransparent($pre_width, $pre_height);

  if ($status = imagecopyresized($img, $this->tmp_image, 0, 0, 0, 0, $pre_width, $pre_height,   $width, $height))
  {
    // Swap the new image for the old one
    imagedestroy($this->tmp_image);
    $this->tmp_image = $img;
  }

  // Set the width and height to the presize
  $width  = $pre_width;
  $height = $pre_height;
 }

   
We can see, that in case when old size of picture is larger than new more than 2 times, this method uses imagecopyresized to resize image to 110% of target size to make imagecopyresampled faster without quality losing. It's nice decision but it's not working for PNG!

To solve this problem in my project I've just copied GD.php from system/libraries/drivers/Image/GD.php to application/libraries/drivers/Image/GD.php and then removed this block from resize method.

Good luck!



Stop comparing PHP to Rails

PHP is a language. Rails is a Ruby framework. Comparing PHP to Rails is like comparing Perl to Django, or Haskell to Seaside, and that makes no sense. Two things that DO make sense:

  • Using PHP for web development. It deploys and scales great.
  • Using Ruby on Rails for web development. The framework provides an excellent set of conventions for rapid development.

text source: stop-comparing-php-to-rails

Everybody knows, that php is language and rails is framework. But when we talk about php side we mean main ways of developing with php. It is a context of this day.

Fact is that rails was written on ruby. And even symphony-project can't beat it.



Rails way on PHP

People love their history. That's why sometimes they try to make something like Ruby on Rails but on PHP or something else. Examples: Symphony, PHP on Rails.

I think that the spirit of pioneer is very important.

Ruby on Rails is:
  • fast;
  • flexible;
  • beautiful (i don't mean textmate or mac :-);
  • original.. as Mohamed Ali.
and no one can beat it.

PHP is good only if you want to make static html site.



PHP is not dead!

Sometimes it seems like Ruby on Rails is so cool. It is. But in some ways PHP is better. In small projects, where price of hosting is important.

Hmm. But at hostingrails dot com we can buy rails for only $3.59 / month.

F*ck. PHP is dead!




2008–2014 © Сергей Удалов Реклама Система Orphus