Skip to content

Instantly share code, notes, and snippets.

View guangningyu's full-sized avatar
🎯
Focusing

Guangning Yu guangningyu

🎯
Focusing
View GitHub Profile

XPath 是一门在 XML 文档中查找信息的语言。XPath 可用来在 XML 文档中对元素和属性进行遍历。 在 XPath 中,有七种类型的节点:元素、属性、文本、命名空间、处理指令、注释以及文档节点(或称为根节点)。

###选取节点 节点是通过沿着路径或者 step 来选取的。

表达式:

nodename          选取此节点的所有子节点
/                 从根节点选取

###安装pdfkit

pip install pdfkit
sudo apt-get install wkhtmltopdf

###安装pypdf

pip install pypdf

###生成pdf并添加水印

// 鼠标移入背景色变浓,移出变淡
$(document).ready(function() { // $(document)是一个封装好的函数,将DOM映射为一个jQuery对象
$('div').mouseenter(function() {
$('div').fadeTo('fast', 1); // 0.25是透明度,1代表完全不透明
}) ;
$('div').mouseleave(function() {
$('div').fadeTo('fast', 0.5);
}) ;
});

###Background Color

body {
    background-color: lightblue;
}

###Background Image

body {
@guangningyu
guangningyu / gen_qrcode.py
Created December 4, 2016 03:04
Generate QRCode from text using Python.
import sys
import qrcode
LINES_PER_PARA = 60
def split_file(infile):
para_list = []
para = []
with open(infile, 'rb') as f:
for line in f.readlines():
@guangningyu
guangningyu / NameCleaner.java
Created December 4, 2016 17:11
Reference: Functional Thinking Chapter 2
// Java版本
import java.util.List;
import java.util.ArrayList;
public class NameCleaner {
public static String cleanNames(List<String> listOfNames) {
StringBuilder result = new StringBuilder();
for(int i = 0; i < listOfNames.size(); i++) {
if(listOfNames.get(i).length() > 1) {
result.append(capitalizeString(listOfNames.get(i))).append(",");
}
@guangningyu
guangningyu / send_email.py
Created December 5, 2016 16:15
Send email in HTML format with embedded attachments and images.
#!/usr/bin/python
# -*- coding: utf-8 -*-
"""
This module is used to send emails in HTML format, with embedded attachments and images.
"""
__version__ = '0.2'
__date__ = '2016-04-25'
__author__ = 'Guangning Yu'
@guangningyu
guangningyu / run_sql.py
Created December 6, 2016 14:34
Run SQL queries from remote database using Python.
#!/usr/bin/python
# -*- coding: utf-8 -*-
"""
This module is used to run SQL code from remote DB host.
"""
__version__ = '0.2'
__date__ = '2016-04-13'
__author__ = 'Guangning Yu'
@guangningyu
guangningyu / HTML.py
Created December 6, 2016 14:42
Generate HTML format file containing tables, images and paragraphs using Python.
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
This module provides a few classes to easily generate HTML code
for tables, images and paragraphs.
"""
__version__ = '0.2'
__date__ = '2016-04-13'
@guangningyu
guangningyu / saga_post_method.js
Created December 25, 2016 08:13
An example of using POST method in a Saga.
function statusHelper(response) {
if (response.status >= 200 && response.status < 300) {
return Promise.resolve(response);
}
return Promise.reject(new Error(response.statusText));
}
/* Function: handle the async api call
* Params:
* url: api url