需要实现以下所有功能:
- 从指定文件(参数传递)中读取需要分析的英文文章
- 计算文章所有单词加标点符号的数量
- 单独计算所有单词数量
- 单独计算所有标点符号的数量
- 统计每个单词在文中出现的频数
| <VirtualHost *:80> | |
| ServerName example.com | |
| ServerAlias *.example.com | |
| DocumentRoot /rails_app_directory/public | |
| # Redirect all requests that don't match a file on disk under DocumentRoot get proxied to Puma | |
| RewriteEngine On | |
| <Proxy balancer://unicornservers> | |
| BalancerMember http://127.0.0.1:5100 |
| # ansi_colors.rb | |
| # Implement add ansi color escape code to normal string | |
| # | |
| # Created by Martin Hong on 1/17/2015 | |
| # Copyright (c) 2015 Martin Hong. All rights reserved. | |
| # | |
| String.class_eval do | |
| # ==== Start colors with ANSI escape code ==== | |
| # |
| // | |
| // main.m | |
| // words-statistics | |
| // | |
| // Created by Martin Hong on 1/5/15. | |
| // Calculate the total count of words in a speficified paragraph. | |
| // | |
| // Features: | |
| // 1. 计算文章所有单词加标点符号的数量 | |
| // 2. 单独计算文章所有单词的数量 |
| # ~/.bash_profile | |
| function cd { | |
| # actually change the directory with all args passed to the function | |
| builtin cd "$@" | |
| auto_set_tab_chrome_background_color; | |
| } | |
| function auto_set_tab_chrome_background_color { |
| #! /bin/sh | |
| # /etc/init.d/nginx | |
| ### BEGIN INIT INFO | |
| # Provides: nginx | |
| # Required-Start: $all | |
| # Required-Stop: $all | |
| # Default-Start: 2 3 4 5 | |
| # Default-Stop: 0 1 6 | |
| # Short-Description: starts the nginx web server |
| require 'rubygems' | |
| require 'net/smtp' | |
| require 'roo' | |
| def load_receivers | |
| receivers = [] | |
| excel_file = Roo::Excel.new(ENV['EXCEL']) | |
| 2.upto(excel_file.last_row).each do |row| | |
| # Assume that the name is in the second column, and email is in the third column. |
| # Copied from https://gist.github.com/rainchen, original author: https://github.com/rainchen | |
| # | |
| # set in application.rb | |
| # config.middleware.insert_after 'Rack::MethodOverride', 'BlockBadSpider' | |
| class BlockBadSpider | |
| def initialize(app) | |
| @app = app | |
| end | |
| def call(env) |
| hash[:new_key] = hash.delete :old_key |
| require 'socket' | |
| include Socket::Constants | |
| client = TCPSocket.open 'example.com', 1234 | |
| begin | |
| retry_counter = 0 | |
| client.write( "GET / HTTP/1.0\r\n\r\n" ) | |
| results = client.read |