This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import System.Environment | |
import Text.Regex | |
import qualified Data.String.Utils as Utils | |
import qualified Data.Map as Map (fromList, lookup, Map, member, toList) | |
-- when expression | |
import Control.Monad | |
-- exitFailure | |
import System.Exit | |
import Debug.Trace |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="UTF-8"?> | |
<nsclick type="product" > | |
<hao123_nsclick_log type="module" delimiter=" "> | |
<ip type="string"/> | |
<char1 type="string"/> | |
<char2 type="string"/> | |
<time type="string" surrounded_delimiter="[]"/> | |
<query type="record" surrounded_delimiter='""' delimiter=" "> | |
<http_method type="string" /> | |
<url type="record" delimiter="?" extend_record_str="true"> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- Initial cabalTest.cabal generated by cabal init. For further | |
-- documentation, see http://haskell.org/cabal/users-guide/ | |
name: cabalTest | |
version: 0.1 | |
author: zenloner | |
maintainer: [email protected] | |
build-type: Simple | |
cabal-version: >=1.8 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package test.zenloner.com; | |
import org.junit.Assert; | |
import org.junit.Test; | |
public class JTest { | |
@Test | |
public void testHello() { | |
Assert.assertEquals("Hello World", MyTest.hello_world()); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#coding=utf-8 | |
import re | |
def extract_info(pattern, input_file_name, output_file_name, prefix_list): | |
output_file = open(output_file_name, 'w') | |
for line in open(input_file_name,'r'): | |
m = re.match(pattern, line) | |
if m: | |
origin_field = m.group(1) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
//0.函数名、变量名、返回值不可更改 | |
function agent($line) | |
{ | |
//1. 函数体前面部分填写所有需要在统计中使用的变量(不管是否能够匹配出变量值) | |
$res['_OriginalLogLine'] = $line; | |
$line = str_replace("\\x","%",$line); //以\x开头的需要换乘%才能解析出汉字 | |
//$line = urldecode($line); //将line中的汉字解码出来 | |
$res['_UrlPre'] = null; | |
$res['_UrlFields'] = array(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- there is only a after the first of Vector | |
-- a like T in C++ template, declare once and use many times | |
data Vector a = Vector a a a deriving (Show) | |
--use => as the delimiter of type constraint and type declaration | |
-- there is also only one a after Vector, because Vector a is a type and Vector a a a is a type constructor, there are only types in a type declaration, not any type constructors | |
vplus::(Num a) => Vector a->Vector a->Vector a | |
(Vector i j k) `vplus` (Vector l m n) = Vector (i+l) (j+m) (k+n) | |
main = do |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
data Person = Person { | |
firstName::String, | |
lastName::String, | |
age::Int, | |
height::Float, | |
phoneNumber::String, | |
flavor::String | |
} deriving (Show) | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
data Point = Point Float Float deriving (Show) | |
data Shape = Circle Point Float | Rectangle Point Point deriving (Show) | |
area::Shape->Float | |
area (Circle _ r) = pi * r^2 | |
area (Rectangle (Point x1 y1) (Point x2 y2)) = (abs $ x2 -x1)*(abs $ y2-y1) | |
main = do | |
-- fun $ x... is the same as fun(x...) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
data Shape = Circle Float Float Float | Rectange Float Float Float Float | |
area :: Shape -> Float | |
area (Circle _ _ r) = pi * r^2 | |
area (Rectange x1 y1 x2 y2) = (abs $ x2 - x1) * (abs $ y2 - y1) | |
main = do | |
print $ area (Circle 0 0 7.5) |
NewerOlder