Skip to content

Instantly share code, notes, and snippets.

@icella
icella / regx_remove_html_tag.java
Created June 20, 2019 02:18
去掉字符串中的html标签的正则表达式
//定义script的正则表达式,去除js可以防止注入
String scriptRegex="<script[^>]*?>[\\s\\S]*?<\\/script>";
//定义style的正则表达式,去除style样式,防止css代码过多时只截取到css样式代码
String styleRegex="<style[^>]*?>[\\s\\S]*?<\\/style>";
//定义HTML标签的正则表达式,去除标签,只提取文字内容
String htmlRegex="<[^>]+>";
//定义空格,回车,换行符,制表符
String spaceRegex = "\\s*|\t|\r|\n";
@icella
icella / DisappearedException.java
Last active July 20, 2018 02:18
消失的异常
// Bad code. Lose NumberFomatException, but throw ArithmeticExcption
public class DisappearedException {
public void show() throws BaseException{
try{
Integer.parseInt("Hello");
}catch (NumberFormatException nfe) {
throw new BaseException(nfe);
} finally {
try {
int result = 2 / 0;
@icella
icella / CurrentTimeId.java
Last active June 18, 2024 09:29
Java – Ways to Generate Unique Ids in Java
/**
* The object creation time can be set to object’s identifier property.
* For this purpose, System.currentTimeMillis() can be used. However,
* two or more objects may be created in a single millisecond.
* In this case, these objects will have the same id which is unacceptable.
* One way to cope with this problem is to use System.nanoTime().
* Even if the nano time is the smallest interval we can use, it does not
* also guarantee the uniqueness. To provide unique time stamps,
* I got help from AtomicReference class as follows.
*/
@icella
icella / git_toturial
Created March 31, 2016 06:20 — forked from guweigang/git_toturial
git命令大全
git init # 初始化本地git仓库(创建新仓库)
git config --global user.name "xxx" # 配置用户名
git config --global user.email "xxx@xxx.com" # 配置邮件
git config --global color.ui true # git status等命令自动着色
git config --global color.status auto
git config --global color.diff auto
git config --global color.branch auto
git config --global color.interactive auto
git config --global --unset http.proxy # remove proxy configuration on git
git clone git+ssh://git@192.168.53.168/VT.git # clone远程仓库
@icella
icella / maven-333.sh
Created March 6, 2016 04:45 — forked from ervinb/maven-333.sh
Install Maven 3.3.3 on Ubuntu 14.04
#!/bin/sh
sudo apt-get purge -y maven
if ! [ -e .semaphore-cache/apache-maven-3.3.3-bin.tar.gz ]; then (cd .semaphore-cache; curl -OL http://mirror.olnevhost.net/pub/apache/maven/maven-3/3.3.3/binaries/apache-maven-3.3.3-bin.tar.gz); fi
sudo tar -zxf .semaphore-cache/apache-maven-3.3.3-bin.tar.gz -C /usr/local/
sudo ln -s /usr/local/apache-maven-3.3.3/bin/mvn /usr/bin/mvn
echo "Maven is on version `mvn -v`"
@icella
icella / javascript_resources.md
Last active August 29, 2015 14:08 — forked from jookyboi/javascript_resources.md
Here are a set of libraries, plugins and guides which may be useful to your Javascript coding.

Libraries

  • jQuery - The de-facto library for the modern age. It makes things like HTML document traversal and manipulation, event handling, animation, and Ajax much simpler with an easy-to-use API that works across a multitude of browsers.
  • Backbone - Backbone.js gives structure to web applications by providing models with key-value binding and custom events, collections with a rich API of enumerable functions, views with declarative event handling, and connects it all to your existing API over a RESTful JSON interface.
  • AngularJS - Conventions based MVC framework for HTML5 apps.
  • Underscore - Underscore is a utility-belt library for JavaScript that provides a lot of the functional programming support that you would expect in Prototype.js (or Ruby), but without extending any of the built-in JavaScript objects.
  • lawnchair - Key/value store adapter for indexdb, localStorage
@icella
icella / python_resources.md
Last active August 29, 2015 14:08 — forked from jookyboi/python_resources.md
Python-related modules and guides.

Packages

  • lxml - Pythonic binding for the C libraries libxml2 and libxslt.
  • boto - Python interface to Amazon Web Services
  • Django - Django is a high-level Python Web framework that encourages rapid development and clean, pragmatic design.
  • Fabric - Library and command-line tool for streamlining the use of SSH for application deployment or systems administration task.
  • PyMongo - Tools for working with MongoDB, and is the recommended way to work with MongoDB from Python.
  • Celery - Task queue to distribute work across threads or machines.
  • pytz - pytz brings the Olson tz database into Python. This library allows accurate and cross platform timezone calculations using Python 2.4 or higher.

Guides

@icella
icella / 0_reuse_code.js
Last active August 29, 2015 14:08
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console