Skip to content

Instantly share code, notes, and snippets.

@subchen
subchen / webstorm-eval-reset.sh
Created December 3, 2017 11:20
删除 WebStorm 30 days
#!/bin/sh
set -e
set -x
defaults delete com.apple.java.util.prefs || true
for f in ~/Library/Preferences/jetbrains.*.plist; do
if [[ -f $f ]]; then
fn=${f##*/}; key=${fn%.plist}
echo delete $key from pref and file $f
@subchen
subchen / sshExpect.js
Created December 2, 2017 14:52
sshExpect for nodejs
var SshClient = require('ssh2').Client;
/**
* @example
*
* var sshExpect = require('./sshExpect');
* sshExpect({
* host: '10.79.53.164',
* port: 22,
* username: 'admin',
@subchen
subchen / test.java
Last active September 12, 2017 08:02
issue fix
@SuppressWarnings("unchecked")
private <T> T stringAsObject(String value, Class<T> targetClass, String defaultValue) {
value = StringUtils.trimToNull(value);
if (value == null) {
value = defaultValue;
}
if (value == null || value.length() == 0) {
return null;
}
@subchen
subchen / disable-selinux-firewall.sh
Created March 18, 2015 07:41
disable selinux & firewall
# disable selinux
echo SELINUX=disabled > /etc/sysconfig/selinux
echo SELINUXTYPE=targeted >> /etc/sysconfig/selinux
setenforce 0
# disable firewall
systemctl disable firewalld
@subchen
subchen / dns-server-setup.md
Last active June 20, 2019 09:33
setup dns server on centos

环境

域名: demo.com

  • (主) DNS 服务器的详细信息:
Operating System     : CentOS 7 minimal server
Hostname             : dns1.demo.com
IP Address           : 10.0.1.254/24
// package de.spieleck.servlets;
// ProxyServlet - serving pages from foreign servers....
//
import java.io.*;
import java.net.*;
import java.lang.Integer;
import java.util.StringTokenizer;
import javax.servlet.*;
@subchen
subchen / SafeSimpleDateFormat.java
Created January 9, 2015 00:58
SafeSimpleDateFormat
package jetbrick.util;
import java.text.DateFormatSymbols;
import java.text.FieldPosition;
import java.text.Format;
import java.text.NumberFormat;
import java.text.ParseException;
import java.text.ParsePosition;
import java.text.SimpleDateFormat;
import java.util.Calendar;
@subchen
subchen / isElementInViewport.md
Last active August 29, 2015 14:10
检查该元素是完全可见在当前视口 (How to tell if a DOM element is visible in the current viewport?)
@subchen
subchen / jetbrick.print.js
Created November 3, 2014 10:30
JavaScript 实现打印功能(只打印网页中的一部分)
(function(window, $) {
/**
* 实现打印功能(只打印网页中的一部分)
*
* Usage:
* <button jw-click-print="#printContext">Print</button>
*/
var print = function($dom) {
$("iframe.js-print").remove();
@subchen
subchen / jaxb-sample.md
Created November 3, 2014 09:35
JAXB Hello World Example

JAXB, stands for Java Architecture for XML Binding, using JAXB annotation to convert Java object to / from XML file. In this tutorial, we show you how to use JAXB to do following stuffs :

  • Marshalling – Convert a Java object into a XML file.
  • Unmarshalling – Convert XML content into a Java Object.

Technologies used in this article

  • JDK 1.6
  • JAXB 2.0