apt-get remove --purge apache2 apache2-data apache2-utils
Saturday, August 22, 2020
Completely uninstall apache2 to get fresh config
Thursday, August 20, 2020
Powershell command to debug ios in chrome
remotedebug_ios_webkit_adapter --port=9000Open safari, browse to the page that is going to be inspected. Then in chrome go to chrome://inspect/#devices and choose the device.
Copy all lastly updated files into a single directory if the version control is horribly not done by git:
Instantiate a git repository (don't need to connect to any remote branch, do everything locally).
Create a .sh file at the current directory, and paste:
#!/bin/bash
git add .
git status
updatedFiles=$(git status | awk '{print $2}' | grep -P "\..*$")
touch updates/update.txt
git status > updates/update.txt
for file in $updatedFiles
do
cp --parents "$file" ./updates
echo "copied $file to ./updates/$file"
done;
read -p "Press enter to exit"
mkdir updates
and then run the bash script above. Files will be copied into updates directory, and we can manage it by date.
Monday, August 3, 2020
如果用了 spring-boot-devtools 的話,謹記在開啟 SpringApplication 前:
public class Main {
public static void main(String[] args) {
System.setProperty("spring.devtools.restart.enabled", "false");
SpringApplication.run(Main.class, args);
}
}
不然不知為甚麼它有 restart 機制,restart 前後的同一個 class 將不視為同一個 class,database transaction 將發生錯誤。
Sunday, August 2, 2020
Hilbernate Database Configuration without XML
package com.springboot.mvc;
import java.util.Properties;
import com.springboot.mvc.models.Customer;
import org.hibernate.SessionFactory;
import org.hibernate.boot.registry.StandardServiceRegistryBuilder;
import org.hibernate.cfg.Configuration;
import org.hibernate.cfg.Environment;
import org.hibernate.service.ServiceRegistry;
public class HibernateUtil {
private static SessionFactory sessionFactory;
public static SessionFactory getSessionFactory() {
if (sessionFactory == null) {
try {
Configuration configuration = new Configuration();
// Hibernate settings equivalent to hibernate.cfg.xml's properties
Properties settings = new Properties();
settings.put(Environment.DRIVER, "com.mysql.cj.jdbc.Driver");
settings.put(Environment.URL,
"jdbc:mysql://192.168.99.100:3306/JDBC_spring_mvc_tutorial?useSSL=false&serverTimezone=UTC");
settings.put(Environment.USER, "cclee");
settings.put(Environment.PASS, "ccleedb12345");
settings.put(Environment.DIALECT, "org.hibernate.dialect.MySQL55Dialect");
settings.put(Environment.SHOW_SQL, "true");
settings.put(Environment.CURRENT_SESSION_CONTEXT_CLASS, "thread");
settings.put(Environment.HBM2DDL_AUTO, "create-drop");
configuration.setProperties(settings);
configuration.addAnnotatedClass(Customer.class);
// we add more and more classes here.
ServiceRegistry serviceRegistry = new StandardServiceRegistryBuilder()
.applySettings(configuration.getProperties()).build();
sessionFactory = configuration.buildSessionFactory(serviceRegistry);
} catch (Exception e) {
e.printStackTrace();
}
}
// Then:
// Session session = sessionFactory.openSession();
// Transaction transaction = session.beginTransaction();
return sessionFactory;
}
}
Tuesday, July 21, 2020
basic setup for hibernate
For hiberante.cfg.xml:
and pom.xml we need:update com.mysql.cj.jdbc.Driver jdbc:mysql://192.168.99.100:3306/JDBC_test?useSSL=false root cclee12345@12345 1 org.hibernate.dialect.MySQL55Dialect true thread create-drop
in additional to the hibernate maven dependencies.mysql mysql-connector-java 8.0.20
Wednesday, July 1, 2020
Record for my Docker Files
FROM node:10 WORKDIR /usr/src/app COPY package*.json ./ RUN npm install && npm rebuild bcrypt --build-from-source EXPOSE 3000 CMD ["npm", "start"]and
version: "3.7"
services:
db:
container_name: postgres_screencapdic_db
image: postgres
restart: always
environment:
POSTGRES_USER: cclee11111
POSTGRES_PASSWORD: cclee11111
POSTGRES_DB: screencapdb
volumes:
- screencapdb:/var/lib/postgresql/data
ports:
- "5432:5432"
# screencap_api:
# build:
# context: ./
# dockerfile: Dockerfile-screepcap-express
# container_name: screencap_api
# restart: always
# ports:
# - "8080:3000"
# volumes:
# - type: bind
# source: ./
# target: /usr/src/app
# - /usr/src/app/node_modules
volumes:
screencapdb:
Subscribe to:
Posts (Atom)