Preface: On a similar article, it is in March of 2011, saw the written at the time, in addition to the code, there are other thinking, but less and less, behind the old, want to things less, also have nothing to write, now back up and feel really necessary, can be a month of practice, reflection, or a year later, Nothing seems to have been learned.
Coding summary
Golang
How to integrate some resource files into binary executable files is studied, and then the system will be published.
Nodejs
Excel resolution:
var xlsx = require('node-xlsx'); var obj = xlsx.parse("foo.xlsx"); Var excelObj=obj[0].data; Console. log(excelObj) // There are only 3 columns, a column is empty, a column name, etcCopy the code
Other code snippets:
/ / remove the Spaces, tabs, carriage returns the function such as trim (s) {/ / return s.r eplace (/ (^ \ s *) | (\ s * $)/g, ""); return s.replace(/(^\s*)|(\s*$)|([\t\r\n])/g, ""); / / | (\ +)} / / intercept gxcode = 2 character code before the substring (0, 2) / / interception of four before and after the fourth string code_1 = code. The substring (0, 4) code_2 = code.subString (4) code_2.trim() var outData = []; Var tmpData = new Array(); Tmpdata. code = code tmpdata.name = district_name outdata.push(tmpdata)Copy the code
Get location information (administrative region, latitude and longitude, code, etc.) using the Amap API
const superagent = require("superagent"); Function getLocationFromWeb(nameArray) {newName = changeName(nameArray); Then add | var needbatch = "" the if (newname. IndexOf (" |")! Needbatch = "batch=true&" Batch to true} var getstr = "https://restapi.amap.com/v3/geocode/geo?address=" getstr + + = = newname + "&" getstr needbatch Getstr += "key=mykey" // mykey is the requested key // console.log("getting: ", newname) // Contain Chinese, Escape var target = encodeURI(getstr) // console.log(target) let userAgent = userAgents[parseInt(math.random () * userAgents.length)]; superagent .get(target) .set({'User-Agent': UserAgent}).end(function(error, response) {if (error == null) {var myHtml = response.text; var ret = parseHtml(myHtml); } else { console.log("get url failed: %s", error.errno) } }); }Copy the code
Other encoding
Makefile: a project directory contains both files needed to compile into so and files used for testing. So files are not mixed with test files, and the test program compiles with all files (no extra calls to the.so function). During compilation, two makefiles are used, where unnecessary files are filtered when compiling only so files, as shown in the following example:
SRCS1 := $(shell find $(SRC_DIRS) -maxdepth 2 -name '*.cpp' -or -name '*.c')
NONEEDFILES := ./test.cpp ./time_utils.c
SRCS = $(filter-out $(NONEEDFILES), $(SRCS1))
Copy the code
In the above example, test.cpp and time_utils.c are the files used for the tests, filtered out using the filter-out function provided with the Makefile.
Note: Compile all files into so can also, but there will be more unnecessary functions and variables, but also more main function, if opened with dlopen, use DLSYM to view the function, it does not affect, but if so also compile into the test program, then main will be repeated definition.
General knowledge
Github can create a readme. md file to display personal information or profile. See:
https://github.com/nate-lin/github-readme-stats
Copy the code
Github’s Person Access Tokens seem to have changed and need to be regenerated. Do a good job of automation before, do not understand but also can not modify.
Research and development of thinking
Without this month.
The follow-up plan
During the past year, I have been thinking about the construction of a knowledge sharing platform and researched the theme of Hexo + Wiki, but still found it difficult to use. It is mainly used for sharing within the company. Supported functions: Document encryption, PDF preview.
Other intravenous drip
During the qingming Festival and “March 3” holidays, I took part of the time to watch the video of the front end and checked the frame of the front end. Get ready to apply it at work. Sophomore determined not to learn Java, to break, as a worker, dry over. Department moved, farther away, no sledgehammer to kindergarten in the morning.