主頁 >  其他 > 一個策略模式結合spring-boot的starter (設計模式:策略模式 工廠模式 單例模式)

一個策略模式結合spring-boot的starter (設計模式:策略模式 工廠模式 單例模式)

2021-01-05 12:22:50 其他

一個spring-boot自動注入策略工廠的starter (設計模式:策略模式 工廠模式 單例模式)

這個專案寫了幾天了 想寫個博客記錄一下 這個心路歷程 也是和大家的一份分享 但是比較懶 一直沒寫 今天是2020年12月31日 2020年的最后一天了 這一年發生了一些眾所周知的事情 想到這些事 我提起筆想記錄一下
代碼鏈接

專案需求

最近在做 資料可視化 的專案 有一些excel匯入的結構化資料. 雖然資料比較完整的 有一部分是從其他系統中匯出的資料 但是也有一部分是手填的資料 還是需要做一下資料審計的 把 缺失值 例外值 偏離值 找出來

  1. 缺失值 : NULL NONE NaN 空格 空字符
  2. 例外值 : 0值 負值 小于1的數
  3. 離群值: 箱線圖模型超過上界下界的值

在這里插入圖片描述


簡單技術實作

遍歷資料庫表的欄位 查找 缺失值 例外值 加入串列 再把串列合并成了 例外值 的串列

	for(String table : tableList){
	  for(String field : fieldList){
		// 資料庫中查詢到的資料
		List<Map> dataList = new ArrayList();
		
		// a/b/c/d表 a/b/c/d欄位
		if("a".equals(table)){
		  if("a".equals(field)){
		    dataList = aDao.listFieldA();
		  } else if("b".equals(field)){
		    dataList = aDao.listFieldB();
		  } else if("c".equals(field)){
		    dataList = aDao.listFieldC();
		  } else if("d".equals(field)){
		    dataList = aDao.listFieldD();
		  }
		} else if("b".equals(table)){
		  if("a".equals(field)){
		    dataList = bDao.listFieldA();
		  }
		} else if("c".equals(table)){
		  if("a".equals(field)){
		    dataList = cDao.listFieldA();
		  } else if("b".equals(field)){
		    dataList = cDao.listFieldB();
		  } else if("c".equals(field)){
		    dataList = cDao.listFieldC();
		  }
		} else if("d".equals(table)){
    	  if("a".equals(field)){
		    dataList = dDao.listFieldA();
		  } else if("b".equals(field)){
		    dataList = dDao.listFieldB();
		  } else if("c".equals(field)){
		    dataList = dDao.listFieldC();
		  } else if("d".equals(field)){
		    dataList = dDao.listFieldD();
		  }
		}
		if(Collections.isEmpty(dataList)){
		  return;
		}

		JSONArray nullArr=new JSONArray();
		JSONArray zeroArr=new JSONArray();
		JSONArray negativeArr=new JSONArray();
		JSONArray smallArr=new JSONArray();
		// 全部例外值 
		JSONArray allArr=new JSONArray();
		
        for (Map<String,Object> map : totalPowerAllMonth) {
            String electricity_consumption_str_list = (String) map.get("electricity_consumption_list");
            String[] list = StringUtils.split(electricity_consumption_str_list, ',');

            if (Objects.isNull(list)) {
                continue;
            }

            JSONObject data;
            data = new JSONObject();
            
			List<Integer> nullIndexList=new ArrayList();
			List<Integer> zeroIndexList=new ArrayList();
			List<Integer> negativeIndexList=new ArrayList();
			List<Integer> smallIndexList=new ArrayList();
			
            int month = 0;
            for (String electricity_consumption_str : list) {
                month++;
                Double current = null;
                
                try {
                    current = Double.valueOf(electricity_consumption_str);
                } catch (Exception e) {
               		nullIndexList.add(month);
                    continue;
                }
                if (Objects.isNull(current)) {
                	nullIndexList.add(month);
                }else if("0".equals(current.toString())){
                	zeroIndexList.add(month);
                }else if(current<0){
                	negativeIndexList.add(month);
                }else if(current<1){
                	smallIndexList.add(month);
                }
            }
            data.put("electricity_consumption", pre.toString());
	        data.put("province", map.get("province"));
	        data.put("data_year", map.get("data_year"));
	        data.put("kpi_num", map.get("kpi_num"));
	        if(nullIndexlist.size()>0){
		        data.put("index_list", month);
		        data.put("type","空值");
		        nullArr.add(data);
	        }else if(zeroIndexlist.size()>0){
		        data.put("index_list", month);
		        data.put("type","零值");
		        zeroArr.add(data);
	        }else if(negativeIndexlist.size()>0){
		        data.put("index_list", month);
		        data.put("type","負值");
		        negativeArr.add(data);
	        }else if(smallIndexlist.size()>0){
		        data.put("index_list", month);
		        data.put("type","小數");
		        smallArr.add(data);
	        }
        }
        allArr.addAll(nullArr);
        allArr.addAll(zeroArr);
        allArr.addAll(negativeArr);
        allArr.addAll(smallArr);
      }
    }

這是一個簡單的實作了 可以滿足我們的要求 但是問題來了 我們是通過嵌套 if else 的方式 來獲取資料的 當我們的表和欄位發生了改變我們再來 修改資料是很麻煩的 這不符合 開閉原則(對擴展開放,對修改關閉) 代碼也不優雅 會影響我們對代碼的復用以及后續的維護

那么我們需要對代碼進行重構


代碼重構-使用策略模式

這段代碼中 我們需要對不同表的指定幾個欄位進行處理 也需要對不同的例外值型別進行處理 那么我們可以

  1. 將表定義為一個策略
  2. 將例外值型別定義為一個策略

表的策略中包括了需要處理的欄位 然后欄位需要處理的例外值型別通過表策略定義
策略的實作需要繼承自策略介面 這樣我們再利用 spring-boot 的Map注入 將所有的策略實作注入到一個Map中 我們可以根據名稱直接get

表策略介面

需要兩個方法 一個是獲取全部欄位的方法 一個是獲取指定欄位的資料

public interface IAuditStrategy {
    List<String> listField();

    List<Map> listData(String field);
}

四個表策略實作

@Component("auditStrategy_one")
public class OneAuditStrategyImpl implements IAuditStrategy {
	@Autowired
	private Dao dao;
    @Override
    public List<String> listField() {
        List<String> fieldList = new ArrayList<>();
        fieldList.add("a");
        fieldList.add("b");
        fieldList.add("c");
        fieldList.add("d");
        return fieldList;
    }

    @Override
    public List<Map> listData(String field) {
        switch (field) {
            case "a":
                return dao.listA();
            case "b":
                return dao.listB();
            case "c":
                return dao.listC();
            case "d":
                return dao.listD();
        }
        return null;
    }
}
@Component("auditStrategy_two")
public class TwoAuditStrategyImpl implements IAuditStrategy {
    @Override
    public List<String> listField() {
        ...
    }
    @Override
    public List<Map> listData(String field) {
        ...
    }
}
@Component("auditStrategy_three")
public class ThreeAuditStrategyImpl implements IAuditStrategy {
    @Override
    public List<String> listField() {
        ...
    }
    @Override
    public List<Map> listData(String field) {
        ...
    }
}
@Component("auditStrategy_four")
public class FourAuditStrategyImpl implements IAuditStrategy {
    @Override
    public List<String> listField() {
        ...
    }
    @Override
    public List<Map> listData(String field) {
        ...
    }
}

例外值策略介面

可以設定例外型別 放入值 生成索引串列 值串列
資料結構: List< Map< String, Object > >

[
	{
		type: '空值',
		indexList: [ 0 , 1 , 2 ],
		...
	}
]
public interface IAuditInvalidStrategy<T> extends Strategy {
    /**
     * @param type 例外值型別
     */
    void setType(String type);
    /**
     * @return 例外值型別
     */
    String getType();
    /**
     * 手動設定值串列
     *
     * @param valueList 值串列
     */
    void setValueList(List<T> valueList);
    /**
     * 添加值
     *
     * @param value 值
     */
    void addValue(T value);
    /**
     * 添加索引 需要維護一個索引串列
     *
     * @param index 索引
     * @param value 值
     */
    void addIndex(Integer index, T value);
    /**
     * 獲取添加的索引串列
     *
     * @return 索引串列
     */
    List<Integer> getIndexList();
    /**
     * 添加例外值 map 添加后會清空索引串列 值串列
     *
     * @param map map
     */
    void add(Map map);
    /**
     * 獲取全部的map 獲取后會清空 list
     *
     * @return 全部map
     */
    List<Map> getList();
    /**
     * @return list是否為空
     */
    boolean isEmpty();
    /**
     * @return list是否不為空
     */
    boolean isNotEmpty();
}

例外值策略抽象類

抽象類是主要的對資料結構的實作 是策略核心方法的實作 例外值策略實作需要繼承這個抽象類 定義了索引串列和值串列 以及全部的串列
簡化了一些實作 文章里只展示業務邏輯

public abstract class AbsInvalidStrategy<T> implements IAuditInvalidStrategy<T> {
    private String type;
    private boolean isIndexEmpty = true;
    private boolean isEmpty = true;
    protected List<T> valueList;
    protected List<Integer> indexList;
    private List<Map> list;

    protected boolean isNull(T value) {
    	// 例外值判斷簡化了實作 這里只展示業務邏輯
        return Objects.isNull(value);
    }

    protected boolean isZero(T value) {
    	// 例外值判斷簡化了實作 這里只展示業務邏輯
        if (isNull(value)) {
            return false;
        }
        return isZero(value);
    }

    protected boolean isNegative(T value) {
        if (isNull(value) || isZero(value)) {
            return false;
        }
        return isNegative();
    }

    protected boolean isSmall(T value) {
        if (isNull(value) || isZero(value) || isNegative(value)) {
            return false;
        }
        return isSmall();
    }

    @Override
    public void setType(String type) {
        this.type = type;
    }

    @Override
    public String getType() {
        return type;
    }

    @Override
    public void setValueList(List<T> valueList) {
        this.valueList = valueList;
    }

    @Override
    public void addValue(T value) {
        if (Objects.isNull(valueList)) {
            valueList = new ArrayList<>();
        }
        valueList.add(value);
    }

    @Override
    public void beforeAddIndex() {
        if (Objects.isNull(indexList)) {
            indexList = new ArrayList<>();
        }
        if (isIndexEmpty) {
            isIndexEmpty = false;
        }
    }

    @Override
    public List<Integer> getIndexList() {
        if (Objects.isNull(indexList)) {
            indexList = new ArrayList<>();
        }
        return indexList;
    }

    @Override
    public void add(Map map) {
        if (isIndexEmpty) {
            indexList = new ArrayList<>();
            valueList = new ArrayList<>();
            return;
        }
        if (Objects.isNull(list)) {
            list = new ArrayList<>();
        }
        list.add(map);
        if (isEmpty) {
            isEmpty = false;
        }
        indexList = new ArrayList<>();
        isIndexEmpty = true;
        valueList = new ArrayList<>();
    }

    @Override
    public List<Map> getList() {
        isIndexEmpty = true;
        indexList = new ArrayList<>();
        valueList = new ArrayList<>();
        isEmpty = true;

        List<Map> ret = Arrays.asList(new Map[list.size()]);
        Collections.copy(ret, list);
        list = new ArrayList<>();
        return ret;
    }

    @Override
    public boolean isEmpty() {
        return isEmpty;
    }

    @Override
    public boolean isNotEmpty() {
        return !isEmpty;
    }
}

例外值策略實作

主要的實作在抽象類里面已經實作了 不同的策略只需要實作 addIndex 方法 如果是當前例外型別就把索引加入索引串列

@Component("auditStrategyInvalid_零值")
public class AuditZeroStrategyImpl<T> extends AbsInvalidStrategy<T> {
    @Override
    public void addIndex(Integer index, T value) {
        if (isZero(value)) {
            beforeAddIndex();
            indexList.add(index);
        }
    }
}

策略注入與使用

@Service
public class AuditService{
	
	@Autowired
	private Map<String,IAuditStrategy> auditStrategyMap;
	
	@Autowired
	private Map<String,IInvalidStrategy> invalidStrategyMap;

	public JSONArray audit(String table,String field,String type){
		IAuditStrategy auditStrategy = auditStrategyMap.get("auditStrategy_"+table);
		List<Map> dataList = auditStrategy.listData(field);
		
 		IInvalidStrategy invalidHandler = invalidStrategyMap.get("auditStrategyInvalid_"+type);

		int index=0;
		for(Map data:dataList){
		
			List<String> valueList=data.get("valueList");
			for(String value_str:valueList){
				invalidHandler.addValue(value_str);
	            invalidHandler.addIndex(index++, value_str);
			}
			
 			Map invalidMap=new HashMap();
			invalidMap.put("dataIndex", invalidHandler.getIndexList());
			...
			invalidHandler.add(invalidMap);
		}
		
		return invalidHandler.getList();
	}

}

策略模式重構后的代碼變得優雅了將實作與主業務邏輯解耦 如果需要再加入表欄位 或者例外值處理型別 只需要創建對應的檔案 實作策略介面 使用 @Component 注解 交由spring-boot管理 spring-boot 會自動注入到策略Map 我們只需要提供一個字串就可以獲取對應的策略 無需if else判斷


成員變數 執行緒安全問題

spring-boot 中的 bean 是單例的 一個 bean 的成員變數會被多個執行緒訪問 我們的例外值策略實作中的 indexlistlist 并發訪問會出現 執行緒安全 的問題 這個時候我們可以引入一個策略工廠 strategyFatctory

public abstract class AbsInvalidStrategy<T> implements IAuditInvalidStrategy<T> {
    protected List<T> valueList;
    protected List<Integer> indexList;
    private List<Map> list;
}

spring-boot-starter 策略工廠

通過 spring-boot-starter 注入一個 策略工廠 每個執行緒從工廠中創建map避免共享成員變數導致的 執行緒安全 問題

1.策略注解

策略注解 結合了 @Component 會將策略注入到 spring-boot 中 可以通過默認的map方式注入 也可以通過 策略工廠 生產

@Target({ElementType.TYPE})
@Retention(RetentionPolicy.RUNTIME)
@Documented
@Component
public @interface StrategyComponent {
    String value();
}

使用注解

@StrategyComponent("auditStrategy_one")
public class OneAuditStrategyImpl implements IAuditStrategy {
    ...
}

2.策略介面

策略介面只做為一個標識 沒有任何的方法

public interface Strategy {
}

表策略和例外值策略介面繼承策略介面

public interface IAuditStrategy extends Strategy {
	...
}
public interface IAuditInvalidStrategy<T> extends Strategy {
	...
}

3.策略工廠

public class StrategyFactory {
    // 策略工廠實體單例
    private static volatile StrategyFactory instance = null;
    // 策略介面Map<策略介面包名,Map<策略StrategyComponent名,策略實作類class>>
    protected Map<String, Map<String, Class>> interfaceStrategyMap;
    private StrategyFactory() {
    }

    // 單例模式
    static StrategyFactory getInstance() {
        if (Objects.isNull(instance)) {
            synchronized (StrategyFactory.class) {
                if (Objects.isNull(instance)) {
                    instance = new StrategyFactory();
                }
            }
        }
        return instance;
    }

    void setMap(Map<String, Map<String, Class>> interfaceStrategyMap) {
        this.interfaceStrategyMap = interfaceStrategyMap;
    }

    /**
     * 根據策略介面獲取實作自該介面的所有策略實作
     *
     * @param strategyInterfaceClass 策略介面
     * @param <T>                    策略介面型別
     * @return 回傳實作自該介面的所有策略實作的物件實體
     */
    public <T> Map<String, T> getStrategyMap(Class<? extends T> strategyInterfaceClass) {
        Map<String, T> strategyMap = new HashMap<>();
        // 從策略介面Map中獲取實作自該介面的map
        Map<String, Class> strategyClassMap = interfaceStrategyMap.get(strategyInterfaceClass.getName());
        // 遍歷map獲取class檔案生成策略物件實體
        for (Map.Entry<String, Class> entry : strategyClassMap.entrySet()) {
            Class strategyClass = entry.getValue();
            T strategy = null;
            try {
                strategy = (T) strategyClass.newInstance();
            } catch (InstantiationException | IllegalAccessException e) {
                throw new RuntimeException(e);
            }
            strategyMap.put(entry.getKey(), strategy);
        }
        return strategyMap;
    }
}

策略工廠使用 通過

@Service
public class auditService{
	@Autowired
    private StrategyFactory strategyFactory;
	
	public JSONArray audit(){
		// 策略模式
        Map<String, IAuditStrategy> auditStrategyMap = strategyFactory.getStrategyMap(IAuditStrategy.class);
	}
}

4.配置

@Configuration
public class StrategyConfiguration {

    @Autowired
    private ApplicationContext applicationContext;

    /**
     * 策略工廠 bean 生成
     *
     * @return 策略工廠 bean
     */
    @ConditionalOnMissingBean
    @Bean
    public StrategyFactory getStrategyFactory() {
        Map<String, Map<String, Class>> strategyInterfaceMap = new HashMap<>();
        // 獲取實作自策略介面的所有strategyComponent bean
        Map<String, Strategy> strategyMap = applicationContext.getBeansOfType(Strategy.class);
        for (Map.Entry<String, Strategy> strategyEntry : strategyMap.entrySet()) {
            // 策略實作bean的class
            Class strategyClass = strategyEntry.getValue().getClass();
            // 策略介面的包名串列
            List<String> interfaceNameList = getInterfaceNameList(strategyClass);
            if (CollectionUtils.isEmpty(interfaceNameList)) {
                continue;
            }
            // 遍歷策略介面包名生成策略Map
            for (String interfaceName : interfaceNameList) {
                Map<String, Class> strategyClassMap = strategyInterfaceMap.get(interfaceName);
                if (Objects.isNull(strategyClassMap)) {
                    strategyClassMap = new HashMap<>();
                    strategyInterfaceMap.put(interfaceName, strategyClassMap);
                }
                strategyClassMap.put(strategyEntry.getKey(), strategyClass);
            }
        }
        // 策略工廠單例
        StrategyFactory strategyFactory = StrategyFactory.getInstance();
        // 放入全部的策略
        strategyFactory.setMap(strategyInterfaceMap);
        return strategyFactory;
    }

    /**
     * 通過策略實作class 反射 獲取實作的全部策略介面名稱
     *
     * @param strategyClass
     * @return
     */
    private List<String> getInterfaceNameList(Class strategyClass) {
        List<String> interfaceNameList = new ArrayList<>();
        // 從遞回全部父類中找到實作的介面
        getExtendsOf(strategyClass, interfaceNameList);

        return interfaceNameList;
    }

    /**
     * 從遞回全部父類中找到實作的介面
     *
     * @param strategyClass     當前類
     * @param interfaceNameList 介面名稱串列
     */
    public void getExtendsOf(Class strategyClass, List<String> interfaceNameList) {
        // 獲取父類
        Class supperClass = strategyClass.getSuperclass();
        if (Objects.nonNull(supperClass)) {
            // 如果存在父類 遞回呼叫
            getExtendsOf(supperClass, interfaceNameList);
        }
        // 獲取實作的介面陣列
        Class<?>[] interfaces = strategyClass.getInterfaces();
        if (ArrayUtils.isNotEmpty(interfaces)) {
            // 獲取繼承自Strategy介面的策略介面
            getImplementsOf(strategyClass, interfaceNameList);
        }
    }

    /**
     * 遞回查找繼承自Strategy介面的策略介面
     *
     * @param strategyClass     實作了策略介面的策略類
     * @param interfaceNameList 策略介面名稱串列
     * @return 回傳是否為Strategy
     */
    public boolean getImplementsOf(Class strategyClass, List<String> interfaceNameList) {
        // 獲取策略介面中的繼承或者多繼承的介面陣列
        Class[] interfaces = strategyClass.getInterfaces();
        if (ArrayUtils.isNotEmpty(interfaces)) {
            // 遍歷介面查詢繼承自Strategy的介面
            for (Class inter : interfaces) {
                // 如果是Strategy回傳true
                if (Objects.equals(inter.getName(), Strategy.class.getName())) {
                    return true;
                }
                // 如果繼承的介面串列中有Strategy 把介面包名加入串列
                if (getImplementsOf(inter, interfaceNameList)) {
                    interfaceNameList.add(inter.getName());
                }
            }
        }
        return false;
    }

}

spring-boot-starter

我們需要寫一個 spring-boot-starter 在pom中引入這個starter 就會自動加載這個 策略工廠

org.springframework.boot.autoconfigure.EnableAutoConfiguration = com.colagy.starter.strategy.StrategyConfiguration

代碼連接

轉載請註明出處,本文鏈接:https://www.uj5u.com/qita/244794.html

標籤:其他

上一篇:XCTF pwn 高手進階區 250

下一篇:K8s下載kube-flannel失敗解決方法

標籤雲
其他(157675) Python(38076) JavaScript(25376) Java(17977) C(15215) 區塊鏈(8255) C#(7972) AI(7469) 爪哇(7425) MySQL(7132) html(6777) 基礎類(6313) sql(6102) 熊猫(6058) PHP(5869) 数组(5741) R(5409) Linux(5327) 反应(5209) 腳本語言(PerlPython)(5129) 非技術區(4971) Android(4554) 数据框(4311) css(4259) 节点.js(4032) C語言(3288) json(3245) 列表(3129) 扑(3119) C++語言(3117) 安卓(2998) 打字稿(2995) VBA(2789) Java相關(2746) 疑難問題(2699) 细绳(2522) 單片機工控(2479) iOS(2429) ASP.NET(2402) MongoDB(2323) 麻木的(2285) 正则表达式(2254) 字典(2211) 循环(2198) 迅速(2185) 擅长(2169) 镖(2155) 功能(1967) .NET技术(1958) Web開發(1951) python-3.x(1918) HtmlCss(1915) 弹簧靴(1913) C++(1909) xml(1889) PostgreSQL(1872) .NETCore(1853) 谷歌表格(1846) Unity3D(1843) for循环(1842)

熱門瀏覽
  • 網閘典型架構簡述

    網閘架構一般分為兩種:三主機的三系統架構網閘和雙主機的2+1架構網閘。 三主機架構分別為內端機、外端機和仲裁機。三機無論從軟體和硬體上均各自獨立。首先從硬體上來看,三機都用各自獨立的主板、記憶體及存盤設備。從軟體上來看,三機有各自獨立的作業系統。這樣能達到完全的三機獨立。對于“2+1”系統,“2”分為 ......

    uj5u.com 2020-09-10 02:00:44 more
  • 如何從xshell上傳檔案到centos linux虛擬機里

    如何從xshell上傳檔案到centos linux虛擬機里及:虛擬機CentOs下執行 yum -y install lrzsz命令,出現錯誤:鏡像無法找到軟體包 前言 一、安裝lrzsz步驟 二、上傳檔案 三、遇到的問題及解決方案 總結 前言 提示:其實很簡單,往虛擬機上安裝一個上傳檔案的工具 ......

    uj5u.com 2020-09-10 02:00:47 more
  • 一、SQLMAP入門

    一、SQLMAP入門 1、判斷是否存在注入 sqlmap.py -u 網址/id=1 id=1不可缺少。當注入點后面的引數大于兩個時。需要加雙引號, sqlmap.py -u "網址/id=1&uid=1" 2、判斷文本中的請求是否存在注入 從文本中加載http請求,SQLMAP可以從一個文本檔案中 ......

    uj5u.com 2020-09-10 02:00:50 more
  • Metasploit 簡單使用教程

    metasploit 簡單使用教程 浩先生, 2020-08-28 16:18:25 分類專欄: kail 網路安全 linux 文章標簽: linux資訊安全 編輯 著作權 metasploit 使用教程 前言 一、Metasploit是什么? 二、準備作業 三、具體步驟 前言 Msfconsole ......

    uj5u.com 2020-09-10 02:00:53 more
  • 游戲逆向之驅動層與用戶層通訊

    驅動層代碼: #pragma once #include <ntifs.h> #define add_code CTL_CODE(FILE_DEVICE_UNKNOWN,0x800,METHOD_BUFFERED,FILE_ANY_ACCESS) /* 更多游戲逆向視頻www.yxfzedu.com ......

    uj5u.com 2020-09-10 02:00:56 more
  • 北斗電力時鐘(北斗授時服務器)讓網路資料更精準

    北斗電力時鐘(北斗授時服務器)讓網路資料更精準 北斗電力時鐘(北斗授時服務器)讓網路資料更精準 京準電子科技官微——ahjzsz 近幾年,資訊技術的得了快速發展,互聯網在逐漸普及,其在人們生活和生產中都得到了廣泛應用,并且取得了不錯的應用效果。計算機網路資訊在電力系統中的應用,一方面使電力系統的運行 ......

    uj5u.com 2020-09-10 02:01:03 more
  • 【CTF】CTFHub 技能樹 彩蛋 writeup

    ?碎碎念 CTFHub:https://www.ctfhub.com/ 筆者入門CTF時時剛開始刷的是bugku的舊平臺,后來才有了CTFHub。 感覺不論是網頁UI設計,還是題目質量,賽事跟蹤,工具軟體都做得很不錯。 而且因為獨到的金幣制度的確讓人有一種想去刷題賺金幣的感覺。 個人還是非常喜歡這個 ......

    uj5u.com 2020-09-10 02:04:05 more
  • 02windows基礎操作

    我學到了一下幾點 Windows系統目錄結構與滲透的作用 常見Windows的服務詳解 Windows埠詳解 常用的Windows注冊表詳解 hacker DOS命令詳解(net user / type /md /rd/ dir /cd /net use copy、批處理 等) 利用dos命令制作 ......

    uj5u.com 2020-09-10 02:04:18 more
  • 03.Linux基礎操作

    我學到了以下幾點 01Linux系統介紹02系統安裝,密碼啊破解03Linux常用命令04LAMP 01LINUX windows: win03 8 12 16 19 配置不繁瑣 Linux:redhat,centos(紅帽社區版),Ubuntu server,suse unix:金融機構,證券,銀 ......

    uj5u.com 2020-09-10 02:04:30 more
  • 05HTML

    01HTML介紹 02頭部標簽講解03基礎標簽講解04表單標簽講解 HTML前段語言 js1.了解代碼2.根據代碼 懂得挖掘漏洞 (POST注入/XSS漏洞上傳)3.黑帽seo 白帽seo 客戶網站被黑帽植入劫持代碼如何處理4.熟悉html表單 <html><head><title>TDK標題,描述 ......

    uj5u.com 2020-09-10 02:04:36 more
最新发布
  • 2023年最新微信小程式抓包教程

    01 開門見山 隔一個月發一篇文章,不過分。 首先回顧一下《微信系結手機號資料庫被脫庫事件》,我也是第一時間得知了這個訊息,然后跟蹤了整件事情的經過。下面是這起事件的相關截圖以及近日流出的一萬條資料樣本: 個人認為這件事也沒什么,還不如關注一下之前45億快遞資料查詢渠道疑似在近日復活的訊息。 訊息是 ......

    uj5u.com 2023-04-20 08:48:24 more
  • web3 產品介紹:metamask 錢包 使用最多的瀏覽器插件錢包

    Metamask錢包是一種基于區塊鏈技術的數字貨幣錢包,它允許用戶在安全、便捷的環境下管理自己的加密資產。Metamask錢包是以太坊生態系統中最流行的錢包之一,它具有易于使用、安全性高和功能強大等優點。 本文將詳細介紹Metamask錢包的功能和使用方法。 一、 Metamask錢包的功能 數字資 ......

    uj5u.com 2023-04-20 08:47:46 more
  • vulnhub_Earth

    前言 靶機地址->>>vulnhub_Earth 攻擊機ip:192.168.20.121 靶機ip:192.168.20.122 參考文章 https://www.cnblogs.com/Jing-X/archive/2022/04/03/16097695.html https://www.cnb ......

    uj5u.com 2023-04-20 07:46:20 more
  • 從4k到42k,軟體測驗工程師的漲薪史,給我看哭了

    清明節一過,盲猜大家已經無心上班,在數著日子準備過五一,但一想到銀行卡里的余額……瞬間心情就不美麗了。最近,2023年高校畢業生就業調查顯示,本科畢業月平均起薪為5825元。調查一出,便有很多同學表示自己又被平均了。看著這一資料,不免讓人想到前不久中國青年報的一項調查:近六成大學生認為畢業10年內會 ......

    uj5u.com 2023-04-20 07:44:00 more
  • 最新版本 Stable Diffusion 開源 AI 繪畫工具之中文自動提詞篇

    🎈 標簽生成器 由于輸入正向提示詞 prompt 和反向提示詞 negative prompt 都是使用英文,所以對學習母語的我們非常不友好 使用網址:https://tinygeeker.github.io/p/ai-prompt-generator 這個網址是為了讓大家在使用 AI 繪畫的時候 ......

    uj5u.com 2023-04-20 07:43:36 more
  • 漫談前端自動化測驗演進之路及測驗工具分析

    隨著前端技術的不斷發展和應用程式的日益復雜,前端自動化測驗也在不斷演進。隨著 Web 應用程式變得越來越復雜,自動化測驗的需求也越來越高。如今,自動化測驗已經成為 Web 應用程式開發程序中不可或缺的一部分,它們可以幫助開發人員更快地發現和修復錯誤,提高應用程式的性能和可靠性。 ......

    uj5u.com 2023-04-20 07:43:16 more
  • CANN開發實踐:4個DVPP記憶體問題的典型案例解讀

    摘要:由于DVPP媒體資料處理功能對存放輸入、輸出資料的記憶體有更高的要求(例如,記憶體首地址128位元組對齊),因此需呼叫專用的記憶體申請介面,那么本期就分享幾個關于DVPP記憶體問題的典型案例,并給出原因分析及解決方法。 本文分享自華為云社區《FAQ_DVPP記憶體問題案例》,作者:昇騰CANN。 DVPP ......

    uj5u.com 2023-04-20 07:43:03 more
  • msf學習

    msf學習 以kali自帶的msf為例 一、msf核心模塊與功能 msf模塊都放在/usr/share/metasploit-framework/modules目錄下 1、auxiliary 輔助模塊,輔助滲透(埠掃描、登錄密碼爆破、漏洞驗證等) 2、encoders 編碼器模塊,主要包含各種編碼 ......

    uj5u.com 2023-04-20 07:42:59 more
  • Halcon軟體安裝與界面簡介

    1. 下載Halcon17版本到到本地 2. 雙擊安裝包后 3. 步驟如下 1.2 Halcon軟體安裝 界面分為四大塊 1. Halcon的五個助手 1) 影像采集助手:與相機連接,設定相機引數,采集影像 2) 標定助手:九點標定或是其它的標定,生成標定檔案及內參外參,可以將像素單位轉換為長度單位 ......

    uj5u.com 2023-04-20 07:42:17 more
  • 在MacOS下使用Unity3D開發游戲

    第一次發博客,先發一下我的游戲開發環境吧。 去年2月份買了一臺MacBookPro2021 M1pro(以下簡稱mbp),這一年來一直在用mbp開發游戲。我大致分享一下我的開發工具以及使用體驗。 1、Unity 官網鏈接: https://unity.cn/releases 我一般使用的Apple ......

    uj5u.com 2023-04-20 07:40:19 more