Skip to content

Instantly share code, notes, and snippets.

View benweizhu's full-sized avatar
🇨🇳
I may be slow to respond.

Ben benweizhu

🇨🇳
I may be slow to respond.
View GitHub Profile
.pure_top {
width: 100%;
height: 100px;
position: relative;
z-index: -1;
overflow: hidden;
}
.pure_top::after {
content: '';
it('handles async useEffect', async () => {
const component = mount(<MyComponent />);
await act(async () => {
await Promise.resolve(component);
await new Promise(resolve => setImmediate(resolve));
component.update();
});
console.log(component.debug());
});
{
not: {
toBe: [Function: throwingMatcher],
toBeCloseTo: [Function: throwingMatcher],
toBeDefined: [Function: throwingMatcher],
toBeFalsy: [Function: throwingMatcher],
toBeGreaterThan: [Function: throwingMatcher],
toBeGreaterThanOrEqual: [Function: throwingMatcher],
toBeInstanceOf: [Function: throwingMatcher],
toBeLessThan: [Function: throwingMatcher],
@benweizhu
benweizhu / gist:846929eb797c747cd17db0deb60921e0
Created April 11, 2020 02:28
How to switch java version on mac
https://stackoverflow.com/questions/21964709/how-to-set-or-change-the-default-java-jdk-version-on-os-x
alias j12="export JAVA_HOME=`/usr/libexec/java_home -v 12`; java -version"
alias j11="export JAVA_HOME=`/usr/libexec/java_home -v 11`; java -version"
alias j10="export JAVA_HOME=`/usr/libexec/java_home -v 10`; java -version"
alias j9="export JAVA_HOME=`/usr/libexec/java_home -v 9`; java -version"
alias j8="export JAVA_HOME=`/usr/libexec/java_home -v 1.8`; java -version"
alias j7="export JAVA_HOME=`/usr/libexec/java_home -v 1.7`; java -version"
@benweizhu
benweizhu / The Many Meanings of Event-Driven Architecture.md
Created February 27, 2020 08:20 — forked from xpepper/The Many Meanings of Event-Driven Architecture.md
My notes on the talk "The Many Meanings of Event-Driven Architecture" by Martin Fowler (GOTO 2017)

GOTO 2017 • The Many Meanings of Event-Driven Architecture - Martin Fowler

(the video is here, the original talk notes are here)

At least one of those four patterns are in play when you talk about "event-driven" architectures:

  1. Event Notification: components communicating via events
  2. Event-carried State Transfer: allowing components to access data without calling the source
  3. Event Sourcing: using an event log as the primary record for a system
  4. CQRS: having a separate component for updating a store from any readers of the store
[server]
SERVER
[server:vars]
server_name=SERVER
[email protected]
docker_nginx_ssl=true
@benweizhu
benweizhu / replace text and new line in sed
Created September 26, 2019 14:42
replace text and new line
sed ':a;N;$!ba;s/\n/ /g' input.txt
sed -i 's/old-text/new-text/g' input.txt
@benweizhu
benweizhu / build.gradle
Created April 24, 2019 08:51 — forked from KenVanHoeylandt/build.gradle
Gradle auto-installing pre-commit hook
apply from: rootProject.file('gradle/install-git-hooks.gradle')
@benweizhu
benweizhu / mysql-docker.sh
Created January 6, 2019 02:28 — forked from spalladino/mysql-docker.sh
Backup and restore a mysql database from a running Docker mysql container
# Backup
docker exec CONTAINER /usr/bin/mysqldump -u root --password=root DATABASE > backup.sql
# Restore
cat backup.sql | docker exec -i CONTAINER /usr/bin/mysql -u root --password=root DATABASE
@benweizhu
benweizhu / App.java
Created September 7, 2018 03:29 — forked from thomasdarimont/App.java
Secure REST API Example with Spring Security, Spring Session, Spring Boot
package demo;
import java.io.Serializable;
import java.security.Principal;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import java.util.UUID;