Page 27 of 30

My phone is manufactured!

I was waiting for years for some company that will manifacture as good as sony k750 phone.

The time has come, htc diamond is the choosen one :)

Vim vim vim

I cant live without vim. Today is the day I understand this and have install vim on my home windows:) I hope that no one will start it accidently.

Ok. Here i will keep track of the commands that I use in vim.

configuring vim and nice screenshots tutorial

Here is more on the topic

  • Open many files in tabs:  vim -p file*
  • Search & Replace:  %s/something/nothing/g
  • cntrl-space in vim is: cntr-n /  cntrl-p
    load words from all pl/pm files: ctags *.p?
  • windows: :split / :vsplit
    cntr-w – switch
    :close
    :only
  • tabs:
  • set tabstop=2
    set autoindent
    << >>  size is controller:
    shiftwidth=4

VimDiff

Keyboard Shortcuts:

do – Get changes from other window into the current window.

dp – Put the changes from current window into the other window.

]c – Jump to the next change.

[c – Jump to the previous change.

Ctrl W + Ctrl W – Switch to the other split window.

Copy checkboxes from one form to another with Prototype

I have a case where the user must select items from a basket and use them with different forms.

Example:
Some items in this form
  • Item:
  • Item:
  • Item:
  • Item:
Another form here
(I will create here hidden fields from the the checkboxes in the first box)

I will show you how to use the checked boxes from the first form with the submit action in the second form

It would be easy if the form could be one – less support.

I am starting with those two forms

  • Helper form – Form with checkboxes
  • Action form – the form that will do the real action based on the selected items in the helper form

Here is how it looks the helper form. All the checkboxes are tagged with the class=”selectable”. Here is rails example but you can implement it pure html.

<%= check_box_tag('selected[]', true, image.selected?, :class=>"selectable") %>

Then we can select all the checkboxes with this javascript.

var make_to_hidden = $$('input.selectable');

Put on your action form an id so we can access it easy in this case:

<form id="mail_form" onsubmit="import_selected_basket()"> ... </form>

Lets add those checkboxes from the first form to the real action form with this javascript function

      function import_selected_basket() {
          var make_to_hidden = $$('input.selectable');
          make_to_hidden.each(function(item) {
              if (item.checked) {
                var new_item = new Element('input', { 'type': 'hidden', name: item.name, value: item.value })
                $('mail_form').appendChild(new_item)
              }
          });

Rails conf 2008/6/2

Its aways nice to know whats going on in rails field

http://railsenvy.com/2008/6/2/Railsconf-videos

Whats new for me was flog:

  • http://on-ruby.blogspot.com/2007/12/flog-profiling-complexity.html
  • http://ruby.sadi.st/Flog.html

Some more video links

Нова търсачка за цените

От известно време си имаме на http://www.cenite.com чисто нова търсачка.

Преди беше просто досадно да се търси в сайта и макар, сайта върши работа.

Резултатите с новата търсачка са налице, вижте разликата:

  • Преди за един резултат се чакаше приблизително от 2 до 4 (олеле) секунди.
  • Търсеше се само в името на продукта

Сега:

  • Търсенето става мигновенно – повече време отнема да се изобрази страницата от броузера :)
  • Търсенето е едновременно в заглавието на продукта, както и в описанието му, като се дава превес в резултатите съдържащи ключовите думи в името на продукта.
  • Може да се избира по кой полета да се търси, макар че не ми е останало време да публикувам HELP към търсачката.
  • Сортиране по точност на намерите резултати.
  • Отпаднаха притесненията за Иванчо ;drop table students;

Изглежда и посетителите също оценяват предимствата на новото търсене, от 1000 посетителя на ден в момента са над 2500 като всеки ден се увеличават.

Only get, head, post, put, and delete requests are allowed.

I got this error when I have to upgrade one old project from rails 1.2.5 to rails 2.1 (the problem is not in rails)

ActionController::MethodNotAllowed

Only get, head, post, put, and delete requests are allowed.

The exception:

ActionController::MethodNotAllowed (Only get, head, post, put, and delete requests are allowed.):
    /usr/lib/ruby/gems/1.8/gems/actionpack-2.1.0/lib/action_controller/routing/recognition_optimisation.rb:65:in `recognize_path'
    /usr/lib/ruby/gems/1.8/gems/actionpack-2.1.0/lib/action_controller/routing/route_set.rb:384:in `recognize'

I got this error only when I access URL’s with param like

http://127.0.0.1:3000/dod/images/show_big_image/1639

I found that the problem was in the :id because without the :id the method was called correctly

This means that there is something with the routes.

Not working routes.rb: ….

  map.connect '', :controller => 'auth'

  # Install the default route as the lowest priority.
  map.connect ':controller/:action/:id'
  map.connect ':controller/:action/:sort_key/:sort_order'

it will work if you swap the last two lines….

  map.connect '', :controller => 'auth'

  # Install the default route as the lowest priority.
  map.connect ':controller/:action/:sort_key/:sort_order'
  map.connect ':controller/:action/:id'

It seems that it does reading the comments in the routes.rb is usefull. There is written:

# Install the default route as the lowest priority.

This error also occurs if you haven't restart your webserver. I know that there is no need to restart it but its true, try restarting and check.

Upgrading Rails

Here is nice tutorial how to move your project from rails 1.2.x to 2.0

  • upgrade the gems: http://wiki.rubyonrails.org/rails/pages/HowtoUpgrade
    • gem update --system
  • http://macournoyer.wordpress.com/2007/10/28/moving-to-rails-20/
    • nice task to find the deprecated elements: “rake -T deprecated”, 10x!

Gentoo Cheatsheet

Java install

ls /usr/portage/dev-java/sun-jdk/
emerge -av =dev-java/sun-jdk-1.5.0.13
java-config -L
java-config -S 1
/usr/sbin/env-update && source /etc/profile

Emerge and Equery

Taken from here

emerge brings in new packages. equery looks at the package database.

update repository:
emerge –sync
install package with query
emrge -av sun-jdk
start with this software
emerge links wget htop
emerge …
manipulate package database
emerge -NDtu world
–update packages and packages that depend on updated packages (–deep) in the world list. Give output in –tree format. Consider packages changed if their USE flags have changed (–newuse, -N) Add –pretend (-p) to just see what it will do first.
emerge –skipfirst …
skip first pkg on a rebuild; very useful if something doesn’t work
equery …
query package database
equary belongs
who owns these files?
equery list
list packages on system

Maintenance

Taken from here

Do this whenever you want a steaming pile of fresh packages.

# emerge --sync
# emerge --update system
# etc-update
if necessary
# emerge --update world

I have seen Meddle to do it this way

emerge –newuse –deep –update world
emerge –ask –verbose coreutils
emerge –resume

Fix the mktemp / coreutils block in Gentoo

Looks like mktemp is now provided by coreutils. No wonder. This block has been bugging me (read: I’ve been ignoring it) for months.

To fix just unmerge mktemp and update coreutils.

Update: Same for the setarch / util-linux block should you come across it. Unmerge setarch.

CSS Tricks

.clearfix

<div style=”clear: both”> – do you remember this? I hate it.

The people has found a solution for this.

http://www.positioniseverything.net/easyclearing.html

.clearfix:after {
content: ".";
display: block;
height: 0;
clear: both;
visibility: hidden;
}

.clearfix {display: inline-block;}

/* Hides from IE-mac \*/
* html .clearfix {height: 1%;}
.clearfix {display: block;}
/* End hide from IE-mac */

CSS tools

Layout generator – http://csscreator.com/tools/layout

PNG Patch for IE

Since IE6 doesn’t render PNG-24 properly, the following hack is required in order to display the transparent PNG (add anywhere in between the <head> tag):

<!--[if lt IE 7]>

<style>
h1 span {
  background: none;
  filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src='gradient.png', sizingMethod='scale');
}
</style>

<![endif]-->
/***** Selector Hacks ******/
 
/* IE6 and below */
* html #uno  { color: red }
 
/* IE7 */
*:first-child+html #dos { color: red } 
 
/* IE7, FF, Saf, Opera  */
html>body #tres { color: red }
 
/* IE8, FF, Saf, Opera (Everything but IE 6,7) */
html>/**/body #cuatro { color: red }
 
/* Opera 9.27 and below, safari 2 */
html:first-child #cinco { color: red }
 
/* Safari 2-3 */
html[xmlns*=""] body:last-child #seis { color: red }
 
/* safari 3+, chrome 1+, opera9+, ff 3.5+ */
body:nth-of-type(1) #siete { color: red }
 
/* safari 3+, chrome 1+, opera9+, ff 3.5+ */
body:first-of-type #ocho {  color: red }
 
/* saf3+, chrome1+ */
@media screen and (-webkit-min-device-pixel-ratio:0) {
 #diez  { color: red  }
}
 
/* Safari 2 - 3.1 */
html[xmlns*=""]:root #trece  { color: red  }
 
/* Safari 2 - 3.1, Opera 9.25 */
*|html[xmlns*=""] #catorce { color: red  }
 
/* Everything but IE6-8 */
:root *> #quince { color: red  }
 
/* IE7 */
*+html #dieciocho {  color: red }
 
/* Firefox only. 1+ */
#veinticuatro,  x:-moz-any-link  { color: red }
 
/* Firefox 3.0+ */
#veinticinco,  x:-moz-any-link, x:default  { color: red  }
 
 
 
/***** Attribute Hacks ******/
 
/* IE6 */
#once { _color: blue }
 
/* IE6, IE7 */
#doce { *color: blue }
 
/* Everything but IE6 */
#diecisiete { color/**/: blue }
 
/* IE6, IE7, IE8 */
#diecinueve { color: blue\9; }
 
/* IE7, IE8 */
#veinte { color/*\**/: blue\9; }

http://paulirish.com/2009/browser-specific-css-hacks/

Web Spiders and expired content

All my spiders were taking all content from a website on a single visit starting from the begining.

It seems that the idea of remembering which urls “produce” links with content is not so very bad.

Here is what I found for diri.bg – a local Bulgarian SE.

I see that diri.bg hasn’t remove from their page

show_categories.php

Even I have no links to this page. Check the result here

Ops. Google do it the same way: here

Then how to get rid of old pages without leaving “bad” links in internet?

I will try to put show_categories.php in robots.txt to see what will happen with this page.

© 2025 Gudasoft

Theme by Anders NorénUp ↑