Unix quotes, regural expressions and sed

Good tutorial for unix scripting

UNIX SHELL Quote Tutorial

http://www.grymoire.com/Unix/Quote.html

Regular Expressions

http://www.grymoire.com/Unix/Regular.html

Sed – An Introduction and Tutorial

http://www.grymoire.com/Unix/Sed.html

How to mount Win partition on Ubuntu

This guide has worked for me:

https://help.ubuntu.com/community/MountingWindowsPartitions

Particularly this section:

https://help.ubuntu.com/community/MountingWindowsPartitions#Manual_Configuration

Presentation in HTML5

Here’s a link to a Ben Brton’s github page where he has i.a. his presentation in HTML5

https://github.com/benburton/presentations

Ubuntu Linux Start / Restart / Stop Apache Web Server

/etc/init.d/apache2 is service script used to start / stop / restart the Apache2 service under Debian or Ubuntu Linux. You need to login as root or use sudo command restart Apache.

Task: Start Apache 2 Server

# /etc/init.d/apache2 start
or
$ sudo /etc/init.d/apache2 start

Task: Restart Apache 2 Server

# /etc/init.d/apache2 restart
or
$ sudo /etc/init.d/apache2 restart

Task: Stop Apache 2 Server

# /etc/init.d/apache2 stop
or
$ sudo /etc/init.d/apache2 stop

The usual location for Debian-like systems (ubuntu) is to place webfiles under the /var/www/… branch of dirs. That is also the location where apache would look (at least you find it in many example apache config files).
So you could build dirs like that:

/var/www/example.com
/var/www/sub1.example.com
/var/www/sub2.example.com
etc.

You may see such statement:

„Could not reliably determine the server’s fully qualified domain name, using 127.0.1.1 for ServerName”

To fix that problem, you need to edit the httpd.conf file. Open the terminal and type,

sudo gedit /etc/apache2/httpd.conf

By default httpd.conf file will be blank. Now, simply add the following line to the file.

ServerName localhost

Save the file and exit from gEdit. Finally restart the server.

sudo /etc/init.d/apache2 restart

How to check what libs are installed

pip freeze

How to check if Postgres is running

/etc/init.d/postgresql status

Django – how to view executed queries

You also can use python logging to log all queries generated by Django. Just add this to your settings file.

LOGGING = {
    'disable_existing_loggers': False,
    'version': 1,
    'handlers': {
        'console': {
            # logging handler that outputs log messages to terminal
            'class': 'logging.StreamHandler',
            'level': 'DEBUG', # message level to be written to console
        },
    },
    'loggers': {
        '': {
            # this sets root level logger to log debug and higher level
            # logs to console. All other loggers inherit settings from
            # root level logger.
            'handlers': ['console'],
            'level': 'DEBUG',
            'propagate': False, # this tells logger to send logging message
                                # to its parent (will send if set to True)
        },
        'django.db': {
            # django also has database level logging
        },
    },
}

 

Also useful some template to show queries in the DEBUG mode:  http://djangosnippets.org/snippets/93/

Follow

Get every new post delivered to your Inbox.