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:4138796
Created November 24, 2012 07:34 — forked from saga/gist:4137880
appfog get youtube
#!/usr/bin/env python
import simplejson
import logging
import random
import re
import datetime
import string
import time
import sys
import urllib
@eagleon
eagleon / hircd.py
Created November 24, 2012 10:55
HIrcd – minimal IRC server in Python
#!/usr/bin/python
#
# Very simple hacky ugly IRC server.
#
# Todo:
# - Encode format for each message and reply with ERR_NEEDMOREPARAMS
# - starting server when already started doesn't work properly. PID file is not changed, no error messsage is displayed.
# - Delete channel if last user leaves.
# - [ERROR] <socket.error instance at 0x7f9f203dfb90> (better error msg required)
@eagleon
eagleon / proxy.py
Created November 24, 2012 15:40
http代理服务器
# -*- coding:utf-8 -*-
# http代理服务器
# 1.ip限制,mac限制
#
# [email protected]
# www.sw2us.com
"exec" "python" "-O" "$0" "$@"
__doc__ = """sw2us HTTP Proxy.
@eagleon
eagleon / .vimrc
Created December 26, 2012 01:18
MacVim环境文件配置。 brew install ctags
" =========
" 功能函数
" =========
" 获取当前目录
func GetPWD()
return substitute(getcwd(), "", "", "g")
endf
" =========
" 环境配置
" =========
package com;
import java.io.*;
public class Keygen {
private static final String LL = "Decompiling this copyrighted software is a violation of both your license agreement and the Digital Millenium Copyright Act of 1998 (http://www.loc.gov/copyright/legislation/dmca.pdf). Under section 1204 of the DMCA, penalties range up to a $500,000 fine or up to five years imprisonment for a first offense. Think about it; pay for a license, avoid prosecution, and feel better about yourself.";
public String getSerial(String userId, String licenseNum) {
java.util.Calendar cal = java.util.Calendar.getInstance();
cal.add(1, 3);
@eagleon
eagleon / sublime_gbk.py
Created January 20, 2013 17:17
我安装了GBK Encoding Support这款插件可以解决打开GBK编码的文件中文乱码的问题,但是随之而来的确是tab显示的标题乱码了,不怎么好看.于是自己动手丰衣足食,我就修改了一下原作者的代码,修改代码文件的路径如下:C:\Users\你的用户名\AppData\Roaming\Sublime Text 2\Packages\GBK Encoding Support\sublime_gbk.py,达到我的目的,当然这样我就把原来文件的gbk给转换成了utf-8了。大家看代码吧,注释部分原作者的代码,newline注释下面的是我修改的代码,替换gbk2utf8即可。
#coding: utf8
import sublime, sublime_plugin
import os, re
import urllib
TEMP_PATH = os.path.join(os.getcwd(), 'tmp')
SEPERATOR = ' '
def gbk2utf8(view):
try:
1.python是一个解释性语言:
一个用编译性语言比如C或C++写的程序可以从源文件(即C或C++语言)转换到一个你的计算机使用的语言(二进制代码,即0和1)。这个过程通过编译器和不同的标记、选项完成。当你运行你的程序的时候,连接/转载器软件把你的程序从硬盘复制到内存中并且运行。
而Python语言写的程序不需要编译成二进制代码。你可以直接从源代码 运行 程序。在计算机内部,Python解释器把源代码转换成称为字节码的中间形式,然后再把它翻译成计算机使用的机器语言并运行。事实上,由于你不再需要担心如何编译程序,如何确保连接转载正确的库等等,所有这一切使得使用Python更加简单。由于你只需要把你的Python程序拷贝到另外一台计算机上,它就可以工作了,这也使得你的Python程序更加易于移植。
2.查询机器是否安装python成功:python -V
3.得到类的帮助文档:
help('str')#得到str类的文档
help(list)#得到list类的文档字符串
@eagleon
eagleon / nginx.conf
Last active December 16, 2015 14:39
图片服务器
user nginx;
worker_processes 1;
error_log /var/log/nginx/error.log warn;
pid /var/run/nginx.pid;
events {
worker_connections 1024;
}
@eagleon
eagleon / default.css
Created May 17, 2013 03:08
个人通用css文件头,借鉴了bootstrap的grid 布局。
@charset="utf-8"
/* 公共部分 */
.clearfix {
*zoom: 1
}
.clearfix:before,.clearfix:after {
display: table;
content: ""
select branch_name,
sum(case level when 1 then final_score else 0 end) z_s,
count(case level when 1 then final_score else null end) z_c,
sum(case level when 2 then final_score else 0 end) f_s,
count(case level when 2 then final_score else null end) f_c,
sum( final_score) t_s,
count(final_score) t_c