台式机高级维护

台式机高级维护,定期性大规模清灰,把硅脂均匀涂在CPU表面

image

image

$ x= \int v_x {\rm d}t $
$ y= \int v_y {\rm d}t $
$ \left|v \right|= \sqrt{x^2 + y^2} = v_1 $

【160718】ACM俱乐部暑期交流

  • C++兼容C,但C++不是C的超集。

  • gcc与Visual C++分别代表两种编译器套装,各自都包含C编译器和C++编译器。

  • gcc或Visual C++都根据源代码文件的扩展名*.c/*.cpp选择语言,但评测时的语言选项并非如此。
    提交代码时如需选择语言或编译器,(GNU) gcc=C语言,g++=C++;
    (Microsoft) C=C语言,(Microsoft) C++=C++.

  • 可以把C语言代码当做C++代码提交。

C语言标准 gcc编译选项
ANSI C(C89) -ansi
C99 -std=c99
C11 -std=c11

评测环境、选项会在OJ、正式比赛的文件上说明。

  • 64位整数的输入输出
    __int64类型只能在Visual C++中使用。
    long long的输入输出格式符为%I64d%lld,会出错?
    unsigned long long的输入输出格式符为%I64u%llu,会出错?

  • 输入若干组数据?
    利用scanf函数的返回值。
    利用gets函数的返回值。

  • 变量的内存空间分配

    静态区: 保存自动全局变量和 static 变量(包括 static 全局和局部变量)。静态区的内容在总个程序的生命周期内都存在,由编译器在编译的时候分配。

    堆: 由 malloc 系列函数或 new 操作符分配的内存,其生命周期由 free 或 delete 决定。在没有释放之前一直存在,直到程序结束,其特点是使用灵活,空间比较大,但容易出错

    栈: 保存局部变量,栈上的内容只在函数的范围内存在,当函数运行结束,这些内容也会自动被销毁,其特点是效率高,但空间大小有限

【160713】服务器管理记录

uname -a

py编写blog爬虫初步

教程指导

urllib2.HTTPError: HTTP Error 403: Forbidden

需添加header以伪装成浏览器访问。

UnicodeEncodeError: ‘gbk’ codec can’t encode character u’\u200e’ in position 43: illegal multibyte sequence

应在编码转换时略去无关紧要的不可见字符。参见

import urllib
import urllib2
import re
import os

def mkdir(path):
    path = path.strip()

    isExists=os.path.exists(path)

    if not isExists:
        os.makedirs(path)
        return True
    else:
        return False

def output_file(dir,name,content,charset):
    fileName = dir + "/" + name#.encode('utf-8','ignore')
    f = open(fileName,"w+")
    f.write(content.encode(charset,'ignore'))
    print "Output file",fileName

def scan_article(host,link,dir,charset):
    url=host+link

    request = urllib2.Request(url)
    # disguising web browser headers
    request.add_header('User-Agent','Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/51.0.2704.106 Safari/537.36')

    response=urllib2.urlopen(request)

    html= response.read().decode('utf-8','ignore')

    # print html

    pattern=re.compile(r'\s*([\s\S]*?)\s*')

    matches=re.findall(pattern,html)

    if matches:
        title=matches[0]
        # filename=re.sub("\s+","_",title)
        filename=re.sub(r'[\s\\\\\\/:\\*\\?"<>\\|]+',"_",title)
        #print title,"[",filename,"]"
    else:
        print "No title matches"
        return

    pattern=re.compile(r'
\s*([\s\S]*?)\s*
\s*
') matches=re.findall(pattern,html) if matches: html=matches[0] # print html else: print "No contents" return # print "Output file",filename+'.html' try: output_file(dir,filename+'.html',html,charset); except Exception as e: print str(e) return def scan_page(id,host,url,dir,charset): request = urllib2.Request(host+url+str(id)) # disguising web browser headers request.add_header('User-Agent','Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/51.0.2704.106 Safari/537.36') response=urllib2.urlopen(request) html= response.read().decode('utf-8','ignore') # print html; pattern=re.compile(r'([\s\S]*?)',re.I|re.M) items=re.findall(pattern,html) if items: # print items for item in items: next=re.match(re.compile(r'\s*([\s\S]+\S)\s*'),item) if next: href=next.group(1) title=next.group(2) scan_article(host,href,dir,charset) # print href,"->",title,"[",filename,"]" else: print "Invalid item" return else: print "No title matches" return dir='data/csdn_utf-8'; host="http://blog.csdn.net" url="/u013491262/article/list/" charset='utf-8' mkdir(dir) # scan_article(host,"/u013491262/article/details/20783371",dir,'utf-8') for i in range(28,31): print "page ",str(i),":" dir='data/csdn_utf-8'+"/"+str(i).zfill(2) mkdir(dir) scan_page(i,host,url,dir,charset)

2016年上半年写前端的点滴汇总

其实只做了一件事情:写异步回调函数。

附带的成就是知道了如何调用cdn资源,如何使用bootstrap框架,如何jquery.