Thoughts and tutorials on programming

Friday, June 29, 2007

ruby err

driver.rb:270:in `startServerAndGoAndStop': private method `doAllPeersWithDelta' called for # (NoMethodError)
means "you have an extra end in driver class!"

Thursday, June 28, 2007

ruby-debug ctrl-c

So...you run your ruby app with ruby-debug rdebug and it doesn't catch ctrl-c interrupts anymore? Do not fear. Just run rdebug scriptname then 'catch Interrupt' and it will always catch them from then on.

.bashrc doesn't work

find that ~/.bashrc isn't getting loaded on login? Try renaming it ~/.profile (or creating such page and having it do '. ~/.bashrc'.

Wednesday, June 27, 2007

how to install rmagick to a custom directory (gem)

So..you install rmagick as a gem and it goes to the right gemrepository, but that still doesn't work? I search for RMagick.rb and then added that path to the RUBYLIB path, thus
export RUBYLIB=$RUBYLIB:/home/rdp/i386/gemrepository/gems/rmagick-1.15.7/lib/
(in ~/.bashrc). Voila

Tuesday, June 26, 2007

how to convert you putty key to linux

So...you use putty agent to login to your linux box, and now you wish you could use the same key within linux? Not a problem. right click on the private key, choose edit, then choose "export" save the file somewhere (anywhere), then eventually copy it over to your ~/.ssh/identity file [may need to change permissions on said file so that it's not readable by anyone]. Voila.

Monday, June 25, 2007

more install errs

get /home/rdp/i386/bin/gem:9:in `require': no such file to load -- rubygems (LoadError)
or
(maybe -- might be prev. post) install gemconfigure.rb /usr/lib/ruby/site_ruby/1.8/
or
no such file to load -- ubygems (LoadError)
then see the faq at http://rubygems.org/read/chapter/15 at the bottom
must do things like
export RUBYLIB=$RUBYLIB:/home/rdp/i386/gemrepository:/home/rdp/i386/usr/lib/ruby/site_ruby/1.8/

installing rubygems as non root

so...install it and it does this?
rdp@ilab4 ~/downloads/rubygems-0.9.4 $ ruby setup.rb --verbose install
rm -f InstalledFiles
---> bin
mkdir -p /home/rdp/i386/bin
install gem /home/rdp/i386/bin/
install gem_mirror /home/rdp/i386/bin/
install gem_server /home/rdp/i386/bin/
install gemlock /home/rdp/i386/bin/
install gemri /home/rdp/i386/bin/
install gemwhich /home/rdp/i386/bin/
install index_gem_repository.rb /home/rdp/i386/bin/
install update_rubygems /home/rdp/i386/bin/
<--- bin
---> lib
mkdir -p /usr/lib/ruby/site_ruby/1.8
install gemconfigure.rb /usr/lib/ruby/site_ruby/1.8/
setup.rb:633:in `initialize': Permission denied - /usr/lib/ruby/site_ruby/1.8/gemconfigure.r b (Errno::EACCES)
from setup.rb:633:in `open'
from setup.rb:633:in `install'
from setup.rb:1377:in `install_files'
from setup.rb:1376:in `each'
from setup.rb:1376:in `install_files'
from setup.rb:1350:in `install_dir_lib'
from setup.rb:1532:in `__send__'
from setup.rb:1532:in `traverse'
... 7 levels...
from setup.rb:826:in `__send__'
from setup.rb:826:in `invoke'
from setup.rb:773:in `invoke'
from setup.rb:1578


try runing ruby setup.rb install --prefix=/path [though it doesn't say this]

Tuesday, June 19, 2007

parameters in django templates

It seems that it may be possible to have parameters within called functions in a django template. {% url path.to.some_view arg1,arg2,name1=value1 %} (see http://www.djangoproject.com/documentation/templates/). GL!

Thursday, June 07, 2007

how to host static files in a django app for development

add the following to urls.py (first line optional :)

if settings.DEBUG: # then serve static files here :)
urlpatterns += patterns('',
(r'^static_files/(?P.*)$', 'django.views.static.serve', {'document_root': 'C:/office_in_out/oliver/drb/static_files', 'show_indexes': True}),

Then you can access /static_files/filename.jpg and it should work. See the other post for production setup :)


As a side note, "how to change your django app from development to production" is you go to settings.py and change DEBUG = True to DEBUG = False. I'm not sure what to do with TEMPLATE_DEBUG after that :)

Wednesday, June 06, 2007

Django static files, using fcgi

On blue host we use fcgi. So here is how to make static subdirectories work.
Django wants to host static files, for example the admin interface uses static files (hosted at /media/) for its css.
To create these what you will want to do is create create some sym links within your public_html/whatever sub-directory, then instruct apache, in .htaccess, to follow those links.

Here's an example for my admin media setup.


cd public_html/subdomain

ln -s media /home/wilkboar/checked_out_svn_all/edited_django_repository_files/django/contrib/admin/media

(media being where ADMIN_MEDIA_PREFIX is set to in settings.py -- defaults to media)

Then edit .htaccess, add
Options +FollowSymLinks
RewriteRule ^(media/.*)$ - [L]

media is the same name as the directory, above.

Repeat for other static files desired. Should work!

django strange error

so...ever get one of these?


Request Method: GET
Request URL: http://localhost:8000/generic_html/traffic_color_definitions.html
Exception Type: AttributeError
Exception Value: 'str' object has no attribute 'resolve'
Exception Location: C:\office_in_out\oliver\edited_django_repository_files\django\core\urlresolvers.py in resolve, line 163


It may be because you add to your urlpatterns, in settings.py, but forget to name it urlpatterns. Why this sometimes works, and sometimes doesn't, I have no idea :)

urlpatterns += ('',
(r'^static_files/(?P.*)$', 'django.views.static.serve', {'document_root': 'C:/office_in_out/oliver/drb/static_files', 'show_indexes': True}),
)

This is bad. it should be patterns('',...
GL!

Monday, June 04, 2007

D&C thought

Well it appears there was some confusion about D&C 89 on teh internet, thought I'd put in my $.02...

Noticed an article of yours at http://www.johnankerberg.org/Articles/apologetics/AP0501W1.htm and I thank you for your respectful comments (I am LDS). As a contemplative addition (something to think about), the reference in v. 7 to "strong drinks" may also be 'pointing back' to v. 5 "wine or strong drinks" which is why it is typically construed to mean alcoholic beverages. Some people get confused and it's easy to do so. Keep up the good work!

--
-Roger Pack
"Men are that they might have joy." (2 ne 2:25)

Contributors

Followers