Skip to content

Instantly share code, notes, and snippets.

View LeslieZhu's full-sized avatar
🏠
Working from home

LeslieZhu LeslieZhu

🏠
Working from home
View GitHub Profile
@LeslieZhu
LeslieZhu / grspider.py
Created December 18, 2014 10:23
A spider to get gnma remic pdf file list, as each page maybe generated by JavaScript event, so need simulator the POST method.
#!/usr/bin/env python
# coding: utf-8
"""
grspider.py ----- A spider to get gnma remic prospectuses list
author: Leslie Zhu
email: pythonisland@gmail.com
In GNMA Agency webiste http://www.ginniemae.gov/, there are some remic prospectuses published by month.
Like url :
http://www.ginniemae.gov/doing_business_with_ginniemae/investor_resources/prospectuses/Pages/remic_prospectuses.aspx
@LeslieZhu
LeslieZhu / dumpftp.sh
Last active August 29, 2015 14:09
dump a ftp website files
#!/usr/bin/env bash
# dumpftp.sh ---- download ftp website files
#
# author: Leslie Zhu <[email protected]>
# date: 2014/11/11
#
# Get each href element in each html page, if it's a plain file, then download it;
# else if it's a dir, then get its href element and download them.
#
@LeslieZhu
LeslieZhu / 0_reuse_code.js
Last active August 29, 2015 14:07
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@LeslieZhu
LeslieZhu / rss.xml
Created February 15, 2014 17:27
An example of RSS xml file
<rss version="2.0">
<channel>
<title>博客名字</title>
<link>博客网址</link>
<description>
<![CDATA[ 博客简介]]>
</description>
@LeslieZhu
LeslieZhu / genrss.py
Last active August 29, 2015 13:56
Read http://lesliezhu.github.com/Notes/index.html and gen my blog's RSS feed file.
#!/usr/bin/env python
#-*- coding:utf-8 -*-
import os,sys,re,time
_rss_ = "http://lesliezhu.github.com/rss.xml"
_dirs_ = ["Notes"] # only RSS Feed 'Notes'
def gen_url(dir=""):
@LeslieZhu
LeslieZhu / wc.lex
Created January 3, 2014 13:49
一个Lex输入文件,可生成计算文本文件的字符、单词和行数且能报告该数字的程 序。单词的定义是不带标点或空格的字符和/或数字的序列。标点和空白格不计算为单 词。习题2.24
%option noyywrap
%{
int ch_c = 0;
int word_c = 0;
int line_c = 0;
%}
fix [\ \,\;\.\}\{\)\(\n\:\#\%\-\+\*\&\^\$\!\~\`\=]
@LeslieZhu
LeslieZhu / upper-keyword.lex
Created January 2, 2014 18:46
Lex输入文件,将C语言中注释之外的保留字转换为大写。习题2.23
%option noyywrap
types auto|enum|unsigned|void|float|short|volatile|char|signed|const|int|double|long
control break|return|case|for|while|goto|continue|if|do|switch|else
other extern|sizeof|static|default|struct|typedef|register|union
keywords {types}|{control}|{other}
prefix [ \,\;\{\}\(\)\t\n\#]
suffix [ \,\;\{\}\(\)\t\n\:\*]
@LeslieZhu
LeslieZhu / uppper-comment.lex
Last active January 2, 2016 00:09
一个Lex文件,通过flex upper-comment.lex; gcc lex.yy.c -o upper-comment;生成一个C语言程序,用于将C语言中注释内的字符转换为大写,是《编译原理及实践》习题2.22。 参考了info flex文档里面给出的例子,增加对“//”注释的支持,是lex中基础知识内容。
%option noyywrap
%%
"/*" ECHO;{
register int c,prev_c;
for ( ; ; ){
while ( (c = input()) != '*' && c != EOF ){
printf("%c",toupper(c));
@LeslieZhu
LeslieZhu / lineno.flex
Last active January 1, 2016 15:09
一个Flex例子,用于生成显示行号的词法分析程序。flex linno.lex; gcc lex.yy.c -o lineno; cat file.txt | ./lineno;
%option noyywrap
%{
/* a Lex program that adds line numbers
to lines of text, printing the new text
to the standard output
*/
#include <stdio.h>
int lineno = 1;
%}
@LeslieZhu
LeslieZhu / upper_keyword.py
Created December 27, 2013 03:40
将C语言源程序文件中的C89的32个关键字转换为大写,但不包括在注释里面的。 可以批处理文件,也可以通过管道输入,或者进入交互模式。 这是《编译原理及实践》的2.21习题的一个实践。
#!/usr/bin/env python
#-*- coding:utf-8 -*-
"""
upper-keyword.py ------- Change C source keyword which not in comment to UPPER.
Author: Leslie Zhu
Email: pythonisland@gmail.com
Version: 1.0