Skip to content

Instantly share code, notes, and snippets.

View suxiaogang's full-sized avatar
🙄
busy writing bugs

Sam Su suxiaogang

🙄
busy writing bugs
  • NULL
  • UTM Zone 49
View GitHub Profile
@suxiaogang
suxiaogang / CreateJavaProject.java
Created June 23, 2014 12:04
CreateJavaProject.java
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import org.eclipse.core.resources.ICommand;
import org.eclipse.core.resources.IFolder;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IProjectDescription;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.IWorkspace;
CREATE DATABASE IF NOT EXISTS `blog_mvc` /*!40100 DEFAULT CHARACTER SET utf8 */;
USE `blog_mvc`;
-- MySQL dump 10.13 Distrib 5.6.13, for osx10.6 (i386)
--
-- Host: 127.0.0.1 Database: blog_mvc
-- ------------------------------------------------------
-- Server version 5.6.12
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
@suxiaogang
suxiaogang / jQuery_window
Created August 31, 2014 04:23
jQuery_window
alert($(window).height()); //浏览器当前窗口可视区域高度
alert($(document).height()); //浏览器当前窗口文档的高度
alert($(document.body).height());//浏览器当前窗口文档body的高度
alert($(document.body).outerHeight(true));//浏览器当前窗口文档body的总高度 包括border padding margin
alert($(window).width()); //浏览器当前窗口可视区域宽度
alert($(document).width());//浏览器当前窗口文档对象宽度
alert($(document.body).width());//浏览器当前窗口文档body的高度
alert($(document.body).outerWidth(true));//浏览器当前窗口文档body的总宽度 包括border padding margin
// 获取页面的高度、宽度
@suxiaogang
suxiaogang / server.xml
Created March 20, 2015 05:45
Tomcat server.xml
<?xml version='1.0' encoding='utf-8'?>
<!--
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
@suxiaogang
suxiaogang / nginx.conf
Created March 20, 2015 05:46
Nginx nginx.conf
user www www;
worker_processes auto;
error_log /vps_log/nginx_error.log crit;
pid /usr/local/nginx/logs/nginx.pid;
#Specifies the value for maximum file descriptors that can be opened by this process.
worker_rlimit_nofile 51200;
# -*- coding:utf-8 -*-
__author__ = 'Delbert'
# Using Python3
# beautifulsoup4 is needed.
from bs4 import BeautifulSoup
from urllib import request
import os
def main():
begin_page = int(input("From: "))
@suxiaogang
suxiaogang / iptables
Created December 25, 2015 10:00
iptables for mongodb
# Generated by iptables-save v1.4.7 on Thu Jan 22 12:02:20 2009
*filter
:INPUT DROP [62:7014]
:FORWARD ACCEPT [0:0]
:OUTPUT ACCEPT [212:25039]
-A INPUT -i lo -j ACCEPT
-A INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT
@suxiaogang
suxiaogang / Vertically centering Bootstrap modal window
Created January 7, 2016 06:45
Vertically centering Bootstrap modal window
<button class="btn btn-primary btn-lg" data-toggle="modal" data-target="#myModal">Launch demo modal</button>
<!-- Modal -->
<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
<div class="vertical-alignment-helper">
<div class="modal-dialog vertical-align-center">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span class="sr-only">Close</span>
@suxiaogang
suxiaogang / gist:1e5461afe399414654d5
Last active January 26, 2016 09:47
Jackson & POJO
String str = "[{\"catId\":\"55e7479ae4b043f0f65c010f\",\"orderId\":1},{\"catId\":\"55ede02ae4b092d8492030c1\",\"orderId\":2},{\"catId\":\"55ede04ae4b092d8492030c3\",\"orderId\":3},{\"catId\":\"567203210cf23be06e8b8cc4\",\"orderId\":4}]";
ObjectMapper mapper = new ObjectMapper();
List<Dummy> list = mapper.readValue(param, new TypeReference<List<Dummy>>(){});
private static class Dummy{
String catId;
int orderId;
public String getCatId() {
return catId;
#!/bin/sh
#================================================
# backup mysql
#================================================
# set up all the mysqldump options
FILE=backup_`date +"%Y%m%d_%H_%M"`_structure.sql
DATABASE=DBNAME
USER=root