??xml version="1.0" encoding="utf-8" standalone="yes"?>BlogJava-gembinhttp://www.dentisthealthcenter.com/gembin/<font color="red">OSGi, Eclipse Equinox, ECF, Virgo, Gemini, Apache Felix, Karaf, Aires, Camel, Eclipse RCP</font><br/><br/> <font color="green">HBase, Hadoop, ZooKeeper, Cassandra</font><br/><br/> <font color="blue">Flex4, AS3, Swiz framework, GraniteDS, BlazeDS etc.</font><br/><br/> <font color="black"> There is nothing that software can't fix. Unfortunately, there is also nothing that software can't completely fuck up. That gap is called talent.</font> <br/><br/> <a >About Me</a> <script type="text/javascript" src="http://platform.linkedin.com/in.js"></script><script type="in/share" data-counter="right"></script> zh-cnThu, 07 Dec 2023 17:56:42 GMTThu, 07 Dec 2023 17:56:42 GMT60Overriding Vs Hiding http://www.dentisthealthcenter.com/gembin/archive/2014/05/29/414246.htmlgembingembinThu, 29 May 2014 07:52:00 GMThttp://www.dentisthealthcenter.com/gembin/archive/2014/05/29/414246.htmlhttp://www.dentisthealthcenter.com/gembin/comments/414246.htmlhttp://www.dentisthealthcenter.com/gembin/archive/2014/05/29/414246.html#Feedback0http://www.dentisthealthcenter.com/gembin/comments/commentRss/414246.htmlhttp://www.dentisthealthcenter.com/gembin/services/trackbacks/414246.htmlhttp://yuzan.me/

Can I override a static method?

Many people have heard that you can't override a static method. This is true - you can't. However it is possible to write code like this:


class Foo {
    public static void method() {
        System.out.println("in Foo");
    }
}

class Bar extends Foo {
    public static void method() {
        System.out.println("in Bar");
    }
}

This compiles and runs just fine. Isn't it an example of a static method overriding another static method? The answer is no - it's an example of a static method hiding another static method. If you try to override a static method, the compiler doesn't actually stop you - it just doesn't do what you think it does.

So what's the difference?

Briefly, when you override a method, you still get the benefits of run-time polymorphism, and when you hide, you don't. So what does that mean? Take a look at this code:


class Foo {
    public static void classMethod() {
        System.out.println("classMethod() in Foo");
    }

    public void instanceMethod() {
        System.out.println("instanceMethod() in Foo");
    }
}

class Bar extends Foo {
    public static void classMethod() {
        System.out.println("classMethod() in Bar");
    }

    public void instanceMethod() {
        System.out.println("instanceMethod() in Bar");
    }
}
 
class Test {
    public static void main(String[] args) {
        Foo f = new Bar();
        f.instanceMethod();
        f.classMethod();
    }
}

If you run this, the output is

instanceMethod() in Bar classMethod() in Foo

Why do we get instanceMethod from Bar, but classMethod() from Foo? Aren't we using the same instance f to access both of these? Yes we are - but since one is overriding and the other is hiding, we see different behavior.

Since instanceMethod() is (drum roll please...) an instance method, in which Bar overrides the method from Foo, at run time the JVM uses the actual class of the instance f to determine which method to run. Although f was declared as a Foo, the actual instance we created was a new Bar(). So at runtime, the JVM finds that f is a Bar instance, and so it calls instanceMethod() in Bar rather than the one in Foo. That's how Java normally works for instance methods.

With classMethod() though. since (ahem) it's a class method, the compiler and JVM don't expect to need an actual instance to invoke the method. And even if you provide one (which we did: the instance referred to by f) the JVM will never look at it. The compiler will only look at the declared type of the reference, and use that declared type to determine, at compile time, which method to call. Since f is declared as type Foo, the compiler looks at f.classMethod() and decides it means Foo.classMethod. It doesn't matter that the instance reffered to by f is actually a Bar - for static methods, the compiler only uses the declared type of the reference. That's what we mean when we say a static method does not have run-time polymorphism.

Because instance methods and class methods have this important difference in behavior, we use different terms - "overriding" for instance methods and "hiding" for class methods - to distinguish between the two cases. And when we say you can't override a static method, what that means is that even if you write code that looks like it's overriding a static method (like the first Foo and Bar at the top of this page) - it won't behave like an overridden method.

So what about accessing a static method using an instance?

It's possible in Java to write something like:

   f.classMethod();

where f is an instance of some class, and classMethod() is a class method (i.e. a static method) of that class. This is legal, but it's a bad idea because it creates confusion. The actual instance f is not really important here. Only the declared type of f matters. That is, what class is f declared to be? Since classMethod() is static, the class of f (as determined by the compiler at compile time) is all we need.

Rather than writing:

    f.classMethod();
It would be better coding style to write either:
    Foo.classMethod();
or
    Bar.classMethod(); 
That way, it is crystal clear which class method you would like to call. It is also clear that the method you are calling is indeed a class method.

Barring that, you could always come up with this monstrosity:

    f.getClass().getMethod("classMethod", new Class[]).invoke(null, new Object[]);

But all this could be avoided by simply not trying to override your static (class) methods. :-)

Why does the compiler sometimes talk about overriding static methods?

Sometimes you will see error messages from the compiler that talk about overriding static methods. Apparently, whoever writes these particular messages has not read the Java Language Specification and does not know the difference between overriding and hiding. So they use incorrect and misleading terminology. Just ignore it. The Java Language Specification is very clear about the difference between overriding and hiding, even if the compiler messages are not. Just pretend that the compiler said "hide" rather than "override"..

ref: http://www.coderanch.com/how-to/java/OverridingVsHiding



gembin 2014-05-29 15:52 发表评论
]]>
Fuck GFWhttp://www.dentisthealthcenter.com/gembin/archive/2014/05/18/413795.htmlgembingembinSat, 17 May 2014 16:21:00 GMThttp://www.dentisthealthcenter.com/gembin/archive/2014/05/18/413795.htmlhttp://www.dentisthealthcenter.com/gembin/comments/413795.htmlhttp://www.dentisthealthcenter.com/gembin/archive/2014/05/18/413795.html#Feedback1http://www.dentisthealthcenter.com/gembin/comments/commentRss/413795.htmlhttp://www.dentisthealthcenter.com/gembin/services/trackbacks/413795.html Just one word: FUCK!! 
Two words: FUCK YOU!! 
Three words: FUCK YOU Forever!! 

I JUST want to access github !! WHY is this! GFWQthe son of a bitch!!!!
 

gembin 2014-05-18 00:21 发表评论
]]>
A web-based monitoring tool for WebSphere MQhttp://www.dentisthealthcenter.com/gembin/archive/2013/12/04/407231.htmlgembingembinWed, 04 Dec 2013 15:22:00 GMThttp://www.dentisthealthcenter.com/gembin/archive/2013/12/04/407231.htmlhttp://www.dentisthealthcenter.com/gembin/comments/407231.htmlhttp://www.dentisthealthcenter.com/gembin/archive/2013/12/04/407231.html#Feedback0http://www.dentisthealthcenter.com/gembin/comments/commentRss/407231.htmlhttp://www.dentisthealthcenter.com/gembin/services/trackbacks/407231.html
My developerWorks article on WebSphere MQ
http://www.ibm.com/developerworks/websphere/library/techarticles/1311_jin/1311_jin.html


gembin 2013-12-04 23:22 发表评论
]]>
How JavaScript Timers Workhttp://www.dentisthealthcenter.com/gembin/archive/2013/05/27/399816.htmlgembingembinMon, 27 May 2013 05:50:00 GMThttp://www.dentisthealthcenter.com/gembin/archive/2013/05/27/399816.htmlhttp://www.dentisthealthcenter.com/gembin/comments/399816.htmlhttp://www.dentisthealthcenter.com/gembin/archive/2013/05/27/399816.html#Feedback0http://www.dentisthealthcenter.com/gembin/comments/commentRss/399816.htmlhttp://www.dentisthealthcenter.com/gembin/services/trackbacks/399816.htmlAt a fundamental level it’s important to understand how JavaScript timers work. Often times they behave unintuitively because of the single thread which they are in. Let’s start by examining the three functions to which we have access that can construct and manipulate timers.

  • var id = setTimeout(fn, delay); – Initiates a single timer which will call the specified function after the delay. The function returns a unique ID with which the timer can be canceled at a later time.
  • var id = setInterval(fn, delay); – Similar to setTimeout but continually calls the function (with a delay every time) until it is canceled.
  • clearInterval(id);clearTimeout(id); – Accepts a timer ID (returned by either of the aforementioned functions) and stops the timer callback from occurring.

In order to understand how the timers work internally there’s one important concept that needs to be explored: timer delay is not guaranteed. Since all JavaScript in a browser executes on a single thread asynchronous events (such as mouse clicks and timers) are only run when there’s been an opening in the execution. This is best demonstrated with a diagram, like in the following:


(Click to view full size diagram)

There’s a lot of information in this figure to digest but understanding it completely will give you a better realization of how asynchronous JavaScript execution works. This diagram is one dimensional: vertically we have the (wall clock) time, in milliseconds. The blue boxes represent portions of JavaScript being executed. For example the first block of JavaScript executes for approximately 18ms, the mouse click block for approximately 11ms, and so on.

Since JavaScript can only ever execute one piece of code at a time (due to its single-threaded nature) each of these blocks of code are “blocking” the progress of other asynchronous events. This means that when an asynchronous event occurs (like a mouse click, a timer firing, or an XMLHttpRequest completing) it gets queued up to be executed later (how this queueing actually occurs surely varies from browser-to-browser, so consider this to be a simplification).

To start with, within the first block of JavaScript, two timers are initiated: a 10mssetTimeout and a 10ms setInterval. Due to where and when the timer was started it actually fires before we actually complete the first block of code. Note, however, that it does not execute immediately (it is incapable of doing that, because of the threading). Instead that delayed function is queued in order to be executed at the next available moment.

Additionally, within this first JavaScript block we see a mouse click occur. The JavaScript callbacks associated with this asynchronous event (we never know when a user may perform an action, thus it’s consider to be asynchronous) are unable to be executed immediately thus, like the initial timer, it is queued to be executed later.

After the initial block of JavaScript finishes executing the browser immediately asks the question: What is waiting to be executed? In this case both a mouse click handler and a timer callback are waiting. The browser then picks one (the mouse click callback) and executes it immediately. The timer will wait until the next possible time, in order to execute.

Note that while mouse click handler is executing the first interval callback executes. As with the timer its handler is queued for later execution. However, note that when the interval is fired again (when the timer handler is executing) this time that handler execution is dropped. If you were to queue up all interval callbacks when a large block of code is executing the result would be a bunch of intervals executing with no delay between them, upon completion. Instead browsers tend to simply wait until no more interval handlers are queued (for the interval in question) before queuing more.

We can, in fact, see that this is the case when a third interval callback fires while the interval, itself, is executing. This shows us an important fact: Intervals don’t care about what is currently executing, they will queue indiscriminately, even if it means that the time between callbacks will be sacrificed.

Finally, after the second interval callback is finished executing, we can see that there’s nothing left for the JavaScript engine to execute. This means that the browser now waits for a new asynchronous event to occur. We get this at the 50ms mark when the interval fires again. This time, however, there is nothing blocking its execution, so it fires immediately.

Let’s take a look at an example to better illustrate the differences betweensetTimeout and setInterval.

  1. setTimeout(function(){
  2.     /* Some long block of code... */
  3.     setTimeout(arguments.callee, 10);
  4.   }, 10);
  5.  
  6.   setInterval(function(){
  7.     /* Some long block of code... */
  8.   }, 10);

These two pieces of code may appear to be functionally equivalent, at first glance, but they are not. Notably the setTimeout code will always have at least a 10ms delay after the previous callback execution (it may end up being more, but never less) whereas the setInterval will attempt to execute a callback every 10ms regardless of when the last callback was executed.

There’s a lot that we’ve learned here, let’s recap:

  • JavaScript engines only have a single thread, forcing asynchronous events to queue waiting for execution.
  • setTimeout and setInterval are fundamentally different in how they execute asynchronous code.
  • If a timer is blocked from immediately executing it will be delayed until the next possible point of execution (which will be longer than the desired delay).
  • Intervals may execute back-to-back with no delay if they take long enough to execute (longer than the specified delay).

All of this is incredibly important knowledge to build off of. Knowing how a JavaScript engine works, especially with the large number of asynchronous events that typically occur, makes for a great foundation when building an advanced piece of application code.

from: http://ejohn.org/blog/how-javascript-timers-work/




gembin 2013-05-27 13:50 发表评论
]]>
Tip of changing the language settings for Websphere MQ Explorerhttp://www.dentisthealthcenter.com/gembin/archive/2013/03/23/396905.htmlgembingembinSat, 23 Mar 2013 09:26:00 GMThttp://www.dentisthealthcenter.com/gembin/archive/2013/03/23/396905.htmlhttp://www.dentisthealthcenter.com/gembin/comments/396905.htmlhttp://www.dentisthealthcenter.com/gembin/archive/2013/03/23/396905.html#Feedback0http://www.dentisthealthcenter.com/gembin/comments/commentRss/396905.htmlhttp://www.dentisthealthcenter.com/gembin/services/trackbacks/396905.htmlOpen <InstallDir>/MQExplorer/eclipse/configuration/config.ini
Add these two lines before eof

org.osgi.framework.language=en
osgi.nl=en_US


gembin 2013-03-23 17:26 发表评论
]]>
Mac技巧之让U盘、移动硬盘在Ҏ电脑和Windows PC都能识别/dQ且支持4GB大文ӞexFAT格式http://www.dentisthealthcenter.com/gembin/archive/2013/03/12/396297.htmlgembingembinMon, 11 Mar 2013 17:27:00 GMThttp://www.dentisthealthcenter.com/gembin/archive/2013/03/12/396297.htmlhttp://www.dentisthealthcenter.com/gembin/comments/396297.htmlhttp://www.dentisthealthcenter.com/gembin/archive/2013/03/12/396297.html#Feedback0http://www.dentisthealthcenter.com/gembin/comments/commentRss/396297.htmlhttp://www.dentisthealthcenter.com/gembin/services/trackbacks/396297.html 如果您的 U 盘、移动硬盘既要用?PC 又要用于Ҏ电脑QMac OS X pȝ?HFSQ??Windows ?NTFS 格式昄都不?#8230;…HFS+ ?Windows 下不识别QNTFS 格式?U 盘、移动硬盘插在苹果电脑上只能M能写。格式化?FAT32 昄可以支持两个pȝQ但单一文g大于 4GB 歇菜?/span>

exFAT 格式

    但苹果电?Mac OS X 10.6.5 pȝ做出了一Ҏ义重大的升Q支?exFAT 盘格式Q格式化?exFAT 格式?U 盘、移动硬盘在 Windows PC 上和Ҏ电脑 Mac OS X pȝ下均能读写,而且支持过单个体积过 4 GB 的大文g?/p>

    下面是将 U 盘、移动硬盘格式化?exFAT 格式的方法,以及 exFAT、FAT32、HFSQ?三种格式下同一?U 盘的d速度试

Ҏ电脑 Mac OS X pȝ下把U盘、移动硬盘格式化成exFAT格式
Ҏ电脑 Mac OS X pȝ下把U盘、移动硬盘格式化成exFAT格式

    点击Ҏ电脑屏幕右上角的攑֤镜按钮,Sportlight 搜烦“盘工具”Q在盘工具侧边栏选择要格式化?U 盘或Ud盘分区Q右侧选择“Ҏ”标签Q在格式下拉菜单里选择 ExFAT 卛_。如上图所C?/p>

Windows pȝ下把U盘、移动硬盘格式化成exFAT格式
Windows pȝ下把U盘、移动硬盘格式化成exFAT格式

    Windows 7 ?Vista 默认支?exFAT 格式Q如果是 XP pȝQ要下蝲 KB955704 补丁Q?u style="margin: 0px auto; padding: 0px;">http://www.microsoft.com/downloads/details.aspx?displaylang=zh-cn&FamilyID=1cbe3906-ddd1-4ca2-b727-c2dff5e30f61

    至于 exFAT 格式?U 盘的d速度Q下面是同一?U 盘在同一台电脑(我的 Macbook ProQ上的读写速度试Q测试Y件ؓ 以前介绍的免费YӞAJA System Test?br style="margin: 0px auto; padding: 0px;" />

FAT32、HFSQ、exFAT 格式?U 盘读写速度试
FAT32、HFSQ、exFAT 格式?U 盘读写速度试

    时针依ơ是 FAT32、HFSQ、exFAT 格式?U 盘读写速度试l果Q不太妙。所以:只把 U 盘和Ud盘的一个分区(专门用于 PC、Mac 之间交换文gQ格式化?exFAT p了?br />KEEP FOR REF: http://www.mac52ipod.cn/post/use-u-disk-hdd-on-windows-pc-and-mac-os-x-4gb-exfat.php



gembin 2013-03-12 01:27 发表评论
]]>
JPA Conceptshttp://www.dentisthealthcenter.com/gembin/archive/2013/03/07/396169.htmlgembingembinThu, 07 Mar 2013 08:58:00 GMThttp://www.dentisthealthcenter.com/gembin/archive/2013/03/07/396169.htmlhttp://www.dentisthealthcenter.com/gembin/comments/396169.htmlhttp://www.dentisthealthcenter.com/gembin/archive/2013/03/07/396169.html#Feedback0http://www.dentisthealthcenter.com/gembin/comments/commentRss/396169.htmlhttp://www.dentisthealthcenter.com/gembin/services/trackbacks/396169.html
keep it for reference
http://tomee.apache.org/jpa-concepts.html
http://www.jpalace.org/docs/tutorials/jee/jpa_2.html


gembin 2013-03-07 16:58 发表评论
]]>
JPA Criteria API http://www.dentisthealthcenter.com/gembin/archive/2013/03/06/396131.htmlgembingembinWed, 06 Mar 2013 05:44:00 GMThttp://www.dentisthealthcenter.com/gembin/archive/2013/03/06/396131.htmlhttp://www.dentisthealthcenter.com/gembin/comments/396131.htmlhttp://www.dentisthealthcenter.com/gembin/archive/2013/03/06/396131.html#Feedback0http://www.dentisthealthcenter.com/gembin/comments/commentRss/396131.htmlhttp://www.dentisthealthcenter.com/gembin/services/trackbacks/396131.html
Count
CriteriaBuilder critBuilder = entityManager.getCriteriaBuilder();
CriteriaQuery<Long> critQuery = criteriaBuilder.createQuery(Long.class);
Root<Foo> root = critQuery.from(Foo.class);
critQuery.select(critBuilder.countDistinct(root));
int count = entityManager.createQuery(critQuery).getSingleResult().intValue();


 

 Result

CriteriaBuilder critBuilder = entityManager.getCriteriaBuilder(); 
CriteriaQuery<Long> critQuery = criteriaBuilder.createQuery(Long.class);
Root<Foo> root = critQuery.from(Foo.class);
critQuery.select(root).distinct(true);
List<Foo> result = entityManager.createQuery(critQuery).getResultList();


gembin 2013-03-06 13:44 发表评论
]]>
Adobe Photoshop Source Code - version 1.0.1http://www.dentisthealthcenter.com/gembin/archive/2013/02/14/395312.htmlgembingembinThu, 14 Feb 2013 08:28:00 GMThttp://www.dentisthealthcenter.com/gembin/archive/2013/02/14/395312.htmlhttp://www.dentisthealthcenter.com/gembin/comments/395312.htmlhttp://www.dentisthealthcenter.com/gembin/archive/2013/02/14/395312.html#Feedback0http://www.dentisthealthcenter.com/gembin/comments/commentRss/395312.htmlhttp://www.dentisthealthcenter.com/gembin/services/trackbacks/395312.htmlpho·to·shop, transitive verb, often capitalized \ˈfō-(ˌ)tō-ˌshäp\

  1. to alter (a digital image) with Photoshop software or other image-editing software especially in a way that distorts reality (as for deliberately deceptive purposes)

– Merriam-Webster online dictionary, 2012

When brothers Thomas and John Knoll began designing and writing an image editing program in the late 1980s, they could not have imagined that they would be adding a word to the dictionary.

Thomas Knoll

John Knoll


Thomas Knoll, a PhD student in computer vision at the University of Michigan, had written a program in 1987 to display and modify digital images. His brother John, working at the movie visual effects company Industrial Light & Magic, found it useful for editing photos, but it wasn’t intended to be a product. Thomas said, “We developed it originally for our own personal use…it was a lot a fun to do.”

Gradually the program, called “Display”, became more sophisticated. In the summer of 1988 they realized that it indeed could be a credible commercial product. They renamed it “Photoshop” and began to search for a company to distribute it. About 200 copies of version 0.87 were bundled by slide scanner manufacturer Barneyscan as “Barneyscan XP”.

The fate of Photoshop was sealed when Adobe, encouraged by its art director Russell Brown, decided to buy a license to distribute an enhanced version of Photoshop. The deal was finalized in April 1989, and version 1.0 started shipping early in 1990.

Over the next ten years, more than 3 million copies of Photoshop were sold.

  That first version of Photoshop was written primarily in Pascal for the Apple Macintosh, with some machine language for the underlying Motorola 68000 microprocessor where execution efficiency was important. It wasn’t the effort of a huge team. Thomas said, “For version 1, I was the only engineer, and for version 2, we had two engineers.” While Thomas worked on the base application program, John wrote many of the image-processing plug-ins.

With the permission of Adobe Systems Inc., the Computer History Museum is pleased to make available, for non-commercial use, the source code to the 1990 version 1.0.1 of Photoshop. All the code is here with the exception of the MacApp applications library that was licensed from Apple. There are 179 files in the zipped folder, comprising about 128,000 lines of mostly uncommented but well-structured code. By line count, about 75% of the code is in Pascal, about 15% is in 68000 assembler language, and the rest is data of various sorts. To download the code you must agree to the terms of the license.

Download Photoshop version 1.0.1 Source Code

The 1990 version of the Adobe Photoshop User Guide is athttp://www.computerhistory.org/collections/accession/102640940

and the 1990 Adobe Photoshop tutorial is athttp://www.computerhistory.org/collections/accession/102640945 

Commentary on the source code

Software architect Grady Booch is the Chief Scientist for Software Engineering at IBM Research Almaden and a trustee of the Computer History Museum. He offers the following observations about the Photoshop source code:

“Opening the files that constituted the source code for Photoshop 1.0, I felt a bit like Howard Carter as he first breached the tomb of King Tutankhamen. What wonders awaited me?

I was not disappointed by what I found. Indeed, it was a marvelous journey to open up the cunning machinery of an application I’d first used over 20 years ago.

Architecturally, this is a very well-structured system. There’s a consistent separation of interface and abstraction, and the design decisions made to componentize those abstractions – with generally one major type for each combination of interface and implementation — were easy to follow.

The abstractions are quite mature. The consistent naming, the granularity of methods, the almost breathtaking simplicity of the implementations because each type was so well abstracted, all combine to make it easy to discern the texture of the system.

Having the opportunity to examine Photoshop’s current architecture, I believe I see fundamental structures that have persisted, though certainly in more evolved forms, in the modern implementation. Tiles, filters, abstractions for virtual memory (to attend to images far larger than display buffers or main memory could normally handle) are all there in the first version. Yet it had just over 100,000 lines of code, compared to well over 10 million in the current version! Then and now, much of the code is related to input/output and the myriad of file formats that Photoshop has to attend to.

There are only a few comments in the version 1.0 source code, most of which are associated with assembly language snippets. That said, the lack of comments is simply not an issue. This code is so literate, so easy to read, that comments might even have gotten in the way.

It is delightful to find historical vestiges of the time: code to attend to Andy Herzfield’s software for the Thunderscan scanner, support of early TARGA raster graphics file types, and even a few passing references to Barneyscan lie scattered about in the code. These are very small elements of the overall code base, but their appearance reminds me that no code is an island.

This is the kind of code I aspire to write.”

And this is the kind of code we all can learn from. Software source code is the literature of computer scientists, and it deserves to be studied and appreciated. Enjoy a view of Photoshop from the inside.

 

Early Photoshop screenshots*

 

The home screen, showing the available tools.

 

Photoshop allowed you to select brush color as well as size and texture. (The first color Mac was the Macintosh II in 1987.)

 

There were some sophisticated selection tools, and a good assortment of image filters. One important missing feature, which came with version 3 in 1994, was the ability to divide an image into multiple layers.

 

The preferences page allowed for some customization of the features.

 

There was a limited choice of fonts, font sizes, and font styles. The text was entered into this dialog box, then moved into the image.

*Screen shots courtesy of creativebits, www.creativebits.org.
from:  
http://computerhistory.org/atchm/adobe-photoshop-source-code/



gembin 2013-02-14 16:28 发表评论
]]>
Thread-safety when injecting JPA EntityManagerhttp://www.dentisthealthcenter.com/gembin/archive/2013/02/04/395088.htmlgembingembinMon, 04 Feb 2013 02:49:00 GMThttp://www.dentisthealthcenter.com/gembin/archive/2013/02/04/395088.htmlhttp://www.dentisthealthcenter.com/gembin/comments/395088.htmlhttp://www.dentisthealthcenter.com/gembin/archive/2013/02/04/395088.html#Feedback0http://www.dentisthealthcenter.com/gembin/comments/commentRss/395088.htmlhttp://www.dentisthealthcenter.com/gembin/services/trackbacks/395088.html阅读全文

gembin 2013-02-04 10:49 发表评论
]]>
Java Exception Practiceshttp://www.dentisthealthcenter.com/gembin/archive/2012/12/26/393525.htmlgembingembinWed, 26 Dec 2012 15:56:00 GMThttp://www.dentisthealthcenter.com/gembin/archive/2012/12/26/393525.htmlhttp://www.dentisthealthcenter.com/gembin/comments/393525.htmlhttp://www.dentisthealthcenter.com/gembin/archive/2012/12/26/393525.html#Feedback1http://www.dentisthealthcenter.com/gembin/comments/commentRss/393525.htmlhttp://www.dentisthealthcenter.com/gembin/services/trackbacks/393525.htmlJust keep it for reference.

Best Practices for Exception Handling
http://onjava.com/pub/a/onjava/2003/11/19/exceptions.html

The Trouble with Checked Exceptions
http://www.artima.com/intv/handcuffs.html

Exception-Handling Antipatterns
http://today.java.net/pub/a/today/2006/04/06/exception-handling-antipatterns.html

Exception management and error tracking in J2EE
http://www.javaworld.com/javaworld/jw-07-2005/jw-0711-exception.html?page=1

Exceptional practices
http://www.javaworld.com/javaworld/jw-12-2001/jw-1221-exceptions.html?page=1

Exception Handling
http://www.objectsource.com/j2eechapters/Ch18-Exception_Handling.htm

Spring MVC REST Exception Handling Best Practices 
http://www.stormpath.com/blog/spring-mvc-rest-exception-handling-best-practices-part-1
http://www.stormpath.com/blog/spring-mvc-rest-exception-handling-best-practices-part-2


gembin 2012-12-26 23:56 发表评论
]]>
The Trouble with Checked Exceptionshttp://www.dentisthealthcenter.com/gembin/archive/2012/12/26/393523.htmlgembingembinWed, 26 Dec 2012 15:35:00 GMThttp://www.dentisthealthcenter.com/gembin/archive/2012/12/26/393523.htmlhttp://www.dentisthealthcenter.com/gembin/comments/393523.htmlhttp://www.dentisthealthcenter.com/gembin/archive/2012/12/26/393523.html#Feedback0http://www.dentisthealthcenter.com/gembin/comments/commentRss/393523.htmlhttp://www.dentisthealthcenter.com/gembin/services/trackbacks/393523.htmlSummary
Anders Hejlsberg, the lead C# architect, talks with Bruce Eckel and Bill Venners about versionability and scalability issues with checked exceptions.

Anders Hejlsberg, a distinguished engineer at Microsoft, led the team that designed the C# (pronounced C Sharp) programming language. Hejlsberg first vaulted onto the software world stage in the early eighties by creating a Pascal compiler for MS-DOS and CP/M. A very young company called Borland soon hired Hejlsberg and bought his compiler, which was thereafter marketed as Turbo Pascal. At Borland, Hejlsberg continued to develop Turbo Pascal and eventually led the team that designed Turbo Pascal's replacement: Delphi. In 1996, after 13 years with Borland, Hejlsberg joined Microsoft, where he initially worked as an architect of Visual J++ and the Windows Foundation Classes (WFC). Subsequently, Hejlsberg was chief designer of C# and a key participant in the creation of the .NET framework. Currently, Anders Hejlsberg leads the continued development of the C# programming language.

On July 30, 2003, Bruce Eckel, author of Thinking in C++ and Thinking in Java, and Bill Venners, editor-in-chief of Artima.com, met with Anders Hejlsberg in his office at Microsoft in Redmond, Washington. In this interview, which will be published in multiple installments on Artima.com and on an audio CD-ROM to be released this fall by Bruce Eckel, Anders Hejlsberg discusses many design choices of the C# language and the .NET framework.

  • In Part I: The C# Design Process, Hejlsberg discusses the process used by the team that designed C#, and the relative merits of usability studies and good taste in language design.
  • In this second installment, Hejlsberg discusses versionability and scalability issues with checked exceptions.

    Remaining Neutral on Checked Exceptions

    Bruce Eckel: C# doesn't have checked exceptions. How did you decide whether or not to put checked exceptions into C#?

    Anders Hejlsberg: I see two big issues with checked exceptions: scalability and versionability. I know you've written some about checked exceptions too, and you tend to agree with our line of thinking.

    Bruce Eckel: I used to think that checked exceptions were really great.

    Anders Hejlsberg: Exactly. Frankly, they look really great up front, and there's nothing wrong with the idea. I completely agree that checked exceptions are a wonderful feature. It's just that particular implementations can be problematic. By implementing checked exceptions the way it's done in Java, for example, I think you just take one set of problems and trade them for another set of problems. In the end it's not clear to me that you actually make life any easier. You just make it different.

    Bruce Eckel: Was there a lot of disagreement in the C# design team about checked excpetions?

    Anders Hejlsberg: No, I think there was fairly broad agreement in our design group.

    C# is basically silent on the checked exceptions issue. Once a better solution is known—and trust me we continue to think about it—we can go back and actually put something in place. I'm a strong believer that if you don't have anything right to say, or anything that moves the art forward, then you'd better just be completely silent and neutral, as opposed to trying to lay out a framework.

    If you ask beginning programmers to write a calendar control, they often think to themselves, "Oh, I'm going to write the world's best calendar control! It's going to be polymorphic with respect to the kind of calendar. It will have displayers, and mungers, and this, that, and the other." They need to ship a calendar application in two months. They put all this infrastructure into place in the control, and then spend two days writing a crappy calendar application on top of it. They'll think, "In the next version of the application, I'm going to do so much more."

    Once they start thinking about how they're actually going to implement all of these other concretizations of their abstract design, however, it turns out that their design is completely wrong. And now they've painted themself into a corner, and they have to throw the whole thing out. I have seen that over and over. I'm a strong believer in being minimalistic. Unless you actually are going to solve the general problem, don't try and put in place a framework for solving a specific one, because you don't know what that framework should look like.

    Bruce Eckel: The Extreme Programmers say, "Do the simplest thing that could possibly work."

    Anders Hejlsberg: Yeah, well, Einstein said that, "Do the simplest thing possible, but no simpler." The concern I have about checked exceptions is the handcuffs they put on programmers. You see programmers picking up new APIs that have all these throws clauses, and then you see how convoluted their code gets, and you realize the checked exceptions aren't helping them any. It is sort of these dictatorial API designers telling you how to do your exception handling. They should not be doing that.

    Versioning with Checked Exceptions

    Bill Venners: You mentioned scalability and versioning concerns with respect to checked exceptions. Could you clarify what you mean by those two issues?

    Anders Hejlsberg: Let's start with versioning, because the issues are pretty easy to see there. Let's say I create a method foo that declares it throws exceptions AB, and C. In version two of foo, I want to add a bunch of features, and now foo might throw exception D. It is a breaking change for me to add D to the throws clause of that method, because existing caller of that method will almost certainly not handle that exception.

    Adding a new exception to a throws clause in a new version breaks client code. It's like adding a method to an interface. After you publish an interface, it is for all practical purposes immutable, because any implementation of it might have the methods that you want to add in the next version. So you've got to create a new interface instead. Similarly with exceptions, you would either have to create a whole new method called foo2 that throws more exceptions, or you would have to catch exception D in the new foo, and transform the D into an A,B, or C.

    Bill Venners: But aren't you breaking their code in that case anyway, even in a language without checked exceptions? If the new version of foo is going to throw a new exception that clients should think about handling, isn't their code broken just by the fact that they didn't expect that exception when they wrote the code?

    Anders Hejlsberg: No, because in a lot of cases, people don't care. They're not going to handle any of these exceptions. There's a bottom level exception handler around their message loop. That handler is just going to bring up a dialog that says what went wrong and continue. The programmers protect their code by writing try finally's everywhere, so they'll back out correctly if an exception occurs, but they're not actually interested in handling the exceptions.

    The throws clause, at least the way it's implemented in Java, doesn't necessarily force you to handle the exceptions, but if you don't handle them, it forces you to acknowledge precisely which exceptions might pass through. It requires you to either catch declared exceptions or put them in your own throws clause. To work around this requirement, people do ridiculous things. For example, they decorate every method with, "throws Exception." That just completely defeats the feature, and you just made the programmer write more gobbledy gunk. That doesn't help anybody.

    Bill Venners: So you think the more common case is that callers don't explicitly handle exceptions in deference to a general catch clause further up the call stack?

    Anders Hejlsberg: It is funny how people think that the important thing about exceptions is handling them. That is not the important thing about exceptions. In a well-written application there's a ratio of ten to one, in my opinion, of try finally to try catch. Or in C#, using statements, which are like try finally.

    Bill Venners: What's in the finally?

    Anders Hejlsberg: In the finally, you protect yourself against the exceptions, but you don't actually handle them. Error handling you put somewhere else. Surely in any kind of event-driven application like any kind of modern UI, you typically put an exception handler around your main message pump, and you just handle exceptions as they fall out that way. But you make sure you protect yourself all the way out by deallocating any resources you've grabbed, and so forth. You clean up after yourself, so you're always in a consistent state. You don't want a program where in 100 different places you handle exceptions and pop up error dialogs. What if you want to change the way you put up that dialog box? That's just terrible. The exception handling should be centralized, and you should just protect yourself as the exceptions propagate out to the handler.

    The Scalability of Checked Exceptions

    Bill Venners: What is the scalability issue with checked exceptions?

    Anders Hejlsberg: The scalability issue is somewhat related to the versionability issue. In the small, checked exceptions are very enticing. With a little example, you can show that you've actually checked that you caught the FileNotFoundException, and isn't that great? Well, that's fine when you're just calling one API. The trouble begins when you start building big systems where you're talking to four or five different subsystems. Each subsystem throws four to ten exceptions. Now, each time you walk up the ladder of aggregation, you have this exponential hierarchy below you of exceptions you have to deal with. You end up having to declare 40 exceptions that you might throw. And once you aggregate that with another subsystem you've got 80 exceptions in your throws clause. It just balloons out of control.

    In the large, checked exceptions become such an irritation that people completely circumvent the feature. They either say, "throws Exception," everywhere; or—and I can't tell you how many times I've seen this—they say, "try, da da da da da, catch curly curly." They think, "Oh I'll come back and deal with these empty catch clauses later," and then of course they never do. In those situations, checked exceptions have actually degraded the quality of the system in the large.

    And so, when you take all of these issues, to me it just seems more thinking is needed before we put some kind of checked exceptions mechanism in place for C#. But that said, there's certainly tremendous value in knowing what exceptions can get thrown, and having some sort of tool that checks. I don't think we can construct hard and fast rules down to, it is either a compiler error or not. But I think we can certainly do a lot with analysis tools that detect suspicious code, including uncaught exceptions, and points out those potential holes to you.

    from:  http://www.artima.com/intv/handcuffs.html



gembin 2012-12-26 23:35 发表评论
]]>
CentOS 6 安装后基本配|?/title><link>http://www.dentisthealthcenter.com/gembin/archive/2012/12/23/393380.html</link><dc:creator>gembin</dc:creator><author>gembin</author><pubDate>Sun, 23 Dec 2012 14:57:00 GMT</pubDate><guid>http://www.dentisthealthcenter.com/gembin/archive/2012/12/23/393380.html</guid><wfw:comment>http://www.dentisthealthcenter.com/gembin/comments/393380.html</wfw:comment><comments>http://www.dentisthealthcenter.com/gembin/archive/2012/12/23/393380.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.dentisthealthcenter.com/gembin/comments/commentRss/393380.html</wfw:commentRss><trackback:ping>http://www.dentisthealthcenter.com/gembin/services/trackbacks/393380.html</trackback:ping><description><![CDATA[<p style="font-family: verdana; font-size: 13px; line-height: normal; background-color: #ffffff; "><strong>1</strong><strong>Q网l配|?/strong></p><p style="font-family: verdana; font-size: 13px; line-height: normal; background-color: #ffffff; ">Q?Q命令配|?br /># ifconfig eth0 192.168.0.2 netmask 255.255.255.0   //ip地址、子|掩?br /># route add default gw 192.168.0.1 dev eth0  //|关<br /># hostname centos   //计算机名</p><p style="font-family: verdana; font-size: 13px; line-height: normal; background-color: #ffffff; ">Q?Q文仉|?br /><1>修改IP地址<br />修改对应|卡的IP地址的配|文?br /># vi /etc/sysconfig/network-scripts/ifcfg-eth0<br />DEVICE=eth0 (描述|卡对应的设备别名,例如ifcfg-eth0的文件中它ؓeth0)<br />BOOTPROTO=static (讄|卡获得ip地址的方式,可能的选项为staticQdhcp或bootpQ分别对应静态指定的ip地址Q通过dhcp协议获得的ip地址Q通过bootp协议获得的ip地址)<br />BROADCAST=192.168.0.255 (对应的子|广播地址)<br />HWADDR=00:07:E9:05:E8:B4  (对应的网卡物理地址)<br />IPADDR=12.168.1.2 (如果讄|卡获得ip地址的方式ؓ静态指定,此字D就指定了网卡对应的ip地址)<br />IPV6INIT=no  (开启或关闭IPv6Q关闭noQ开启yes)<br />IPV6_AUTOCONF=no  (开启或关闭IPv6自动配置Q关闭noQ开启yes)<br />NETMASK=255.255.255.0 (|卡对应的网l掩?<br />NETWORK=192.168.1.0 (|卡对应的网l地址)<br />ONBOOT=yes (pȝ启动时是否设|此|络接口Q设|ؓyesӞpȝ启动时激zL讑֤)<br /><br /><2>修改|关<br />修改对应|卡的网关的配置文g<br /># vi /etc/sysconfig/network<br />NETWORKING=yes (表示pȝ是否使用|络Q一般设|ؓyes。如果设为noQ则不能使用|络Q而且很多pȝ服务E序无法启?<br />HOSTNAME=centos (讄本机的主机名Q这里设|的L名要?etc/hosts中设|的L名对?<br />GATEWAY=192.168.1.1 (讄本机q接的网关的IP地址。例如,|关?0.0.0.2)<br /><br /><3>修改DNS<br />修改对应|卡的DNS的配|文?br /># vi /etc/resolv.conf<br />nameserver 202.101.224.68 (域名服务?<br />nameserver 202.101.224.69 (域名服务?<br /><br /><4>重新启动|络配置<br /># service network restart<br />?br /># /etc/init.d/network restart<br /><br /><strong>2</strong><strong>QY件源配置</strong></p><p style="font-family: verdana; font-size: 13px; line-height: normal; background-color: #ffffff; ">国内速度较快的常用更新源如下Q?br />http://mirrors.163.com/centos/ 163-|易<br />http://mirrors.ta139.com/centos/ 中国Ud通信Q山东移动)<br />http://centos.ustc.edu.cn/centos/ 中国U学技术大?br />http://mirror.neu.edu.cn/centos/ 东北大学</p><p style="font-family: verdana; font-size: 13px; line-height: normal; background-color: #ffffff; "><strong>~辑yum</strong><strong>配置文gQ?nbsp;</strong><br />#vi /etc/yum.repos.d/CentOS-Base.repo<br />[base]<br />name=CentOS-$releasever - Base<br />mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=os<br />#baseurl=http://mirror.centos.org/centos/$releasever/os/$basearch/<br />baseurl=http://mirrors.163.com/centos/$releasever/os/$basearch/<br />http://mirrors.ta139.com/centos/$releasever/os/$basearch/<br />http://centos.ustc.edu.cn/centos/$releasever/os/$basearch/<br />http://mirror.neu.edu.cn/centos/$releasever/os/$basearch/<br />gpgcheck=1<br />gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-6</p><p style="font-family: verdana; font-size: 13px; line-height: normal; background-color: #ffffff; ">#released updates <br />[updates]<br />name=CentOS-$releasever - Updates<br />mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=updates<br />#baseurl=http://mirror.centos.org/centos/$releasever/updates/$basearch/<br />baseurl=http://mirrors.163.com/centos/$releasever/updates/$basearch/<br />http://mirrors.ta139.com/centos/$releasever/updates/$basearch/<br />http://centos.ustc.edu.cn/centos/$releasever/updates/$basearch/<br />http://mirror.neu.edu.cn/centos/$releasever/updates/$basearch/<br />gpgcheck=1<br />gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-6</p><p style="font-family: verdana; font-size: 13px; line-height: normal; background-color: #ffffff; ">#additional packages that may be useful<br />[extras]<br />name=CentOS-$releasever - Extras<br />mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=extras<br />#baseurl=http://mirror.centos.org/centos/$releasever/extras/$basearch/<br />baseurl=http://mirrors.163.com/centos/$releasever/extras/$basearch/<br />http://mirrors.ta139.com/centos/$releasever/extras/$basearch/<br />http://centos.ustc.edu.cn/centos/$releasever/extras/$basearch/<br />http://mirror.neu.edu.cn/centos/$releasever/extras/$basearch/<br />gpgcheck=1<br />gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-6</p><p style="font-family: verdana; font-size: 13px; line-height: normal; background-color: #ffffff; ">#additional packages that extend functionality of existing packages<br />[centosplus]<br />name=CentOS-$releasever - Plus<br />mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=centosplus<br />#baseurl=http://mirror.centos.org/centos/$releasever/centosplus/$basearch/<br />baseurl=http://mirrors.163.com/centos/$releasever/centosplus/$basearch/<br />http://mirrors.ta139.com/centos/$releasever/centosplus/$basearch/<br />http://centos.ustc.edu.cn/centos/$releasever/centosplus/$basearch/<br />http://mirror.neu.edu.cn/centos/$releasever/centosplus/$basearch/<br />gpgcheck=1<br />enabled=0<br />gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-6</p><p style="font-family: verdana; font-size: 13px; line-height: normal; background-color: #ffffff; ">#contrib - packages by Centos Users<br />[contrib]<br />name=CentOS-$releasever - Contrib<br />mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=contrib<br />#baseurl=http://mirror.centos.org/centos/$releasever/contrib/$basearch/<br />baseurl=http://mirrors.163.com/centos/$releasever/contrib/$basearch/<br />http://mirrors.ta139.com/centos/$releasever/contrib/$basearch/<br />http://centos.ustc.edu.cn/centos/$releasever/contrib/$basearch/<br />http://mirror.neu.edu.cn/centos/$releasever/contrib/$basearch/<br />gpgcheck=1<br />enabled=0<br />gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-6</p><p style="font-family: verdana; font-size: 13px; line-height: normal; background-color: #ffffff; ">然后使用如下命o更新到最新系l:</p><p style="font-family: verdana; font-size: 13px; line-height: normal; background-color: #ffffff; ">#rpm –import /etc/pki/rpm-gpg-key*</p><span style="font-family: verdana; font-size: 13px; line-height: normal; background-color: #ffffff; ">#yum upgrade</span><p style="font-family: verdana; font-size: 13px; line-height: normal; background-color: #ffffff; "><strong>3</strong><strong>Q安装语a?/strong></p><p style="font-family: verdana; font-size: 13px; line-height: normal; background-color: #ffffff; ">从安装盘q行安装Q找到对应rpm包:<br />fonts-chinese-3.02-9.6.el5.noarch.rpm<br />fonts-ISO8859-2-75dpi-1.0-17.1.noarch.rpm</p><p style="font-family: verdana; font-size: 13px; line-height: normal; background-color: #ffffff; ">可以通过yumq行安装Q安装办法ؓQ?br />#yum groupinstall <language>-support</p><p style="font-family: verdana; font-size: 13px; line-height: normal; background-color: #ffffff; ">?上面的命令中Q?lt;language> 是下列之一: assamese, bengali, chinese, gujarati, hindi, japanese, kannada, korean, malayalam, marathi, oriya, punjabi, sinhala, tamil, thai, ?telegu?/p><p style="font-family: verdana; font-size: 13px; line-height: normal; background-color: #ffffff; "><strong>4</strong><strong>Q解压羃软g </strong><br />#yum install unrar unzip p7zip-full</p><img src ="http://www.dentisthealthcenter.com/gembin/aggbug/393380.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.dentisthealthcenter.com/gembin/" target="_blank">gembin</a> 2012-12-23 22:57 <a href="http://www.dentisthealthcenter.com/gembin/archive/2012/12/23/393380.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>VirtualBox 安装Centos 之访问虚拟机里面的服务受阻解x?/title><link>http://www.dentisthealthcenter.com/gembin/archive/2012/12/23/393378.html</link><dc:creator>gembin</dc:creator><author>gembin</author><pubDate>Sun, 23 Dec 2012 14:40:00 GMT</pubDate><guid>http://www.dentisthealthcenter.com/gembin/archive/2012/12/23/393378.html</guid><wfw:comment>http://www.dentisthealthcenter.com/gembin/comments/393378.html</wfw:comment><comments>http://www.dentisthealthcenter.com/gembin/archive/2012/12/23/393378.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.dentisthealthcenter.com/gembin/comments/commentRss/393378.html</wfw:commentRss><trackback:ping>http://www.dentisthealthcenter.com/gembin/services/trackbacks/393378.html</trackback:ping><description><![CDATA[<p style="margin: 0px 0px 10px; padding: 0px; color: #333333; font-family: 微Y雅黑, Verdana, Tahoma, 'BitStream vera Sans', Arial, Helvetica, sans-serif; font-size: 13px; line-height: 26px; background-color: #fcfff6; ">情况是这LQ我学习cenots一直是在系l中采用virtualbox里面安装一个虚拟系l的方式。每ơ安装之后,都发C能访问里面的80?1?306{这些常用的端口。也是_我只能在本机讉Kq些端口Q想从其他机器访问不OK了。想起以前自׃ؓ了这件事׃整整一周的时候才知道是端口的问题。今天一定要记录下来Q免得下ơ又忘记了?/p><p style="margin: 0px 0px 10px; padding: 0px; color: #333333; font-family: 微Y雅黑, Verdana, Tahoma, 'BitStream vera Sans', Arial, Helvetica, sans-serif; font-size: 13px; line-height: 26px; background-color: #fcfff6; ">开?0?1?306端口Q?/p><pre prettyprint"="" style="margin-top: 6px; margin-bottom: 6px; padding: 2px 7px; font-family: 'Courier New', Courier, monospace, Fixed; overflow: auto; background-color: #f0f6e9; border: 1px solid #cccccc; font-size: 12.3px; line-height: 16px; width: 645.816650390625px; color: #333333; "><span style="margin: 0px; padding: 0px; color: #008800; ">/sbin/</span><span style="margin: 0px; padding: 0px; color: #000000; ">iptables </span><span style="margin: 0px; padding: 0px; color: #666600; ">-</span><span style="margin: 0px; padding: 0px; color: #000000; ">I INPUT </span><span style="margin: 0px; padding: 0px; color: #666600; ">-</span><span style="margin: 0px; padding: 0px; color: #000000; ">p tcp </span><span style="margin: 0px; padding: 0px; color: #666600; ">--</span><span style="margin: 0px; padding: 0px; color: #000000; ">dport </span><span style="margin: 0px; padding: 0px; color: #006666; ">80</span> <span style="margin: 0px; padding: 0px; color: #666600; ">-</span><span style="margin: 0px; padding: 0px; color: #000000; ">j ACCEPT <br /></span><span style="margin: 0px; padding: 0px; color: #666600; ">/</span><span style="margin: 0px; padding: 0px; color: #000000; ">sbin</span><span style="margin: 0px; padding: 0px; color: #666600; ">/</span><span style="margin: 0px; padding: 0px; color: #000000; ">iptables </span><span style="margin: 0px; padding: 0px; color: #666600; ">-</span><span style="margin: 0px; padding: 0px; color: #000000; ">I INPUT </span><span style="margin: 0px; padding: 0px; color: #666600; ">-</span><span style="margin: 0px; padding: 0px; color: #000000; ">p tcp </span><span style="margin: 0px; padding: 0px; color: #666600; ">--</span><span style="margin: 0px; padding: 0px; color: #000000; ">dport </span><span style="margin: 0px; padding: 0px; color: #006666; ">3306</span> <span style="margin: 0px; padding: 0px; color: #666600; ">-</span><span style="margin: 0px; padding: 0px; color: #000000; ">j ACCEPT <br /></span><span style="margin: 0px; padding: 0px; color: #666600; ">/</span><span style="margin: 0px; padding: 0px; color: #000000; ">sbin</span><span style="margin: 0px; padding: 0px; color: #666600; ">/</span><span style="margin: 0px; padding: 0px; color: #000000; ">iptables </span><span style="margin: 0px; padding: 0px; color: #666600; ">-</span><span style="margin: 0px; padding: 0px; color: #000000; ">I INPUT </span><span style="margin: 0px; padding: 0px; color: #666600; ">-</span><span style="margin: 0px; padding: 0px; color: #000000; ">p tcp </span><span style="margin: 0px; padding: 0px; color: #666600; ">--</span><span style="margin: 0px; padding: 0px; color: #000000; ">dport </span><span style="margin: 0px; padding: 0px; color: #006666; ">21</span> <span style="margin: 0px; padding: 0px; color: #666600; ">-</span><span style="margin: 0px; padding: 0px; color: #000000; ">j ACCEPT <br /></span><span style="margin: 0px; padding: 0px; color: #666600; ">/</span><span style="margin: 0px; padding: 0px; color: #000000; ">etc</span><span style="margin: 0px; padding: 0px; color: #666600; ">/</span><span style="margin: 0px; padding: 0px; color: #000000; ">init</span><span style="margin: 0px; padding: 0px; color: #666600; ">.</span><span style="margin: 0px; padding: 0px; color: #000000; ">d</span><span style="margin: 0px; padding: 0px; color: #666600; ">/</span><span style="margin: 0px; padding: 0px; color: #000000; ">iptables save <br />service iptables restart</span></pre><p style="margin: 0px 0px 10px; padding: 0px; color: #333333; font-family: 微Y雅黑, Verdana, Tahoma, 'BitStream vera Sans', Arial, Helvetica, sans-serif; font-size: 13px; line-height: 26px; background-color: #fcfff6; ">其实Q刚刚看了以前写q的一文章。发现此文已l是多余的了。唉。既然写了。就写完整一点吧?/p><p style="margin: 0px 0px 10px; padding: 0px; color: #333333; font-family: 微Y雅黑, Verdana, Tahoma, 'BitStream vera Sans', Arial, Helvetica, sans-serif; font-size: 13px; line-height: 26px; background-color: #fcfff6; ">一般来_我们不会使用linux自带的防火墙的。在IDC机房Qh家的防火墙是g。肯定比软g要强大得多?/p><p style="margin: 0px 0px 10px; padding: 0px; color: #333333; font-family: 微Y雅黑, Verdana, Tahoma, 'BitStream vera Sans', Arial, Helvetica, sans-serif; font-size: 13px; line-height: 26px; background-color: #fcfff6; ">可以使用如下方式Ҏ作防火墙Q?br style="margin: 0px; padding: 0px; " />怹性关掉防火墙shellQ?/p><pre prettyprint"="" style="margin-top: 6px; margin-bottom: 6px; padding: 2px 7px; font-family: 'Courier New', Courier, monospace, Fixed; overflow: auto; background-color: #f0f6e9; border: 1px solid #cccccc; font-size: 12.3px; line-height: 16px; width: 645.816650390625px; color: #333333; "><span style="margin: 0px; padding: 0px; color: #000000; ">chkconfig </span><span style="margin: 0px; padding: 0px; color: #666600; ">--</span><span style="margin: 0px; padding: 0px; color: #000000; ">level </span><span style="margin: 0px; padding: 0px; color: #006666; ">35</span><span style="margin: 0px; padding: 0px; color: #000000; "> iptables off</span></pre><p style="margin: 0px 0px 10px; padding: 0px; color: #333333; font-family: 微Y雅黑, Verdana, Tahoma, 'BitStream vera Sans', Arial, Helvetica, sans-serif; font-size: 13px; line-height: 26px; background-color: #fcfff6; ">通过如下命o查看防火墙是否关闭:</p><pre prettyprint"="" style="margin-top: 6px; margin-bottom: 6px; padding: 2px 7px; font-family: 'Courier New', Courier, monospace, Fixed; overflow: auto; background-color: #f0f6e9; border: 1px solid #cccccc; font-size: 12.3px; line-height: 16px; width: 645.816650390625px; color: #333333; "><span style="margin: 0px; padding: 0px; color: #000000; ">service iptables status</span></pre><p style="margin: 0px 0px 10px; padding: 0px; color: #333333; font-family: 微Y雅黑, Verdana, Tahoma, 'BitStream vera Sans', Arial, Helvetica, sans-serif; font-size: 13px; line-height: 26px; background-color: #fcfff6; ">如果已经正确关闭Q则会输出如下信息:</p><pre prettyprint"="" style="margin-top: 6px; margin-bottom: 6px; padding: 2px 7px; font-family: 'Courier New', Courier, monospace, Fixed; overflow: auto; background-color: #f0f6e9; border: 1px solid #cccccc; font-size: 12.3px; line-height: 16px; width: 645.816650390625px; color: #333333; "><span style="margin: 0px; padding: 0px; color: #000000; ">iptables</span><span style="margin: 0px; padding: 0px; color: #666600; ">Q未q行防火墙?/span></pre><p style="margin: 0px 0px 10px; padding: 0px; color: #333333; font-family: 微Y雅黑, Verdana, Tahoma, 'BitStream vera Sans', Arial, Helvetica, sans-serif; font-size: 13px; line-height: 26px; background-color: #fcfff6; ">如果Q你的是英文版本Q则可能提示信息不太一栗?br style="margin: 0px; padding: 0px; " />如果没有输出cM防火墙关闭的信息Q直接重启系l或者执行如下命令试一试:</p><pre prettyprint"="" style="margin-top: 6px; margin-bottom: 6px; padding: 2px 7px; font-family: 'Courier New', Courier, monospace, Fixed; overflow: auto; background-color: #f0f6e9; border: 1px solid #cccccc; font-size: 12.3px; line-height: 16px; width: 645.816650390625px; color: #333333; "><span style="margin: 0px; padding: 0px; color: #000000; ">service iptables stop</span></pre><p style="margin: 0px 0px 10px; padding: 0px; color: #333333; font-family: 微Y雅黑, Verdana, Tahoma, 'BitStream vera Sans', Arial, Helvetica, sans-serif; font-size: 13px; line-height: 26px; background-color: #fcfff6; ">x防火墙之后,那么所有开启的端口都将会暴露给互联|所有h。那么,可能会导致别有用心的人针对你的系l漏z做Z些破坏的事情?/p><p style="margin: 0px 0px 10px; padding: 0px; color: #333333; font-family: 微Y雅黑, Verdana, Tahoma, 'BitStream vera Sans', Arial, Helvetica, sans-serif; font-size: 13px; line-height: 26px; background-color: #fcfff6; ">除了q个q有一个东西是SELINUXq个玩意ѝ如果防火墙攑ּ了端口也无法q行讉K。说明这个玩意做了限Ӟ大家它关闭卛_?/p><img src ="http://www.dentisthealthcenter.com/gembin/aggbug/393378.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.dentisthealthcenter.com/gembin/" target="_blank">gembin</a> 2012-12-23 22:40 <a href="http://www.dentisthealthcenter.com/gembin/archive/2012/12/23/393378.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>VirtualBox 安装 CentOs 6.3http://www.dentisthealthcenter.com/gembin/archive/2012/12/23/393376.htmlgembingembinSun, 23 Dec 2012 14:15:00 GMThttp://www.dentisthealthcenter.com/gembin/archive/2012/12/23/393376.htmlhttp://www.dentisthealthcenter.com/gembin/comments/393376.htmlhttp://www.dentisthealthcenter.com/gembin/archive/2012/12/23/393376.html#Feedback0http://www.dentisthealthcenter.com/gembin/comments/commentRss/393376.htmlhttp://www.dentisthealthcenter.com/gembin/services/trackbacks/393376.html一、环境及资源准备Q?br style="margin: 0px; padding: 0px; " />1Q虚拟机VritualBox 4.2版本。百度搜索下载此软g很容易下载,我一般是dIY件和华军软g|站M载?br style="margin: 0px; padding: 0px; " />2QCentOs版本采用的是CentOS-6.3-x86_64-minimal.isoQ即最化安装的版本。最化安装版本没有囑Ş界面Q这h耗CPU和内存的大大减少Q所以,常常用来安装服务器系l用。而桌面版本学习用居多。而我们的目的是要以服务器配|ؓ目标q行?br style="margin: 0px; padding: 0px; " />CentOS 6.3 64位下载地址Q?a title="http://mirror.bit.edu.cn/centos/6.3/isos/x86_64/CentOS-6.3-x86_64-minimal.iso" target="_blank" style="margin: 0px; padding: 0px; text-decoration: none; color: #0b75b6; ">http://mirror.bit.edu.cn/centos/6.3/isos/x86_64/CentOS-6.3-x86_64-minimal.iso
3Q我的系l是Win7 64位的?windows xp 和windows 7 32位均可?/p>

二、安装配|虚拟机pȝ
1Q?打虚拟机。然后,选择虚拟机工h上的“新徏”按钮。如图:

 

 

 

 

 

 

 

 

 

 

 

 

2Q点?#8220;新徏”按钮后,弹出如下弹出框,我们在名U项里面输入Qcentos 6.3 mini。这个位|随便填写没有Q何问题。如果,你填写的是windows xp的话Q则cd会自动变成windowsQ版本自动会变成windows xp。当我们填写centos 6.3的时候,cd会自动变成LinuxQ版本会变成 Red Hat。但是,我们安装的是64位的Q所以,要修改Red Hat (64 bit)?br style="margin: 0px; padding: 0px; " />

3Q点?#8220;下一?#8221;Q弹出内存分配的选项框。这个地方特别要注意Q内存在768MBq个位置是一个分水岭。如果低于这个这个|则安装的时候会q入字符安装模式。大于等于这个gq入囑Ş安装界面。刚开始我不太熟悉字符安装模式Q一直在q里U结了很久都不知道ؓ什么。后面,癑ֺ搜烦{案的时候,发现官方已经有说明。如图,我分配了1024MB的内存。图中的l色的线代表是内存最佳的分配|过q个|可能会造成pȝ内存不的问题?br style="margin: 0px; padding: 0px; " />

4Q点?#8220;下一?#8221;保持默认的选项不变Q如图:

5Q点?#8220;创徏”Q弹出选项框,保持默认不变。如图:

6Q点?#8220;下一?#8221;Q弹拟硬盘空间分配的方式。一般保持默认不变。如图:

7Q点?#8220;下一?#8221;Q设|虚拟硬盘位|和大小。我虚拟硬盘文件的位置攄在了G:\VBoxs中,大小配置20GB。如图:

8Q点?#8220;创徏”按钮Q即完成了对虚拟机的创徏。但是,此时只是把配|做好了。即下来的操作才是安装系l。此Ӟ在VBox列表里面已经有了刚才创徏的虚拟机。如图:

9Q到此一步,我们的配|ƈ没有l束。因为,很多机器现在的内存都已经4GB了。这会给32位的pȝ安装造成一些问题。所以,我们q需要来消除q些问题。右键选中QVBox列表中刚才创建的虚拟机,选择“讄”Q选择“pȝ”Q再选择“处理?P)”Q会看到一:扩展Ҏ。我们把它勾选上Q让虚拟机支?GB以上的内存。如图:

10Q现在我们要把Centos ISO镜像文g加蝲到虚拟机中。在上图中的左侧中选择“储存”。然后根据下图中的操作进行:

11Q虚拟机除了镜像q可以用电脑的光驱q行安装。如图:

然后点击“定”卛_?/p>

12Q此Ӟ我们再点击VBox工具样上?#8220;启动”按钮。点M前,必须先选中刚才我们创徏的虚拟机。就会到辑֦下界面:

如果Q你q入q个界面之前Q弹出如下错误提C:
VT-x/AMD-V g加速器已被启动Q但当前处于无效状态。您虚拟电脑内的操作pȝ无法检到64位的CPUQ因此也无法启?#8230;.

那么Q你要确定你的CPU是支?4位的Q可以按照如下方式进行解冻I
1、请认你的iso文g或DVD?4位的IOS文g?br style="margin: 0px; padding: 0px; " />2、请认你的CPU?4位的CPU?br style="margin: 0px; padding: 0px; " />3、请认BIOS的Virtualization是否为Enabled。设|方法:q入BIOS—->Advanced BIOS Features—–>Virtualization—->Disabled(预设?修改为EnabledQ储?save)Q重启。有些BIOS讄Ҏ与此q不相同Q比如,有些W记本Virualizationq个选项q去是将VT-x与AMD-v两项讄分开的。所以,要将两个选项都要讄为Enabled?/p>

13Q我们选择”Install or upgrade an existsing system”Q然后,敲击回R键往下安装?/p>

14Q接下来会的界面是让你检要安装的系l介质是否完整有效。因为我是从正规渠道下蝲的系lISOQ所以,基本上不会出现问题。所以,我选择?#8220;Skip”选项跌介质。如图:

 

15Q回?#8220;Skip”之后出现如下界面Q选择点击“Next”?/p>

16Q此时会出现一个选择当前pȝ语言的选项Q我们肯定是选择体中文了Q选择之后点击下一步。如图:

17Q此时会出现一个键盘语a的选择Q我们肯定是选择“国式英?#8221;了。也是保持默认选项Q点?#8220;下一?#8221;卛_。如图:

18Q出现如下界面,保持默认卛_Q然后点?#8220;下一?#8221;l箋往下安装。如图:

19Q出现如下界面,点击“是,忽略所有数?#8221;。因为,在VirtualBox里面Q所做的M操作都不会媄响到真实pȝ里面的数据。所以,攑ֿ大胆地选择此项吧。如图:

20Q然后出现如下界面,要求我们台计机取一个名字。很单,我们按照要求填写卛_。如图:

21Q接下来的界面是让我们ؓ电脑讄一个时区。我的选择如图所C:

22Q即下来Q会要求我们为默认的rootpȝ账户讄一个密码。如图:

如果Q你讄的密码过于简单。如Q?23456q样的密码,则系l会提示我们Q密码强度不够安全。我们不它Q直接选择“无论如何都?U)” 卛_。如图:

23Q在接下来的界面中,我们选择“使用所有空?#8221;的选项q行安装。如果,你想在电脑上装双pȝQ那么请不要选择此项。我们是用VittualBox完全不用担心盘会被格式化的问题。如图:

24Q点?#8220;下一?#8221;会弹出如下提C框Q我们选择“修改写入硬?#8221;选择?/p>

25QOK。一切完毕之后,p执行安装q程了。我们能做的是{待。当安装q度100%的时候,会提C我们重新引导系l。到时候记得点d可。如图:

 
可选的cd说明如下Q?nbsp;
Desktop  Q基本的桌面pȝQ包括常用的桌面软gQ如文查看工具?/span>
Minimal Desktop Q基本的桌面pȝQ包含的软g更少?/span>
Minimal Q基本的pȝQ不含有M可选的软g包?/span>
Basic Server  Q安装的基本pȝ的^台支持,不包含桌面?/span>
Database Server Q基本系l^収ͼ加上MySQL和PostgreSQL数据库,无桌面?/span>
Web Server Q?/strong>基本pȝq_Q加上PHPQWeb serverQ还有MySQL和PostgreSQL数据库的客户端,无桌面?/span>
Virtual Host Q基本系l加虚拟q_?/span>
Software Development Workstation Q包含Y件包较多Q基本系l,虚拟化^収ͼ桌面环境Q开发工兗?/span>

到此关于VirtualBox安装Centos 6.3 最化安装已经介绍完了?/p>

gembin 2012-12-23 22:15 发表评论
]]>
CentOS-语言讄http://www.dentisthealthcenter.com/gembin/archive/2012/12/23/393375.htmlgembingembinSun, 23 Dec 2012 14:08:00 GMThttp://www.dentisthealthcenter.com/gembin/archive/2012/12/23/393375.htmlhttp://www.dentisthealthcenter.com/gembin/comments/393375.htmlhttp://www.dentisthealthcenter.com/gembin/archive/2012/12/23/393375.html#Feedback0http://www.dentisthealthcenter.com/gembin/comments/commentRss/393375.htmlhttp://www.dentisthealthcenter.com/gembin/services/trackbacks/393375.html查看所有的locale语言

  1. # locale -a 
  2. # locale -a|grep en 

■ 查看当前操作pȝ使用的语a

  1. # echo $LANG 

■ 讄pȝlocale语言Z文环境(怹生效Q?/p>

# vi /etc/sysconfig/i18n

  1. LANG="zh_CN.UTF-8" 

■ 讄pȝlocale语言文环境(怹生效Q?/p>

  1. LANG="en_US.UTF-8" 

■ 临时改变pȝlocale语言Q退出本ơ登录立卛_效)

  1. # export LANG=zh_CN.UTF-8 

■ 安装中文字体

  1. # yum install fonts-chinese.noarch 

■ 指定中文字体路径

# vi /etc/X11/fs/config

  1. catalogue = /usr/X11R6/lib/X11/fonts/misc:unscaled, 
  2.         /usr/X11R6/lib/X11/fonts/75dpi:unscaled, 
  3.         /usr/X11R6/lib/X11/fonts/100dpi:unscaled, 
  4.         /usr/X11R6/lib/X11/fonts/Type1, 
  5.         /usr/share/fonts/default/Type1, 
  6.         , 
  7.         /usr/share/fonts/zh_CN/TrueType, 
  8.         /usr/share/fonts/zh_TW/TrueType 



    Ҏ2

    修改CentOSq行环境的默认语a环境变量?/p>

    [root@www ~]# vi /etc/profile

    扑ֈexport语句Q在语句前面加入

    LANG=”en_US.UTF-8″

    再在export后面q加LANG

    export PATH USER LOGNAME MAIL HOSTNAME HISTSIZE INPUTRC LANG

    保存配置Q修改CentOS语言完成?/p>



gembin 2012-12-23 22:08 发表评论
]]>
MySQL on Mac OS Xhttp://www.dentisthealthcenter.com/gembin/archive/2012/09/22/388351.htmlgembingembinSat, 22 Sep 2012 15:38:00 GMThttp://www.dentisthealthcenter.com/gembin/archive/2012/09/22/388351.htmlhttp://www.dentisthealthcenter.com/gembin/comments/388351.htmlhttp://www.dentisthealthcenter.com/gembin/archive/2012/09/22/388351.html#Feedback0http://www.dentisthealthcenter.com/gembin/comments/commentRss/388351.htmlhttp://www.dentisthealthcenter.com/gembin/services/trackbacks/388351.htmlIf you have installed the Startup Item, use this command:

shell> sudo /Library/StartupItems/MySQLCOM/MySQLCOM start 
(Enter your password, if necessary)
(Press Control-D or enter "exit" to exit the shell)

If you do not use the Startup Item, enter the following command sequence:

shell> cd /usr/local/mysql 
shell> sudo ./bin/mysqld_safe
(Enter your password, if necessary)
(Press Control-Z)
shell> bg
(Press Control-D or enter "exit" to exit the shell)

You should be able to connect to the MySQL server, for example, by running /usr/local/mysql/bin/mysql.
alias mysql=/usr/local/mysql/bin/mysql
alias mysqladmin=/usr/local/mysql/bin/mysqladmin


Sequel Pro is a database management app for MySQL databases
http://www.sequelpro.com/


gembin 2012-09-22 23:38 发表评论
]]>
ethtool and mii-toolhttp://www.dentisthealthcenter.com/gembin/archive/2012/09/07/387249.htmlgembingembinFri, 07 Sep 2012 06:41:00 GMThttp://www.dentisthealthcenter.com/gembin/archive/2012/09/07/387249.htmlhttp://www.dentisthealthcenter.com/gembin/comments/387249.htmlhttp://www.dentisthealthcenter.com/gembin/archive/2012/09/07/387249.html#Feedback0http://www.dentisthealthcenter.com/gembin/comments/commentRss/387249.htmlhttp://www.dentisthealthcenter.com/gembin/services/trackbacks/387249.htmlmii-toolQ这是Linux下专门设|网卡工作模式的命oQ?/span>
  1. 查看|卡的工作模式,输入命oQ?/span>
  #mii-tool -v
  eth0: negotiated 100baseTx-FD, link ok
  product info: vendor 00:aa:00, model 56 rev 0
  basic mode: autonegotiation enabled
  basic status: autonegotiation complete, link ok
  capabilities: 100baseTx-FD 100baseTx-HD 10baseT-FD 10baseT-HD
  advertising: 100baseTx-FD 100baseTx-HD 10baseT-FD 10baseT-HD flow-control
  link partner: 100baseTx-FD 100baseTx-HD 10baseT-FD 10baseT-HD
  从以上信息中可以看出Q这块网卡工作在100M全双工自适应模式下,“100BaseTx-FD”意ؓ100M Full Duplex?/span>
  2. 更改|卡的工作模式,输入命oQ?/span>
  #mii-tool -F media [interface]
  media可选的模式?00baseTx-FD?00baseTx-HD?0baseT-FD?0baseT-HD{?Interface代表所选择的网卡,如eth0、eth1{,默认为eth0?/span>
  例如Q设|网卡工作在10M半双工模式下Q输入命令:
  #mii-tool -F 10baseT-HD eth0
  3. 恢复|卡的自适应工作模式Q输入命令:
  #mii-tool -r eth0
  更详l的使用Ҏ可以用mii-tool -h来获得?br />


ethtool/mii-tool

PrintPDF

Linux LAN card: Find out full duplex / half speed or mode

Q. How do I find out if my Lan (NIC) card working at full or halt duplex mode / speed under Linux?

A. LAN card or NIC is use to send and receive data. Technically, we use word Duplex for this functionality. Full duplex means you are able to send and receive data (files) simultaneously. In half duplex, you can either send or receive data at a time (i.e. you cannot send receive data (files) simultaneously). Obviously, full duplex gives you best user experience. However, how can I find out whether I am using full duplex/half duplex speed/mode?
Task: Find full or half duplex speed

You can use dmesg command to find out your duplex mode:

# dmesg | grep -i duplex

Output:

eth0: link up, 100Mbps, full-duplex, lpa 0x45E1

ethtool command

Uss ethtool to display or change ethernet card settings. To display duplex speed, enter:

# ethtool eth1

Output:

Settings for eth1:
Supported ports: [ TP ]
Supported link modes:   10baseT/Half 10baseT/Full
100baseT/Half 100baseT/Full
1000baseT/Full
Supports auto-negotiation: Yes
Advertised link modes:  10baseT/Half 10baseT/Full
100baseT/Half 100baseT/Full
1000baseT/Full
Advertised auto-negotiation: Yes
Speed: 10Mb/s
Duplex: Full
Port: Twisted Pair
PHYAD: 0
Transceiver: internal
Auto-negotiation: on
Supports Wake-on: umbg
Wake-on: g
Current message level: 0x00000007 (7)
Link detected: yes

mii-tool command

You can also use mii-tool to find out your duplex mode. Type following command at shell prompt:

# mii-tool


Output:

eth0: negotiated 100baseTx-FD flow-control, link ok

Remember,


1. 100baseTx-FD: 100Mbps full duplex (FD)
2. 100baseTx-HD: 100Mbps half duplex (HD)
3. 10baseT-FD: 10Mbps full duplex (FD)
4. 10baseT-HD: 10Mbps half duplex (HD)

mii-tool utility checks or sets the status of a network interface Media Independent Interface (MII) unit. Most fast ethernet adapters use an MII to autonegotiate link speed and duplex setting. If you are using old card then this utility may not work (use dmesg command).

This utility is useful for forcing specific Ethernet speed and duplex settings too, setup 100Mbps full duplex speed under Linux:

# mii-tool -F 100baseTx-FD


Setup 10Mbps half duplex:

# mii-tool -F 10baseT-HD


source:

http://www.cyberciti.biz/faq/howto-setup-linux-lan-card-find-out-full-duplex-half-speed-or-mode/



gembin 2012-09-07 14:41 发表评论
]]>
XML Naming Conventionshttp://www.dentisthealthcenter.com/gembin/archive/2012/08/25/386269.htmlgembingembinSat, 25 Aug 2012 08:43:00 GMThttp://www.dentisthealthcenter.com/gembin/archive/2012/08/25/386269.htmlhttp://www.dentisthealthcenter.com/gembin/comments/386269.htmlhttp://www.dentisthealthcenter.com/gembin/archive/2012/08/25/386269.html#Feedback0http://www.dentisthealthcenter.com/gembin/comments/commentRss/386269.htmlhttp://www.dentisthealthcenter.com/gembin/services/trackbacks/386269.htmlNames can start with dash (-) character.
Names cannot start with numbers or other punctuation characters. 
After the first character, numbers, hyphens, and periods are allowed. 
Names can't contain spaces. 
Names can't contain the colon (:) character. 
Names can't start with the letters xml, in uppercase, lowercase, or mixed.
There can't be a space after the opening <
There can be space before the closing > character. 

Here are some examples of valid names: <first.name> 

Following are some examples of invalid names: 

<xml-element> which starts with xml, 

<123> which starts with a number, 

<your=xml> because the equals sign (=)sign is illegal, and 

<your element> which contains a space.


Case Sensitivity
Most XML standards originating from the W3C tend to use lower case with hyphens.
<first> is different from <FIRST>, which is different from <First>. 

It's a good idea to pick a naming style and stick to it. 
Some examples of common styles are as follows: 

<first_name> 
<firstName> 
<first-name> 
<FirstName>



gembin 2012-08-25 16:43 发表评论
]]>
ANSI sequence parser (Node.js) and client-side rendererhttp://www.dentisthealthcenter.com/gembin/archive/2012/07/21/383681.htmlgembingembinSat, 21 Jul 2012 15:16:00 GMThttp://www.dentisthealthcenter.com/gembin/archive/2012/07/21/383681.htmlhttp://www.dentisthealthcenter.com/gembin/comments/383681.htmlhttp://www.dentisthealthcenter.com/gembin/archive/2012/07/21/383681.html#Feedback0http://www.dentisthealthcenter.com/gembin/comments/commentRss/383681.htmlhttp://www.dentisthealthcenter.com/gembin/services/trackbacks/383681.html

gembin 2012-07-21 23:16 发表评论
]]>
Flash 3d Sokoban Prototype With Alternativa3dhttp://www.dentisthealthcenter.com/gembin/archive/2012/07/21/383679.htmlgembingembinSat, 21 Jul 2012 15:03:00 GMThttp://www.dentisthealthcenter.com/gembin/archive/2012/07/21/383679.htmlhttp://www.dentisthealthcenter.com/gembin/comments/383679.htmlhttp://www.dentisthealthcenter.com/gembin/archive/2012/07/21/383679.html#Feedback0http://www.dentisthealthcenter.com/gembin/comments/commentRss/383679.htmlhttp://www.dentisthealthcenter.com/gembin/services/trackbacks/383679.html阅读全文

gembin 2012-07-21 23:03 发表评论
]]>
Flash 3d Sokoban Prototype With Alternativa3d Textured Versionhttp://www.dentisthealthcenter.com/gembin/archive/2012/07/21/383678.htmlgembingembinSat, 21 Jul 2012 15:00:00 GMThttp://www.dentisthealthcenter.com/gembin/archive/2012/07/21/383678.htmlhttp://www.dentisthealthcenter.com/gembin/comments/383678.htmlhttp://www.dentisthealthcenter.com/gembin/archive/2012/07/21/383678.html#Feedback0http://www.dentisthealthcenter.com/gembin/comments/commentRss/383678.htmlhttp://www.dentisthealthcenter.com/gembin/services/trackbacks/383678.html阅读全文

gembin 2012-07-21 23:00 发表评论
]]>
Flash 3d Sokoban Prototype With Alternativa3d Textured Versionhttp://www.dentisthealthcenter.com/gembin/archive/2012/07/21/383677.htmlgembingembinSat, 21 Jul 2012 14:58:00 GMThttp://www.dentisthealthcenter.com/gembin/archive/2012/07/21/383677.htmlhttp://www.dentisthealthcenter.com/gembin/comments/383677.htmlhttp://www.dentisthealthcenter.com/gembin/archive/2012/07/21/383677.html#Feedback0http://www.dentisthealthcenter.com/gembin/comments/commentRss/383677.htmlhttp://www.dentisthealthcenter.com/gembin/services/trackbacks/383677.htmlEmanuele Feronato added textures and some environment to Sokoban game prototype made with Flare3D.

I reproduced this prototype on Alternativa3D engine. And here you can find it:

Generally this port is bit different from Emanuele’s version. I can’t find information about feature like SkyBox in Alternativa3D, so this feature coded manually. Another difference is camera behavior. Emanuele binds camera to object and during rotations player object stand still and only camera fly around by its orbit. In Alternativa3d version object rotates too, this allow us to face player object it to it’s current direction. Camera is not binded to the object directly it is binded to object container and we can manipulate with player object in container, add animations, rotations etc. But both variants are good I think.


Here is source code:

package  { 	import alternativa.Alternativa3D; 	import alternativa.engine3d.containers.*; 	import alternativa.engine3d.controllers.*; 	import alternativa.engine3d.core.Camera3D; 	import alternativa.engine3d.core.Clipping; 	import alternativa.engine3d.core.Debug; 	import alternativa.engine3d.core.MipMapping; 	import alternativa.engine3d.core.MouseEvent3D; 	import alternativa.engine3d.core.Object3D; 	import alternativa.engine3d.core.Object3DContainer; 	import alternativa.engine3d.core.Sorting; 	import alternativa.engine3d.core.View; 	import alternativa.engine3d.materials.FillMaterial; 	import alternativa.engine3d.materials.TextureMaterial; 	import alternativa.engine3d.objects.Sprite3D; 	import alternativa.engine3d.primitives.Box; 	import alternativa.engine3d.primitives.Plane; 	import alternativa.engine3d.primitives.Sphere; 	 	import flash.display.BitmapData; 	import flash.display.BlendMode; 	import flash.display.Sprite; 	import flash.display.StageAlign; 	import flash.display.StageQuality; 	import flash.display.StageScaleMode; 	import flash.events.Event; 	import flash.events.KeyboardEvent; 	import flash.filters.GlowFilter; 	import flash.geom.ColorTransform; 	import flash.geom.Vector3D; 	import flash.sampler.NewObjectSample; 	import flash.system.Capabilities; 	import flash.ui.Keyboard; 		 	[SWF(backgroundColor="#000000", frameRate="100", width="640", height="480")] 	public class alternativa3dSokoban extends Sprite  	{ 		private const CUBESIZE:Number=10; 		//embeding textures images 		[Embed(source="resource/crateTextureImg.jpg")] static private const crateTextureImg:Class; 		[Embed(source="resource/floorTextureImg.png")] static private const floorTextureImg:Class; 		[Embed(source="resource/crateTopTextureImg.jpg")] static private const crateTopTextureImg:Class; 		[Embed(source="resource/crateTopGoalTextureImg.jpg")] static private const crateTopGoalTextureImg:Class; 		[Embed(source="resource/wallTextureImg.png")] static private const wallTextureImg:Class; 		[Embed(source="resource/goalTextureImg.jpg")] static private const goalTextureImg:Class; 		[Embed(source="resource/playerTextureImg.jpg")] static private const playerTextureImg:Class; 		[Embed(source="resource/backBitmapImg.jpg")] static private const backTextureImg:Class; 		[Embed(source="resource/backBottomBitmapImg.jpg")] static private const backBottomTextureImg:Class;  		// sokobal demo level and player position 		private var levels:Array=[[1,1,1,1,0,0,0,0],[1,0,0,1,1,1,1,1],[1,0,2,0,0,3,0,1],[1,0,3,0,0,2,4,1],[1,1,1,0,0,1,1,1],[0,0,1,1,1,1,0,0]]; 		private var playerCol:uint; 		private var playerRow:uint; 		private var playerRotation:Number=0; 		private var playerAngle:Number=0; 		private var playerMovement:Number=0; 		private var dRow:int; 		private var dCol:int; 		 		// alternativa3d  engine variables 		private var camera:Camera3D; 		private var controller:SimpleObjectController; 		private var container:ConflictContainer;			 		private var frame:Sprite = new Sprite(); 		public var player:Sphere;// Sphere primitive representing the player 		public var cplayer:SimpleObjectController; //controller for player object 		public var conplayer:Object3DContainer; //container for player 		private var movingCrate:Box;// cube primitive representing the moving crate		 			 		// textures		 		private var crateTexture:TextureMaterial = new TextureMaterial(new crateTextureImg().bitmapData); 		private var floorTexture:TextureMaterial = new TextureMaterial(new floorTextureImg().bitmapData); 		private var crateTopTexture:TextureMaterial = new TextureMaterial(new crateTopTextureImg().bitmapData); 		private var crateTopGoalTexture:TextureMaterial = new TextureMaterial(new crateTopGoalTextureImg().bitmapData); 		private var wallTexture:TextureMaterial = new TextureMaterial(new wallTextureImg().bitmapData); 		private var goalTexture:TextureMaterial = new TextureMaterial(new goalTextureImg().bitmapData); 		private var playerTexture:TextureMaterial = new TextureMaterial(new playerTextureImg().bitmapData); 		// SkyBox textures 		private var backTexture:TextureMaterial = new TextureMaterial(new backTextureImg().bitmapData); 		private var backBottomTexture:TextureMaterial = new TextureMaterial(new backBottomTextureImg().bitmapData); 						 		public function alternativa3dSokoban()  		{			 			stage.scaleMode = StageScaleMode.NO_SCALE; 			stage.align = StageAlign.TOP_LEFT; 			stage.quality = StageQuality.BEST; 			 			// Camera 			camera = new Camera3D(); 			camera.view = new View(640, 480); 			addChild(camera.view); 						 			// Camera controller 			controller = new SimpleObjectController(stage, camera, 200, 3); 			 			// Root object 			container = new ConflictContainer(); 			container.resolveByAABB = true; 			container.resolveByOOBB = true; 			 			//Player controller 			conplayer = new Object3DContainer(); 			cplayer = new SimpleObjectController(stage, player, 3); 			 //i am not shure about SkyBox in Alternativa and will prepare it manually 			var backBottom:Plane = new Plane(200*CUBESIZE/2,200*CUBESIZE/2); 			backBottom.setMaterialToAllFaces(backBottomTexture); 			backBottom.x = 0; 			backBottom.y = -100*CUBESIZE/2; 			backBottom.z = 0; 			backBottom.rotationX = 90*Math.PI/180; 			container.addChild(backBottom); 			 			var backLeft:Plane = new Plane(200*CUBESIZE/2,200*CUBESIZE/2); 			backLeft.setMaterialToAllFaces(backTexture); 			backLeft.x = 0; 			backLeft.y = 0; 			backLeft.z = 100*CUBESIZE/2; 			container.addChild(backLeft);  			var backRight:Plane = new Plane(200*CUBESIZE/2,200*CUBESIZE/2); 			backRight.setMaterialToAllFaces(backTexture); 			backRight.x = 0; 			backRight.y = 0; 			backRight.z = -100*CUBESIZE/2; 			container.addChild(backRight);  			var backFront:Plane = new Plane(200*CUBESIZE/2,200*CUBESIZE/2); 			backFront.setMaterialToAllFaces(backTexture); 			backFront.x = -100*CUBESIZE/2; 			backFront.y = 0; 			backFront.z = 0; 			backFront.rotationY = 90*Math.PI/180; 			container.addChild(backFront);  			var backBack:Plane = new Plane(200*CUBESIZE/2,200*CUBESIZE/2); 			backBack.setMaterialToAllFaces(backTexture); 			backBack.x = 100*CUBESIZE/2; 			backBack.y = 0; 			backBack.z = 0; 			backBack.rotationY = 90*Math.PI/180; 			container.addChild(backBack); // end SkyBox 			 			var box:Box; 			/* 			[[1,1,1,1,0,0,0,0], 			 [1,0,0,1,1,1,1,1], 			 [1,0,2,0,0,3,0,1], 			 [1,0,3,0,0,2,4,1], 			 [1,1,1,0,0,1,1,1], 			 [0,0,1,1,1,1,0,0]]; 			*/ 			// level construction 			for (var i:uint=0; i<6; i++)  			{ 				for (var j:uint=0; j<8; j++)  				{ 					switch (levels[i][j])  					{ 						case 0 : 							box = new Box(CUBESIZE,CUBESIZE/2,CUBESIZE,1,1); 							box.setMaterialToAllFaces(floorTexture); 							box.x = CUBESIZE*j; 							box.y = 0; 							box.z = CUBESIZE*i; 							container.addChild(box); 							break; 						case 1 : 							box = new Box(CUBESIZE,CUBESIZE/2,CUBESIZE,1); 							box.setMaterialToAllFaces(floorTexture); 							box.x = CUBESIZE*j; 							box.y = 0; 							box.z = CUBESIZE*i; 							container.addChild(box); 							 							box = new Box(CUBESIZE,CUBESIZE,CUBESIZE,1); 							box.setMaterialToAllFaces(wallTexture); 							box.x = CUBESIZE*j; 							box.y = CUBESIZE*3/4; 							box.z = CUBESIZE*i; 							container.addChild(box); 							break; 						case 2 : 							box = new Box(CUBESIZE,CUBESIZE/2,CUBESIZE,1); 							box.setMaterialToAllFaces(goalTexture); 							box.x = CUBESIZE*j; 							box.y = 0; 							box.z = CUBESIZE*i; 							container.addChild(box); 							break; 						case 3 : 							box = new Box(CUBESIZE,CUBESIZE/2,CUBESIZE,1); 							box.setMaterialToAllFaces(floorTexture); 							box.x = CUBESIZE*j; 							box.y = 0; 							box.z = CUBESIZE*i; 							container.addChild(box); 							box = new Box(CUBESIZE,CUBESIZE,CUBESIZE,1); 							box.name = "crate_"+i+"_"+j; 							box.setMaterialToAllFaces(crateTexture); 							box.x = CUBESIZE*j; 							box.y = CUBESIZE*3/4; 							box.z = CUBESIZE*i; 							box.rotationX -= 90*Math.PI/180; 							// top of the crate 							box.faces[4].material=crateTopTexture; 							box.faces[5].material=crateTopTexture;  							container.addChild(box); 							break; 						case 4 : 							box = new Box(CUBESIZE,CUBESIZE/2,CUBESIZE,1); 							box.setMaterialToAllFaces(floorTexture); 							box.x = CUBESIZE*j; 							box.y = 0; 							box.z = CUBESIZE*i; 							container.addChild(box); 														 							player = new Sphere(CUBESIZE/2,16,16,false,playerTexture);  							conplayer.addChild(player); 							conplayer.visible = true; 							conplayer.x = CUBESIZE*j; 							conplayer.y = CUBESIZE*3/4; 							conplayer.z = CUBESIZE*i; 							conplayer.rotationX -= 90*Math.PI/180; 							container.addChild(conplayer); 							playerCol=j; 							playerRow=i; 							break; 					} 				} 			}  			// Adding camera 			container.addChild(camera); 			 			// View frame 			addChild(frame);												 			onResize();		 			stage.addEventListener(Event.ENTER_FRAME, updateEvent);			 			stage.addEventListener(KeyboardEvent.KEY_DOWN, onKeyDwn);		 			stage.addEventListener(Event.RESIZE, onResize); 		}  		private function onKeyDwn(e:KeyboardEvent):void  		{ 			if (playerRotation==0&&playerMovement==0)  			{ 				switch (e.keyCode)  				{ 					case Keyboard.LEFT : 						playerRotation=+9; 						playerAngle+=90; 						break; 					case Keyboard.RIGHT : 						playerRotation=-9; 						playerAngle-=90; 						break; 					case Keyboard.UP : 						movingCrate=null; 						playerAngle=Math.round(conplayer.rotationY*180/Math.PI)%360; 						if (playerAngle<0)  						{ 							playerAngle+=360; 						} 						// we have to determine the difference between current row and column 						// and the new row and column according to player heading 						switch (playerAngle)  						{ 							case 0 : 								dRow=0; 								dCol=-1; 								break; 							case 90 : 								//dRow=-1; 								dRow=1; 								dCol=0; 								break; 							case 180 : 								dRow=0; 								dCol=1; 								break; 							case 270 : 								//dRow=1; 								dRow=-1; 								dCol=0; 								break; 						} 						if (levels[playerRow+dRow][playerCol+dCol]==0||levels[playerRow+dRow][playerCol+dCol]==2)  						{ 							// the player can move 							playerMovement=-CUBESIZE/10; 						}  						else  						{ 							if (levels[playerRow+dRow][playerCol+dCol]==3||levels[playerRow+dRow][playerCol+dCol]==5) { 								if (levels[playerRow+2*dRow][playerCol+2*dCol]==0||levels[playerRow+2*dRow][playerCol+2*dCol]==2) { 									// the player can move and can push a crate 									movingCrate=container.getChildByName("crate_"+(playerRow+dRow)+"_"+(playerCol+dCol))as Box; 									playerMovement=-CUBESIZE/10; 								} 							} 						} 						break;  				} 			} 		}   		public function updateEvent(e:Event):void  		{		 				if (playerRotation)  				{ 					conplayer.rotationY+=playerRotation*Math.PI/180; 					 					if (Math.abs(Math.round(conplayer.rotationY*180/Math.PI))%90==0) 					{ 						playerRotation=0; 					} 				} 				 				if (playerMovement)  				{					 					switch (playerAngle)  					{ 					case 0 : 						conplayer.x += playerMovement; 						player.rotationY -= 18*Math.PI/180; 					break; 					case 90 : 						conplayer.z += -playerMovement; 						player.rotationY -= 18*Math.PI/180; 					break; 					case 180 : 						conplayer.x += -playerMovement; 						player.rotationY -= 18*Math.PI/180; 						break; 					case 270 : 						conplayer.z += playerMovement; 						player.rotationY -= 18*Math.PI/180; 						break; 					} 					 					if (movingCrate)  					{ 						switch (playerAngle)  						{ 							case 0 : 								movingCrate.x += playerMovement; 								break; 							case 90 : 								movingCrate.z += -playerMovement; 								break; 							case 180 : 								movingCrate.x += -playerMovement; 								break; 							case 270 : 								movingCrate.z += playerMovement; 								break; 						} 					}  					// we need this to know if the player stopped on the destination tile 					if ((playerAngle%180==0&&(Math.round(conplayer.x*10)/10)%CUBESIZE==0)||(playerAngle%180!=0&&(Math.round(conplayer.z*10)/10)%CUBESIZE==0))  					{ 						playerMovement=0; 						levels[playerRow+dRow][playerCol+dCol]+=4; 						levels[playerRow][playerCol]-=4; 						if (movingCrate) { 							levels[playerRow+2*dRow][playerCol+2*dCol]+=3; 							if (levels[playerRow+2*dRow][playerCol+2*dCol]==5) { 								// changing materials on the fly 								movingCrate.setMaterialToAllFaces(crateTexture); 								// top of the crate on goal 								movingCrate.faces[4].material=crateTopGoalTexture; 								movingCrate.faces[5].material=crateTopGoalTexture;								  							} 							else  							{ 								//movingCrate.setMaterialToAllFaces(crateMaterial); 								movingCrate.setMaterialToAllFaces(crateTexture); 								// top of the crate 								movingCrate.faces[4].material=crateTopTexture; 								movingCrate.faces[5].material=crateTopTexture;								 							} 							levels[playerRow+dRow][playerCol+dCol]-=3; 							movingCrate.name="crate_"+(playerRow+2*dRow)+"_"+(playerCol+2*dCol); 						} 						playerCol+=dCol; 						playerRow+=dRow; 					} 				}  				onEnterFrame(); 		}			  		public function correct_camera_angles():void 		{ 			//set camera position 			var r:Number = 10*CUBESIZE/3;			 			var a:Number = -conplayer.rotationY; 			var cx:Number = conplayer.x+Math.cos(a)*r; 			var cz:Number = conplayer.z+Math.sin(a)*r; 			var cy:Number = conplayer.y+r;			 			controller.setObjectPosXYZ(cx,cy,cz); 			 			//look at player box 			controller.lookAtXYZ(conplayer.x,conplayer.y,conplayer.z); 			 			//correct camera angles			 				var cprotY:Number; 				 				cprotY=Math.round(conplayer.rotationY*180/Math.PI)%360;			 				if (cprotY<0)  				{ 					cprotY+=360; 				} 				if (cprotY>180) 				{ 					camera.rotationX = camera.rotationX + (90*Math.PI/180)*Math.sin((cprotY%180)*Math.PI/180); 				}										 				camera.rotationY = camera.rotationY+90*Math.PI/180-conplayer.rotationY; 		} 		 		public function onEnterFrame(e:Event = null):void  		{ 			controller.update(); 			correct_camera_angles(); 			cplayer.update(); 			camera.render();		 		} 		  		public function onResize(e:Event = null):void  		{ 			//here you can add border size for view 			var pd:Number = 0; 			camera.view.width = stage.stageWidth - pd*2; 			camera.view.height = stage.stageHeight - pd*2; 			camera.view.x = pd; 			camera.view.y = pd; 			 			frame.graphics.clear(); 			frame.graphics.beginFill(0x000000, 0); 			frame.graphics.drawRect(0, 0, stage.stageWidth, stage.stageHeight); 			//frame.graphics.lineStyle(0, 0x7F7F7F); 			frame.graphics.drawRect(pd, pd, camera.view.width, camera.view.height); 			frame.graphics.endFill(); 		} 	} }

Here you can download sources.



gembin 2012-07-21 22:58 发表评论
]]>
Embedding fonts into ActionScript 3 projecthttp://www.dentisthealthcenter.com/gembin/archive/2012/07/21/383676.htmlgembingembinSat, 21 Jul 2012 14:56:00 GMThttp://www.dentisthealthcenter.com/gembin/archive/2012/07/21/383676.htmlhttp://www.dentisthealthcenter.com/gembin/comments/383676.htmlhttp://www.dentisthealthcenter.com/gembin/archive/2012/07/21/383676.html#Feedback0http://www.dentisthealthcenter.com/gembin/comments/commentRss/383676.htmlhttp://www.dentisthealthcenter.com/gembin/services/trackbacks/383676.html阅读全文

gembin 2012-07-21 22:56 发表评论
]]>
Setting up the VNC Server in Mac OS X Lionhttp://www.dentisthealthcenter.com/gembin/archive/2012/07/14/383070.htmlgembingembinFri, 13 Jul 2012 16:00:00 GMThttp://www.dentisthealthcenter.com/gembin/archive/2012/07/14/383070.htmlhttp://www.dentisthealthcenter.com/gembin/comments/383070.htmlhttp://www.dentisthealthcenter.com/gembin/archive/2012/07/14/383070.html#Feedback0http://www.dentisthealthcenter.com/gembin/comments/commentRss/383070.htmlhttp://www.dentisthealthcenter.com/gembin/services/trackbacks/383070.html

VNC server is included in every edition of Mac OS X, including Mac OS X 10.6 –aka Snow Leopard. You can start the server through a hidden check box in the Sharing preferences.

VNC server lets you control your Mac from another computer using the VNCprotocol. With recent editions of Mac OS X, Apple has moved to a more sophisticated method of screen sharing. However, a traditional VNC server is still included but is turned off by default.

Starting the Mac OS X VNC Server
  1. Launch the System Preferences.

    Launch the System Preferences

    Launch the System Preferences

  2. Select the Sharingpreferences.

    Select the Sharing preferences icon

    Select the Sharing preferences icon

  3. Enable Screen Sharing within the Servicelist.

    Enable the Screen Sharing service

    Enable the Screen Sharing service

  4. Click Computer Settings…to show the VNC password setting.

    Enable VNC and choose a password

    Enable VNC and choose a password

  5. Enable VNC viewers may control screen with password:.
  6. Enter a strong password.
  7. Click OK to save your settings.

Your Mac is now running a traditional VNC server. You can now connect to your Mac using a VNC client running on another Mac, Windows, or Linux computer.

NOTE: the default vnc listening port is 5900



gembin 2012-07-14 00:00 发表评论
]]>
Enable Telnet in MAC OS X Lionhttp://www.dentisthealthcenter.com/gembin/archive/2012/07/13/383063.htmlgembingembinFri, 13 Jul 2012 14:43:00 GMThttp://www.dentisthealthcenter.com/gembin/archive/2012/07/13/383063.htmlhttp://www.dentisthealthcenter.com/gembin/comments/383063.htmlhttp://www.dentisthealthcenter.com/gembin/archive/2012/07/13/383063.html#Feedback0http://www.dentisthealthcenter.com/gembin/comments/commentRss/383063.htmlhttp://www.dentisthealthcenter.com/gembin/services/trackbacks/383063.html[gembin@localhost bin]$ sudo launchctl
Password:
launchd% 
launchd% load -F /System/Library/LaunchDaemons/telnet.plist
launchd% exit

and now the telnet is enabled, try to test it.
[gembin@localhost bin]$ telnet localhost
Trying ::1...
Connected to localhost.
Escape character is '^]'.
login: gembin
Password:
Last login: Fri Jul 13 22:21:08 on ttys002


gembin 2012-07-13 22:43 发表评论
]]>
Comparing the syntax of Java 5 and ActionScript 3http://www.dentisthealthcenter.com/gembin/archive/2012/07/07/382482.htmlgembingembinSat, 07 Jul 2012 14:44:00 GMThttp://www.dentisthealthcenter.com/gembin/archive/2012/07/07/382482.htmlhttp://www.dentisthealthcenter.com/gembin/comments/382482.htmlhttp://www.dentisthealthcenter.com/gembin/archive/2012/07/07/382482.html#Feedback0http://www.dentisthealthcenter.com/gembin/comments/commentRss/382482.htmlhttp://www.dentisthealthcenter.com/gembin/services/trackbacks/382482.html

This list is not complete, and your input is appreciated.

Concept/Language Construct

Java 5.0

ActionScript 3.0

Class library packaging

.jar

.swc

Inheritance

class Employee extends Person{…}

class Employee extends Person{…}

Variable declaration and initialization

String firstName=”John”;

Date shipDate=new Date();

int i;

int a, b=10;

double salary;

var firstName:String=”John”;

var shipDate:Date=new Date();

var i:int;

var a:int, b:int=10;

var salary:Number;

Undeclared variables

n/a

It’s an equivalent to the wild card type notation *. If you declare a variable but do not specify its type, the * type will apply.

A default value: undefined

var myVar:*;

Variable scopes

block: declared within curly braces,
local: declared within a method or a block

member: declared on the class level

no global variables

No block scope: the minimal scope is a function

local: declared within a function

member: declared on the class level

If a variable is declared outside of any function or class definition, it has global scope.

Strings

Immutable, store sequences of two-byte Unicode characters

Immutable, store sequences of two-byte Unicode characters

Terminating statements with semicolons

A must

If you write one statement per line you can omit it.

Strict equality operator

n/a

===

for strict non-equality use

!==

Constant qualifier

The keyword final

final int STATE=”NY”;

The keyword const

const STATE:int =”NY”;

Type checking

Static (checked at compile time)

Dynamic (checked at run-time) and static (it’s so called ‘strict mode’, which is default in Flex Builder)

Type check operator

instanceof

is – checks data type, i.e. if (myVar is String){…}

The is operator is a replacement of older instanceof

The as operator

n/a

Similar to is operator, but returns not Boolean, but the result of expression:

var orderId:String=”123”;

var orderIdN:Number=orderId as Number;

trace(orderIdN);//prints 123

Primitives

byte, int, long, float, double,short, boolean, char

all primitives in ActionScript areobjects.
Boolean, int, uint, Number, String

The following lines are equivalent;

var age:int = 25;

var age:int = new int(25);

Complex types

n/a

Array, Date, Error, Function, RegExp, XML, and XMLList

Array declaration and instantiation

int quarterResults[];

quarterResults =
new int[4];

int quarterResults[]={25,33,56,84};

var quarterResults:Array
=new Array();

or

var quarterResults:Array=[];

var quarterResults:Array=
[25, 33, 56, 84];

AS3 also has associative arrays that uses named elements instead of numeric indexes (similar to Hashtable).

The top class in the inheritance tree

Object

Object

Casting syntax: cast the class Object to Person:

Person p=(Person) myObject;

var p:Person= Person(myObject);

or

var p:Person= myObject as Person;

upcasting

class Xyz extends Abc{}

Abc myObj = new Xyz();

class Xyz extends Abc{}

var myObj:Abc=new Xyz();

Un-typed variable

n/a

var myObject:*

var myObject:

packages

package com.xyz;

class myClass {…}

package com.xyz{

class myClass{…}

}

ActionScript packages can include not only classes, but separate functions as well

Class access levels

public, private, protected

if none is specified, classes have package access level

public, private, protected

if none is specified, classes haveinternal access level (similar to package access level in Java)

Custom access levels: namespaces

n/a

Similar to XML namespaces.

namespace abc;

abc function myCalc(){}

or

abc::myCalc(){}

use namespace abc ;

Console output

System.out.println();

// in debug mode only

trace();

imports

import com.abc.*;

import com.abc.MyClass;

import com.abc.*;

import com.abc.MyClass;

packages must be imported even if the class names are fully qualified in the code.

Unordered key-value pairs

Hashtable, Map

Hashtable friends = new Hashtable();

friends.put(“good”,
“Mary”);

friends.put(“best”,
“Bill”);

friends.put(“bad”,
“Masha”);

String bestFriend= friends.get(“best”);

// bestFriend is Bill

Associative Arrays

Allows referencing its elements by names instead of indexes.

var friends:Array=new Array();
friends["good"]=”Mary”;

friends["best"]=”Bill”;

friends["bad"]=”Masha”;

var bestFriend:String= friends[“best”]

friends.best=”Alex”;

Another syntax:

var car:Object = {make:”Toyota”, model:”Camry”};

trace (car["make"], car.model);

// Output: Toyota Camry

Hoisting

n/a

Compiler moves all variable declarations to the top of the function, so you can use a variable name even before it’s been explicitly declared in the code.

Instantiation objects from classes

Customer cmr = new Customer();

Class cls = Class.forName(“Customer”);

Object myObj= cls.newInstance();

var cmr:Customer = new Customer();

var cls:Class = flash.util.getClassByName(“Customer”);
var myObj:Object = new cls();

Private classes

private class myClass{…}

There is no private classes in AS3.

Private constructors

Supported. Typical use: singleton classes.

Not available. Implementation of private constructors is postponed as they are not the part of the ECMAScript standard yet.

To create a Singleton, use public static getInstance(), which sets a private flag instanceExists after the first instantiation. Check this flag in the public constructor, and if instanceExists==true, throw an error.

Class and file names

A file can have multiple class declarations, but only one of them can be public, and the file must have the same name as this class.

A file can have multiple class declarations, but only one of them can be placed inside the package declaration, and the file must have the same name as this class.

What can be placed in a package

Classes and interfaces

Classes, interfaces, variables, functions, namespaces, and executable statements.

Dynamic classes (define an object that can be altered at runtime by adding or changing properties and methods).

n/a

dynamic class Person {

var name:String;

}

//Dynamically add a variable // and a function

var p:Person = new Person();

p.name=”Joe”;

p.age=25;

p.printMe = function () {

trace (p.name, p.age);

}

p.printMe(); // Joe 25

function closures

n/a. Closure is a proposed addition to Java 7.

myButton.addEventListener(“click”, myMethod);

A closure is an object that represents a snapshot of a function with its lexical context (variable’s values, objects in the scope). A function closure can be passed as an argument and executed without being a part of any object

Abstract classes

supported

n/a

Function overriding

supported

Supported. You must use the override qualifier

Function overloading

supported

Not supported.

Interfaces

class A implements B{…}

interfaces can contain method declarations and final variables.

class A implements B{…}

interfaces can contain only function declarations.

Exception handling

Keywords: try, catch, throw, finally, throws

Uncaught exceptions are propagated to the calling method.

Keywords: try, catch, throw, finally

A method does not have to declare exceptions.

Can throw not only Error objects, but also numbers:

throw 25.3;

Flash Player terminates the script in case of uncaught exception.

Regular expressions

Supported

Supported




gembin 2012-07-07 22:44 发表评论
]]>
MySQL basishttp://www.dentisthealthcenter.com/gembin/archive/2012/05/22/378747.htmlgembingembinMon, 21 May 2012 16:25:00 GMThttp://www.dentisthealthcenter.com/gembin/archive/2012/05/22/378747.htmlhttp://www.dentisthealthcenter.com/gembin/comments/378747.htmlhttp://www.dentisthealthcenter.com/gembin/archive/2012/05/22/378747.html#Feedback0http://www.dentisthealthcenter.com/gembin/comments/commentRss/378747.htmlhttp://www.dentisthealthcenter.com/gembin/services/trackbacks/378747.htmlbasic steps to play with mysql

# 1) login mysql with root
     mysql -u root -p
# 2) update password for root (optional)
UPDATE mysql.user SET password=PASSWORD('newPasswordForRoot'WHERE User='root';
FLUSH PRIVILEGES;

# 3) create a new user 'user1'

CREATE USER user1 IDENTIFIED BY 'mypassword'
# 4) grant all privileges for this user 
GRANT ALL PRIVILEGES ON *.* TO 'user1'@'localhost' IDENTIFIED BY 'mypassword'
FLUSH PRIVILEGES;

# 5) create a database with char set utf-8

create database mydatabase character set utf8;
set character_set_client=utf8;
set character_set_connection=utf8;
set character_set_database=utf8;
set character_set_results=utf8;
set character_set_server=utf8;


# 6) switch to a database
use mydatabase;
show tables;

# 7) Sample JDBC connection URL

jdbc:mysql://localhost:3306/mydatabase?useUnicode=true&characterEncoding=utf-8&autoReconnect=true&failOverReadOnly=false




gembin 2012-05-22 00:25 发表评论
]]>
Spring AOP: JDK Dynamic Proxy vs. CGLib proxyhttp://www.dentisthealthcenter.com/gembin/archive/2012/05/03/377268.htmlgembingembinThu, 03 May 2012 05:16:00 GMThttp://www.dentisthealthcenter.com/gembin/archive/2012/05/03/377268.htmlhttp://www.dentisthealthcenter.com/gembin/comments/377268.htmlhttp://www.dentisthealthcenter.com/gembin/archive/2012/05/03/377268.html#Feedback0http://www.dentisthealthcenter.com/gembin/comments/commentRss/377268.htmlhttp://www.dentisthealthcenter.com/gembin/services/trackbacks/377268.htmlSpring's AOP is proxy-based. Spring provides two different options to create the proxies. One is based on JDK dynamic proxies and works with interfaces, the other one utilizes CGLib and is based on classes. (That's why the property is called proxyTargetClass respectively proxy-target-class.) For the moment I just want to provide a quick summary on the pros and cons of both options:

JDK dynamic proxies:

  • The class has to implement interfaces. Otherwise you will get ClassCastExceptions saying that $Proxy0 can not be casted to the particular class.

  • Eventually dynamic proxies force you to program to interfaces since you can not cast the proxy to the class - a feature I really like about them.


CGLib proxies:

  • The proxies are created by sub-classing the actual class. This means wherever an instance of the class is used it is also possible to use the CGLib proxy.

  • The class needs to provide a default constructor, i.e. without any arguments. Otherwise you'll get an IllegalArgumentException: "Superclass has no null constructors but no arguments were given." This makes constructor injection impossible.

  • The proxying does not work with final methods since the proxy sub class can not override the class' implementation.

  • The CGLib proxy is final, so proxying a proxy does not work. You will get an IllegalArgumentException saying "Cannot subclass final class $Proxy0". But this feature is usually not needed anyway. 

  • Since two objects are created (the instance of the class and the proxy as instance of a sub class) the constructor is called twice. In general this should not matter. I consider changing the class' state based on constructor calls a code smell anyway.

  • You have CGLib as additional dependency.

    ref:  http://static.springsource.org/spring/docs/3.1.1.RELEASE/spring-framework-reference/htmlsingle/spring-framework-reference.html#aop-introduction-proxies 




gembin 2012-05-03 13:16 发表评论
]]>
Deep Copy And Shallow Copyhttp://www.dentisthealthcenter.com/gembin/archive/2012/04/07/373545.htmlgembingembinSat, 07 Apr 2012 10:41:00 GMThttp://www.dentisthealthcenter.com/gembin/archive/2012/04/07/373545.htmlhttp://www.dentisthealthcenter.com/gembin/comments/373545.htmlhttp://www.dentisthealthcenter.com/gembin/archive/2012/04/07/373545.html#Feedback0http://www.dentisthealthcenter.com/gembin/comments/commentRss/373545.htmlhttp://www.dentisthealthcenter.com/gembin/services/trackbacks/373545.htmlLets first separate it out and see what each one means.

What is Shallow Copy?

Shallow copy is a bit-wise copy of an object. A new object is created that has an exact copy of the values in the original object. If any of the fields of the object are references to other objects, just the reference addresses are copied i.e., only the memory address is copied.

Shallow Copy

In this figure, the MainObject1 have fields "field1" of int type, and "ContainObject1" of ContainObject type. When you do a shallow copy of MainObject1, MainObject2 is created with "field3" containing the copied value of "field1" and still pointing to ContainObject1 itself. Observe here and you will find that since field1 is of primitive type, the values of it are copied to field3 but ContainedObject1 is an object, so MainObject2 is still pointing to ContainObject1. So any changes made to ContainObject1 in MainObject1 will reflect in MainObject2.

Now if this is shallow copy, lets see what's deep copy?

What is Deep Copy?

A deep copy copies all fields, and makes copies of dynamically allocated memory pointed to by the fields. A deep copy occurs when an object is copied along with the objects to which it refers.

Deep Copy

In this figure, the MainObject1 have fields "field1" of int type, and "ContainObject1" of ContainObject type. When you do a deep copy of MainObject1, MainObject2 is created with "field3" containing the copied value of "field1" and "ContainObject2" containing the copied value of ContainObject1.So any changes made to ContainObject1 in MainObject1 will not reflect in MainObject2.

Well, here we are with what shallow copy and deep copy are and obviously the difference between them. Now lets see how to implement them in java.

How to implement shallow copy in java?

Here is an example of Shallow Copy implementation

 1 class Subject {
 2 
 3   private String name;
 4 
 5   public String getName() {
 6     return name;
 7   }
 8 
 9   public void setName(String s) {
10     name = s;
11   }
12 
13   public Subject(String s) {
14     name = s;
15   }
16 }
17 
18 class Student implements Cloneable {
19   //Contained object
20   private Subject subj;
21 
22   private String name;
23 
24   public Subject getSubj() {
25     return subj;
26   }
27 
28   public String getName() {
29     return name;
30   }
31 
32   public void setName(String s) {
33     name = s;
34   }
35 
36   public Person(String s, String sub) {
37     name = s;
38     subj = new Subject(sub);
39   }
40 
41   public Object clone() {
42     //shallow copy
43     try {
44       return super.clone();
45     } catch (CloneNotSupportedException e) {
46       return null;
47     }
48   }
49 }
50 
51 public class CopyTest {
52 
53   public static void main(String[] args) {
54     //Original Object
55     Student stud = new Student("John", "Algebra");
56 
57     System.out.println("Original Object: " + stud.getName() + " - "
58         + stud.getSubject().getName());
59 
60     //Clone Object
61     Student clonedStud = (Student) stud.clone();
62 
63     System.out.println("Cloned Object: " + clonedStud.getName() + " - "
64         + clonedStud.getSubject().getName());
65 
66     stud.setStudentName("Dan");
67     stud.getSubject().setSubjectName("Physics");
68 
69     System.out.println("Original Object after it is updated: " 
70         + stud.getName() + " - " + stud.getStudent().getName());
71 
72     System.out.println("Cloned Object after updating original object: "
73         + clonedStud.getName() + " - " + clonedStud.getSubject().getName());
74 
75   }
76 }

Output is:
Original Object: John - Algebra
Cloned Object: John - Algebra
Original Object after it is updated: Dan - Physics
Cloned Object after updating original object: John - Physics

In this example, all I did is, implement the class that you want to copy with Clonable interface and override clone() method of Object class and call super.clone() in it. If you observe, the changes made to "name" field of original object (Student class) is not reflected in cloned object but the changes made to "name" field of contained object (Subject class) is reflected in cloned object. This is because the cloned object carries the memory address of the Subject object but not the actual values. Hence any updates on the Subject object in Original object will reflect in Cloned object.

 

How to implement deep copy in java?

Here is an example of Deep Copy implementation. This is the same example of Shallow Copy implementation and hence I didnt write the Subject and CopyTest classes as there is no change in them.

 1 class Student implements Cloneable {
 2   //Contained object
 3   private Subject subj;
 4 
 5   private String name;
 6 
 7   public Subject getSubj() {
 8     return subj;
 9   }
10 
11   public String getName() {
12     return name;
13   }
14 
15   public void setName(String s) {
16     name = s;
17   }
18 
19   public Person(String s, String sub) {
20     name = s;
21     subj = new Subject(sub);
22   }
23 
24   public Object clone() {
25     //deep copy
26     try {
27       //Deep copy
28       Student s = new Student(name, subj.getName());
29       return s;
30     } catch (CloneNotSupportedException e) {
31       return null;
32     }
33   }
34 }
 
 Output is:
 Original Object: John - Algebra
 Cloned Object: John - Algebra
 Original Object after it is updated: Dan - Physics
 Cloned Object after updating original object: Dan - Physics

 

Well, if you observe here in the "Student" class, you will see only the change in the "clone()" method. Since its a deep copy, you need to create an object of the cloned class. Well if you have have references in the Subject class, then you need to implement Cloneable interface in Subject class and override clone method in it and this goes on and on.

There is an alternative way for deep copy.

Yes, there is. You can do deep copy through serialization. What does serialization do? It writes out the whole object graph into a persistant store and read it back when needed, which means you will get a copy of the whole object graph whne you read it back. This is exactly what you want when you deep copy an object. Note, when you deep copy through serialization, you should make sure that all classes in the object's graph are serializable. Let me explain you this alternative way with an example.

 1 public class ColoredCircle implements Serializable
 2 {
 3     private int x;
 4     private int y;
 5 
 6     public ColoredCircle(int x, int y){
 7         this.x = x;
 8         this.y = y;
 9     }
10 
11     public int getX(){
12         return x;
13     }
14 
15     public void setX(int x){
16         this.x = x;
17     }
18 
19     public int getY(){
20         return y;
21     }
22 
23     public void setX(int x){
24         this.x = x;
25     }
26 }
27 
28 public class DeepCopy
29 {
30     static public void main(String[] args)
31     {
32         ObjectOutputStream oos = null;
33         ObjectInputStream ois = null;
34 
35         try
36         {
37             // create original serializable object
38             ColoredCircle c1 = new ColoredCircle(100,100);
39             // print it
40             System.out.println("Original = " + c1);
41 
42             ColoredCircle c2 = null;
43 
44             // deep copy
45             ByteArrayOutputStream bos = new ByteArrayOutputStream(); 
46             oos = new ObjectOutputStream(bos); 
47             // serialize and pass the object
48             oos.writeObject(c1);   
49             oos.flush();               
50             ByteArrayInputStream bin = 
51                     new ByteArrayInputStream(bos.toByteArray()); 
52             ois = new ObjectInputStream(bin);                  
53             // return the new object
54             c2 = ois.readObject(); 
55 
56             // verify it is the same
57             System.out.println("Copied   = " + c2);
58             // change the original object's contents
59             c1.setX(200);
60             c1.setY(200);
61             // see what is in each one now
62             System.out.println("Original = " + c1);
63             System.out.println("Copied   = " + c2);
64         }
65         catch(Exception e)
66         {
67             System.out.println("Exception in main = " +  e);
68         }
69         finally
70         {        
71             oos.close();
72             ois.close();
73         }
74     }
75 }

 The output is:
 Original = x=100,y=100
 Copied   = x=100,y=100
 Original = x=200,y=200
 Copied   = x=100,y=100

All you need to do here is:
  • Ensure that all classes in the object's graph are serializable.
  • Create input and output streams.
  • Use the input and output streams to create object input and object output streams.
  • Pass the object that you want to copy to the object output stream.
  • Read the new object from the object input stream and cast it back to the class of the object you sent.

In this example, I have created a ColoredCircle object, c1 and then serialized it (write it out to ByteArrayOutputStream). Then I deserialed the serialized object and saved it in c2. Later I modified the original object, c1. Then if you see the result, c1 is different from c2. c2 is deep copy of first version of c1. So its just a copy and not a reference. Now any modifications to c1 wont affect c2, the deep copy of first version of c1.

Well this approach has got its own limitations and issues:

As you cannot serialize a transient variable, using this approach you cannot copy the transient variables. 
Another issue is dealing with the case of a class whose object's instances within a virtual machine must be controlled. This is a special case of the Singleton pattern, in which a class has only one object within a VM. As discussed above, when you serialize an object, you create a totally new object that will not be unique. To get around this default behavior you can use the readResolve() method to force the stream to return an appropriate object rather than the one that was serialized. In this particular case, the appropriate object is the same one that was serialized.
Next one is the performance issue. Creating a socket, serializing an object, passing it through the socket, and then deserializing it is slow compared to calling methods in existing objects. I say, there will be vast difference in the performance. If your code is performance critical, I suggest dont go for this approach. It takes almost 100 times more time to deep copy the object than the way you do by implementing Clonable interface.

When to do shallow copy and deep copy?

Its very simple that if the object has only primitive fields, then obviously you will go for shallow copy but if the object has references to other objects, then based on the requiement, shallow copy or deep copy should be chosen. What I mean here is, if the references are not modified anytime, then there is no point in going for deep copy. You can just opt shallow copy. But if the references are modified often, then you need to go for deep copy. Again there is no hard and fast rule, it all depends on the requirement.

Finally lets have a word about rarely used option - Lazy copy

A lazy copy is a combination of both shallow copy and deep copy. When initially copying an object, a (fast) shallow copy is used. A counter is also used to track how many objects share the data. When the program wants to modify the original object, it can determine if the data is shared (by examining the counter) and can do a deep copy at that time if necessary.

Lazy copy looks to the outside just as a deep copy but takes advantage of the speed of a shallow copy whenever possible. It can be used when the references in the original object are not modified often. The downside are rather high but constant base costs because of the counter. Also, in certain situations, circular references can also cause problems.



gembin 2012-04-07 18:41 发表评论
]]>
SAX vs. DOMhttp://www.dentisthealthcenter.com/gembin/archive/2012/04/01/373206.htmlgembingembinSun, 01 Apr 2012 08:32:00 GMThttp://www.dentisthealthcenter.com/gembin/archive/2012/04/01/373206.htmlhttp://www.dentisthealthcenter.com/gembin/comments/373206.htmlhttp://www.dentisthealthcenter.com/gembin/archive/2012/04/01/373206.html#Feedback0http://www.dentisthealthcenter.com/gembin/comments/commentRss/373206.htmlhttp://www.dentisthealthcenter.com/gembin/services/trackbacks/373206.htmlWhile comparing two entities, we tend to see both of them as competitors and consequently comparing them to find a winner. This of course is not applicable in every case - not at least in the case of SAX and DOM. Both have their own pros and cons and they are certainly not in direct competition with each other.

SAX vs. DOM

Main differences between SAX and DOM, which are the two most popular APIs for processing XML documents in Java, are:-
  • Read v/s Read/Write: SAX can be used only for reading XML documents and not for the manipulation of the underlying XML data whereas DOM can be used for both read and write of the data in an XML document.
  • Sequential Access v/s Random Access: SAX can be used only for a sequential processing of an XML document whereas DOM can be used for a random processing of XML docs. So what to do if you want a random access to the underlying XML data while using SAX? You got to store and manage that information so that you can retrieve it when you need.
  • Call back v/s Tree: SAX uses call back mechanism and uses event-streams to read chunks of XML data into the memory in a sequential manner whereas DOM uses a tree representation of the underlying XML document and facilitates random access/manipulation of the underlying XML data.
  • XML-Dev mailing list v/s W3C: SAX was developed by the XML-Dev mailing list whereas DOM was developed by W3C (World Wide Web Consortium).
  • Information Set: SAX doesn't retain all the info of the underlying XML document such as comments whereas DOM retains almost all the info. New versions of SAX are trying to extend their coverage of information.
Usual Misconceptions
  • SAX is always faster: this is a very common misunderstanding and one should be aware that SAX may not always be faster because it might not enjoy the storage-size advantage in every case due to the cost of call backs depending upon the particular situation, SAX is being used in.
  • DOM always keeps the whole XML doc in memory: it's not always true. DOM implementations not only vary in their code size and performance, but also in their memory requirements and few of them don't keep the entire XML doc in memory all the time. Otherwise, processing/manipulation of very large XML docs may virtually become impossible using DOM, which is of course not the case.

How to choose one between the two?

It primarily depends upon the requirement. If the underlying XML data requires manipulation then almost always DOM will be used as SAX doesn't allow that. Similarly if the nature of access is random (for example, if you need contextual info at every stage) then DOM will be the way to go in most of the cases. But, if the XML document is only required to be read and that too sequentially, then SAX will probably be a better alternative in most of the cases. SAX was developed mainly for pasring XML documents and it's certainly good at it. SO, if you need to process an XML document maybe to update a datasource, SAX will probably make a alternative.
Requirements may certainly fall between the two extremes discussed above and for any such situation you should weight both the alternatives before picking any of the two. There are applications where a combination of both SAX and DOM are used for XML processing so that might also be an alternative in your case. But, basically it would be a design decision and evidently it would require a thorough analysis of the pros and cons of all possible approaches in that situation.


gembin 2012-04-01 16:32 发表评论
]]>
Top Ten Reasons not to use the C shellhttp://www.dentisthealthcenter.com/gembin/archive/2012/04/01/373205.htmlgembingembinSun, 01 Apr 2012 08:30:00 GMThttp://www.dentisthealthcenter.com/gembin/archive/2012/04/01/373205.htmlhttp://www.dentisthealthcenter.com/gembin/comments/373205.htmlhttp://www.dentisthealthcenter.com/gembin/archive/2012/04/01/373205.html#Feedback0http://www.dentisthealthcenter.com/gembin/comments/commentRss/373205.htmlhttp://www.dentisthealthcenter.com/gembin/services/trackbacks/373205.html http://www.grymoire.com/Unix/CshTop10.txt

gembin 2012-04-01 16:30 发表评论
]]>
Get substring of a string under UNIX/Linuxhttp://www.dentisthealthcenter.com/gembin/archive/2012/04/01/373200.htmlgembingembinSun, 01 Apr 2012 07:38:00 GMThttp://www.dentisthealthcenter.com/gembin/archive/2012/04/01/373200.htmlhttp://www.dentisthealthcenter.com/gembin/comments/373200.htmlhttp://www.dentisthealthcenter.com/gembin/archive/2012/04/01/373200.html#Feedback0http://www.dentisthealthcenter.com/gembin/comments/commentRss/373200.htmlhttp://www.dentisthealthcenter.com/gembin/services/trackbacks/373200.htmlthere many ways to do so.


str="hello world"

1) cut
Where -cN-M tells the cut command to return columns N to M, inclusive. 
cut -cN-M

start=1
end=5
sub_str=`echo ${str} | cut -c${start}-${end}`
output: hello

2) bash 
Note: if you are not sure of having bash, consider using cut. 
${str:offset}
$
{str:offset:length}

sub_str=${str:0:5}
output: hello

3) expr

expr substr string position length 
sub_str=`expr substr $str 1 5`
output: hello

 



gembin 2012-04-01 15:38 发表评论
]]>
Get the length of a string under UNIX/Linuxhttp://www.dentisthealthcenter.com/gembin/archive/2012/04/01/373199.htmlgembingembinSun, 01 Apr 2012 07:14:00 GMThttp://www.dentisthealthcenter.com/gembin/archive/2012/04/01/373199.htmlhttp://www.dentisthealthcenter.com/gembin/comments/373199.htmlhttp://www.dentisthealthcenter.com/gembin/archive/2012/04/01/373199.html#Feedback0http://www.dentisthealthcenter.com/gembin/comments/commentRss/373199.htmlhttp://www.dentisthealthcenter.com/gembin/services/trackbacks/373199.htmlthere many ways to do so.

str="hello world"

len=`expr length ${str}`

len=${#str}

len=`echo ${str} | awk "{ print length }"`

len=`echo -n ${str} | wc -c` 

 



gembin 2012-04-01 15:14 发表评论
]]>
TreeSet vs HashSet vs LinkedHashSethttp://www.dentisthealthcenter.com/gembin/archive/2012/03/31/373111.htmlgembingembinSat, 31 Mar 2012 03:30:00 GMThttp://www.dentisthealthcenter.com/gembin/archive/2012/03/31/373111.htmlhttp://www.dentisthealthcenter.com/gembin/comments/373111.htmlhttp://www.dentisthealthcenter.com/gembin/archive/2012/03/31/373111.html#Feedback0http://www.dentisthealthcenter.com/gembin/comments/commentRss/373111.htmlhttp://www.dentisthealthcenter.com/gembin/services/trackbacks/373111.html
TreeSetHashSetLinkedHashSet
public class TreeSet
extends AbstractSet
implements SortedSetCloneableSerializable
public class HashSet
extends AbstractSet
implements SetCloneableSerializable
public class LinkedHashSet
extends HashSet
implements SetCloneableSerializable
unique valuesunique valuesUnique values
It stores its elements in a red-black treeIt stores its elements in a hash tableis implemented as a hash table with a linked list running through it
Order : ascending orderundefinedinsertion order
Performance : Slowbetter than LinkedHashSethas fast adding to the start of the list, and fast deletion from the interior via iteration
operations (addremove and contains)operations (addremovecontains and size)operations (addcontains and remove)
add, addAll,ceiling,clear,clone,comparator,contains,
descendingIterator,descendingSet,first,floor,
hashSet,higher,isEmpty,iterator,last,lower,pollFirst,
remove,size,subSet,tailSet
addclearclonecontainsisEmpty,iteratorremovesizeaddclearclonecontainsisEmpty,iteratorremovesize
From AbstractSet:
equalshashCoderemoveAll
equalshashCoderemoveAllequalshashCoderemoveAll
containsAllretainAlltoArraytoArray,toStringAbstractCollection:
addAllcontainsAllretainAlltoArray,toArraytoString
addAllcontainsAllretainAlltoArray,toArraytoString
Set:
containsAllequalshashCoderemoveAll,retainAlltoArraytoArray
addAllcontainsAllequalshashCode,removeAllretainAlltoArraytoArrayaddaddAllclearcontainscontainsAll,equalshashCodeisEmptyiteratorremove,removeAllretainAllsizetoArraytoArray



gembin 2012-03-31 11:30 发表评论
]]>
Objective-C NSString formatting http://www.dentisthealthcenter.com/gembin/archive/2012/03/04/371188.htmlgembingembinSat, 03 Mar 2012 16:27:00 GMThttp://www.dentisthealthcenter.com/gembin/archive/2012/03/04/371188.htmlhttp://www.dentisthealthcenter.com/gembin/comments/371188.htmlhttp://www.dentisthealthcenter.com/gembin/archive/2012/03/04/371188.html#Feedback0http://www.dentisthealthcenter.com/gembin/comments/commentRss/371188.htmlhttp://www.dentisthealthcenter.com/gembin/services/trackbacks/371188.htmlThe format specifiers supported by the NSString formatting methods and CFString formatting
functions follow the IEEE printf specification; the specifiers are summarized in Table 1.
Note that you can also use the “n$” positional specifiers such as %1$@ %2$s.
For more details, see the IEEE printf specification. You can also use these format specifiers with the NSLog function.

Table 1 Format specifiers supported by the NSString formatting methods and CFString formatting functions
定义说明
%@Objective-C object, printed as the string returned by descriptionWithLocale: if available, or description otherwise. Also works with CFTypeRef objects, returning the result of the CFCopyDescription function.
%%‘%’ character
%d, %D, %iSigned 32-bit integer (int)
%u, %UUnsigned 32-bit integer (unsigned int)
%hiSigned 16-bit integer (short)
%huUnsigned 16-bit integer (unsigned short)
%qiSigned 64-bit integer (long long)
%quUnsigned 64-bit integer (unsigned long long)
%xUnsigned 32-bit integer (unsigned int), printed in hexadecimal using the digits 0–9 and lowercase a–f
%XUnsigned 32-bit integer (unsigned int), printed in hexadecimal using the digits 0–9 and uppercase A–F
%qxUnsigned 64-bit integer (unsigned long long), printed in hexadecimal using the digits 0–9 and lowercase a–f
%qXUnsigned 64-bit integer (unsigned long long), printed in hexadecimal using the digits 0–9 and uppercase A–F
%o, %OUnsigned 32-bit integer (unsigned int), printed in octal
%f64-bit floating-point number (double)
%e64-bit floating-point number (double), printed in scientific notation using a lowercase e to introduce the exponent
%E64-bit floating-point number (double), printed in scientific notation using an uppercase E to introduce the exponent
%g64-bit floating-point number (double), printed in the style of %e if the exponent is less than –4 or greater than or equal to the precision, in the style of %f otherwise
%G64-bit floating-point number (double), printed in the style of %E if the exponent is less than –4 or greater than or equal to the precision, in the style of %f otherwise
%c8-bit unsigned character (unsigned char), printed by NSLog() as an ASCII character, or, if not an ASCII character, in the octal format \\ddd or the Unicode hexadecimal format \\udddd, where d is a digit
%C16-bit Unicode character (unichar), printed by NSLog() as an ASCII character, or, if not an ASCII character, in the octal format \\ddd or the Unicode hexadecimal format \\udddd, where d is a digit
%sNull-terminated array of 8-bit unsigned characters. %s interprets its input in the system encoding rather than, for example, UTF-8.
%SNull-terminated array of 16-bit Unicode characters
%pVoid pointer (void *), printed in hexadecimal with the digits 0–9 and lowercase a–f, with a leading 0x
%LLength modifier specifying that a following a, A, e, E, f, F, g, or G conversion specifier applies to a long double argument
%a64-bit floating-point number (double), printed in scientific notation with a leading 0x and one hexadecimal digit before the decimal point using a lowercase p to introduce the exponent
%A64-bit floating-point number (double), printed in scientific notation with a leading 0X and one hexadecimal digit before the decimal point using a uppercase P to introduce the exponent
%F64-bit floating-point number (double), printed in decimal notation
%zLength modifier specifying that a following d, i, o, u, x, or X conversion specifier applies to a size_t or the corresponding signed integer type argument
%tLength modifier specifying that a following d, i, o, u, x, or X conversion specifier applies to a ptrdiff_t or the corresponding unsigned integer type argument
%jLength modifier specifying that a following d, i, o, u, x, or X conversion specifier applies to a intmax_t or uintmax_t argument


Mac OS X uses several data types—NSInteger, NSUInteger,CGFloat, and CFIndex—to provide a
consistent means of representing values in 32- and 64-bit environments. In a 32-bit environment,
NSInteger and NSUInteger are defined as int and unsigned int, respectively. In 64-bit environments,
NSInteger and NSUInteger are defined as long and unsigned long, respectively. To avoid the need to
use different printf-style type specifiers depending on the platform, you can use the specifiers shown
in Table 2. Note that in some cases you may have to cast the value.

Table 2 Format specifiers for data types
cd定义
NSInteger%ld or %lxCast the value to long
NSUInteger%lu or %lxCast the value to unsigned long
CGFloat%f or %g%f works for floats and doubles when formatting; but see below warning when scanning
CFIndex%ld or %lxThe same as NSInteger
pointer%p%p adds 0x to the beginning of the output. If you don’t want that, use %lx and cast to long.
long long%lld or %llxlong long is 64-bit on both 32- and 64-bit platforms
unsigned long long%llu or %llxunsigned long long is 64-bit on both 32- and 64-bit platforms

The following example illustrates the use of %ld to format an NSInteger and the use of a cast.

1
2
NSInteger i = 42;
printf("%ld\n", (long)i);

In addition to the considerations mentioned in Table 2, there is one extra case with scanning:
you must distinguish the types for float and double. You should use %f for float, %lf for double.
If you need to use scanf (or a variant thereof) with CGFloat, switch to double instead, and copy the double to CGFloat.

1
2
3
4
CGFloat imageWidth;
double tmp;
sscanf (str, "%lf", &amp;tmp);
imageWidth = tmp;

It is important to remember that %lf does not represent CGFloat correctly on either 32- or 64-bit platforms.
This is unlike %ld, which works for long in all cases.







gembin 2012-03-04 00:27 发表评论
]]>
Sharing Objective-C, Cocoa and iOS [ebooks]http://www.dentisthealthcenter.com/gembin/archive/2012/03/03/371166.htmlgembingembinSat, 03 Mar 2012 07:43:00 GMThttp://www.dentisthealthcenter.com/gembin/archive/2012/03/03/371166.htmlhttp://www.dentisthealthcenter.com/gembin/comments/371166.htmlhttp://www.dentisthealthcenter.com/gembin/archive/2012/03/03/371166.html#Feedback2http://www.dentisthealthcenter.com/gembin/comments/commentRss/371166.htmlhttp://www.dentisthealthcenter.com/gembin/services/trackbacks/371166.htmli got several objective-c & iOS related books collected from the internet for sharing.


Hope u will like it.






































































Pro_Objective-C_Design_Patterns_for_iOS.pdf


=====================================
=  others
=====================================

Learn_Objective-C_for_Java_Developers.pdf








gembin 2012-03-03 15:43 发表评论
]]>
Giulia - Ce Frumoasa E Iubirea (爱情多美?http://www.dentisthealthcenter.com/gembin/archive/2012/01/21/368811.htmlgembingembinSat, 21 Jan 2012 03:21:00 GMThttp://www.dentisthealthcenter.com/gembin/archive/2012/01/21/368811.htmlhttp://www.dentisthealthcenter.com/gembin/comments/368811.htmlhttp://www.dentisthealthcenter.com/gembin/archive/2012/01/21/368811.html#Feedback0http://www.dentisthealthcenter.com/gembin/comments/commentRss/368811.htmlhttp://www.dentisthealthcenter.com/gembin/services/trackbacks/368811.html
Ce frumoasa e iubirea 爱情多美?
Fiecare clipa pictata-n roz, 每一分每一U都涂成了玫瑰色
Tre'sa recunosc,iti apartine... 我必d承认Q这属于?
Si nici macar eu nu ma cunosc 我已无法认识自己
Asa cum ma stii pe mine.. 只有你了解真正的?
Ma tem uneori ca ai sa pleci 有时候我担心你将dQ?
Si nu vreau sa ma lasi fara tine...不要留下孤单的我
Iar eu nu sunt eu...而我已不是我Q?
De fapt,fara tine,sunt nimeni...事实上,没有你,我也无法存?
Refren: Ce frumoasa e iubirea Q爱情多呀Q?
Cand ma alinti cu zambetul tau curat! 当你用纯z的微笑爱抚我时
Ce frumoasa e iubirea 爱情多美呀
Cand tot ce spui devine adevarat!当你说的话成真的那一?
(bis)

Ficare clipa trecuta-n alb 白日里度q的每一?
A insemna ca tu esti departe 告诉你已走远
Uneori ma intreb daca esti real 有时候我问自׃是否真的存在
Sau inchipuit din printr-o carte! 也许你只是书中的虚
Ma tem uneori ca ai sa pleci 有时担心你会d
Si nu vreau sa ma lasi fara tine... 不要留下孤单的我
Iar eu nu sunt eu... 而我已不是我
De fapt,fara tine,sunt nimeni... 没有你,我也不再存?
Refren: Ce frumoasa e iubirea 爱情多美呀
Cand ma alinti cu zambetul tau curat! 当你用纯z的微笑爱抚我时
Ce frumoasa e iubirea 爱情多美呀
Cand tot ce spui devine adevarat! 当你的话语成真时
(bis)
Ma cuprinzi incet..ma stangi la piept 慢慢我拥入怀?
Imi spui ca nu..n-ai sa pleci prea curand... Ҏ说不。。。不要马上立开?
(bis)
Refren: Ce frumoasa e iubirea 爱情多美呀
Cand ma alinti cu zambetul tau curat! 当你用纯z的微笑爱抚我时
Ce frumoasa e iubirea 爱情多美呀
Cand tot ce spui devine adevarat! 当你的话语成真时
(bis)


gembin 2012-01-21 11:21 发表评论
]]>
Mac Keyboard Shortcutshttp://www.dentisthealthcenter.com/gembin/archive/2012/01/21/368798.htmlgembingembinFri, 20 Jan 2012 16:57:00 GMThttp://www.dentisthealthcenter.com/gembin/archive/2012/01/21/368798.htmlhttp://www.dentisthealthcenter.com/gembin/comments/368798.htmlhttp://www.dentisthealthcenter.com/gembin/archive/2012/01/21/368798.html#Feedback0http://www.dentisthealthcenter.com/gembin/comments/commentRss/368798.htmlhttp://www.dentisthealthcenter.com/gembin/services/trackbacks/368798.html阅读全文

gembin 2012-01-21 00:57 发表评论
]]>
心理学英文词?/title><link>http://www.dentisthealthcenter.com/gembin/archive/2012/01/14/368493.html</link><dc:creator>gembin</dc:creator><author>gembin</author><pubDate>Sat, 14 Jan 2012 07:19:00 GMT</pubDate><guid>http://www.dentisthealthcenter.com/gembin/archive/2012/01/14/368493.html</guid><wfw:comment>http://www.dentisthealthcenter.com/gembin/comments/368493.html</wfw:comment><comments>http://www.dentisthealthcenter.com/gembin/archive/2012/01/14/368493.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.dentisthealthcenter.com/gembin/comments/commentRss/368493.html</wfw:commentRss><trackback:ping>http://www.dentisthealthcenter.com/gembin/services/trackbacks/368493.html</trackback:ping><description><![CDATA[     摘要: 心理?psychology心理现象 mental phenomenon心理q程 mental process心理状?mental state心理zd mental activity意识 consciousness心理l度 psychological dimension心理q动 psychomotor内部zd internal activity普通心理学 general psychology实验...  <a href='http://www.dentisthealthcenter.com/gembin/archive/2012/01/14/368493.html'>阅读全文</a><img src ="http://www.dentisthealthcenter.com/gembin/aggbug/368493.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.dentisthealthcenter.com/gembin/" target="_blank">gembin</a> 2012-01-14 15:19 <a href="http://www.dentisthealthcenter.com/gembin/archive/2012/01/14/368493.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item></channel></rss> <a href="http://www.dentisthealthcenter.com/">久久一级片</a> <div style="position:fixed;left:-9000px;top:-9000px;"><video id="395jp"><font id="395jp"><font id="395jp"><video id="395jp"></video></font></font></video><meter id="395jp"><video id="395jp"></video></meter><nobr id="395jp"></nobr><dl id="395jp"><i id="395jp"></i></dl><nobr id="395jp"><nobr id="395jp"></nobr></nobr><dl id="395jp"></dl><delect id="395jp"><font id="395jp"></font></delect><meter id="395jp"><font id="395jp"></font></meter><noframes id="395jp"></noframes><i id="395jp"><i id="395jp"></i></i><meter id="395jp"></meter><i id="395jp"></i><noframes id="395jp"><noframes id="395jp"></noframes></noframes><noframes id="395jp"><noframes id="395jp"><video id="395jp"><video id="395jp"></video></video></noframes></noframes><font id="395jp"></font><video id="395jp"><noframes id="395jp"></noframes></video><dl id="395jp"></dl><font id="395jp"><meter id="395jp"></meter></font><video id="395jp"><dl id="395jp"></dl></video><font id="395jp"><meter id="395jp"></meter></font><delect id="395jp"></delect><nobr id="395jp"><nobr id="395jp"></nobr></nobr><i id="395jp"><i id="395jp"><dl id="395jp"><i id="395jp"></i></dl></i></i><nobr id="395jp"><noframes id="395jp"></noframes></nobr><delect id="395jp"><font id="395jp"><font id="395jp"><meter id="395jp"></meter></font></font></delect><meter id="395jp"><nobr id="395jp"></nobr></meter><meter id="395jp"><nobr id="395jp"><nobr id="395jp"><nobr id="395jp"></nobr></nobr></nobr></meter><delect id="395jp"><delect id="395jp"></delect></delect><delect id="395jp"><delect id="395jp"><meter id="395jp"><nobr id="395jp"></nobr></meter></delect></delect><i id="395jp"></i><nobr id="395jp"><meter id="395jp"><nobr id="395jp"><nobr id="395jp"></nobr></nobr></meter></nobr><dl id="395jp"><i id="395jp"></i></dl><nobr id="395jp"><video id="395jp"></video></nobr><video id="395jp"><nobr id="395jp"><dl id="395jp"><video id="395jp"></video></dl></nobr></video><i id="395jp"><i id="395jp"></i></i><dl id="395jp"></dl><font id="395jp"><font id="395jp"></font></font><dl id="395jp"></dl><font id="395jp"></font><i id="395jp"><meter id="395jp"><meter id="395jp"><font id="395jp"></font></meter></meter></i><meter id="395jp"></meter><meter id="395jp"><video id="395jp"><video id="395jp"><dl id="395jp"></dl></video></video></meter><delect id="395jp"></delect><meter id="395jp"><nobr id="395jp"><nobr id="395jp"><nobr id="395jp"></nobr></nobr></nobr></meter><noframes id="395jp"></noframes><dl id="395jp"></dl><font id="395jp"><font id="395jp"></font></font><font id="395jp"><meter id="395jp"></meter></font><noframes id="395jp"></noframes><delect id="395jp"><delect id="395jp"></delect></delect> <video id="395jp"></video><i id="395jp"><dl id="395jp"><font id="395jp"><i id="395jp"></i></font></dl></i><dl id="395jp"><video id="395jp"><noframes id="395jp"><video id="395jp"></video></noframes></video></dl><font id="395jp"></font><noframes id="395jp"><i id="395jp"><font id="395jp"><delect id="395jp"></delect></font></i></noframes><delect id="395jp"><nobr id="395jp"></nobr></delect><dl id="395jp"><dl id="395jp"></dl></dl><meter id="395jp"><nobr id="395jp"><video id="395jp"><noframes id="395jp"></noframes></video></nobr></meter><dl id="395jp"><i id="395jp"><font id="395jp"><noframes id="395jp"></noframes></font></i></dl><i id="395jp"><video id="395jp"><nobr id="395jp"><nobr id="395jp"></nobr></nobr></video></i><noframes id="395jp"><nobr id="395jp"></nobr></noframes><font id="395jp"></font><i id="395jp"><i id="395jp"></i></i><delect id="395jp"></delect><nobr id="395jp"><noframes id="395jp"></noframes></nobr><i id="395jp"><i id="395jp"></i></i><i id="395jp"><font id="395jp"><meter id="395jp"><meter id="395jp"></meter></meter></font></i><font id="395jp"><font id="395jp"></font></font><delect id="395jp"><i id="395jp"><font id="395jp"><meter id="395jp"></meter></font></i></delect><noframes id="395jp"><noframes id="395jp"><noframes id="395jp"><dl id="395jp"></dl></noframes></noframes></noframes><noframes id="395jp"><video id="395jp"></video></noframes><noframes id="395jp"><noframes id="395jp"></noframes></noframes><noframes id="395jp"><dl id="395jp"></dl></noframes><delect id="395jp"><delect id="395jp"></delect></delect><noframes id="395jp"></noframes><nobr id="395jp"></nobr><nobr id="395jp"><font id="395jp"><delect id="395jp"><dl id="395jp"></dl></delect></font></nobr><video id="395jp"><video id="395jp"><video id="395jp"><video id="395jp"></video></video></video></video><nobr id="395jp"><video id="395jp"></video></nobr><nobr id="395jp"><video id="395jp"></video></nobr><meter id="395jp"><meter id="395jp"><delect id="395jp"><font id="395jp"></font></delect></meter></meter><dl id="395jp"></dl><video id="395jp"><video id="395jp"><video id="395jp"><dl id="395jp"></dl></video></video></video><dl id="395jp"><video id="395jp"><noframes id="395jp"><video id="395jp"></video></noframes></video></dl><delect id="395jp"></delect><font id="395jp"><font id="395jp"></font></font><nobr id="395jp"><meter id="395jp"></meter></nobr><meter id="395jp"><nobr id="395jp"><nobr id="395jp"><nobr id="395jp"></nobr></nobr></nobr></meter><i id="395jp"><font id="395jp"></font></i><font id="395jp"><delect id="395jp"></delect></font><font id="395jp"><nobr id="395jp"><nobr id="395jp"><noframes id="395jp"></noframes></nobr></nobr></font><noframes id="395jp"></noframes><nobr id="395jp"></nobr><i id="395jp"></i><nobr id="395jp"><video id="395jp"><video id="395jp"><dl id="395jp"></dl></video></video></nobr><i id="395jp"></i><noframes id="395jp"><video id="395jp"><video id="395jp"><dl id="395jp"></dl></video></video></noframes><delect id="395jp"></delect><meter id="395jp"></meter><delect id="395jp"><meter id="395jp"><meter id="395jp"><meter id="395jp"></meter></meter></meter></delect> <noframes id="395jp"><nobr id="395jp"><nobr id="395jp"><meter id="395jp"></meter></nobr></nobr></noframes><dl id="395jp"><delect id="395jp"></delect></dl><noframes id="395jp"><video id="395jp"></video></noframes><meter id="395jp"><noframes id="395jp"></noframes></meter><video id="395jp"><dl id="395jp"><dl id="395jp"><dl id="395jp"></dl></dl></dl></video><font id="395jp"><noframes id="395jp"></noframes></font><noframes id="395jp"><nobr id="395jp"></nobr></noframes><nobr id="395jp"></nobr><dl id="395jp"></dl><dl id="395jp"></dl><font id="395jp"></font><dl id="395jp"></dl><font id="395jp"><font id="395jp"></font></font><video id="395jp"></video><font id="395jp"></font><delect id="395jp"><nobr id="395jp"></nobr></delect><video id="395jp"><dl id="395jp"></dl></video><meter id="395jp"></meter><nobr id="395jp"><video id="395jp"><noframes id="395jp"><nobr id="395jp"></nobr></noframes></video></nobr><i id="395jp"><i id="395jp"><font id="395jp"><delect id="395jp"></delect></font></i></i><dl id="395jp"><i id="395jp"></i></dl><dl id="395jp"></dl><video id="395jp"><delect id="395jp"></delect></video><video id="395jp"></video><delect id="395jp"><delect id="395jp"><delect id="395jp"><delect id="395jp"></delect></delect></delect></delect><meter id="395jp"><meter id="395jp"><nobr id="395jp"><font id="395jp"></font></nobr></meter></meter><video id="395jp"></video><nobr id="395jp"><nobr id="395jp"></nobr></nobr><delect id="395jp"></delect><meter id="395jp"><nobr id="395jp"><nobr id="395jp"><noframes id="395jp"></noframes></nobr></nobr></meter><font id="395jp"><delect id="395jp"><nobr id="395jp"><noframes id="395jp"></noframes></nobr></delect></font><font id="395jp"><nobr id="395jp"></nobr></font><delect id="395jp"></delect><i id="395jp"><delect id="395jp"><font id="395jp"><i id="395jp"></i></font></delect></i><i id="395jp"></i><video id="395jp"><dl id="395jp"><font id="395jp"><delect id="395jp"></delect></font></dl></video><font id="395jp"></font><video id="395jp"><noframes id="395jp"></noframes></video><font id="395jp"><i id="395jp"><delect id="395jp"><delect id="395jp"></delect></delect></i></font><meter id="395jp"><meter id="395jp"><nobr id="395jp"><dl id="395jp"></dl></nobr></meter></meter><dl id="395jp"><video id="395jp"><i id="395jp"><dl id="395jp"></dl></i></video></dl><delect id="395jp"></delect><noframes id="395jp"></noframes><i id="395jp"><font id="395jp"></font></i><noframes id="395jp"></noframes><i id="395jp"><delect id="395jp"><font id="395jp"><font id="395jp"></font></font></delect></i><i id="395jp"><font id="395jp"></font></i><nobr id="395jp"><nobr id="395jp"></nobr></nobr><delect id="395jp"></delect><nobr id="395jp"><nobr id="395jp"><noframes id="395jp"><video id="395jp"></video></noframes></nobr></nobr></div> <script> (function(){ var bp = document.createElement('script'); var curProtocol = window.location.protocol.split(':')[0]; if (curProtocol === 'https') { bp.src = 'https://zz.bdstatic.com/linksubmit/push.js'; } else { bp.src = 'http://push.zhanzhang.baidu.com/push.js'; } var s = document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(bp, s); })(); </script> </body>