Welcome, Guest! Registration

loc2log

Thursday, 2024-04-25
Seems like BeautifulSoup may help.
Views: 1058 | Added by: ep | Date: 2012-06-24 | Comments (0)

Wanted a clean CSS solution for centering DIV HTML content, something to replace

DIV align="center"

Found somewhere a solution, which looked easy enough:

.center {margin-left:auto;margin-right:auto;}

Good write-ups: http://css-discuss.incutio.com/wiki/Centering_Block_Element, http://www.w3schools.com/css/css_align.asp

... on vertical alignment - Understanding vertical-align, or "How (Not) To Vertically Center Content"

Views: 1219 | Added by: loc2log | Date: 2012-05-22 | Comments (1)

Ucoz web hosting provides useful features, such as RSS Reader and Informers so you can easily integrate RSS newsfeeds or aggregated views to your pages. But there is a big gotcha: These things are best integrated with so called ucoz codes, e.g. $RSSIT_xxx$, $MYINF_xxx$ which are supposed to be just copy-pasted to pages. BUT unlike "Page Editor", the "Publisher" module does not process these directives. There is a solution though, - Java Script.

Instead of RSS Reader's $RSSIT_xxx$, put

<script type="text/javascript" src=http://your_site_address/rssi/xxx>
</script>

Instead of Informer's $MYINF_xxx$, put

<script type="text/javascript" src="http://your_site_address/informer/xxx">
</script>

With RSS Reader there is another gotcha: If there is a problem with the feed source, your visitors will see the last successful record from there. This could be misleading at times. Addressing this issue is not that simple, but some clues could probably be found here - http://likbezz.ru/publ/ucoz/scripts/correct_the_image_links_rss_for_ucoz/29-1-0-77 (Russian)

Given the Ucoz codes are not working in articles, why use the Publisher module at all? Well, it is somewhat better for publishing articles as it has reach catalogging feature, fine grain access control, it is possible to split material into summary and full body, and the most important - it has commeting feature (the basic "Site Pages" does not provide this feature at all).

Views: 1767 | Added by: loc2logg | Date: 2012-05-06 | Comments (0)

Something for Python 2.6, work in progress.
#!/usr/bin/env python
"""loc2log template v.0.2
Template for a simple command line script, Python 2.6.

Usage:
    <script_name> [-hvd]
 
    -v, --verbose
        Verbose output
    -d, --debug
        Debug level
    -h, --help
        This usage screen
"""
import traceback
import os
import sys
import subprocess
import getopt
import datetime
import re

is_verbose = False
debug_level = 0

def usage(rc):
    """Show usage from 'About', then exit."""
    print globals()['__doc__']
    sys.exit(rc)

def do(cmd):
    p = subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE)
    (std, err) = p.communicate()
    # rc = p.returncode
    return std

def main():
    try:
        optlist, arglist = getopt.getopt(sys.argv[1:],
                                         'hvd:',
                                         ['help','h','verbose', 'debug'])
    except Exception, e:
        print >>sys.stderr, "[ERROR] Unexpected input."
        usage(1)

    if len(optlist) == 0:
        print >>sys.stderr, "[ERROR] Missing input parameters."
        usage(1)

    for opt, arg in optlist:
        if opt in ('-h','--help'):
            print 'Help:'
            usage(0)
        elif opt in ('-v', '--verbose'):
            is_verbose = True
        elif opt in ('-d', '--debug'):
            debug_level = int(arg)
            print "debug_level=" + str(arg)
        else:
            print >>sys.stderr, "[ERROR] Unknown input parameter(s)."
            usage(1) 

if __name__ == "__main__":
    try:
        main()
        sys.exit(0)
    except KeyboardInterrupt:
        print("Keyboard interrupt.")
        sys.exit(0)
    except SystemExit:
        sys.exit(0)
    except Exception, e:
        print str(e)
        traceback.print_exc()
        sys.exit(1)
Note:
For Python 2.7 or 3.2, the recommended way for handing command-line parameters is argparse instead of getopt. The latter does not handle optional parameters. Good reads:
getopt – Command line option parsing by Doug Hellman
Views: 3100 | Added by: loc2logg | Date: 2012-05-01 | Comments (0)

Problem: Read items pairwise from list with single elements (planar_list)
from itertools import izip 

planar_list = [1, 2, 3, 4]

for item1, item2 rom izip(*[iter( planar_list )]*2):
    print str(item1) + " " + str(item2)
See Pairs from single list - http://stackoverflow.com/questions/4628290/pairs-from-single-list for details.
Views: 1483 | Added by: loc2logg | Date: 2012-04-22 | Comments (0)

Here is how to enable ssh access root on RedHat(ish) systems.

You need to change in /etc/ssh/sshd_config:

PermitRootLogin no
to
PermitRootLogin yes
and let sshd know its configuration needs to be re-read.

Here is a quick'n'dirty way to be executed from root account, or with sudo,
to enable ssh root access:

sed -e "s/PermitRootLogin no/PermitRootLogin yes/" -i /etc/ssh/sshd_config
/sbin/service sshd reload
to disable ssh root access:
sed -e "s/PermitRootLogin yes/PermitRootLogin no/" -i /etc/ssh/sshd_config
/sbin/service sshd reload

Views: 1264 | Added by: loc2logg | Date: 2012-03-31 | Comments (0)

Here are command line calls for MS Windows admin utilities. Use them from Run or cmd:

adsiedit.msc - edit Acrive Directory, you can see it "as is", all elements, with all prefixes.

gpedit.msc - edit domain policy, remote desktop (terminal) users

Views: 1021 | Added by: loc2logg | Date: 2012-03-27 | Comments (0)

« 1 2 ... 6 7 8 9 »