Skip to content

Instantly share code, notes, and snippets.

@liangzai-cool
liangzai-cool / FullWidth2HalfWidth.java
Created December 5, 2017 06:16
全角转半角工具类
public class FullWidth2HalfWidth {
/**
* ASCII表中可见字符从!开始,偏移位值为33(Decimal)
*/
static final char DBC_CHAR_START = 33; // 半角!
/**
* ASCII表中可见字符到~结束,偏移位值为126(Decimal)
*/
static final char DBC_CHAR_END = 126; // 半角~
@liangzai-cool
liangzai-cool / Perceptron.java
Last active August 7, 2017 09:45
零基础入门深度学习(1) - 感知器
import java.util.Arrays;
import java.util.function.Function;
public class Perceptron {
private Function<Double, Integer> activator;
private double bias;
private double[] weights;
public Perceptron() { }
@liangzai-cool
liangzai-cool / apache_reverse_proxy.conf
Last active April 4, 2017 08:10
apache reverse proxy settings.
`conf/httpd.conf`:
```
Define SRVROOT "D:\ProgramFiles\httpd-2.4.25-x64-vc14-r1\Apache24"
LoadModule access_compat_module modules/mod_access_compat.so
LoadModule headers_module modules/mod_headers.so
LoadModule proxy_module modules/mod_proxy.so
LoadModule proxy_http_module modules/mod_proxy_http.so
Include conf/extra/httpd-vhosts.conf
```
@liangzai-cool
liangzai-cool / HttpUtils.java
Last active February 26, 2019 18:35
convert relative url to absolute url and beautify the result in java.
```
import java.net.MalformedURLException;
import java.net.URL;
public class HttpUtils {
public static void main(String[] args) throws MalformedURLException {
String urlString = "https://www.google.com///images//branding/1234567890/..\\googlelogo/abcdefg/../1x/googlelogo_color_272x92dp.png";
System.out.println(absUrl(urlString));
@liangzai-cool
liangzai-cool / Easily keep gh-pages in sync with master.md
Last active February 16, 2017 06:13
Easily keep gh-pages in sync with master
@liangzai-cool
liangzai-cool / init.gradle
Created January 19, 2017 07:57
Using plugins in init scripts.
apply plugin:EnterpriseRepositoryPlugin
class EnterpriseRepositoryPlugin implements Plugin<Gradle> {
private static String ENTERPRISE_REPOSITORY_URL = "https://my.repository.com/repository/maven-public/"
void apply(Gradle gradle) {
// ONLY USE ENTERPRISE REPO FOR DEPENDENCIES
gradle.allprojects{ project ->
project.repositories {
@liangzai-cool
liangzai-cool / blog-build.xml
Created January 4, 2017 08:03
blog's ant build file.
<?xml version="1.0" encoding="UTF-8"?>
<project name="project-builder" basedir="." default="build-all">
<property environment="env"/>
<property name="debug" value="false"/>
<property name="src.dir" value="src"/>
<property name="build.dir" value="build"/>
<property name="dist.dir" value="dist"/>
<property name="dist.war" value="blog.war"/>
@liangzai-cool
liangzai-cool / build.gradle
Created November 2, 2016 06:11
config java compile encoding using gradle
tasks.withType(JavaCompile) {
options.encoding = "UTF-8"
}
/**
* jsoup 工具包
* founder
* @author XueLiang
* @date 2016年9月23日 下午3:16:36
* @version 1.0
*/
public class JsoupUtils {
/**
@liangzai-cool
liangzai-cool / 20microsoft-win10.patch
Created September 19, 2016 06:19
a patch for os-prober, to resolve centos 7 + win10 dual system, but boot menu show 'Windows 7...'
--- /usr/libexec/os-probes/mounted/20microsoft 2016-09-19 00:09:25.917283774 -0400
+++ 20microsoft 2016-09-19 00:55:38.750505997 -0400
@@ -31,7 +31,9 @@
for boot in $(item_in_dir boot "$2"); do
bcd=$(item_in_dir bcd "$2/$boot")
if [ -n "$bcd" ]; then
- if grep -qs "W.i.n.d.o.w.s. .8" "$2/$boot/$bcd"; then
+ if grep -qs "W.i.n.d.o.w.s. .1.0" "$2/$boot/$bcd"; then
+ long="Windows 10 (loader)"
+ elif grep -qs "W.i.n.d.o.w.s. .8" "$2/$boot/$bcd"; then