Skip to content

Instantly share code, notes, and snippets.

View 0xffan's full-sized avatar
🔨
building...

X.F. 0xffan

🔨
building...
  • Chengdu, China
View GitHub Profile
@0xffan
0xffan / scrollbar.css
Created June 24, 2023 03:36
自定义 Scrollbar 样式
html {
scroll-behavior: smooth;
}
/* Scrollbar size */
::-webkit-scrollbar {
width: 10px;
height: 10px;
transition: 1.0s;
}
# ● ○ ❯❯❯
function prompt_char {
git branch >/dev/null 2>/dev/null && echo '%F{green}±%f' && return
hg root >/dev/null 2>/dev/null && echo '%F{red}λ%f' && return
echo '%F{magenta}»%f'
}
PROMPT='%F{magenta}%n%f at %F{yellow}%m%f in %B%F{green}%~%f%b$(git_prompt_info)
$(virtualenv_prompt_info) $(prompt_char) '
@0xffan
0xffan / Caddyfile
Created August 22, 2022 01:08
在 Docker 中部署 VLESS (WebSocket + TLS + Web)
your.domain.name {
reverse_proxy /ws v2ray://v2ray:36240 {
header_up -Origin
}
root * /usr/share/caddy/public
file_server
tls example@mail.com {
dns cloudflare {env.CLOUDFLARE_API_TOKEN}
resolvers 1.1.1.1
}
@0xffan
0xffan / ReverseProxyController.java
Last active June 24, 2022 13:49
Reverse proxy using spring-cloud-gateway-mvc
package com.example.reverseproxy;
import com.example.ApiResponse;
import org.springframework.cloud.gateway.mvc.ProxyExchange;
import org.springframework.http.HttpMethod;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
# Sunrise theme for oh-my-zsh (https://github.com/ohmyzsh/ohmyzsh/blob/master/themes/sunrise.zsh-theme)
#
# Color shortcuts
R=$fg_no_bold[red]
G=$fg_no_bold[green]
M=$fg_no_bold[magenta]
Y=$fg_no_bold[yellow]
B=$fg_no_bold[blue]
C=$fg_no_bold[cyan]
@0xffan
0xffan / RedisClient.java
Last active September 21, 2018 08:56
Spring Data Redis (2.0.10.RELEASE): Lettuce pooling Java configuration.
import java.util.Collection;
import java.util.List;
import java.util.Map;
import java.util.concurrent.TimeUnit;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
@0xffan
0xffan / MD5.java
Last active August 21, 2017 06:44
Generate MD5 digest in Java
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
public class MD5 {
private static final char[] hexCode = "0123456789abcdef".toCharArray();
private static String toHexString(byte[] data) {
if (data == null) {
return null;
package me.ixfan.wechatkit.wxpay;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.util.TreeMap;
import java.util.stream.Collectors;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;
// https://developer.mozilla.org/en-US/Firefox/Releases/1.5/Using_Firefox_1.5_caching
window.onpageshow = function(event) {
if (event.persisted) {
// the page is loaded from cache
}
}
// in jQuery
$(window).bind("pageshow", function(event) {
@0xffan
0xffan / gist:c38571948e05dba46d4b239aa8b83ef2
Last active November 12, 2016 14:17 — forked from jagregory/gist:710671
How to move to a fork after cloning
So you've cloned somebody's repo from github, but now you want to fork it and contribute back. Never fear!
Technically, when you fork "origin" should be your fork and "upstream" should be the project you forked;
however, if you're willing to break this convention then it's easy.
* Off the top of my head *
1. Fork their repo on Github
2. In your local, add a new remote to your fork; then fetch it, and push your changes up to it