Welcome to my site
This is my personal multi-purpose website. I will have info here, my blog, anime drawings, music, web design articles and tips, and other miscelaneous stuff.
My name is Aleksey, I'm just a regular 19.349726776 year old Evangelical Christian Baptist from California. Any questions?
Thursday, 10 April 2008
Bash history meme - every ...
$ history|awk '{a[$2]++ } END{for(i in a){print a[i] " " i}}'|sort -rn|head
71 ./record.py
67 sudo
34 ping
21 killall
20 xvnc4viewer
19 nmap
13 mplayer
13 bin/ie6
11 cat
9 rm
I guess I use the shell more for launching my python church service recording script and doing administrative tasks. also seems I use it a lot for networking and web development. And the most interesting one is that I apparently kill applications too often.
Monday, 25 February 2008
Auto expanding textarea i ...
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:
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.
Friday, 08 February 2008
New internet threat of an ...
These things pop up daily, but I haven't found anything about this one on Google or anywhere yet, so I guess I'm the first to write about it.
There's a new threat out there in which you download a Windows application, run it, and as far as I can tell (I didn't run the program, but looked at it with a few "hacking" tools), it signs on to your Windows Live Messenger account and spams all your contacts with a link which supposedly advertises a program to speed up your web browsing experience (for Internet Explorer and Mozilla browsers, I assume), which in reality is the first program I'm talking about, and does the same thing all over again and infects more people. What else the program does, I don't know, it could be spyware, a virus, worm, trojan, etc. This kind of thing isn't new, but this is the latest incarnation and nobody has talked about it yet, I guess.
For the inexperienced, just stay away from this scam and all others like it. You are not required to understand the rest of this blog post.
Here are the technical details for the experts (Note to inexperienced users: Do NOT go to the following website and DON'T download the program on it unless you don't care at all about your computer, data, social life, etc. and love me so much that you will not blame me for any damage this program might do to your computer.):
The evil website: http://www.xnetspeed.com/
The contents of the main page:
Code:
<html>
<head>
<style>
body{
margin:0;
padding:0;
background:url(faster.png) top center repeat-x;
}
</style>
</head>
<body onclick="document.location='setup.exe'">
</body>
</html>What all that means is, there's absolutely nothing on the website except this large pretty image: http://www.xnetspeed.com/faster.png
and it doesn't matter where you click, all it will do is download a file called setup.exe
The evil program: 'setup.exe'
As far as I can tell, it was written in the classic Visual Basic and signs into the mobile version of Windows Live Messenger to do it's thing.
The program's Version Info might give some insight as to who made this program and where it's from (extracted using Resource Hacker):
Code:
1 VERSIONINFO
FILEVERSION 3,0,0,0
PRODUCTVERSION 3,0,0,0
FILEOS 0x4
FILETYPE 0x1
{
BLOCK "StringFileInfo"
{
BLOCK "040904B0"
{
VALUE "CompanyName", "sinerji"
VALUE "ProductName", "system"
VALUE "FileVersion", "3.00"
VALUE "ProductVersion", "3.00"
VALUE "InternalName", "setup"
VALUE "OriginalFilename", "setup.exe"
}
}
BLOCK "VarFileInfo"
{
VALUE "Translation", 0x0409 0x04B0
}
}What this means is the program is supposedly at version 3.0 and is written by someone who goes as "sinerj" and this program pretends to be something to do with the main system on your computer.
I tried searching for sinerj setup.exe on Google, but all I got was Turkish websites, and a lot of them too, so I can't really track where this came from, but that's the info we have.
So there you have it, yet another messenger hijacker, which unfortunately many people will get into. So I wanted to warn readers of my blog about it, so at least there will be a few less people who get into this. ![]()
Edit: Checking the domain information, it leads to blockdelete.com name servers. So this is really just the latest scam from the same people who have been at this for almost a year with sites like msnliststatus.com. This particular scam just popped up today, btw. Fresh....
Thursday, 17 January 2008
Another Boring Update
Wow, I haven't blogged for a really long time. And the only thing I'll say today is the same thing I said last time: I updated my age script.
I fixed two bugs and I also made a Javascript port. I need to write a real blog post that has something to do with real life. Hopefully, I'll do that soon. Well, here's the code for those interested:
PHP:
Code:
$birthday = "1989-03-18";
list($year,$month,$day) = explode("-",$birthday);
$year_diff = date("Y") - $year;
$month_diff = date("m") - $month;
$day_diff = date("d") - $day;
if ($month_diff < 0) $year_diff--;
elseif (($month_diff==0) && ($day_diff < 0)) $year_diff--;
$bdoy = date("z", mktime(0, 0, 0, $month, $day, date("Y"))) + 1;
$cdoy = date("z") + 1;
$daysinyear = date("L") == 1 ? 366 : 365;
$days = $cdoy = $bdoy ? $cdoy - $bdoy : $cdoy + ($daysinyear - $bdoy);
if ($days == $daysinyear) $days = 0;
echo $year_diff + ($days / $daysinyear);Javascript:
Code:
Date.prototype.getDOY = function() {
var onejan = new Date(this.getFullYear(),0,1);
return 1 + Math.floor((this - onejan) / 86400000);
}
function isLeapYear(yr) {
return yr % 4 == 0 && (yr % 400 == 0 || yr % 100 != 0);
}
var birthday = "1989-03-18";
var ymd = birthday.split("-");
var curDate = new Date();
var ydiff = curDate.getFullYear() - ymd[0];
var mdiff = curDate.getMonth()+1 - ymd[1];
var ddiff = curDate.getDate() - ymd[2];
if (mdiff < 0) ydiff--;
else if (mdiff == 0 && ddiff < 0) ydiff--;
var bdate = new Date(curDate.getFullYear(),ymd[1]-1,ymd[2]);
var bdoy = bdate.getDOY();
var cdoy = curDate.getDOY();
var daysinyear = isLeapYear(curDate.getFullYear()) ? 366 : 365;
var days = cdoy > bdoy ? cdoy - bdoy : cdoy + (daysinyear - bdoy);
if (days == daysinyear) days = 0;
alert(ydiff+(days/daysinyear));I believe there is still one issue with leap years, but I'll take care of it later.
Sunday, 16 September 2007
Updated age script
I updated my age script to work properly with leap years and auto-calculate the day of year. Here it is for those who want it:
Edit: Removed code because of 2 embarrasing bugs.





