I will be moving have moved to a new domain soon. I know it's often not a good idea to move domains, but detyabozhye.com is not so easy for people to remember, especially those who don't speak my native language (and even then, it is slightly misspelled).
The new domain name is lyosha.me.
Edit: I have moved over to the new domain now. Anyone linking to my website, please update your links.
I just want to break the silence and wish everyone a merry Christmas, happy New Year, and all the other holidays you might enjoy this season. Personally, I don't celebrate any other winter holidays, but I do believe some others, such as Hanukkah, are great holidays.
I haven't blogged in a really long time. I am always busy working on many things and often neglect my own projects. I wanted to say some things that have happened and are coming up for my website (which nobody is interested in anyway) and other things I am working on.
Most of the things I have done so far on my blog is behind the scenes. I have improved spam management and fixed a bug in which spam messages, though not visible, were counted with the legitimate comments on the home page.
If anyone is interested, I will release my blog source on Github. I know that the open source world has many blogging systems already, but none of the Rails systems seemed to cut it for me when I set mine up, so I wrote my own. I think we can build a good system with this base if there is interest.
I am going to add some of my more useful content from my old blog here and delete my forums. I will also add a proper portfolio on my website where I can include my graphic design work, art, etc.
As for other projects, I plan on letting members on Bryte Youth to log into their accounts and start interacting on the website some time in January. I know it's been a long time since I started development and have estimated incorrectly many times when it will be ready for use, but don't worry, it will be ready soon ("soon" is the favorite release date for programmers).
I have also been put in charge of the technical side of Anime Angels. I have plans on greatly revamping that website too. I don't know when or if that might happen, but if it's the Lord's will, it will happen. We are also getting ready to release a new magazine issue to mark 10 years of Anime Angels: a rather long time for an online community. I pray it will continue strong as it has over the past 10 years.
For about a year, I've slowly been migrating to HTML 5. First of course was the DOCTYPE. Next I started using new structure elements such as <section>, <article>, <header>, etc. and in some applications - Web Forms 2.0 input types.
To use these elements in Internet Explorer (all currently used versions) and Firefox 2.0 (though I believe this one isn't as important anymore), I wrote a script that looks like a hybrid of John Resig's HTML 5 Shiv and Simon Pieters' Firefox 2 HTML 5 enabling script.
I was happy with that solution and other than using the new structuring elements and a little Web Forms 2, I used HTML 4. One of the applications I was working on needed to use an expanding area for more details. So instead of just making a pure Javascript and HTML 4 solution, I decided to use (and implement for current browsers) the HTML 5 <details> element.
Boy was that fun! I ran into a lot of bugs, and in the end increased my script from about 20 lines to almost 200. Opera was the most tolerant of the new functionality. Firefox had major issues with the DOM, the WebKit browsers had rendering issues, and don't even ask about Internet Explorer. With a few semi-ugly hacks though, I believe I have come up with a forwards compatible solution which I call Fiks.html5.
I plan on adding more HTML 5 functionality as I go. One thing I won't add is support for Web Forms 2 because it has already been done and I believe it belongs in a seperate module.
This is an official archive/portfolio of the work I have done. Some websites I have built are down right now and some old designs are completely gone. I will add to this list when I get some archived wesbites up and when I remember other websites I've built.
Websites in progress
- Bryte Youth - Website for the youth of Russian Baptist Church of Bryte
Archived websites
- K ź D Scooters
- Chudosok - An informational website in Russian on mangosteen. This was built when AJAX was the latest buzzword and I built it with an experimental AJAX navigation system.
I finally made my new blog to replace my old forum-dependant website. I built the blog engine from scratch in Ruby on Rails (and no, it's not just like the one in the tutorial on rubyonrails.org) in a week. If there is enough interest, I will release the source. It is dependant on one gem other than Rails: Authlogic.
There are still things missing on this website that I will put up later. One thing I'm wondering is whether or not I should add some of my old content (that might still be useful) on this blog or not.
I had to return to PHP for a small application I had to write for which Rails would have been too big. Being used to Rails RESTful methods and MVC, I didn't want to make another messy 200 line PHP app that I would not be able to read later, so I coded a very small and simple CRUD "router" (as in Rails' routes) and I decided to share it with the world. So far it only works with a "controller" that manages plural resources. The CRUD pattern here is modeled after the way Rails controllers work. It's really simple, but it sure makes coding tiny apps a lot cleaner. (Helpers, clean URLs, MVC, etc. are up to the reader to implement)
crud.php:
<?php
switch($_SERVER['REQUEST_METHOD']) {
case 'GET':
switch($_GET['action']) {
case 'new':
cnew();
break;
case 'edit':
edit();
break;
default:
if (preg_match('/^[0-9]+$/', $_GET['id']))
show();
else
index();
break;
}
break;
case 'POST':
switch($_POST['_method']) {
case 'put':
update();
break;
case 'delete':
destroy();
break;
default:
create();
}
break;
case 'PUT':
update();
break;
case 'DELETE':
destroy();
break;
}
?>
index.php (an example "controller"):
<?php
require 'crud.php';
function index() {
// grab some data
require 'views/index.php';
}
function cnew() {
// new resource
}
function show() {
// get the resource by id
echo "You requested resource number " . $_REQUEST['id'];
}
function edit() {
// edit resource
}
function create() {
// create something
header('Location: ./');
}
function destroy() {
//delete something
header('Location: ./');
}
?>
I haven't written here in a long time, so as many of you might not know yet, I've been learning Ruby on Rails the past 4 or 5 months. I'll have to say I've run into some pretty big challenges, but overall Ruby on Rails is one awesome framework. My latest challenge has been getting DHH's auto_complete plugin to work with Ryan Bates' complex forms. It might not be the best way to do it, but the solution was to monkey patch ActionView::FormHelper and FormBuilder which I put in a seperate file in the /lib folder of my project. So without further ado, here's the code:
## lib/auto_complete_form_helper.rb
module ActionView
module Helpers
module FormHelper
def text_field_with_auto_complete_mod(object, method, tag_options = {}, completion_options = {})
sanitized_object = object.gsub(/\]\[|[^-a-zA-Z0-9:.]/, "_").sub(/_$/, "")
sanitized_method = method.to_s.sub(/\?$/,"")
(completion_options[:skip_style] ? "" : auto_complete_stylesheet) +
text_field(object, method, tag_options) +
content_tag("div", "", :id => "#{sanitized_object}_#{sanitized_method}_auto_complete", :class => "auto_complete") +
auto_complete_field("#{sanitized_object}_#{sanitized_method}", { :url => { :action => "auto_complete_for_#{sanitized_object}_#{sanitized_method}" } }.update(completion_options))
end
end
class FormBuilder
def text_field_with_auto_complete(method, tag_options = {}, completion_options = {})
@template.text_field_with_auto_complete_mod(@object_name, method,
objectify_options(tag_options), completion_options)
end
end
end
end
Don't forget to include the file in your environment.rb. If you see any bugs or know of a better way (I couldn't find any solutions on the web), please let me know.
I recently had to make an auto expanding textarea for a web application and when it came to Opera, I couldn't find a working solution. The most common way of making the textarea to auto expand is to compare the offsetHeight or clientHeight of the textarea with the scrollHeight. This works fine in IE, Firefox, and Safari (and even allows auto shrinking in IE) but not in Opera or Konqueror. Some solutions I found divided the number of characters by the number of rows and and cols in the textarea. The problem with this is that many people don't type everything on one line, so it won't accurately measure how many lines there are.
After thinking about both of those solutions, I decided to write my own, which calculates the number of lines based on how many newline characters are in the text and whether or not each line has more characters than the number of cols. There is however one catch: for the word wrap to work when there are as many characters in a line as there are cols in the textarea, the font has to be monospace, otherwise the script will not work reliably. So, without futher ado, here's the basic code:
<textarea rows="10" cols="40" onkeyup="adjustRows(this);"></textarea>
...
function adjustRows(ta) {
while(ta.scrollHeight > ta.offsetHeight) //I use offsetHeight rather than clientHeight because scrollHeight is always bigger than clientHeight in Opera on textareas
ta.rows++;
adjustRows2(ta);
}
function adjustRows2(ta) {
if (window.opera || navigator.vendor.indexOf("KDE") > -1) { //detects Opera or Konqueror
var lines = ta.value.split("\n");
var linecount = lines.length;
for (var line in lines)
linecount += parseInt(lines[line].length / ta.cols);
if (linecount > ta.rows)
ta.rows = linecount + 1;
}
}
Auto shrinking is also possible in IE, Opera, and Konqueror and horizontal expanding is possible in Firefox, Opera, and Konqueror. If anyone ever uses that, I can post it too. Note: The script is not perfect, and doesn't calculate 100% acurately, but so far it's the most reliable script for auto expanding a textarea in Opera I know of.
Yesterday (it's past midnight (1:30AM), so forgive me if I say something crazy) it's been one year since my group and I got baptized. Before getting baptized, one of the men who worked with us promised us that the water would be wet in the river. Thinking back to that day and discussing it with another person who got baptized the same day, we came to the conclusion that the water was exactly how the man promised us. But discussing the matter further, my friend argued that water is always wet so the promise was easy for him to keep. However, I have found proof that that is not always so; one of the largest distributors of dehydrated water, http://www.buydehydratedwater.com/ sells hundreds of gallons of dehydrated water daily. So water is NOT always wet.
Yesterday I came across a statistic that only about 5% of those who call themselves Christians have actually read the Bible from cover to cover! How can a Christian not read the work of the One he/she is supposed to love more than anything else? If you had a girlfriend/boyfriend who you haven't heard from in a while and with whom you were totally in love and got a letter in the mail from her/him what would you do? You would tear open the envelope and read and reread the letter a few times before calming down and reading it yet again, right? How can 95% of those who claim to love God not read His letter even once from beginning to end?!
Another interesting thing is that in English, there are like over 400 different translations of the Bible. Why do we need so many? The Bible is easily readable in one. The bigger question is, however: If there are so many, why aren't 95% of Christians reading any of them?
There were about 30,000 "Christian" books published last year. Yet, the number 1 truly Christian book is being ignored by most "Christians". It's like instead of opening and reading the letter from your gf/bf you go and ask all her/his friends about how she/he is doing and what she/he has been up to. Sounds silly? Yes. Put down you Billy Graham, John Hagee, Rick Warren, Thomas Williams, or whatever book you're reading, open your Bible, and start reading it. It's just the best.
You know, lately I've been getting more into real life and all. So far, real life is pretty cool:
I get to meet actual real people,
I'm going to be in the church play (the rehearsal was fun, btw),
I actually get to breath fresh air! Sure beats sitting here. LOL.
There is however one thing about real life that I must warn you about if you guys want to try it:
Ctrl+Z doesn't work in real life! That means we have to be a lot more careful when we do things. For example, today I was cutting branches off our plum tree (# rm -rf /backyard/plumtree/branches/longyoungones/) and one about the thickness of my thumb and 5' long fell on my head. Now it's bleeding and neither Ctrl+Z nor # fsck -a /dev/head will fix the problem!
Another interesting thing about real life is when those real actual people you meet find out you're a geek trying out real life, they'll give you computer related jobs to keep you in your box!
OK, OK, this whole blog post is mostly a joke (except the fact that I did get hit on the head by that branch, and it is bleeding), but that's pretty much what I've been up to lately (you don't want to hear about all the work I've been doing, it's boring).
God Bless. ^_~
- Alyoshka