Quickly setup SQL query logging on console in Django

There is need plugin for Django, named django-debug-toolbar but it needs some time to configure. So when I need simple way to debug SQL queries I use small hack. Add to your settings.py: LOGGING = { 'version': 1, 'disable_existing_loggers': False, 'handlers': { 'console': { 'level': 'DEBUG', 'class': 'logging.StreamHandler', } }, 'loggers': { 'django.db.backends': { 'handlers': ['console'], 'level': 'DEBUG', }, } } To get this working DEBUG option have to be set to True:...

2014-05-28 · 1 min · timor

Changing default php.ini file for PHP-CLI on CentOS

On Debian in default installation you have different configuration files for PHP in Apache, FPM, CLI, etc. But on CentOS you have only one php.ini for all of them. In case I have, I need to have different configuration file for scripts running in CLI mode (more memory, etc). I could run it like this: php -c /etc/php-cli.ini script.php But this a little burdensome. So I do it like this:...

2014-05-08 · 1 min · timor

Command to change root password

Everybody knows passwd command but it’s useless when you need to change ex. root password from command line without waiting for input. In such case oneliner below could help: echo "root:new_password" | chpasswd

2014-05-08 · 1 min · timor

Install Steam on Debian/Ubuntu

These are few steps to get Steam running on Ubuntu: wget -c media.steampowered.com/client/installer/steam.deb dpkg -i steam.deb apt-get install -f apt-get update Solutions for some issues Some time ago I needed 32 bit flash even on 64 bit system - I don’t need it currently but I’m living this as a tip. apt-get install adobe-flashplugin:i386 After Ubuntu upgrade I was unable to run Steam anymore - It shouted on me with strange “networking problem”....

2014-04-22 · 1 min · timor

Rebuild yum/rpm database

When I was trying to update packages on one host I’ve stuck with yum hung on update. I run strace and see: strace -p 43734 Process 43734 attached - interrupt to quit futex(0x807c938, FUTEX_WAIT, 1, NULL <unfinished ...> Process 43734 detached It looks like yum database was corrupted, to repair this run: rm -f /var/lib/rpm/__db* rpm --rebuilddb yum clean all yum update Instead rm on db-files you could use gzip to have backup of these files....

2014-04-04 · 1 min · timor

Nagios - run checks as root with NRPE

I’ve few Nagios checks that require root privileges but running nrpe as root user is not acceptable. I prefer to use sudo for only these few commands. Run visudo and coment out this line: #Defaults requiretty This change is crucial to get scripts working. Then add at the end of file: %nrpe ALL=(ALL) NOPASSWD: /usr/lib64/nagios/plugins/ I’ve used nrpe group, but you have to add exactly group that your nrpe process uses....

2014-03-29 · 1 min · timor

WordPress - add meta tags: author, description, keywords, etc

After reading some SEO stuff I wanted to add some meta tags to my WordPress blog. I found this site: codex.wordpress.org/Meta_Tags_in_WordPress  external link . So WordPress thinks that it’s not necessary to have this meta tags any more… But I want it! 😃 Next funny thing is how they suggest to add meta tags: copy header.php - what about theme updates? I prefer to use functions.php file - just create it in your courrent theme directory with such content:...

2014-03-27 · 1 min · timor

Mediawiki - recover admin rights

Let say you have MediaWiki installation but you lost admin credentials. If you have other account or if you could create one without any rights we’re in home 😉 We have few options to do this. Reset admin password We have to connect to database and use this SQL: UPDATE `user` SET user_password = CONCAT( SUBSTRING(user_password, 1, 3), SUBSTRING(MD5(user_name), 1, 8), ':', MD5(CONCAT(SUBSTRING(MD5(user_name), 1, 8), '-', MD5('new password')))) WHERE user_name = 'Admin'; Just replace Admin with your username and new password with your password....

2014-03-25 · 1 min · timor

Checking memcached status

I need to check memory usage of memcached server so I used: echo stats | nc 127.0.0.1 11211 STAT pid 2743 STAT uptime 263 STAT time 1395438951 STAT version 1.4.13 STAT pointer_size 64 STAT rusage_user 0.482926 STAT rusage_system 2.675593 STAT curr_items 8667 STAT total_items 10742 STAT bytes 23802513 STAT curr_connections 296 STAT total_connections 399 STAT connection_structures 297 STAT cmd_flush 0 STAT cmd_get 52578 STAT cmd_set 10792 STAT get_hits 28692 STAT get_misses 23886 STAT evictions 0 STAT bytes_read 35984361 STAT bytes_written 192647437 STAT limit_maxbytes 536870912 STAT threads 2 STAT accepting_conns 1 STAT listen_disabled_num 0 STAT replication MASTER STAT repcached_qi_free 8189 STAT repcached_wdata 0 STAT repcached_wsize 1026048 END For me, bytes value was important but you could find more about all statistics here  external link ....

2014-03-21 · 1 min · timor

Postfix - automatically drop outbound mail

I have development server with postfix - I wanted to allow outbound traffic to one domain but cut off all the rest. I definitely do not want that test mail or any debug info goes to service users. I have to add something like that to /etc/postfix/transport: allowed.domain.com : * discard: Then run: postmap /etc/postfix/transport At end, add these to /etc/postfix/main.cf: transport_maps = hash:/etc/postfix/transport Reload postfix: postfix reload Test if it works:...

2014-03-18 · 1 min · timor