Skip to content

Instantly share code, notes, and snippets.

View hellokaton's full-sized avatar
:shipit:
Focusing on work

見える hellokaton

:shipit:
Focusing on work
View GitHub Profile
@hellokaton
hellokaton / UrlShortener.java
Created May 29, 2018 10:23
Java 短链接生成算法
public class UrlShortener {
// private static final String ALPHABET = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
private static final String ALPHABET = "mUSNcOa6hDgfnEJ1rGMPC03jv4k9RIqL2Yy7TQdH8xu5XFWwAKoZVstizlepBb";
private static final int BASE = ALPHABET.length();
public static String encode(int num) {
StringBuilder sb = new StringBuilder();
while (num > 0) {
sb.append(ALPHABET.charAt(num % BASE));
@hellokaton
hellokaton / UUIDUtil.java
Created May 29, 2018 09:10
Java 短UUID生成
import java.nio.ByteBuffer;
import java.util.Base64;
import java.util.UUID;
public class UUIDUtil {
public static String shortUUID() {
UUID uuid = UUID.randomUUID();
return shortUUID(uuid);
}
@hellokaton
hellokaton / DataConvertionUtil.java
Created May 17, 2018 05:43 — forked from robertchong/DataConvertionUtil.java
Excel <-> CSV Conversion using Apache POI
import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.InputStreamReader;
import java.math.BigDecimal;
import java.text.SimpleDateFormat;
import java.util.Iterator;
import org.apache.poi.hssf.usermodel.HSSFCell;
import java.util.function.Function;
/**
* @author biezhi
* @date 2018/5/12
*/
public class Demo {
public Function<String, Class> loader() {
return Unchecked.function(Class::forName);
@hellokaton
hellokaton / mysql_back.sh
Created April 24, 2018 06:49
在 Linux 上定时备份 MySQL 数据库,并发送备份到邮件
#!/bin/sh
#this is the prefix before the filename and can be anything you want
fileprefix='mysql_backup_';
#this is your mysql user - best to create a new mysql user called backup that has access to all databases
myuser='backup';
#your mysql password
mypass='s0mething$ecure123';
@hellokaton
hellokaton / AsciiArt.java
Created April 16, 2018 08:47
java 版本 文字生成 ascii 字符
import java.awt.Font;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.RenderingHints;
import java.awt.image.BufferedImage;
public class AsciiArt {
public void drawString(String text, String artChar, Settings settings) {
@hellokaton
hellokaton / email.go
Created March 6, 2018 05:43 — forked from genedna/email.go
Golang 从腾讯企业邮箱的发送邮件和一个 HTML 模板。
package main
import (
"crypto/tls"
"fmt"
"log"
"net"
"net/smtp"
)
@hellokaton
hellokaton / ffmpeg常用操作.md
Last active August 28, 2018 02:37
ffmpeg常用操作

提取音频

ffmpeg -i a.mp4 -f mp3 -vn a.mp3

提取视频

ffmpeg -i a.mp4 -vcodec copy -an b.mp4
@hellokaton
hellokaton / ffmpeg.md
Created February 9, 2018 03:45 — forked from v5tech/ffmpeg.md
ffmpeg视频合并、格式转换、截图

使用ffmpeg合并MP4文件

ffmpeg -i "Apache Sqoop Tutorial Part 1.mp4" -c copy -bsf:v h264_mp4toannexb -f mpegts intermediate1.ts
ffmpeg -i "Apache Sqoop Tutorial Part 2.mp4" -c copy -bsf:v h264_mp4toannexb -f mpegts intermediate2.ts
ffmpeg -i "Apache Sqoop Tutorial Part 3.mp4" -c copy -bsf:v h264_mp4toannexb -f mpegts intermediate3.ts
ffmpeg -i "Apache Sqoop Tutorial Part 4.mp4" -c copy -bsf:v h264_mp4toannexb -f mpegts intermediate4.ts
ffmpeg -i "concat:intermediate1.ts|intermediate2.ts|intermediate3.ts|intermediate4.ts" -c copy -bsf:a aac_adtstoasc "Apache Sqoop Tutorial.mp4"