- 博客(53)
- 收藏
- 关注
原创 将已安装的rpm包按大小排序打印
就这样:[code="sh"]rpm -qa --qf '%10{SIZE}\t%{NAME}\n' | sort -k1,1n > sizes.txt[/code]
2012-06-16 02:21:34
715
普通青年 文艺青年 2B青年
本文纯属搞笑,如有雷同,纯属巧合。[code="c"]/* normal-youth.c */main() { printf("hello world");}[/code][code="c"]/* literature-youth.c */int main(int argc, char** argv) { printf("Hell...
2011-10-26 21:37:08
226
如果你觉得这段代码可读性高,请支持汉语编程。
你有没有想过,为什么编程一定要用英语?为什么美国人天生就有语言优势;而我们为了操作一台机器,却要费那么多时间学习一个鸟语?这对我们公平吗?当然,随着Java语言的到来,用自己的语言编程不再是梦想。一个简单的Java Bean:문서.java[code="java"]package koreantest;import java.util.Date;publ...
2011-08-17 11:12:45
154
提前应用gnome-shell补丁修正css装载问题
补丁不是我写的,我只是把将在下一个版本中应用的补丁提前打入我正在使用的版本中而已。题外话:GnomeShell是GNOME3的新的默认用户界面,和Windows、Mac、GNOME2、KDE的使用方法大相径庭。它使用Clutter作为后端,利用硬件加速实现桌面特效,但是仅仅是最基本的特效,不会消耗太多系统资源。一开始用会不习惯。习惯后,会发现很多设计是很人性化的。当然,Gnome3也刚刚发...
2011-07-25 15:40:16
155
我讨厌XML,还是JSON好。
[b]自问:XML是什么?[/b]自答:XML就是:[list][*] 文本[*] 元素(元素包括名称、属性和其他子节点)[*] 以及以上几种东东的有穷组合。[/list]嗯。就是这些。比如[code="xml"] Hello World 42 [/code]那么,“Hello World”是文本,“42”是文本,“int”, "T...
2011-07-16 22:26:13
179
能在Eclipse 3.7中给m2e提供WTP支持的插件在哪里?
更新:在目前(2012年5月19日),安装m2e-wtp不需要这么麻烦,直接去eclipse marketplace搜索m2e-wtp就可以了。Eclipse for Java自带m2e,但是Eclipse for Java EE不带m2e,可以用eclipse -> help -> install new softwares -> "Work with = Indigo" -> ...
2011-07-09 00:51:49
283
spring-security-config:脱机也能运行带spring-security的web程序。
这是spring xml[code="xml"][/code]把带有这个的web程序放到Tomcat上,每次启动,就会上springframework.org去下载那些.xsd。真的?我想spring没那么笨吧。全世界有多少spring用户,这样下去自己会先被自己的框架slashdot掉。实际上,这些xsd文件,在各自spring组件的jar包里都有一份。所以,既然本地...
2011-04-21 16:14:32
121
原创 WARC里的HTTP响应
WARC是一种格式。Heritrix([url]http://crawler.archive.org/[/url])用它原封不动地储存HTTP请求和HTTP响应的全文。包括请求/状态行、头、内容。读WARC格式很简单。利用Heritrix中提供的工具即可。[code="java"]package warc;import java.io.*;import org....
2011-02-16 17:20:54
284
原创 ThreadPoolExecutor的陷阱
下面的程序有什么问题吗?[code]package tpe2;import java.util.concurrent.*;/** * 这个作业计算两个整数相除的商和余数,并输出。 */class DivideNumbersJob implements Runnable { int a,b; public DivideNumbersJob(int a, i...
2010-11-15 23:15:59
155
原创 Executor介绍
[b]介绍Java的ThreadPoolExecutor[/b]Java1.5提供了java.util.concurrent.*;以方便多线程编程。interface Executor是一个接口。你可以理解成你的一个“奴隶管理器”。你把可以异步执行的作业,封装成一个个的Runnable对象。只要你把这些Runnable对象仍给Executor,它就会用合适的方法帮你执行这些作业,你...
2010-11-15 22:39:33
103
哪个多?
在某种机器上,C语言源程序,和二进制目标代码,哪个多?都是无限的,不是吗?但是,每个C程序都对应一个目标代码,但是,有些目标代码里却包含着C语言无法表达的程序。比如8086的ROL或ROR指令(旋转移位,相当于:[code="c"] unsigned int x; x = (x(8*sizeof(int)-3) & 0xff[/code]),没有直接对应的C...
2010-07-11 02:28:31
140
证明:白马非马
公孙龙说:“白马非马”。当然,这可以理解成,“白马“和“马“不是全同的概念,白马是一种马。但是,我要证明,白马连“一种马”都不是!=========== 我是严肃的分割线 ============首先,要明确,什么是“白马”。我们可以定义:[quote]定义:如果一匹马身上的毛都是白的,那么这匹马可以称为“白马“。[/quote]姑且认为是全白的吧,...
2010-07-07 16:53:14
347
你不可能踏进同一条河两次
Q:你会Java?A:是。Q:请用Java描述一个工人,它有姓名和工龄(可以理解成这项工作做了多少年)A:简单:[code="java"]class Worker { private String name; private int years; // Getters and setters ...}[/code]Q:嗯。很好。继续:程...
2010-07-05 00:23:21
149
PLisp: 集成在Python中的LISP语言实现 (2)
上文我构造了一个简单的Python版Symbolic Expression解释器。可以解释由Python的list, str以及其他数据类型构成的表达式。我们可以用"set"函数赋值,用"+","-"等函数进行简单的计算,用"if"函数进行条件判断,并用"print"函数输出。例如:[code="python"]["set", q("x&q
2010-04-22 00:59:54
309
PLisp: 集成在Python中的LISP语言实现 (1)
看了一点LISP的书,猛然觉得,LISP的原理很简单。LISP里面只有1种数据结构:Symbolic Expression,简称sexp。程序本身也是sexp,处理的数据也是sexp。也就是,如果你能解释用sexp写成的程序,你就制成了LISP解释器。LISP里面,sexp分为两种:表和原子。list(表),内部有序地包含0个或多个sexp。除此之外,其他东西都是atom(原子),比如sy...
2010-04-20 02:21:06
2063
隐式转换:Scala对Extension Method的回应
.NET有Extension Methods。当你:[code="c#"]using System.Linq;[/code]然后,你的所有数组对象神奇般地“拥有”了Contains, Count, GroupBy, OrderBy等一系列“前所未有”的方法。你感觉你的“Array”类被人注入了额外的东西。C#的Extension Method定义为静态方法。如果第一个参数加...
2010-04-12 02:53:01
187
Interpreter模式和Visitor模式
本文解决我的某个未解之谜:http://cloverprince.iteye.com/blog/336641说一个笑话:请问,Java语言的使用者看到了如下的代码会怎么想:[code="cpp"]int calculate(int a, int b, char op){ int c; switch(op) { case '+': c=a+b; break...
2010-04-03 15:36:44
224
原创 Java词汇
学习Java语言是几年前,但近期才开始深入学习各种应用,主要是web。但是,不久就被各种术语淹没。感觉到Java也是个TIMTOWTDI的东西。从web到数据库,每种应用至少有3种以上的构件可供选择。以下列举一堆词汇,很多至今还不甚明了。我希望每个词汇都能找到一句话解释其本质。请用批判的眼光阅读以下列表。这个表可能会越列越长。[list][*] Ant: 一种构建工具,类似...
2010-02-10 11:53:00
135
嫌音乐压缩不利用多核处理器,特意写了个Makefile...
现有很多wav文件,转换成ogg,可以:[code="bash"]$ oggenc -q5 *.wav[/code]但是,如果你用的是双核,只有一个核心在工作。所以,写一个Makefile:[code="Makefile"]SRCS = $(wildcard *.wav)OBJS = $(patsubst %.wav,%.ogg,$(SRCS))al...
2009-12-20 01:35:36
92
GObject 2-01: A convention-compliant minimal complete working example.
My coding style has been so weird that no proper GObject programmers would ever use.GObject do have their coding/naming convention which is "designed by both smart and experienced people" and I am...
2009-12-18 01:19:54
139
[自己动手]用Java的反射实现DAO
(难得,我在JavaEye博客的第一篇Java文章。)Java: 一种语言。具体的说:[quote]来自http://james-iry.blogspot.com/2009/05/brief-incomplete-and-mostly-wrong.html1996 - James Gosling invents Java. Java is a relatively verbos...
2009-12-05 16:21:38
205
GObject 09: An Interface
An interface is a class with multiple abstract methods. A class may implement one or more interfaces which means that the class provides all the abstract methods specified in the interfaces. This se...
2009-11-09 16:56:03
126
原创 适合Python程序员的vim配置文件
转载自[url]http://py.vaults.ca/~x/python_and_vim.html[/url]paste into your ~/.vimrc[quote]set tabstop=4 " A four-space tab indent width is the prefered coding style " f...
2009-10-31 23:36:13
132
GObject 08: A class with a signal
A GObject may emit signals to show that something have happened. Signals can be connected to many "handlers" which are called when the signals are emitted.Full code:[code]/* A subclass of GObje...
2009-10-22 17:09:39
156
GObject 07: A class with properties.
A good practice of Object-oriented Programming is to hide implementation details from the user. As explained before, programmers are encouraged to use "private" fields. However, if you want to let u...
2009-10-22 16:17:21
112
GObject 06: A subclass of GObject
This time GObject refers to the type named GObject in the GObject library. Don't be confused.The type GObject is supposed to be the base class of other user-defined classes.[list][*] GObject ...
2009-10-21 13:44:08
123
GObject 05: An Inheritable class.
In this article I will implement a class inheriting another.An inherited class is also known as a "child class", a "derived class" or a "subclass". The class it inherits is call the "parent class...
2009-10-21 01:32:56
121
GObject 04: A class with private members
A private member is a member that is only accessible by other methods of the class.Q: Why private? It is inconvenient, isn't it?A: Exposing all details may offer some convenience, but it is alm...
2009-10-21 00:49:15
125
GObject 03: An Instantiatable Class
Most of the time classes are instantiatable. It can create "instances", which have their own data and share common methods of the class.So a CLASS is shared by many INSTANCEs.In GObject, we n...
2009-10-16 16:35:17
112
GObject 02: A classed type
Now I am going to create a classed type.Q: What is a class?A: I don't know for sure. In object-oriented programming, a class represents a "kind" of data. It specifies what data there is (the m...
2009-10-13 16:53:21
103
GObject 01: My first fundamental type.
GObject system handles "types".Q: So what is a "type"?A: Err.. A "type" is how you consider a piece of data.See, there is no "type" in assembly language. The data, whether in registers or ...
2009-10-13 01:25:35
140
GObject 00: A bottom-up introduction to the GObject system
This document introduces the GObject library. This cannot replace the official tutorial/reference. It is recommended to lookup the official reference every time you encountered new concepts.--...
2009-10-13 00:34:18
203
1
插件问题回答第1题 另解
问题贴:[url]http://cloverprince.iteye.com/blog/481307[/url][quote]1. 现有一个主程序用C语言写成。现在要允许第三方开发人员编写扩展的模块,约定第三方开发的模块必须提供一系列已知名称的函数(如 foo(),bar(),baz())。如果要求第三方的模块必须与主程序的二进制代码分开发布,把dll或so丢在某个文件夹内即可被动态装载并...
2009-10-08 01:37:00
115
插件问题回答第2题 另解
问题贴:[url]http://cloverprince.iteye.com/blog/481307[/url][quote]2. 现有一个主程序用C++语言写成。现在要允许第三方开发人员编写扩展的类,约定第三方开发的类必须包含一个继承自某个已知类(如class FooPlugin)的子类,名称不限。如果要求第三方的类必须与主程序的二进制代码分开发布,把dll或so丢在某个文件夹内即可...
2009-10-06 23:03:43
150
插件问题回答第5题
问题原贴: http://cloverprince.iteye.com/admin/blogs/481307 [quote]5. 现有一个主程序用Python语言写成。现在要允许第三方开发人员编写扩展的类,约定第三方开发的类必须包含一个继承自某个已知类(如class FooPlugin)的子类,名称不限。如果要求第三方的类必须与主程序的py脚本或pyc字节码分开发布,把py或pyc丢在某个...
2009-10-04 20:35:02
101
插件问题回答第4题
问题原贴: [url]http://cloverprince.iteye.com/admin/blogs/481307[/url][quote]4. 现有一个主程序用C#语言写成。现在要允许第三方开发人员编写扩展的类,约定第三方开发的类必须包含一个实现了某个已知接口(如interface IFooPlugin)的类,名称不限。如果要求第三方的类必须与主程序的二进制代码分开发布,把dll丢在...
2009-10-04 17:47:46
101
插件问题回答第3题
问题原贴: [url]http://cloverprince.iteye.com/admin/blogs/481307[/url][quote]3. 现有一个主程序用Java语言写成。现在要允许第三方开发人员编写扩展的类,约定第三方开发的类必须包含一个实现了某个已知接口(如interface IFooPlugin)的类,名称不限。如果要求第三方的类必须与主程序的bytecode分开发布,把...
2009-10-03 21:58:21
136
插件问题回答第2题
问题贴:[url]http://cloverprince.iteye.com/blog/481307[/url][quote]2. 现有一个主程序用C++语言写成。现在要允许第三方开发人员编写扩展的类,约定第三方开发的类必须包含一个继承自某个已知类(如class FooPlugin)的子类,名称不限。如果要求第三方的类必须与主程序的二进制代码分开发布,把dll或so丢在某个文件夹内即可...
2009-10-02 14:09:25
103
插件问题回答第1题
问题贴:[url]http://cloverprince.iteye.com/blog/481307[/url][quote]1. 现有一个主程序用C语言写成。现在要允许第三方开发人员编写扩展的模块,约定第三方开发的模块必须提供一系列已知名称的函数(如 foo(),bar(),baz())。如果要求第三方的模块必须与主程序的二进制代码分开发布,把dll或so丢在某个文件夹内即可被动态装载并...
2009-10-02 14:05:54
133
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人