Skip to content

Instantly share code, notes, and snippets.

View eagleon's full-sized avatar
🌴
On vacation

eagleon eagleon

🌴
On vacation
View GitHub Profile
@eagleon
eagleon / gist:1600936
Created January 12, 2012 14:48
先说下假设的两个网络环境
先说下假设的两个网络环境:
dhcp 网段:192.168.10.0/24
固定ip 网段:192.168.20.0/24 网关:192.168.20.254 DNS:192.168.20.254和202.100.64.68 指定ip:192.168.20.2
在修改 /etc 下conf前先来用命令 ficonfig route ping 来配置临时的网络参数做测试
假设配置这样的两网卡 eth0 dhcp / eth1 指定固定ip上网
#ifconfig eth0 up
#dhcpcd eth0
#ifconfig eth0 //查看eth0运行情况
@eagleon
eagleon / tcp.py
Created January 13, 2012 08:00
pyton Socket tcp调试
#!/usr/bin/env python
import sys
import os
import socket
import string
# windows only
import msvcrt
if len(sys.argv) != 3:
print "usage: %s target_ip target_port" %(os.path.split(sys.argv[0])[1])
@eagleon
eagleon / gist:1702129
Created January 30, 2012 02:35
阳历转农历PHP实现参考例子
<?php
class Lunar {
var $MIN_YEAR = 1891;
var $MAX_YEAR = 2100;
var $lunarInfo = array(
array(0,2,9,21936),array(6,1,30,9656),array(0,2,17,9584),array(0,2,6,21168),array(5,1,26,43344),array(0,2,13,59728),
array(0,2,2,27296),array(3,1,22,44368),array(0,2,10,43856),array(8,1,30,19304),array(0,2,19,19168),array(0,2,8,42352),
array(5,1,29,21096),array(0,2,16,53856),array(0,2,4,55632),array(4,1,25,27304),array(0,2,13,22176),array(0,2,2,39632),
array(2,1,22,19176),array(0,2,10,19168),array(6,1,30,42200),array(0,2,18,42192),array(0,2,6,53840),array(5,1,26,54568),
array(0,2,14,46400),array(0,2,3,54944),array(2,1,23,38608),array(0,2,11,38320),array(7,2,1,18872),array(0,2,20,18800),
@eagleon
eagleon / Nginx_tomcat
Created May 8, 2012 10:10
Nginx和Tomcat配合的最简单例子
user nginx;
worker_processes 1;
error_log /var/log/nginx/error.log warn;
pid /var/run/nginx.pid;
events {
worker_connections 1024;
}
@eagleon
eagleon / IdcardUtils.java
Created May 20, 2012 07:40
身份证号码生成
/**
* Copyright (C) 2009-2010 Yichuan, Fuchun All rights reserved.
* 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
* Unless required by applicable law or agreed to in writing, software
@eagleon
eagleon / getFileSizeAndType.js
Created June 5, 2012 14:35
JavaScript获取文件的大小和类型
//<INPUT TYPE="file" NAME="file" onchange="getFileSizeAndType(this)"/>
function getFileSizeAndType(obj){
var maxSize= 1024 * 1024 *2;
var objValue = obj.value;
if (objValue=="") return false;
var pos = objValue.lastIndexOf(".");
var lastname = objValue.substring(pos,objValue.length);
if (lastname.toLowerCase()!=".jpg" && lastname.toLowerCase()!=".gif" && lastname.toLowerCase()!=".png" && lastname.toLowerCase()!=".jpeg")
{
@eagleon
eagleon / JSON
Created June 17, 2012 04:10
JSON相关东东
var json = $.parseJSON(data); //jquery直接支持
var json = JSON.parse(data); //jquery直接支持
var json = eval ("(" + data + ")");
@eagleon
eagleon / keyevent
Created June 17, 2012 15:33
javascript 按钮事件
<script type="text/javascript">
$(document).ready(function(){
$("input").keypress(function (e) {
var keyCode = e.keyCode ? e.keyCode : e.which ? e.which : e.charCode;
if (keyCode == 13){
var i;
for (i = 0; i < this.form.elements.length; i++)
if (this == this.form.elements[i])
break;
i = (i + 1) % this.form.elements.length;
@eagleon
eagleon / gist:2945578
Created June 17, 2012 20:09
jQuery表单转化成JSON提交
<h2>Form</h2>
<form action="" method="post">
First Name:<input type="text" name="Fname" maxlength="12" size="12"/> <br/>
Last Name:<input type="text" name="Lname" maxlength="36" size="12"/> <br/>
Gender:<br/>
Male:<input type="radio" name="gender" value="Male"/><br/>
Female:<input type="radio" name="gender" value="Female"/><br/>
Favorite Food:<br/>
Steak:<input type="checkbox" name="food[]" value="Steak"/><br/>
Pizza:<input type="checkbox" name="food[]" value="Pizza"/><br/>
@eagleon
eagleon / PngJpgImagePerTest.java
Created June 20, 2012 06:06
Java图片保存
/**
*目前加载一个png格式的图片,做一些绘图工作,发现ImageIO.write存储png性能较差,转为存储jpg格式图片,性能可以提高6,7倍。
*/
package test;
import java.awt.Color;
import java.awt.Font;
import java.awt.Graphics2D;
import java.awt.RenderingHints;