diff --git a/.idea/libraries/Maven__com_google_guava_guava_19_0.xml b/.idea/libraries/Maven__com_google_guava_guava_19_0.xml
new file mode 100644
index 0000000..68e23cc
--- /dev/null
+++ b/.idea/libraries/Maven__com_google_guava_guava_19_0.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/libraries/Maven__com_squareup_okhttp3_okhttp_3_3_1.xml b/.idea/libraries/Maven__com_squareup_okhttp3_okhttp_3_3_1.xml
new file mode 100644
index 0000000..5fd6a41
--- /dev/null
+++ b/.idea/libraries/Maven__com_squareup_okhttp3_okhttp_3_3_1.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/libraries/Maven__com_squareup_okio_okio_1_8_0.xml b/.idea/libraries/Maven__com_squareup_okio_okio_1_8_0.xml
new file mode 100644
index 0000000..fdf8eb4
--- /dev/null
+++ b/.idea/libraries/Maven__com_squareup_okio_okio_1_8_0.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/libraries/Maven__net_sourceforge_htmlcleaner_htmlcleaner_2_6_1.xml b/.idea/libraries/Maven__net_sourceforge_htmlcleaner_htmlcleaner_2_6_1.xml
new file mode 100644
index 0000000..e53ba9c
--- /dev/null
+++ b/.idea/libraries/Maven__net_sourceforge_htmlcleaner_htmlcleaner_2_6_1.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/libraries/Maven__org_jdom_jdom2_2_0_5.xml b/.idea/libraries/Maven__org_jdom_jdom2_2_0_5.xml
new file mode 100644
index 0000000..a70ae59
--- /dev/null
+++ b/.idea/libraries/Maven__org_jdom_jdom2_2_0_5.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/CountMostImport/CountMostImport.iml b/CountMostImport/CountMostImport.iml
new file mode 100644
index 0000000..5df7139
--- /dev/null
+++ b/CountMostImport/CountMostImport.iml
@@ -0,0 +1,16 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/CountMostImport/pom.xml b/CountMostImport/pom.xml
new file mode 100644
index 0000000..6a22edd
--- /dev/null
+++ b/CountMostImport/pom.xml
@@ -0,0 +1,21 @@
+
+
+ 4.0.0
+
+ com.air
+ CountMostImport
+ 1.0-SNAPSHOT
+
+
+
+
+ com.google.guava
+ guava
+ 19.0
+
+
+
+
+
\ No newline at end of file
diff --git a/CountMostImport/src/main/java/CountMostImport.java b/CountMostImport/src/main/java/CountMostImport.java
new file mode 100644
index 0000000..75fab21
--- /dev/null
+++ b/CountMostImport/src/main/java/CountMostImport.java
@@ -0,0 +1,104 @@
+/**
+ * Created by KL on 2016/6/29.
+ */
+
+import com.google.common.base.CharMatcher;
+import com.google.common.base.Function;
+import com.google.common.base.Splitter;
+import com.google.common.collect.Ordering;
+
+import java.io.*;
+import java.nio.file.*;
+import java.nio.file.attribute.BasicFileAttributes;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import static com.google.common.primitives.Ints.min;
+import static java.lang.Math.PI;
+
+public class CountMostImport {
+ //Match files with suffix java
+ private static final PathMatcher matcher = FileSystems.getDefault().getPathMatcher("glob:**.java");
+ //Most N imported classes
+ private static final int mostN = 1000;
+ private List javaFiles = new ArrayList();
+ //Scan path for java files
+ Path path = Paths.get("E:\\code\\work\\campus2016");
+
+
+ private void getJavaFiles() {
+ SimpleFileVisitor javaFinder = new SimpleFileVisitor(){
+ @Override
+ public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException {
+ if(matcher.matches(file))
+ javaFiles.add(file.toFile());
+ return super.visitFile(file, attrs);
+ }
+ };
+ try {
+ java.nio.file.Files.walkFileTree(path, javaFinder);
+ System.out.println("files = " + javaFiles);
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ }
+
+ public List> countMostImportClass() {
+ Map result = new HashMap<>();
+ getJavaFiles();
+
+ for (File f : javaFiles) {
+ try(BufferedReader bufferedReader = new BufferedReader(new FileReader(f))) { // Java7 try with resources
+ String line = null;
+ while ((line = bufferedReader.readLine()) != null) {
+ //process perline
+ String trimedLine = line.trim();
+ if(!trimedLine.startsWith("import"))
+ continue;
+ //import statement
+ List pieces = Splitter.on(CharMatcher.anyOf(" ;"))
+ .trimResults()
+ .omitEmptyStrings()
+ .splitToList(trimedLine);
+ if (pieces.get(pieces.size() - 1).endsWith("*"))
+ continue;
+ else if(pieces.size() == 3) {
+ //Static import
+ String methodName = pieces.get(pieces.size() - 1);
+ String classQualifiedName = methodName.substring(0, methodName.lastIndexOf('.'));
+ result.put(classQualifiedName, result.containsKey(classQualifiedName) ? result.get(classQualifiedName) + 1 : 1);
+ } else if(pieces.size() == 2) {
+ // None static
+ String classQualifiedName = pieces.get(pieces.size() - 1);
+ result.put(classQualifiedName, result.containsKey(classQualifiedName) ? result.get(classQualifiedName) + 1 : 1);
+ }
+ }
+ } catch (FileNotFoundException e) {
+ e.printStackTrace();
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ }// for end
+
+ //Guava Ordering based on map.value
+ Ordering> valueOrdering = Ordering.natural().onResultOf(
+ new Function, Long>() {
+ @Override
+ public Long apply(Map.Entry entry) {
+ return entry.getValue();
+ }
+ }).reverse();
+
+ List< Map.Entry> l = valueOrdering.sortedCopy(result.entrySet());
+ return l.subList(0, min(l.size(), mostN));
+ }
+
+
+ public static void main(String[] args) {
+ System.out.println(PI);
+ List> l = new CountMostImport().countMostImportClass();
+ System.out.println(l);
+ }
+}
diff --git a/EffectiveLines/EffectiveLines.iml b/EffectiveLines/EffectiveLines.iml
new file mode 100644
index 0000000..b2fa549
--- /dev/null
+++ b/EffectiveLines/EffectiveLines.iml
@@ -0,0 +1,15 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/EffectiveLines/pom.xml b/EffectiveLines/pom.xml
new file mode 100644
index 0000000..06bb6b1
--- /dev/null
+++ b/EffectiveLines/pom.xml
@@ -0,0 +1,24 @@
+
+
+ 4.0.0
+
+ com.air
+ EffectiveLines
+ 1.0-SNAPSHOT
+
+
+
+ org.apache.maven.plugins
+ maven-compiler-plugin
+
+ 1.7
+ 1.7
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/EffectiveLines/src/main/java/EffectiveLines.java b/EffectiveLines/src/main/java/EffectiveLines.java
new file mode 100644
index 0000000..2d54255
--- /dev/null
+++ b/EffectiveLines/src/main/java/EffectiveLines.java
@@ -0,0 +1,58 @@
+import java.io.*;
+
+/**
+ * Created by lqs on 2016/6/25.
+ */
+public class EffectiveLines {
+
+ /**
+ * @param path Java file path in string
+ * @return Effective lines in the java file
+ */
+ public static long countEffectiveLines(String path) {
+ File sourceFile = new File(path);
+ return countEffectiveLines(sourceFile);
+ }
+
+ /**
+ * @param file Java file path
+ * @return Effective lines
+ */
+ public static long countEffectiveLines(File file) {
+ long effectiveLines = 0L;
+
+ try(BufferedReader bufferedReader = new BufferedReader(new FileReader(file))) { // Java7 try with resources
+ String line = null;
+ while ((line = bufferedReader.readLine()) != null) {
+ //process perline
+ String trimedLine = line.trim();
+ if(trimedLine.equals("") || trimedLine.startsWith("//"))
+ continue;
+ else
+ effectiveLines++;
+ }
+ } catch (FileNotFoundException e) {
+ e.printStackTrace();
+ System.out.println("File not found");
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ return effectiveLines;
+ }
+
+ public static final void usage() {
+ System.out.println("Usage:\n" +
+ "EffectiveLines filename\n" +
+ "Output: effective lines in the java file\n" +
+ "A line is considered effective if it is not a blank line nor a comment line\n" +
+ "Multi line comment is not in consideration");
+ }
+
+ public static void main(String[] args) {
+ if(args.length < 1) {
+ usage();
+ return;
+ }
+ System.out.println(EffectiveLines.countEffectiveLines(args[0]));
+ }
+}
diff --git a/ExchangeRate/ExchangeRate.iml b/ExchangeRate/ExchangeRate.iml
new file mode 100644
index 0000000..e2b8b68
--- /dev/null
+++ b/ExchangeRate/ExchangeRate.iml
@@ -0,0 +1,22 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/ExchangeRate/pom.xml b/ExchangeRate/pom.xml
new file mode 100644
index 0000000..2e92eda
--- /dev/null
+++ b/ExchangeRate/pom.xml
@@ -0,0 +1,54 @@
+
+
+ 4.0.0
+
+ com.air
+ ExchangeRate
+ 1.0-SNAPSHOT
+
+
+
+ org.apache.maven.plugins
+ maven-compiler-plugin
+
+ 1.7
+ 1.7
+
+
+
+
+
+
+
+
+ com.squareup.okhttp3
+ okhttp
+ 3.3.1
+
+
+
+
+ net.sourceforge.htmlcleaner
+ htmlcleaner
+ 2.6.1
+
+
+
+
+ org.apache.commons
+ commons-lang3
+ 3.0
+
+
+
+
+ org.apache.poi
+ poi
+ 3.14
+
+
+
+
+
\ No newline at end of file
diff --git a/ExchangeRate/src/main/java/ExchangeRate.java b/ExchangeRate/src/main/java/ExchangeRate.java
new file mode 100644
index 0000000..7ff955f
--- /dev/null
+++ b/ExchangeRate/src/main/java/ExchangeRate.java
@@ -0,0 +1,118 @@
+import okhttp3.*;
+import org.apache.commons.lang3.StringEscapeUtils;
+import org.apache.poi.hssf.usermodel.HSSFWorkbook;
+import org.apache.poi.ss.usermodel.Row;
+import org.apache.poi.ss.usermodel.Sheet;
+import org.apache.poi.ss.usermodel.Workbook;
+import org.htmlcleaner.CleanerProperties;
+import org.htmlcleaner.HtmlCleaner;
+import org.htmlcleaner.TagNode;
+import org.htmlcleaner.XPatherException;
+
+import java.io.FileNotFoundException;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * Created by KL on 2016/6/26.
+ */
+public class ExchangeRate {
+
+ private static final String requestURL = "http://www.safe.gov.cn/AppStructured/view/project_RMBQuery.action";
+ private List data = new ArrayList<>();
+ private final String excelPath = "xlstest.xls";
+ private String startDate = "2016-06-01";
+ private String endDate = "2016-06-26";
+
+
+ public String getExchangeRate() {
+ String result = null;
+ OkHttpClient client = new OkHttpClient();
+ RequestBody formBody = new FormBody.Builder()
+ .add("projectBean.startDate", startDate)
+ .add("projectBean.endDate", endDate)
+ .add("queryYN", "true")
+ .build();
+ Request request = new Request.Builder()
+ .url(requestURL)
+ .header("User-Agent", "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/51.0.2704.63 Safari/537.36")
+ .header("Referer", "")
+ .post(formBody)
+ .build();
+
+ try {
+ Response response = client.newCall(request).execute();
+ result = response.body().string();
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ return result;
+ }
+
+ public void parseHtml(String htmlContent) {
+ HtmlCleaner cleaner = new HtmlCleaner();
+ CleanerProperties properties = cleaner.getProperties();
+
+ try {
+ TagNode nodes = cleaner.clean(htmlContent);
+ Object[] tables = nodes.evaluateXPath("//*[@id=\"InfoTable\"]/tbody");
+ if (tables.length < 1) {
+ System.out.println("parse error");
+ return;
+ }
+ TagNode table = (TagNode) tables[0];
+ List rows = table.getChildTagList();
+ for(int i = 0; i < rows.size(); i++) {
+ TagNode row = (TagNode) rows.get(i);
+
+ List cols = row.getChildTagList();
+ TagNode date = (TagNode) cols.get(0);
+ TagNode dollar = (TagNode) cols.get(1);
+ TagNode euro = (TagNode) cols.get(2);
+ TagNode hkDollar = (TagNode) cols.get(4);
+
+ data.add(new String[]{
+ StringEscapeUtils.unescapeHtml3((date.getText().toString().trim())),
+ StringEscapeUtils.unescapeHtml3((dollar.getText().toString().trim())),
+ StringEscapeUtils.unescapeHtml3((euro.getText().toString().trim())),
+ StringEscapeUtils.unescapeHtml3((hkDollar.getText().toString().trim())),
+ });
+ }
+ } catch (XPatherException e) {
+ e.printStackTrace();
+ }
+ }
+
+ public void writeExcel() {
+ Workbook wb = new HSSFWorkbook();
+ Sheet sheet = wb.createSheet("中国银行汇率中间价");
+
+ for (int i = 0; i < data.size(); i++) {
+ String[] rowData = data.get(i);
+ Row r = sheet.createRow(i);
+ for (int j = 0; j < rowData.length; j++) {
+ r.createCell(j).setCellValue(rowData[j]);
+ }
+ }
+
+ try(FileOutputStream outputStream = new FileOutputStream(excelPath)) { // Java7 try with resources
+ wb.write(outputStream);
+ } catch (FileNotFoundException e) {
+ e.printStackTrace();
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ }
+
+ public void run() {
+ String htmlContent = getExchangeRate();
+ parseHtml(htmlContent);
+ writeExcel();
+ }
+
+ public static void main(String[] args) {
+ new ExchangeRate().run();
+ }
+}
diff --git a/Top10Ip b/Top10Ip
new file mode 100644
index 0000000..6a296a2
--- /dev/null
+++ b/Top10Ip
@@ -0,0 +1 @@
+cat access.log | awk "{print $1}" | sort | uniq -c | sort -n | tail -2
\ No newline at end of file
diff --git a/idea.gitignore b/idea.gitignore
new file mode 100644
index 0000000..8dd1ee5
--- /dev/null
+++ b/idea.gitignore
@@ -0,0 +1,57 @@
+*.class
+
+# Mobile Tools for Java (J2ME)
+.mtj.tmp/
+
+# Package Files #
+*.jar
+*.war
+*.ear
+
+# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
+hs_err_pid*
+
+# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and Webstorm
+# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839
+
+# User-specific stuff:
+.idea/workspace.xml
+.idea/tasks.xml
+.idea/dictionaries
+.idea/vcs.xml
+.idea/jsLibraryMappings.xml
+
+# Sensitive or high-churn files:
+.idea/dataSources.ids
+.idea/dataSources.xml
+.idea/dataSources.local.xml
+.idea/sqlDataSources.xml
+.idea/dynamic.xml
+.idea/uiDesigner.xml
+
+# Gradle:
+.idea/gradle.xml
+.idea/libraries
+
+# Mongo Explorer plugin:
+.idea/mongoSettings.xml
+
+## File-based project format:
+*.iws
+
+## Plugin-specific files:
+
+# IntelliJ
+/out/
+
+# mpeltonen/sbt-idea plugin
+.idea_modules/
+
+# JIRA plugin
+atlassian-ide-plugin.xml
+
+# Crashlytics plugin (for Android Studio and IntelliJ)
+com_crashlytics_export_strings.xml
+crashlytics.properties
+crashlytics-build.properties
+fabric.properties
\ No newline at end of file
diff --git a/linux2 b/linux2
new file mode 100644
index 0000000..7d45e98
--- /dev/null
+++ b/linux2
@@ -0,0 +1 @@
+scp dir1/xxx username@l-test.dev.cn1:/tmp
\ No newline at end of file