“If you're curious, the book“ Effective work with legacy code ”(Michael Feathers) is most often recommended, followed by the work“ Object-oriented design techniques. Design patterns ”(Erich Gamma). Although the titles of these books are dry, like the Atacama Desert, the content of them, one should think, is of rather good quality. You can sort books by tags, such as javascript, c, graphics and so on. Of course, the list of recommendations does not end with these two names, but these are certainly excellent options for starting, if you are just starting to code or want to upgrade your skills, ”review on Lifehacker.com .
def startElement(self, name, attributes): if name == 'row': self.cur.execute(“INSERT INTO posts (Id, Post_Type_Id, Parent_Id, Accepted_Answer_Id, Creation_Date, Score, View_Count, Body, Owner_User_Id, Last_Editor_User_Id, Last_Editor_Display_Name, Last_Edit_Date, Last_Activity_Date, Community_Owned_Date, Closed_Date, Title, Tags, Answer_Count, Comment_Count, Favorite_Count) VALUES (%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s)”, ( (attributes['Id'] if 'Id' in attributes else None), (attributes['PostTypeId'] if 'PostTypeId' in attributes else None), (attributes['ParentID'] if 'ParentID' in attributes else None), (attributes['AcceptedAnswerId'] if 'AcceptedAnswerId' in attributes else None), (attributes['CreationDate'] if 'CreationDate' in attributes else None), (attributes['Score'] if 'Score' in attributes else None), (attributes['ViewCount'] if 'ViewCount' in attributes else None), (attributes['Body'] if 'Body' in attributes else None), (attributes['OwnerUserId'] if 'OwnerUserId' in attributes else None), (attributes['LastEditorUserId'] if 'LastEditorUserId' in attributes else None), (attributes['LastEditorDisplayName'] if 'LastEditorDisplayName' in attributes else None), (attributes['LastEditDate'] if 'LastEditDate' in attributes else None), (attributes['LastActivityDate'] if 'LastActivityDate' in attributes else None), (attributes['CommunityOwnedDate'] if 'CommunityOwnedDate' in attributes else None), (attributes['ClosedDate'] if 'ClosedDate' in attributes else None), (attributes['Title'] if 'Title' in attributes else None), (attributes['Tags'] if 'Tags' in attributes else None), (attributes['AnswerCount'] if 'AnswerCount' in attributes else None), (attributes['CommentCount'] if 'CommentCount' in attributes else None), (attributes['FavoriteCount'] if 'FavoriteCount' in attributes else None) ) );
class docHandler(xml.sax.ContentHandler): def __init__(self, cusor): self.cusor = cusor; self.queue = 0; self.output = StringIO(); def startElement(self, name, attributes): if name == 'row': self.output.write( attributes['Id'] + '\t` + (attributes['PostTypeId'] if 'PostTypeId' in attributes else '\\N') + '\t' + (attributes['ParentId'] if 'ParentId' in attributes else '\\N') + '\t' + (attributes['AcceptedAnswerId'] if 'AcceptedAnswerId' in attributes else '\\N') + '\t' + (attributes['CreationDate'] if 'CreationDate' in attributes else '\\N') + '\t' + (attributes['Score'] if 'Score' in attributes else '\\N') + '\t' + (attributes['ViewCount'] if 'ViewCount' in attributes else '\\N') + '\t' + (attributes['Body'].replace('\\', '\\\\').replace('\n', '\\\n').replace('\r', '\\\r').replace('\t', '\\\t') if 'Body' in attributes else '\\N') + '\t' + (attributes['OwnerUserId'] if 'OwnerUserId' in attributes else '\\N') + '\t' + (attributes['LastEditorUserId'] if 'LastEditorUserId' in attributes else '\\N') + '\t' + (attributes['LastEditorDisplayName'].replace('\n', '\\n') if 'LastEditorDisplayName' in attributes else '\\N') + '\t' + (attributes['LastEditDate'] if 'LastEditDate' in attributes else '\\N') + '\t' + (attributes['LastActivityDate'] if 'LastActivityDate' in attributes else '\\N') + '\t' + (attributes['CommunityOwnedDate'] if 'CommunityOwnedDate' in attributes else '\\N') + '\t' + (attributes['ClosedDate'] if 'ClosedDate' in attributes else '\\N') + '\t' + (attributes['Title'].replace('\\', '\\\\').replace('\n', '\\\n').replace('\r', '\\\r').replace('\t', '\\\t') if 'Title' in attributes else '\\N') + '\t' + (attributes['Tags'].replace('\n', '\\n') if 'Tags' in attributes else '\\N') + '\t' + (attributes['AnswerCount'] if 'AnswerCount' in attributes else '\\N') + '\t' + (attributes['CommentCount'] if 'CommentCount' in attributes else '\\N') + '\t' + (attributes['FavoriteCount'] if 'FavoriteCount' in attributes else '\\N') + '\n' ); self.queue += 1; if (self.queue >= 100000): self.queue = 0; self.flush(); def flush(self): self.output.seek(0); self.cusor.copy_from(self.output, 'posts') self.output.close(); self.output = StringIO();
initdb -D /media/ssd/postgresq/data
vim /usr/lib/systemd/system/postgresql.service Environment=PGROOT=/media/ssd/postgres PIDFile=/media/ssd/postgres/data/postmaster.pid
systemctl daemon-reload postgresql systemctl start postgresql
CREATE TABLE books_posts AS SELECT * FROM posts WHERE body LIKE '%book%'”;
CREATE TABLE http_books AS SELECT * posts WHERE body LIKE '%http%'”;
rads.stackowerflow.com/[$isbn]/
CREATE TABLE rads_posts AS SELECT * FROM posts WHERE body LIKE '%http://rads.stackowerflow.com%'";
SELECT * , ARRAY(SELECT UNNEST(isbns) EXCEPT SELECT UNNEST(to_exclude )) , ARRAY_UPPER(ARRAY(SELECT UNNEST(isbns) EXCEPT SELECT UNNEST(to_exclude )), 1) FROM ( SELECT * , ARRAY['isbn1', 'isbn2', 'isbn3'] AS to_exclude FROM ( SELECT tag , ARRAY_AGG(DISTINCT isbn) AS isbns , COUNT(DISTINCT isbn) FROM ( SELECT * FROM ( SELECT it.* , t.popularity FROM isbn_tags AS it LEFT OUTER JOIN isbns AS i on i.isbn = it.isbn LEFT OUTER JOIN tags AS t on t.tag = it.tag WHERE it.tag in ( SELECT tag FROM tags ORDER BY popularity DESC LIMIT 1 OFFSET 0 ) ORDER BY post_count DESC LIMIT 20 ) AS t1 UNION ALL SELECT * FROM ( SELECT it.* , t.popularity FROM isbn_tags AS it LEFT OUTER JOIN isbns AS i on i.isbn = it.isbn LEFT OUTER JOIN tags AS t on t.tag = it.tag WHERE it.tag in ( SELECT tag FROM tags ORDER BY popularity DESC LIMIT 1 OFFSET 1 ) ORDER BY post_count DESC LIMIT 20 ) AS t2 UNION ALL SELECT * FROM ( SELECT it.* , t.popularity FROM isbn_tags AS it LEFT OUTER JOIN isbns AS i on i.isbn = it.isbn LEFT OUTER JOIN tags AS t on t.tag = it.tag WHERE it.tag in ( SELECT tag FROM tags ORDER BY popularity DESC LIMIT 1 OFFSET 2 ) ORDER BY post_count DESC LIMIT 20 ) AS t3 ... UNION ALL SELECT * FROM ( SELECT it.* , t.popularity FROM isbn_tags AS it LEFT OUTER JOIN isbns AS i on i.isbn = it.isbn LEFT OUTER JOIN tags AS t on t.tag = it.tag WHERE it.tag in ( SELECT tag FROM tags ORDER BY popularity DESC LIMIT 1 OFFSET 78 ) ORDER BY post_count DESC LIMIT 20 ) AS t79 ) AS tt GROUP BY tag ORDER BY max(popularity) DESC ) AS ttt ) AS tttt ORDER BY ARRAY_upper(ARRAY(SELECT UNNEST(arr) EXCEPT SELECT UNNEST(la)), 1) DESC;
var w = $('#plot').width(); var bars = "";var imgs = ""; var texts = ""; var rx = 10; var tx = 25; var max = Math.floor(w / 60); var maxPop = 0; for(var i =0; i < max; i ++){ if(i > books.length - 1 ){ break; } obj = books[i]; if(maxPop < Number(obj.pop)) { maxPop = Number(obj.pop); } } for(var i =0; i < max; i ++){ if(i > books.length - 1){ break; } obj = books[i]; h = Math.floor((180 / maxPop ) * obj.pop); dt = 0; if(('' + obj.pop + '').length == 1){ dt = 5; } if(('' + obj.pop + '').length == 3){ dt = -3; } var scrollTo = 'onclick="scrollTo(\''+ obj.id +'\'); return false;" "'; bars += '<rect id="rect'+ obj.id +'" class="cla" x="'+ rx +'" y="' + (180 - h + 30) + '" width="50" height="' + h + '" ' + scrollTo + '>'; bars += '<title>' + obj.name+ '</title>'; bars += '</rect>'; imgs += '<image height="70" x="'+ rx +'" y="220" href="img/ol/jpeg/' + obj.id + '.jpeg" onmouseout="unhoverbar('+ obj.id +');" onmouseover="hoverbar('+ obj.id +');" width="50" ' + scrollTo + '>'; imgs += '<title>' + obj.name+ '</title>'; imgs += '</image>'; texts += '<text x="'+ (tx + dt) +'" y="'+ (180 - h + 20) +'" class="bar-label" style="font-size: 16px;" ' + scrollTo + '>' + obj.pop + '</text>'; rx += 60; tx += 60; } $('#plot').html( ' <svg width="100%" height="300" aria-labelledby="title desc" role="img">' + ' <defs> ' + ' <style type="text/css"><![CDATA[' + ' .cla {' + ' fill: #337ab7;' + ' }' + ' .cla:hover {' + ' fill: #5bc0de;' + ' }' + ' ]]></style>' + ' </defs>' + ' <g class="bar">' + bars + ' </g>' + ' <g class="bar-images">' + imgs + ' </g>' + ' <g class="bar-text">' + texts + ' </g>' + '</svg>');
Source: https://habr.com/ru/post/323522/
All Articles