Skip to content

Instantly share code, notes, and snippets.

@subchen
subchen / webstorm-eval-reset.sh
Created Dec 3, 2017
删除 WebStorm 30 days
View webstorm-eval-reset.sh
#!/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 Dec 2, 2017
sshExpect for nodejs
View sshExpect.js
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 Sep 12, 2017
issue fix
View test.java
@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 Mar 18, 2015
disable selinux & firewall
View disable-selinux-firewall.sh
# 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 Jun 20, 2019
setup dns server on centos
View dns-server-setup.md

环境

域名: demo.com

  • (主) DNS 服务器的详细信息:
Operating System     : CentOS 7 minimal server
Hostname             : dns1.demo.com
IP Address           : 10.0.1.254/24
View ProxyServlet-1.java
// 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.*;
View SafeSimpleDateFormat.java
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 Aug 29, 2015
检查该元素是完全可见在当前视口 (How to tell if a DOM element is visible in the current viewport?)
View isElementInViewport.md
@subchen
subchen / jetbrick.print.js
Created Nov 3, 2014
JavaScript 实现打印功能(只打印网页中的一部分)
View jetbrick.print.js
(function(window, $) {
/**
* 实现打印功能(只打印网页中的一部分)
*
* Usage:
* <button jw-click-print="#printContext">Print</button>
*/
var print = function($dom) {
$("iframe.js-print").remove();
@subchen
subchen / jaxb-sample.md
Created Nov 3, 2014
JAXB Hello World Example
View jaxb-sample.md

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