Posted 4 days, 7 hours ago at 4:45 pm. 2 comments
cat /path/to/access-log | awk {'print $1'} | sort | uniq -c | sort -n | tail -100
awk {’print $1′} : print the IP column
sort : sort by ip
uniq - c : count uniques
sort -n : numeric sort
tail -100 : show last 100 hits
Posted 5 months ago at 1:01 am. 0 comments
http://inbflat.net/ (watch it, i’ve heard people crashed their browsers)
Text By Daniel Donahoo (2009)
she closes the lid
and unplugs the device
no bigger than her thumb
from the computer.
My lifes work, she says. But, it isn’t her lifes work.
You see, we store information like an Escher painting.
It shouldn’t all fit in there. But, it does.
And every day we manage to fit more and more into smaller and smaller spaces until one day
she says,
we will be able to fit all the information the world has
everything that everyone knows and believes and dreams
into nothing.
It will all be there. Stored and filed.
Tagged with any keywords you might imagine.
Our hard drives will be thin air.
They will make nanobots look like elephants.
And elephants will be in there too. Tagged. Accessible with search terms
like gray, ivory,
and the largest land dwelling mammal
We will process away at nothing and understand everything.
We will think of a word and the information will slip in, not through our ears or eyes
but straight thorough our skin. Information will breathe in and out of us,
permeate our skin.
Our knowing will be as deep as it is wide.
You see our work here is to learn so much,
to be so full of knowing,
that all there is left to do is unlearn.
Humanity must get to a point where we let go.
We leave the useless ideas and the spent ideologies in the recycle bin.
like an adolescent brain shedding neurons.
like a snake slithering from its old skin.
like an old man who has come to understand so well the point where reality meets the intangible that he is able to decide which breath will be his last. And, he will enjoy that breath more than any that he has taken in his entire life.
And, her lifes work is more than a four meg flash drive.
My lifes work, she says, is the impact that this has.
This is not about what I produce. It is all about what others receive.
Posted 6 months, 3 weeks ago at 10:27 pm. 0 comments
I really didn’t like to use mouse for every second action i did on my mac. Today i found a solution for tabbing in forms, moving between values in dialog boxes,…
Just open up System Preferences -> Keyboard & Mouse and click “All controls” instead of “Text boxes and lists only”

Posted 7 months, 1 week ago at 10:37 am. 1 comment
[root@bentley ~]# curl -s -D - http://si2.php.net | head
HTTP/1.1 200 OK
Date: Wed, 01 Jul 2009 08:26:06 GMT
Server: Apache
Last-Modified: Wed, 01 Jul 2009 08:39:37 GMT
Content-language: en
Set-Cookie: COUNTRY=SVN%2C231.127.244.131; expires=Wed, 08-Jul-2009 08:26:06 GMT; path=/; domain=.php.net
X-PHP-QUESTION: I wonder if anyone will ever notice this
Transfer-Encoding: chunked
Content-Type: text/html;charset=utf-8
Posted 8 months, 1 week ago at 3:26 pm. 1 comment
dd if=/dev/random of=test bs=1m count=2
dd if=/dev/urandom of=test bs=1m count=2
(thanks simon!)
This will create 2.0M file called “test”.
[root@bentley ~]# ls -alh test
-rw-r--r-- 1 root wheel 2.0M Jun 4 15:20 test
[root@bentley ~]#
This also works on linux, but he doesn’t understand “m” as unit.
Posted 9 months, 3 weeks ago at 9:34 am. 6 comments
[root@box /var/tmp]# ls -alh | grep magi
-rw------- 1 www wheel 566G Sep 15 2008 magick-6kCJDiQf
-rw------- 1 www wheel 4.9T Sep 15 2008 magick-HBj7nGN4
-rw------- 1 www wheel 3.0T Sep 15 2008 magick-IXNRvqtK
-rw------- 1 www wheel 2.7T Sep 15 2008 magick-irgHIYUQ
-rw------- 1 www wheel 566G Sep 15 2008 magick-qDaohFgm
[root@box /var/tmp]#
Posted 10 months, 2 weeks ago at 8:54 pm. 3 comments
I cannot believe IT! A year ago i was thinking, gr8 Microsoft is getting closer to other browsers and i don’t need to think about IE, like all the time. “Will this work on IE? Is there some kind of a hack to get this work on IE”… IE7 was cool! The frikkin’ madness about IE8 … It comes with a little button called “Compatibility view”. Few weeks ago i started some cool project, which i’ll reveal in the future, without any concerns about IE (I considered IE6 as obsolete and i HANDLE it with “you’re here with IE6 buddy, i’m sorry for you, you cannot see this page”).
I finished with design and checked the site on firefox, chrome, opera, safari - it worked flawlessly. And then i tried it on IE (I accidentally thrown windows 7 beta on my PC and it came with IE8 beta). I could cry when i saw the page… NOT AGAIN! Microsoft took things in his hands… Could not believe my eyes. I clicked “Compatibility view” button when this message popped out: “Websites designed for older browsers will often look better, and problems such as out-of-place menus, images, or text will be corrected with compatibility view”. ?!!?!? It’s like, you’re about to tell me that i don’t know how to make sites for todays standards. (Page is valid - XHTML 1.0 Strict, CSS too, it works in every browser… except your browser!! stupid fucks…).
Nah, when i clicked that button, it all worked OK as it should (i think they’re using IE7 way to display it right). I went to their blog and few other sites to read a thing or two about it. They told me that IE8 is more strict towards web Microsoft standards , and you know what else? There are high-volume sites like facebook.com, myspace.com, bbc.co.uk, and cnn.com which DON’T work properly on IE8. Oh i forgot, msn.com and microsoft.com neither!
Microsoft’s blog: http://blogs.msdn.com/ie/archive/2008/08/27/introducing-compatibility-view.aspx
Here’s one to you Microsoft _.|..! Go fuck yourselves, your stupid browser and releases. I rather break my leg than support your stupid standards.
Posted 11 months, 3 weeks ago at 11:17 pm. 3 comments
Today i had some issues with mysql dbd module for apache.
I had two servers: One located in Slovenia and second located in US.
Imagine how rocket-fast this thing was, when i got 50 requests per page and all of them were authenticated via dbd mysql module.
So i decided to wrote my own script which will fetch all the users from database, convert their passwords with proper encryption and then put them into an .htpasswd file. Script will do this every few minutes.
Copy this code into your favorite nix editor, edit variables and save it on chosen location.
# Variables
define("DB_HOST", "localhost");
define("DB_USER", "htpasswd");
define("DB_PASS", "somepasswd");
define("DB_NAME", "htpasswd");
# data dir - for .htpasswd file
define("ROOTDIR", "/usr/local/www/htpasswd/");
# .htpasswd file - we will call this file from .htaccess
define("HTPASSWDFILE", ROOTDIR . ".htpasswd");
# tmp file for dumping data
define("HTPASSWDTMP", ROOTDIR . ".htpasswd.tmp");
# backup of previous .htpasswd file (if something's foo)
define("HTPASSWDBAK", ROOTDIR . ".htpasswd.bak");
# maybe you would want to add some static users,
# which will be here even if database is empty or there are no "valid" users in database.
$static_users = array(
'staticuser' => 'hispass'
);
# FUNCTIONS
# htpasswd
function htpass($pass) {
return crypt($pass, base64_encode($pass));
}
# database
function connect_to_db() {
if(!$link = @mysql_connect(DB_HOST,DB_USER,DB_PASS)){
die("MYSQL ERROR: " .mysql_error(). "n");
}else{
if(!@mysql_select_db(DB_NAME)){
die ("MYSQL ERROR:".mysql_error());
}else{
return $link;
}
}
}
# init
$link = connect_to_db();
$query = "select username, password from protected_users where DATE(NOW()) < expires";
if(!$result = @mysql_query($query)) {
die(mysql_error(). "n". $query);
} else {
# create backup file if .htpasswd already exists
if(file_exists(HTPASSWDFILE)) {
copy(HTPASSWDFILE, HTPASSWDBAK);
}
# dump DB users into file
$file = fopen(HTPASSWDTMP, 'w') or die("Can't open file");
while ($row = mysql_fetch_array($result, MYSQL_NUM)) {
fwrite($file, $row[0]. ":" .htpass($row[1]). "n");
}
# dump static users into file
foreach($static_users as $user=>$pass) {
fwrite($file, $user. ":" .htpass($pass). "n");
}
# close links / files
mysql_close($link);
fclose($file);
rename(HTPASSWDTMP, HTPASSWDFILE);
}
Create the database and prepare tables:
CREATE DATABASE IF NOT EXISTS htpasswd;
CREATE TABLE IF NOT EXISTS `protected_users` (
`id` int(11) NOT NULL auto_increment,
`username` varchar(32) NOT NULL,
`password` varchar(32) NOT NULL COMMENT 'plain password',
`expires` date NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=2 ;
INSERT INTO `protected_users` (`id`, `username`, `password`, `expires`) VALUES
(1, 'test', 'test', '2012-01-01');
Give some privileges to DB user “htpasswd”:
GRANT SELECT ON htpasswd.* TO 'htpasswd'@'localhost' IDENTIFIED BY 'somepassword';
Now set up your .htaccess file
AuthType Basic
AuthName "Protected"
AuthBasicProvider file
AuthUserFile /usr/local/www/htpasswd/.htpasswd
Require valid-user
and cron job:
*/5 * * * * cd /path/to/your/script/; /path/to/bin/php yourscript.php
.htpassword will be updated every 5 minutes. If you want to increase/decrease time between updates just change the value in cron job.
Have fun!
Posted 11 months, 3 weeks ago at 8:20 pm. 2 comments
Ever wondered how cool it will be to have an random password generator in your shell?
Here’s a little bash script i wrote:
Put this
#!/usr/local/bin/bash
if [ -n $1 ]; then
CHARS=$1
while [[ "$COUNT" -ne "$CHARS" ]]; do
let COUNT=COUNT+1;
done
else
COUNT=8; # DEFAULT NUMBER OF CHARACTERS
fi
/usr/bin/perl -le'print map+(A..Z,a..z,0..9)[rand 62],1..'$COUNT;
into /usr/local/bin/passgen and then chmod it properly:
[root@box ~]# chmod +x /usr/local/bin/passgen
Now try it in action:
[root@box ~]# passgen
UJXG1JMx
[root@box ~]# passgen 15
l3LMgNOuCK3OYnH
[root@box ~]# passgen 1
J
[root@box ~]#
Have fun! :-P
Posted 11 months, 3 weeks ago at 8:14 pm. 0 comments
If you want to have safe shared hosting u will definitely change some user permissions and the UMASK.
Let me first explain what the umask is:
UMASK is an unix env variable which automatically sets file permissions on newly created files.
By default it is set to 022, which means it creates newly created files with permissions 755. (More about permissions - File system permissions)
Now if we want to set user permissions to 700 , we will change that default umask to 007 for this particular user.
Here is the command to set up users class:
pw usermod username -L someclass
Add this line to /etc/login.conf:
someclass:
:umask=007:
:tc=default:
Run the command:
to rebuild database.
Now were set, login to macihne as user “username”:
Create some random directory:
[username@box ~]$ mkdir smth
And the directory permissions should look like this:
[username@box ~]$ ls -al | grep smth
drwx------ 2 username username 512 Feb 16 19:04 smth
[username@box ~]$
If you want to have different permissions, just change the value in /etc/login.conf “:umask=007:” to one that fits to you. More about UMASK - UMASK.
D.
Posted 11 months, 4 weeks ago at 4:21 pm. 5 comments
Yes i’m geek and i’m using VI. I found tons of ^M’s in wordpress files while i was coding this blog.
Here’s how to get rid of them:
Open your file in vi
then press “:” and type this:
[ctrl+v] … hold control and press v
[ctrl+m] … hold control and press m
Voila, there’s no more ^M’s and your code is clean in the way it should be!
Posted 11 months, 4 weeks ago at 2:20 am. 0 comments
Hi there! ;-)
Firing up a brand new blog, powered by wordpress <3.
It’s beta and i hope it will be an stable release soon. I have a lots of geek candies for you! ;-)