Posted by & filed under Linux.

It’s always annoying trying to remember what pid maps to a screen session, but it’s possible to actually name the session.
When starting a screen session, you can start it with arguments:

$ screen -S sessionname

Or within a current screen session, you can do:

C-a : 
sessionname your_session_name

Now when you do a screen -ls, your sessions show up with meaningful names:
There are screens on:

$ screen -ls
        12117.irc      (Detached)
        9905.code      (Multi, detached)
        14850.projectx (Multi, attached)
3 Sockets in /var/run/screen/S-lindsay.

And connecting to them is as easy as:

$ screen -r projectx

Posted by & filed under Webdev.

Классы могут представлять практически любые объекты и взаимоотношения между ними, которые можно выразить словами, для этого просто замените имена существительные классами, глаголы – методами.

Mark Lutz

Posted by & filed under Webdev.

Monit is a Linux Daemon designed to monitor systems internally, can email you when they occur, and provides a nice web interface on port 2812. Additionally, it checks on an interval (every 2 minutes by default) that helps keep your server awake.

Posted by & filed under OSX.

Believe it or not, there’s a modifier command to change how paste works so that it removes all font styles and formatting in the pasting process, regardless of what is stored in the clipboard. It’s just a variation of the normal copy & paste trick:

Copy the text as usual with Command+C
Paste the copied text without formatting by using Command+Option+Shift+V
Notice the difference from the normal Command+V paste trick, which would include the formatting.

Posted by & filed under Webdev.

colout is a simple command to add colors to a text stream in your terminal.

The colout command line interface has been carefully designed to be simple. Basically, you will call it like: | colout [color [style]]

colout has the ability to use 8 colors mode, 256 colors mode, colormaps, themes and source code syntax coloring. Patterns are regular expressions.

You can think of colout as an alternative to grep –color which will preserve the surrounding context, whith more powerful coloring capabilites.

http://nojhan.github.io/colout/

Posted by & filed under Webdev.

lxml is the most feature-rich and easy-to-use library for processing XML and HTML in the Python language.

#! /usr/bin/env python
# -*- coding: utf-8 -*-
# 
import lxml.html

f = open('in.htm', 'r') # http://www.inven.co.kr/board/powerbbs.php?come_idx=2646
html = f.read()
f.close()
doc = lxml.html.document_fromstring(html)
for tr in doc.xpath('//*[@style="border: 1px solid rgb(178, 178, 178); width: 70px; height: 40px; overflow: hidden; margin-left: 5px;"]'):
	url = tr.getchildren()[0].attrib['href']
	preview = tr.getchildren()[0].getchildren()[0].attrib['src']
	print url, preview

Posted by & filed under Webdev.

Using base64 and gzip

<?php
$infile=$_SERVER['argv'][1];
$outfile=$_SERVER['argv'][2];if (!$infile || !$outfile) {
    die("Usage: php {$_SERVER['argv'][0]} <input file> <output file>\n");}
echo "Processing $infile to $outfile\n";
$data="ob_end_clean();?>";
$data.=php_strip_whitespace($infile);
// compress data
$data=gzcompress($data,9);
// encode in base64
$data=base64_encode($data);
// generate output text
$out='<?ob_start();$a=\''.$data.'\';eval(gzuncompress(base64_decode($a)));$v=ob_get_contents();ob_end_clean();?>';
// write output text
file_put_contents($outfile,$out);