Tuesday, December 15, 2020

Macbook air m1

 Macbook Air M1:

1. Cannot install/upgrade any apps from app store. (after click, grey)

2. Can I set my Macbook Air to Do nothing When I close the lid?

3. Cannot develop as no JDK for M1 chip? - wait for VM?

Booked the session with specialist.


Bell Hub 3000 USB can only recognize NTFS format, cannot identify exFAT or MAC format.

For NTFS USB, mac is able to read/write, however it's very slow. It takes 14 mins to copy a 1.47Gb file from mac to the USB on Bell Hub 3000.

It takes 3 mins to copy the same file from the Bell Hub 3000 to mac.

It only takes 1 min to upload and download from google drive in my network (500M Fiber).



Thursday, December 3, 2020

Oracle tidy DDL export

 

set serveroutput on

DECLARE

   V_DDL CLOB;

BEGIN

   DBMS_METADATA.SET_TRANSFORM_PARAM(DBMS_METADATA.SESSION_TRANSFORM,'EMIT_SCHEMA',false);

   DBMS_METADATA.SET_TRANSFORM_PARAM(DBMS_METADATA.SESSION_TRANSFORM,'PHYSICAL_PROPERTIES',false);

   DBMS_METADATA.SET_TRANSFORM_PARAM(DBMS_METADATA.SESSION_TRANSFORM,'SEGMENT_ATTRIBUTES',false);

   DBMS_METADATA.SET_TRANSFORM_PARAM(DBMS_METADATA.SESSION_TRANSFORM,'SQLTERMINATOR',false);

   DBMS_METADATA.SET_TRANSFORM_PARAM(DBMS_METADATA.SESSION_TRANSFORM,'STORAGE',false);

   DBMS_METADATA.SET_TRANSFORM_PARAM(DBMS_METADATA.SESSION_TRANSFORM, 'PRETTY', true);

   DBMS_METADATA.SET_TRANSFORM_PARAM(DBMS_METADATA.SESSION_TRANSFORM, 'TABLESPACE',false);

   V_DDL := DBMS_METADATA.GET_DDL('TABLE', 'VIL_POSTED_TRANSACTION_RAW');

   DBMS_OUTPUT.PUT_LINE(V_DDL); 

END;

Saturday, November 21, 2020

Use docker to install WebSphere 8.5.5

1. docker search websphere

2. docker pull amanly/websphere_8_5_5

3. docker images

4. 

To start the container:

docker run -i -t -p 28000:28000 -p 28001:28001 -v /tmp/websphere:/tmpfromhost amanly/websphere_8_5_5 bash

To start WAS:

cd /opt/IBM/WebSphere/AppServer/profiles/Dmgr01/bin/ ./startManager.sh cd ../../AppSrv01/bin/ ./startNode.sh

To login into the WAS Console:

https://localhost:28001/ibm/console username: wasadmin password: wasadmin

https://hub.docker.com/r/amanly/websphere_8_5_5 

Use docker to install Oracle 12c

It's much more easier to install Oracle 12c using docker, rather than install it on the Windows 10 directly. And it's pretty clean and fast.

1. docker search oracle

2. docker pull truevoly/oracle-12c

3. docker run -d -p 8080:8080 -p 1521:1521 truevoly/oracle-12c

4. docker images

   docker ps -a

5. docker logs -f 1cfd95628164

Database ready to use. Enjoy! ;)

Ctrl+C

6. docker exec -it 1cfd95628164 /bin/bash

su oracle

$ORACLE_HOME/bin/sqlplus / as sysdba (need with $ORACLE_HOME/bin/ or bash: sqlplus: command not found)

. oraenv

SQL> conn system/oracle as sysdba

SQL> select name,open_mode from v$database;

SQL> alter user scott identified by tiger;

SQL> alter user scott account unlock;

Saturday, November 7, 2020

大话西游感悟

 大话西游的情节其实比较简单,至尊宝心上人自杀而死,至尊宝心痛万分,想方设法回到过去,希望能挽救心上人。经过一系列波折,至尊宝认识到,即使回到过去,也不会有真正的改变。再神奇的宝物和际遇,都不能改变什么。人不能改变过去,即使回到过去,都不能改变过去。真正能改变的,只有自己,为此导演特地安排了大段的Only you唱段。

在真正的明白(开悟)之后,发现整个世界都美好了—其实世界没有变,变的是自己。比如说,以前可能觉得师父(父母尊长)婆婆妈妈,师弟们(亲朋好友)争吵不休,明道理之后一切就不同了。有缘时会去帮助他人(其实就是自己),至于他人的不理解(好奇怪)、甚至贬低(像条狗),都不会影响内心的平和喜悦,会继续安心修行。

大话西游讲述的其实是开悟的艰辛和开悟后的体验。

Friday, September 4, 2020

git note

 1.

git config -l

git config --system --list

git config --global --list

system: /etc/gitconfig

user: username/.gitconfig

2.

image-20200830124014556




Saturday, August 29, 2020

logback-spring.xml sample

 logback-spring.xml


<configuration>


    <springProperty name="serviceName" source="spring.application.name" />

    <springProperty name="logRoot" source="logging.root" />


    <appender name="AUSPIX" class="ch.qos.logback.core.rolling.RollingFileAppender">

        <file>${logRoot}/${serviceName}-auspix.log</file>

        <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">

            <fileNamePattern>${logRoot}/${serviceName}-auspix-%d{yyyy-MM-dd}.log</fileNamePattern>


        </rollingPolicy>

        <encoder>

            <pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [%mdc{REQUEST_UUID}] %marker %msg%n</pattern>

        </encoder>

    </appender>


    <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">

        <encoder>

            <pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n</pattern>

        </encoder>

    </appender>


    <logger name="AUSPIX" level="info" additivity="false">

        <appender-ref ref="AUSPIX" />

    </logger>


    <root level="info">

        <appender-ref ref="STDOUT" />

        <appender-ref ref="AUSPIX" />

    </root>


</configuration>

Wednesday, August 19, 2020

Linux commands

 1. Check os version in Linux

cat /etc/os-release

2. Show display the amount of available disk space for file systems 

df -h 

3. Search in gz file

zgrep -H 'key words' *.gz


Sunday, August 16, 2020

Log4j log to MongoDB

 Log4j 2 writes log to MongoDB

1. org.springframework.data.document.mongodb.log4j.MongoLog4jAppender is deprecated and removed

2. In log4j2.xml configuration, should use MongoDb, instead of MongoDb2, MongoDB3, or may get "ERROR NoSql contains an invalid element or attribute "MongoDb2"" or "ERROR NoSql contains an invalid element or attribute "MongoDb3""

    <NoSql name="mongoAppender">

        <MongoDb databaseName="auspix" collectionName="log"

            server="localhost" port="27017" username="" password="" />

    </NoSql>    

    <Async name="mongoAppenderAsync">

        <AppenderRef ref="mongoAppender" />

    </Async>

3. In the pom.xml configuration, must provide the below dependency and the log4j-core version must be 2.9.1, same with log4j-nosql. or will get "ERROR appender NoSql has no parameter that matches element MongoDb"

    <dependency>

      <groupId>org.mongodb</groupId>

      <artifactId>mongo-java-driver</artifactId>

      </dependency>     

        <dependency>

            <groupId>org.apache.logging.log4j</groupId>

            <artifactId>log4j-core</artifactId>

            <version>2.9.1</version>

        </dependency>    

<dependency>

<groupId>org.apache.logging.log4j</groupId>

<artifactId>log4j-nosql</artifactId>

<version>2.9.1</version>

</dependency>


The project is on my githug: https://github.com/auspix/log4j2mongo

Reference:

https://logging.apache.org/log4j/log4j-2.9.1/log4j-nosql/index.html

https://logging.apache.org/log4j/log4j-2.9.1/manual/appenders.html#NoSQLAppender

https://www.codeleading.com/article/53808223/

https://yezhwi.github.io/2018/10/26/%E5%88%A9%E7%94%A8Log4j2%E5%BC%82%E6%AD%A5%E4%BF%9D%E5%AD%98%E6%97%A5%E5%BF%97%E5%88%B0MongoDB%E4%B8%AD/

Friday, August 14, 2020

The note about Java 8 Parallel Streams vs ExecutorService

 The Java 8 parallel streams look neat, compact and easy, however, it has limitations you cannot specify the thread number or thread pool.

I did a comparison using the two implementations, I have a list of stock code, and need access the URL to get the name for the code list (3470 code).

For serial retrieval, it needs 900+ seconds.

For parallel streams retrieval, it spends 138 seconds.

For ExecutorService, it spends 45 seconds for 20 threads, 18 seconds for 50 threads, and 5.75 seconds for 200 threads.

//from 900+ seconds to 138 seconds for parallelStream
List<Code> codeList = codeStringList.parallelStream().map( (code)->{
String name = null;
try {
name = SinaDataProvider.getName(code);
} catch (IOException e) {
logger.error("Fatal error to get name for "+code+","+e.getMessage());
e.printStackTrace();
}
logger.debug(code+","+name);
Code codeObj = new Code();
codeObj.setCode(code);
//remove blank space from name
codeObj.setName(name.replaceAll("\\s",""));
codeObj.setStart_time(yyyyMMdd);
codeObj.setEnd_time("");
return codeObj;
}).collect(Collectors.toList());
//45 seconds for 20 threads for ExecutorService 
//18 seconds for 50 threads
//5.75 seconds for 200 threads
ExecutorService executor = Executors.newFixedThreadPool(200);
Collection<Future<Code>> futures = new LinkedList<Future<Code>>();
for(String code:codeStringList){
futures.add(
executor.submit(()->{
String name = null;
try {
name = SinaDataProvider.getName(code);
} catch (IOException e) {
logger.error("Fatal error to get name for "+code+","+e.getMessage());
e.printStackTrace();
}
logger.debug(code+","+name);
Code codeObj = new Code();
codeObj.setCode(code);
//remove blank space from name
codeObj.setName(name.replaceAll("\\s",""));
codeObj.setStart_time(yyyyMMdd);
codeObj.setEnd_time("");
return codeObj;
}));
};
List<Code> codeList = new ArrayList<>();
for (Future<Code> future : futures) {
try {
Code codeObj = future.get();
codeList.add(codeObj);
} catch (Exception e) {
throw new RuntimeException(e);
}
}
executor.shutdown();

Thursday, August 13, 2020

Nice email

 CEO sends a really nice email

In many ways, the pandemic has changed how we interact with one another – a plastic divider separates us from our colleagues, a mask covers our friendly smile as we greet customers, and many in-person meetings have moved online. And yet, despite this physical distance, our XX family is closer than ever. We are standing together by standing apart – and standing tall – as we demonstrate compassion and understanding in the face of hardship, each in our own way.

Monday, August 10, 2020

Mongodb Auspix note

 db.stock.getIndexes();

db.stock.createIndex({"code":1}); 

db.stock.createIndex({"time":1});

db.stock.find( { $and: [ {"code":"SH1A0001"},{"time":{$lte:"20191231 15:00"}}]} ).sort({"time":-1}).limit(1).pretty();

db.stock.distinct("code").length

db.code.find({start_time:{$ne:20200810}}).pretty()


db.stock.find({code:"SH000001"}).sort({time:1}).limit(3).pretty();


db.code.find({end_time:{$ne:""}}).pretty()

db.code.find({$and:[{code:"SH603277"},{end_time:{$ne:""}}]}).pretty()

--sort and limit, need use match

db.stock.aggregate([

{$match:{code:"SH000001"}},

    {"$sort": {"time":-1}},

    {"$limit": 5},

    {"$sort": {"time": 1}}

]).pretty()


--sort and limit

db.stock.aggregate([

{$match:{ $and: [{code:"SH000001"},{time:{$lte:"20200810 15:00"}}] }},

    {"$sort": {"time":-1}},

    {"$limit": 5},

    {"$sort": {"time": 1}}

]).pretty()

The Java implementation:

public List<Stock> getStockList(String code,String timeStr) throws JsonProcessingException {
List<Stock> stockList = new ArrayList<>();
MongoCollection<Document> stockCollection = mongoTemplate.getCollection(stockColName);
AggregateIterable<Document> stockAgg = stockCollection.aggregate(Arrays.asList(match(Filters.and(Filters.eq("code",code),Filters.lte("time",timeStr))),
sort(Sorts.descending("time")),
limit(379),
sort(Sorts.ascending("time"))));
ObjectMapper objectMapper = new ObjectMapper();
for(Document doc:stockAgg){
doc.remove("_id");
Stock stock = objectMapper.readValue(doc.toJson(),Stock.class);
stockList.add(stock);
logger.debug("stock==="+stock);
}
return stockList;
}


distinct multiple fields are pretty not straightforward and not efficient:

both below are not what I expect


db.stock.aggregate( 

[

{"$group": { "_id": { code: "$code", name: "$name" } } }

]

)


db.stock.aggregate([

{$group: {

    _id: null,

    code: {$addToSet: '$code'},

    name: {$addToSet: '$name'}

    }}

])

Saturday, July 11, 2020

spring boot note


spring-boot-starter-test:测试模块,包括JUnit、Hamcrest、Mockito
'Hamcrest' is an anagram of 'matchers' allowing match rules to be defined declaratively.These matchers have uses in unit testing frameworks such as JUnit and jMock. Hamcrest has been included in JUnit 4 since 2012, but was omitted from Junit 5 in 2017.

虽然,Spring Boot中实现了默认的error映射,但是在实际应用中,错误页面对用户来说并不够友好,我们通常需要去实现我们自己的异常提示。
创建全局异常处理类:通过使用@ControllerAdvice定义统一的异常处理类,而不是在每个Controller中逐个定义。@ExceptionHandler用来定义函数针对的异常类型,最后将Exception对象和请求URL映射到error.html


Spring Boot 2.2.6.RELEASE原理剖析

https://blog.csdn.net/zhaodongchao1992/article/details/105215849

https://blog.csdn.net/weixin_43570367/article/details/104960677

By default, all sensitive endpoints added by actuator are secured. This includes ‘/refresh' endpoint. For simplicity, we will turn off security by updating bootstrap.properties:
management.security.enabled=falseAdditionally, starting with Spring Boot 2, actuator endpoints are not exposed by default. To make them available for access, we need to add this in an application.yml:management:
endpoints:
web:
exposure:
include: "*"
Let's start the client first and update user role from existing ‘Developer' to ‘Programmer' in the properties file on GitHub. Config server will show updated values straight away; however, the client won't. To make client see new files we just need to send an empty POST request to ‘/refresh' endpoint, which was added by actuator:
$> curl -X POST http://localhost:8080/actuator/refreshWe will get JSON file back showing updated properties:[
  "user.role"
]The user role was updated successfully and by calling ‘/refresh' endpoint. Client updated configuration without restarting.
By using Actuator, we can refresh clients. However, in the cloud environment, we would need to go to every single client and reload configuration by accessing actuator endpoint.To solve this problem, we can use Spring Cloud Bus.
By using Actuator, we can refresh clients. However, in the cloud environment, we would need to go to every single client and reload configuration by accessing actuator endpoint.
To solve this problem, we can use Spring Cloud Bus.
Now, the client will have another endpoint ‘/bus-refresh'. Calling this endpoint will cause:
  • get the latest configuration from the config server and update its configuration annotated by @RefreshScope
  • send a message to AMQP exchange informing about refresh event
  • all subscribed nodes will update their configuration as well
This way, we don't need to go to individual nodes and trigger configuration update.
We will use spring-cloud-config-monitor to monitor configuration changes and broadcast events using RabbitMQ as transport.

Customizing the Management Endpoint Paths

You can use the management.endpoints.web.base-path property to change the prefix for your management endpoint, as shown in the following example:
management.endpoints.web.base-path=/manage
spring.datasource.driver-class-name=oracle.jdbc.OracleDriver spring.datasource.type=oracle.jdbc.pool.OracleDataSource

System.out.println(jdbcTemplate.getDataSource().getConnection());
will print oracle.jdbc.driver.T4CConnection instead of HikariProxyConnection

JSR-303 Bean Validation

JSR-303 是 JAVA EE 6 中的一项子规范,叫做 Bean Validation,官方的参考实现是Hibernate Validator。需要注意的是此实现与 Hibernate ORM 没有任何关系。JSR 303 用于对 Java Bean 中的字段的值进行合法性验证。

默认springboot集成了 hibernate-validator,而且默认是生效的,可以直接使用。默认不支持基础类型的验证,必须配置拦截器MethodValidationPostProcessor,在Controller类上加 @Validated注解可以实现对方法参数的校验。而且默认只验证 controller 方法上的 validator 注解,而不会验证 controller 层以外的。所以,如果要在其他层使用 validator 验证的话,需要单独配置拦截器.

这里可能你产生了疑问,如果校验失败我们怎么办?不知道你是否了解springboot 统一异常处理

(通过@ControllerAdvice 声明一个全局异常类)我们可以通过统一拦截处理校验异常把上面注解中的的message信息返回给前端。值得注意的是,如果你前台传入的参数不在body中,校验失败抛出BindException异常,如果接口方法的参数有@RequstBody 注解,即参数放在body中传输,会抛出MethodArgumentNotValidException 异常,分别加以处理即可。

如果上面的不满足需要,我们还可以对hibernate-validator 进行扩展,甚至可以实现fail-fast 机制(当有错误时剩下的都不再进行校验立即失败)。


Tuesday, July 7, 2020

Kafka


1.
Kafka uses ZooKeeper so you need to first start a ZooKeeper server if you don't already have one.
Kafka comes with a command line client that will take input from a file or from standard input and send it out as messages to the Kafka cluster.
The broker.id property is the unique and permanent name of each node in the cluster. 
2.
Kafka Streams is a client library for building mission-critical real-time applications and microservices, where the input and/or output data is stored in Kafka clusters.

Saturday, July 4, 2020

IntelliJ IDEA


IntelliJ IDEA
1. For the JUnit test, the class must be public, or there's no context to run it. IntelliJ also requires the test methods are public. However, by default when Eclipse creates the JUnit test cases, the class is not public, the methods are not public either.
2. Community version "Terminal" works perfect, however in the company Ultimate version "Terminal" doesn't work, even if IntelliJ is started with administrator.
3. IntelliJ occupies much more memories, for one single Project, the memory usage is over 1G, Eclipse only uses 200 M for the same Project
4. IntelliJ doesn't have the work space concept?

Thursday, July 2, 2020

Oracle concern


Oracle concern
1. The sequence could be duplicate when update in parallel?
2. To export huge data, index is helpful/worth?

Wednesday, July 1, 2020

Master Microservices with Spring boot and Spring cloud (udemy) note


1. logging.level.org.springframework=debug
check auto configuration report, dispatch servlet, basicErrorController, HttpMessageConvert
2.
Implement validations for RESTful service (size, past..., message="")
3.
swagger-ui.html
v2/api-docs
4. acuator
management.endpoint.web.exposure.include=*
recheck http://localhost:8080/acuator
hal browser
5. spring cloud config
@EnableConfigServer
spring.cloud.config.server.git.uri=file:///in28mins...
localhost:8888/limits-service/default
6. Spring cloud config server
application.properties:
       spring.application.name=limits-service
limits-service-dev.properties
limits-service-qa.properties
localhost:8888/limits-service/qa
7. application
bootstrap.properties:
  spring.application.name=limits-service
  spring.cloud.config.uri=http://localhost:8888/
  spring.profiles.active=dev
8. Use feign to simplifying the REST client
@EnableFeignClients
  Use ribbon for client side load balancing



Sunday, June 28, 2020


Mockito perform a simple restful API testing:

@ExtendWith(SpringExtension.class)
@WebMvcTest(HelloWorldController.class)
class HelloWorldControllerTest {

    @Autowired    private MockMvc mockMvc;

    @Test    public void helloWorld_basic() throws Exception {
        RequestBuilder request = MockMvcRequestBuilders.get("/hello-world").accept(MediaType.APPLICATION_JSON);
        MvcResult mvcResult = mockMvc.perform(request).andExpect(status().isOk()).andExpect(content().string("Hello World")).andReturn();
        assertEquals("Hello World", mvcResult.getResponse().getContentAsString());
    }

@Testpublic void testPost() throws Exception {
    String json = "{\n" +
            "  \"title\": \"Greetings\",\n" +
            "  \"value\": \"hello\"\n" +
            "}";
    mockMvc.perform(MockMvcRequestBuilders.post("/hello/post")
            .contentType(MediaType.APPLICATION_JSON)
            .content(json))
            .andExpect(status().isOk())
            .andExpect(jsonPath("$.title", Matchers.is("Greetings")))
            .andExpect(jsonPath("$.value", Matchers.is("hello")))
            .andExpect(jsonPath("$.*",Matchers.hasSize(2)));
}
}

<dependency>
   <groupId>org.mockito</groupId>
   <artifactId>mockito-all</artifactId>
   <version>1.10.19</version>
   <scope>test</scope>
</dependency>

Saturday, June 20, 2020

告诉你外语学习的真实方法及误区分析 note

http://bbs.tianya.cn/post-english-121795-19.shtml
楼主漏屋
1.
“会用任何语言流利交流的前提是必须能用这种语言思考,做不到的就永远不能正常交流。”
2. 另外有一个非常重要的“沉默期”(Silent period)的概念,是在这假设里引入的。克拉申认为,无论成人或儿童,在掌握说话能力前,都会有一个相当长的沉默期,直到听懂的量达到一定程度而有足够的自信时,才可能说话。这一沉默期是正常的同时也是必要的。
3.
一、早期(Early Stage)
如果单纯从零基础开始,早期(Early Stage)应该是一到两个月
大量使用视觉辅助工具,直接建立“画面”与“声音”在大脑中的“联系”。最典型的手段有两个,一个是“看图识音”(不是看图识字,这是两个完全不同的概念)。在看图片的同时听与图片相关的英语声音;另一个是我们以前谈到过的“全身肢体反应”(TPR)。在这一时期,有几个严格的要求:
  1. 避免使用中文翻译,充分建立条件反射;
  2. 不要试图说英语,只练听力;(还在沉默期内);
  3. 不要看任何拼写,把拼写的学习完全放弃;(不认识字母又和妨?)
  4. 如果有外教参与,外教可多用肢体语言或用手画图协助这一过程,不要教课;
  5. 不要怕听错,要放松和有信心;
  
   这一过程结束时,应该达到1000个左右的词汇+短语量。
“罗塞达石碑”是本人唯一的为大家直接推荐的“英语教学产品”
另外大家在这阶段,不要试图说,同时不要打开字幕,把“说”和“阅读”练习部分统统跳过。大家最多在听时小声重复一下就好。再有就是大家不要“想中文”。
这样几十小时一个级就能完。大家一定不要拖,非得“全会”不可那就麻烦了。觉得70分以上就好了。第二级如果从零基础直接这么上来有点费力,但有一点基础的同学没问题。一共两个月,每天也就一小时吧,我们的(Early Stage)就成功了。(这要靠以前传统学法,非一年不可。)
不是零基础的同学也强烈建议过一遍该系统,把自己脑子里的只有中文解释而没条件反射的单词这样在脑子里加上画面,形成思维。
二 提高期(Upping the Ante)
首先明确目标:
  1. 要学会听懂单句子,建立整句的英文思维;
  2. 达到能听懂简单的,可能是慢语速的整段英文;
  3. 在提高期后期开始尝试简单“说”英语,实现简单沟通;
  4. 开始引入阅读材料(不是学习如何阅读);
1.续列法 (Series Method)
  外教用简单英语结合肢体语言,实物和实景向你描述你日常生活中很熟悉的一个连续动作,难度控制在有(+1)为大约为10%-20%的新词汇(用1000个左右的词汇描绘这类动作很容易做到)。这种连续动作典型的是:
  如何泡茶?如何开车?如何用钥匙打开房门?如何刷牙等等一些生活经历的全过程,用全程动作和实物配合来边说边完成。
  比如如何开门:“First you take out your keys.(拿出钥匙) This is the key.(晃晃钥匙) Then you find the lock on the door. (找到锁)Use your key to unlock it.(用钥匙开锁) Turn the doorknob this way.(拧门把手) Then you push the door open,(推开门) enter the room,(进屋) and then close the door behind you. (回身关上门)。”
  有第一级基础的同学,结合老师动作完成听这个难度没问题。又形象,又直观。这种训练进行一段时间,很快就能听懂各种与生活经验相关的简单句了。
  上面这种训练还是单人的“独角戏”,达到一定熟练程度就可以进入接下来第二部的 “生成对话”(Dialogue Generation)。
  2.生成对话 (Dialogue Generation)
  大家注意,“生成对话”不是自己试着对话,还是听人家对话。对话只是指从“续列法” (Series Method)中的单人独白式的解说,变成了有交流,有反应的实景对话。对话的背景先用“续列法”同样方式单人介绍完毕,让你已经对对话的程序和大致内容了解,然后听对话。比如“如何打车”。先由“续列法”开始:First, walk to the street. Then hold out your hand when you see an empty taxi. If the taxi stops, you get on to the back seat. Say hello to the driver and tell him where you want to go. Make sure he has reset the meter. When you arrive, pay the amount shows on the meter and say good bye. Then close the door behind you. (当然不一定为此真打一趟车,可用教具模拟)然后听对话:一个人拦住了出租车,司机问“去哪里”,答“去…,离什么著名大楼或什么街很近”。路上人多车多,司机颇有怨言,“周末会好些…”到站了,“多少钱?”“多少多少”“给你100”“找钱50”,“拿好发票,别忘了东西”“再见”。 这一对话可以再来一段,程序差不多,内容不同,句子不同。但由于背景熟悉,程序限定,所以很容易“预测”对话内容。几个回合下来,这种场景的对话就非常熟悉了。生成对话的制作可以都用真人,但也可以找到一段对话的录音,再由外教把背景介绍和对话程序按上述方法表述出来加在对话前先听,再开始听对话。
  这两部听力练习的原则大家要掌握的是:
  1. 使用生活经验中熟悉的情景或经验能够预测的情景;
  2. 尽量使用视觉或动作代替语言解释,全过程都用“亲身经历”完成;
  3. 启始难度控制在第一遍听能到80%~90%能懂;
  4. 注意听,不要试图说话;
  5. 绝对禁止阅读和记笔记;
  6. 可以把过程录音以后听。
   美国、加拿大有一电视节目“Yan Can Cook”,一个著名华裔电视厨师Yan教大家做中国菜。他一边幽默地叨唠一边切菜、炒菜,几乎把每个菜、原料,制作过程的每个动作等,全部同步地用英文仔细地叙述一遍,当时惊叹为理想的“可理解性输入”体系!只是没好意思介绍给周围人,怕他们说我拿他们开逗。
看原文电视剧《老友记》是否好?答案是,在这个阶段不好。先不说这一级的同学听起来难度偏高,大家发现《老友记》中的英文大部分是以生活中成人之间的“对话”形式出现的,跟看到的图象情景关联度不大甚至完全没关系。比如大家一起讲笑话,并没有通过演员的动作完全把该笑话的细节和情景“表演”出来,而是大家一听,从语言上就听懂了,所以哈哈一笑。再加上这一阶段的同学对美国语言中文化的成分也缺乏了解,所以这种语言的“可理解性”很低。(只对更高阶段的同学比较起作用,因为英文水平到那时,很多东西的理解已经不主要依赖于图象了,甚至许多抽象的词和概念,本来就是图象和动作无法展示的,而是靠其他条件,关于这些我们下在阶段会讨论)。
这一阶段的结束,应该可以听懂生活中简单的语言。如果非要与词汇量挂钩,应该是2000到4000。用知识量来衡量,应该也就是高中毕业左右的量,当然听力程度相对高。
另外我们看中文小说,很少有不认识的字或词,但Native Speaker看英文小说,碰到不懂的词是常事。
 第二阶段大致要用6个月左右的时间完成。这一阶段的重点就是听力。在这阶段需要听标准发音(还没到纠正口音的时候),而且尽量要带耳机听。不要急着开始说,也不要开始读和写。最后,我们再带着对单词量,背单词和英文拼写的一些认识,其实已经开始进入下一个阶段了Getting Serious了。
三 增长期 Getting Serious
这一时期的主要任务是语言难度和量增长。重点还是听力,但可以开始有针对性地说英文,同时需要进行阅读(但主要并不是为了学习如何阅读)。这一阶段结束时,可以说已经能够进行正常交流和阅读了。(外企一般职位面试,出国求学,国外生活和从事一般技术型工作等可以应付。一般听英语新闻困难不大,看原版电影可听个大概)。
近几年动画大片的语言都非常复杂。即使对成年人来说,大部分也都应该算是作为我们第四阶段的语言教材(比如Finding Nemo, Madagascar等)
How much is seven times eight? 我们几乎立即转变为母语思维进行思考
“纠正语法错误”的做法几乎不起任何作用,下次还在同一处错。比如纠正he,she的错误,其实都不用别人纠正,有时自己就发现了,但下次还错。那如何才有可能变正确?其实还是思维的作用。只有当你头脑中的关于男人的MIF和he挂上了钩,女人的MIF和she联系上后,才可能少犯错。(大家回去试一下,一见到男性图象或真人就说一遍he,一见到女人就念叨一遍 she,经过一段时间he, she, he, she对应练习就会强化这一形象思维与声音的联系。以后尽管不会完全不出错,但会改进很多。)
近几年的研究显示,如果学习策略正确和条件理想,达到流利外语的时间应该在1000小时左右,与母语学习只有约200到300小时的差距。如果是学和母语相近的外语(比如英语和法语),应该在500小时以内实现。我们的目的就是努力从10000小时向1000小时靠拢,而不建议大家努力用刻苦来体现自我价值。
Narrow Input
   把输入材料限制在一个较窄的话题范围内,效果明显要比涉及面宽要好。
A Sample Acquisition Cycle
1, 先听整段原文,段落长短控制在正常速度10钟内放完。难度选择应该是控制在第一遍能听懂的程度是70%上下。不要看文字或字幕。这步的目的主要是先熟悉要学的内容或说是该内容的声音。
  2, 开始分句模仿跟读,每句约三遍,(听一遍跟一遍,不是听一遍读三遍)不懂的也跟读,别着急查意思。是否全对或是否全会不必太介意,可以看字幕但尽量不看,一边模仿,一边猜测不明白部分的含义。关键技巧是“猜测”。
  3, 不看字幕分句跟读一遍,把原声和自己读的声音都录下来。
  4, 放第3步的录音,努力听每句自己读的和原文有何区别并再次感受刚才的过程,可看字幕帮助核对。
  5, 分句自己先说,然后再听原文。第一次可看字幕,后两次尽量不看字幕。
  6, 自己回想该段剧情,试着复述说刚才每部分的句子。
  7, 如果有测试题,可以测试一下自己对上一段掌握的程度,还是80分就好。
  8, 下一段开始,重复上面同样的程序。
关于连读的误区
无论掌握听、说的连读,都是个自然的过程,不要主动地学习连读和练习连读。第三阶段的跨越是最具挑战的,情况很复杂.
一般在第三阶段花了多少时间,自己都说不清楚了,效率再高至少也得有一年多吧,好在并不是每天都要花大量时间,平均每天一小时就好了。终于到了该向珠峰Mount Everest顶冲击了。先把一个不幸的消息告诉大家:我们的外语永远也不可能达到母语的水平(除非12岁以下就能实现流利交流,那本身形成的就是母语,不算外语)。
听说
这是一般的交流已经提高不大了,甚至在国外的一般工作交流,普遍语言难度都比较简单。开会和谈判的语言会比较复杂,但往往因为注意力在谈判内容上,所以会忽略语言的要素。大家可以找“Frasier”来看(中文叫欢乐一家亲)。其实该片的听力难度主要不是对英语反应慢,而是文化,社会和知识性成分太高,两男主角的讲话方式故意附庸风雅,所以难度颇高,没英文字幕不行。每句话在看到文字后还要琢磨半天。克林顿的演讲应该是非常好的听力素材。(不建议找以前名人的演讲,不是语言过时,而是文字太古板了。)
此阶段用外语进行某个学科知识的学习对提高语言水平效果明显。比如金融,经济,计算机等等。国外各学科学习的书,从内容上讲,阅读难度并不大,不象中国的教科书。当年学习计算机硬件基础,看了清华大学潭浩强的书,才看两页就要跳楼,天书啊!后来找了本英文的教材,小人书啊!各种故事,各种比喻(这象抽屉那象桌面的,排队先进屋的后出来等等),各种图画解释,玩儿似的就看完了,结果比其他同学理解还深刻。对此无话可说了。后来还看了些英文的风水书,也居然比中文的还好看。大家无论对任何科目有兴趣,不妨去找英文的教材来看。如果说第三阶段已经没有固定的方法的话,第四阶段可以说都看不到方法了,已经是Life Style了。

摘录一段释迦牟尼讲的话和大家分享:
  
   不要相信只凭听说的任何事物。不要相信世世代代流传下来的传统。不要因为众人都这么说而相信它。不要因为经典上的记载而相信它。不要相信权威、导师或长辈的教导。当你经过观察和分析后,认为事物与原则一致,并有助于个人和大家的善行与利益,才接受实行。

Saturday, June 13, 2020

Spring Batch in Action 2


1. Spring Batch processes items in chunks. Chunk processing
allows streaming data instead of loading all the data in memory. By default, chunk
processing is single threaded and usually performs well.
Using chunk processing, Spring Batch collects items one at a time from
the item reader into a configurable-sized chunk. Spring Batch then sends the chunk
to the item writer and goes back to using the item reader to create another chunk,
and so on, until the input is exhausted.
If you return null from the ItemProcessor method process, processing for
that item stops and Spring Batch won’t insert the item in the database.
2. First, the size of a chunk and the commit interval are the same thing!
Our recommendation is a value between 10 and 200.
3. For this test, you use the volatile job repository implementation. It’s perfect for testing
and prototyping because it stores execution metadata in memory.
4. To be able to refer to job parameters, a bean must use the Spring Batch step scope.
The step scope means that Spring will create the bean only when the step asks for it
and that values will be resolved then (this is the lazy instantiation pattern; the bean
isn’t created during the Spring application context’s bootstrapping).
4. Assuming you can live with skipping some records instead of failing the whole job
<step id="readWriteProducts">
<tasklet>
<chunk reader="reader" writer="writer" commit-interval="100"
skip-limit="5">
<skippable-exception-classes>
<include class="org.springframework.batch.
➥ item.file.FlatFileParseException" />
</skippable-exception-classes>
</chunk>
</tasklet>
</step>
5. Job attributes
restartable    The default is true.
6. Spring Batch provides a default implementation of this interface with the
DefaultJobParametersValidator class that suits most use cases. This class allows you
to specify which parameters are required and which are optional.
7. Chunk attributes
commit-interval: Number of items to process before issuing a commit. When
the number of items read reaches the commit interval number,
the entire corresponding chunk is written out through the item
writer and the transaction is committed.

8.  JdbcCursorItemReader
The minimal set of properties to use a JdbcCursorItemReader is dataSource, sql,
and rowMapper.
Choosing between cursor-based and page-based item readers
Cursor-based readers issue one query to the database
and stream the data to avoid consuming too much memory. Cursor-based
readers rely on the cursor implementation of the database and of the JDBC driver.
Depending on your database engine and on the driver.
Page-based readers work well with an appropriate page size. In this case, retrieving data consists in successively executingseveral requests with criteria. Spring Batch dynamically builds requests to execute
based on a sort key to delimit data for a page. To retrieve each page, Spring Batch executes
one request to retrieve the corresponding data.
the
size of a page should be around 1,000 items—this is a rule of thumb. The page size
is usually higher than the commit interval (whose reasonable values range from 10
to 200 items). Remember, the point of paging is to avoid consuming too much memory,
so large pages aren’t good. Small pages aren’t good either. If you read 1 million
items in pages of 10 items (a small page size), you’ll send 100,000 queries to the
database.

9. JmsItemReader
The Spring Batch class
JmsItemReader implements the ItemReader interface and internally uses the Spring
JmsTemplate class.


swimming pool paint DIY

swimming pool paint DIY:

0. 关泳池
1. 抽水drain
2. 高压水枪冲+sandblast (sanding 池壁,pressure wash)
3. 修补
4. Paint (C$220*2?)
https://torontopoolsupplies.ca/ep-epoxy-paint.html
5. Repaint after wait 12-24 hours for dry
6. Wait 7 days to fill

先用强力洗涤剂洗一遍去除油污,彻底冲洗干净。等24小时表面干透之后就可以涂了。注意清洗的时候不要用容易掉毛的东西,用刷子就行。
涂料是特殊的(Chlorinated Rubber),我买的20L,将近$700。可以用普通的油漆滚筒。当然要用好一点的不掉毛的滚筒。
涂的时候比刷墙简单因为没什么边界。但是注意路线不要困住出不来了。至少2遍,刷完之后再等72小时干透再放水。
最底部的部分涂了4~5层,之后后几个小时检查清理一遍渗水,旁边放个电扇对着不间断吹加速涂料硬化()

请问一整池的水怎么放掉的?
yanxi8784 发表于 2016-10-4 20:00:10

拿个泳池吸尘水管套到skimmer上。水管沉水底。开wast档。 ?

Thursday, June 11, 2020

Spring batch note


1. The overall architecture 
Figure 2.1: Batch Stereotypes

2. Java Config Annotation
The @EnableBatchProcessing works similarly to the other @Enable* annotations in the Spring family. In this case, @EnableBatchProcessing provides a base configuration for building batch jobs. Within this base configuration, an instance of StepScope is created in addition to a number of beans made available to be autowired:
  • JobRepository - bean name "jobRepository"
  • JobLauncher - bean name "jobLauncher"
  • JobRegistry - bean name "jobRegistry"
  • PlatformTransactionManager - bean name "transactionManager"
  • JobBuilderFactory - bean name "jobBuilders"
  • StepBuilderFactory - bean name "stepBuilders"
The core interface for this configuration is the BatchConfigurer. The default implementation provides the beans mentioned above and requires a DataSource as a bean within the context to be provided. This data source will be used by the JobRepository. You can customize any of these beans by creating a custom implementation of the BatchConfigurer interface. Typically, extending the DefaultBatchConfigurer (which is provided if a BatchConfigurer is not found) and overriding the required getter is sufficient.