Skip to content

Instantly share code, notes, and snippets.

@szitguy
szitguy / GridSpacingItemDecoration.java
Created February 3, 2018 17:22
改进后的等间距GridSpacingItemDecoration
package cn.itguy.widget;
import android.graphics.Rect;
import android.support.v7.widget.RecyclerView;
import android.view.View;
/**
* 设置RecyclerView GridLayoutManager or StaggeredGridLayoutManager spacing from http://blog.csdn.net/johnwcheung/article/details/54953568
* Created by john on 17-1-5.
*/
@fotock
fotock / nginx.conf
Last active May 2, 2024 02:43 — forked from plentz/nginx.conf
Nginx SSL 安全配置最佳实践.
# 生成 dhparam.pem 文件, 在命令行执行任一方法:
# 方法1: 很慢
openssl dhparam -out /etc/nginx/ssl/dhparam.pem 2048
# 方法2: 较快
# 与方法1无明显区别. 2048位也足够用, 4096更强
openssl dhparam -dsaparam -out /etc/nginx/ssl/dhparam.pem 4096
@hjzheng
hjzheng / login.exp
Created October 23, 2015 02:41
用于iTerm2的自动登录脚本
#!/usr/bin/expect
set timeout 30
spawn ssh [lindex $argv 0]@[lindex $argv 1]
expect {
"(yes/no)?"
{send "yes\n";exp_continue}
"password:"
{send "[lindex $argv 2]\n"}
}
@greenido
greenido / gce-vpn-install.sh
Last active March 31, 2022 14:11
Installing vpn on GCE
#!/bin/sh
#
# Automatic configuration of a VPN on GCE debian-7-wheezy server.
# Tested only on debian-7-wheezy.
#
# This work is licensed under the Creative Commons Attribution-ShareAlike 3.0
# Unported License: http://creativecommons.org/licenses/by-sa/3.0/
#
# Thx to: https://github.com/sarfata/voodooprivacy/blob/master/voodoo-vpn.sh for the code/idea
#
@plentz
plentz / nginx.conf
Last active April 24, 2024 11:15
Best nginx configuration for improved security(and performance)
# to generate your dhparam.pem file, run in the terminal
openssl dhparam -out /etc/nginx/ssl/dhparam.pem 2048
@binjoo
binjoo / default.java
Created May 27, 2013 08:58
JAVA:清除HTML标签
import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class HTMLSpirit{
public static String delHTMLTag(String htmlStr){
String regEx_script="<script[^>]*?>[\\s\\S]*?<\\/script>"; //定义script的正则表达式
String regEx_style="<style[^>]*?>[\\s\\S]*?<\\/style>"; //定义style的正则表达式
String regEx_html="<[^>]+>"; //定义HTML标签的正则表达式
Pattern p_script=Pattern.compile(regEx_script,Pattern.CASE_INSENSITIVE);
@z8888q
z8888q / gist:2364151
Created April 12, 2012 01:46
Android 图片上传,包括从相册选取与拍照上传
// 拍照上传
private OnClickListener mUploadClickListener = new OnClickListener() {
public void onClick(View v) {
// 调用相机
Intent mIntent = new Intent("android.media.action.IMAGE_CAPTURE");