понеділок, 12 травня 2014 р.

WinSCP: General failure

WinSCP is a very nice tool for managing your server content form desktop OS. Meantime it sometimes can provide you very confusing error reports. For example, look at this:
General failure (server should provide error description).
Error code: 4
Error message from server:
Failure Request code: 14 

And who knows what's wrong?! Quick googling show that issue is caused by 100% full drive, so all you need is just clean up some space. And this confusing message is gone :)

References:
http://winscp.net/forum/viewtopic.php?t=1668

середу, 30 квітня 2014 р.

Ubuntu: Removing all legacy unused kernels

Sometimes you need to care about each MB of disk space. You are starting to cleanup drives, but there's nothing obviously can be deleted. In such cases you an free-up some space (from dozens to hundreds of MB) by removing all legacy system kernels.
In such case please make sure you are running the latest kernel version
Compare outputs for
uname -r
and
dpkg -l | grep linux-image
Probably you may need to reboot! Then just issue the following command:
dpkg -l 'linux-*' | sed '/^ii/!d;/'"$(uname -r | sed "s/\(.*\)-\([^0-9]\+\)/\1/")"'/d;s/^[^ ]* [^ ]* \([^ ]*\).*/\1/;/[0-9]/!d' | xargs sudo apt-get purge
References:
http://ubuntugenius.wordpress.com/2011/01/08/ubuntu-cleanup-how-to-remove-all-unused-linux-kernel-headers-images-and-modules/

пʼятницю, 18 квітня 2014 р.

Dropping all databases in MongoDB

Just used mongorestore for database transfer to another server and noticed that resulting database have more records. I may assume mongorestore does not delete existing data. Hence after googling a bit I've found a way to clear all databases first and then didn't have any problems with restore.

So here's the recipe how to drop all databases in MongoDB:
var dbs = db.getMongo().getDBNames()
for(var i in dbs){
    db = db.getMongo().getDB( dbs[i] );
    print( "dropping db " + db.getName() );
    db.dropDatabase();
}
References:
http://stackoverflow.com/questions/6376436/mongodb-drop-every-database

VIM: Syntax highlight for cron files

No one can doubt how much easiness can vi(m) bring to your life :) Very important (and useful) thing is syntax highlight. I just realized that if you edit cron tasks, there is no highligh (excluding /etc/crontab, which has automatic highlight).

So first just open needful file with vim. Don't see helpful highlights, right?

Then just use the following command to make it eye-candy:
:set ft=crontab 

And enjoy the editing :)


Good luck!

References:
http://unix.stackexchange.com/questions/68972/no-syntax-highlighting-when-editing-crontab
http://vimdoc.sourceforge.net/htmldoc/filetype.html

четвер, 17 квітня 2014 р.

Find last logon time on Windows

The easiest and the best way to get last logon time for particular user's login in Windows:

net user  username | findstr /B /C:"Last logon"
References:
http://www.windows-commandline.com/last-logon-time-of-user/

четвер, 10 квітня 2014 р.

Resetting a Sandisk Sansa Clip+ player

Freeze - this sometimes happen to hardware! Especially it's critical when you favorite devices stuck. Luckily there's almast always a way to deal with it. THis is how I just restored my stuck Sandisk Sansa Clip+ player:

1. Press and hold the Power/Menu button for approximately 20 seconds.
2. Release the Power/Menu button.
3. Press the Power/Menu button again to turn on the player.

And I can continue enjoying my music, yeah! :)

Reference:
http://kb.sandisk.com/app/answers/detail/a_id/188/kw/reset%20a%20sansa%20player

середу, 9 квітня 2014 р.

Nginx - setting different root folder for different subdomains

Just found useful way to make nginx config more flexible and create as many subdomains as you need without a need to change vhost configuration.

Here is this sample config:

server {
        server_name ~^(?.+)\.example\.com$;
        root /www/$subdomain.example.com;
.....

Then just create needful folders in /www/.

References:
http://stackoverflow.com/questions/9233368/nginx-server-configuration-subdomain-to-folder

середу, 2 квітня 2014 р.

AWS: IAM policy for renaming S3 objects

Here are the minimal needful list of permissions needed to access, create, delete and rename S3 objects within particular S3 bucket

{
"Version" : "2012-10-17",
"Statement" : [{
"Sid" : "Stmt1000000000001",
"Effect" : "Allow",
"Action" : [
"s3:ListBucket",
"s3:GetBucketLocation"
],
"Resource" : [
"arn:aws:s3:::bucket-name"
]
}, {
"Sid" : "Stmt1000000000002",
"Effect" : "Allow",
"Action" : [
"s3:PutObject",
"s3:GetObject",
"s3:GetObjectVersion",
"s3:DeleteObject",
"s3:DeleteObjectVersion",
"s3:PutObjectAcl",
"s3:GetObjectAcl"
],
"Resource" : [
"arn:aws:s3:::bucket-name",
"arn:aws:s3:::bucket-name/*"
]
}
]
}

Do not forget to replace  bucket-name with actual name of needed bucket and change Sid for your policies. Feel free to apply this policy to needful group/user/bucket :)

понеділок, 31 березня 2014 р.

Determining version of PHP MongoDB driver.

This is the probably the simplest way to determine version of PHP MongoDB driver:
php --ri mongo | grep Version 
You'll get the answer immidiately:
Version => 1.4.5
Reference:

 http://stackoverflow.com/questions/19034006/how-to-check-mongodb-php-driver-version

четвер, 27 березня 2014 р.

A bit of (idiotic) UI design from MS.

Sometimes I really thinks that a lot of idiots works at Microsoft. Sometimes I even get the proofs :)
Just take a look at this UI of Office365.
No comments ;)