Skip to content

Instantly share code, notes, and snippets.

View zacker330's full-sized avatar
🌧️

Jack Zhai zacker330

🌧️
View GitHub Profile
@zacker330
zacker330 / Arrays
Last active January 10, 2018 00:22
spring @value 注解
@Value("${some.key:one,two,three}")
private String[] stringArrayWithDefaults;
@Value("${some.key:1,2,3}")
private int[] intArrayWithDefaults;
[
{
"ansible_ssh_pass":"vagrant",
"module_setup":"True",
"ansible_distribution_version":"7.1.1503",
"ansible_env":{
"USERNAME":"root",
"LANG":"C",
"TERM":"xterm-256color",
"SHELL":"/bin/bash",
private Invocable initRuleEngine(String ruleLocation) throws ScriptException, FileNotFoundException {
ScriptEngine engine = new ScriptEngineManager().getEngineByName("nashorn");
Compilable compEngine = (Compilable) engine;
final CompiledScript compiledScript = compEngine.compile(new FileReader(ruleLocation));
compiledScript.eval();
return (Invocable) engine;
}
public static byte[] hexStringToByteArray(String s) {
int len = s.length();
byte[] data = new byte[len / 2];
for (int i = 0; i < len; i += 2) {
data[i / 2] = (byte) ((Character.digit(s.charAt(i), 16) << 4)
+ Character.digit(s.charAt(i+1), 16));
}
return data;
}
yum install nmap-ncat.x86_64
echo mntr|nc 127.0.0.1 2181
import json
r = {'is_claimed': 'True', 'rating': 3.5}
r = json.dumps(r)
cat vars/logstash-vars.yml| python -c 'import sys, yaml, json; y=yaml.load(sys.stdin.read()); print json.dumps(y)'
location ^~ /uri {
index index.html;
root /usr/local/openresty/nginx/html/;
auth_basic "Restricted";
auth_basic_user_file /usr/local/nginx/conf/servers/.httppassword;
}
## httppassword generator: http://www.htaccesstools.com/htpasswd-generator/
@zacker330
zacker330 / open_tcp_port.sh
Created November 23, 2017 05:57
Iptables命令集合
iptables -I INPUT -p tcp --dport 5141 -j ACCEPT
public static String getParameter(ServletRequest request) {
Assert.notNull(request, "request must not be null");
StringBuilder parameter = new StringBuilder();
Enumeration<String> enumeration = request.getParameterNames();
ArrayList<String> parameterList = Collections.list(enumeration);
Collections.sort(parameterList);
for (String paramName : parameterList) {
String value = request.getParameter(paramName);
if (!paramName.equals("sign") && !paramName.equals("pic")) {
parameter.append(paramName).append("=").append(value).append("&");