Skip to content

Instantly share code, notes, and snippets.

View guozi's full-sized avatar
🎯
Focusing

guozi_1989 guozi

🎯
Focusing
View GitHub Profile
@guozi
guozi / private_fork.md
Created July 27, 2022 02:31 — forked from 0xjac/private_fork.md
Create a private fork of a public repository

The repository for the assignment is public and Github does not allow the creation of private forks for public repositories.

The correct way of creating a private frok by duplicating the repo is documented here.

For this assignment the commands are:

  1. Create a bare clone of the repository. (This is temporary and will be removed so just do it wherever.)

git clone --bare git@github.com:usi-systems/easytrace.git

@guozi
guozi / Convert.java
Created April 6, 2022 03:35
Image to Base64 String Conversion
public class Convert {
public static void main(String[] args) {
// Convert Image File to Base64 String
byte[] fileContent = FileUtils.readFileToByteArray(new File(filePath));
String encodedString = Base64.getEncoder().encodeToString(fileContent);
// Convert Base64 String to Image File
byte[] decodedBytes = Base64.getDecoder().decode(encodedString);
FileUtils.writeByteArrayToFile(new File(outputFileName), decodedBytes);
@guozi
guozi / HttpUtil.java
Created March 28, 2022 13:29 — forked from liujbo/HttpUtil.java
HTTP请求工具
package com.xilai.cuteBoy.common.util;
import org.apache.http.HttpEntity;
import org.apache.http.HttpStatus;
import org.apache.http.NameValuePair;
import org.apache.http.client.config.AuthSchemes;
import org.apache.http.client.config.CookieSpecs;
import org.apache.http.client.config.RequestConfig;
import org.apache.http.client.entity.UrlEncodedFormEntity;
import org.apache.http.client.methods.CloseableHttpResponse;
@Bean
public HttpClient httpClient(SSLContext sslContext) {
return HttpClients.custom()
.setMaxConnPerRoute(30)
.setMaxConnTotal(60)
.setSSLContext(sslContext).build();
}
@Bean
public ClientHttpRequestFactory clientHttpRequestFactory(HttpClient httpClient) {
return new HttpComponentsClientHttpRequestFactory(httpClient);
@guozi
guozi / demo.js
Last active January 14, 2022 07:11
[Js根据xpath获取元素或者元素值]
function _x(STR_XPATH) {
var xresult = document.evaluate(STR_XPATH, document, null, XPathResult.ANY_TYPE, null);
var xnodes = [];
var xres;
while (xres = xresult.iterateNext()) {
// 获取元素
xnodes.push(xres);
// 获取指定元素的值
//xnodes.push(xres.getAttribute('data-cgt-code'));
@guozi
guozi / ListPageUtils.java
Created December 8, 2021 07:42
使用Pageable将查询结果list转page分页
class ListPageUtils {
public static void main(String[] args) {
List<String> strings = new ArrayList<String>();
for (int i=0;i<20;i++){
strings.add("第"+i+"数据");
}
Pageable pageRequest = PageRequest.of(1, 10);
Page<String> strings1 = listConvertToPage(strings, pageRequest);
System.out.println(strings1);
@guozi
guozi / ListKeysV1.java
Created November 26, 2021 09:51
How to list all AWS S3 objects in a bucket using Java
public class ListKeysV1 {
private static String bucketName = "***bucket name***";
public static void main(String[] args) throws IOException {
AmazonS3 s3client = new AmazonS3Client(new ProfileCredentialsProvider());
ListObjectsRequest listObjectsRequest = new ListObjectsRequest()
.withBucketName(bucketName)
.withPrefix("m");
ObjectListing objectListing;
@guozi
guozi / HexUtils.java
Created November 17, 2021 09:25 — forked from keepingcoding/HexUtils.java
进制转换工具类
public class HexUtils {
private HexUtils() {
}
/**
* 16进制转2进制
*
* @param str
* @return
@guozi
guozi / App.java
Created March 10, 2021 07:14 — forked from rponte/App.java
Downloading file using Apache HttpClient (>= v4.2) with support to HTTP REDIRECT 301 and 302 when using HTTP method GET or POST
public class App {
public static void main(String[] args) throws MalformedURLException {
URL rightUrl = new URL("http://cursos.triadworks.com.br/assets/css/main.css");
URL redirectableUrl = new URL("http://www.triadworks.com.br/assets/css/main.css"); // redirected to cursos.triadworks.com.br
Downloader downloader = new Downloader();
System.out.println("Downloading file through right Url...");
@guozi
guozi / install-lrzsz.sh
Created September 18, 2020 14:41 — forked from zthxxx/install-lrzsz.sh
install-lrzsz on macOS
#!/usr/bin/env zsh
brew install lrzsz
recv='/usr/local/bin/iterm2-recv-zmodem.sh'
send='/usr/local/bin/iterm2-send-zmodem.sh'
curl -sSL https://github.com/zzy0-0/iterm2-zmodem/raw/master/iterm2-recv-zmodem.sh -o "$recv"
curl -sSL https://github.com/zzy0-0/iterm2-zmodem/raw/master/iterm2-send-zmodem.sh -o "$send"
chmod +x "$recv" "$send"