mysql dump 乱码问题

将utf8编码的数据库使用mysqldump.exe来导出,得到的却是乱码

明明设置了--default-character-set=utf8 任然如此,网上搜了些文章,例如 http://blog.derjohng.com/2006/01/18/backup-mysql-utf8-data/

说的是改为--default-character-set=latin1,我试了一下,还是乱码。莫名其妙,想了想试试如下的命令

"D:\Program Files\MySQL\MySQL Server 5.5\bin\mysqldump.exe" --user=root --password=root --default-character-set=gbk --skip-opt --add-drop-table --set-charset --dump-date --result-file=data.sql test

这样导出的结果编码才是正确的。(注意不要丢掉--skip-opt 选项)

问题是解决了,我还是莫名其妙。

明明设置的是utf8,数据库my.ini里面默认也是utf8,哪里搞出个gbk来了?

看官方文档,有这么一句话:

http://dev.mysql.com/doc/refman/5.1/en/charset-configuration.html

when character_set_system differs from character_set_server or character_set_client, and you input characters manually (as database object identifiers, column values, or both), these may be displayed incorrectly in output from the client or the output itself may be formatted incorrectly. In such cases, starting the mysql client with --default-character-set=system_character_set—that is, setting the client character set to match the system character set—should fix the problem.

似乎是要匹配文件系统字符集,也就是你的操作系统字符集。

Continue reading mysql dump 乱码问题

it-e-07 embedded system

An "embedded system" is a special-purpose computer system, which is completely encapsulated by the device it controls. An embedded system has specific requirements and performs pre-defined tasks, unlike a general-purpose personal computer.
Characteristics

Two major areas of differences are cost and power consumption. Since many embedded systems are produced in the tens of thousands to millions of units range,reducing cost is a major concern. Embedded systems often use a (relatively) slow processor and small memory size to minimize costs. The slowness is not just clock's speed. The wholearchitecture of the computer is often intentionally simplified to lower costs. For example,embedded systems often use peripheralscontrolled by synchronous serial interfaces, which are ten to hundreds of times slower than comparable peripherals used in PCs. Programs on anembedded system often must run with real-time constraints with limited hardware resources:often there is no disk drive, operating system, keyboard or screen. A flash drive may replace rotating media, and a small keypad and LCD screen may be used instead of a PC's keyboard and screen. Firmwareis the name for software that is embedded in hardware devices, e.g. in one or more ROM Flash memory IC chips. Embedded systems are routinely expected to maintain 100% reliability while running continuously for long periods of time, sometimes measured in years.
Firmware is usually developed and tested to much stricter requirements than is general purposesoftware (which can usually be easily restarted if a problem occurs). In addition, because the embedded system may be outside the reach of humans (down an oil well borehole, launched intoouter space, etc.), embedded firmware must usually be able to self-restart even if some sort of catastrophic data corruption has taken place. This last feature often requires external hardware assistance such as a watchdog timer that can automatically restart the system in the event of a software failure.

Platform

There are many different CPU architectures used in embedded designs. This in contrast to the desktop computer market, which as of this writing (2003) is limited to just a few competing architectures, mainly the Intel/AMD x86, and the Apple/Motorola/IBM PowerPC, used in the Apple Macintosh. One common configuration for embedded systems is the system on a chip, an application-specific integrated circuit, for which the CPU was purchased as intellectual property to add to the IC's design.

Continue reading it-e-07 embedded system

读书笔记:Effective Java, Second Edition-5章

Item 23: Don’t use raw types in new code

带参数泛型提供了安全类型检查,自动类型转换的便利,提倡使用。

raw type指没有指明类型的如List

List<String> 是 List的子类 但不是 List<Object>的子类,ArrayList<Object>才是List<Object>的子类。

List.class,String[].class, and int.class 合法,但 List<String>.class and List<?>.class不合法。

instance操作符只能使用Raw Type  (o instanceof Set) √ , (o instanceof Set<?>) ×

Set<Object> is a parameterized type representing a set that can contain objects of  any type,

Set<?> is a wildcard type representing a set that can contain only  objects of some unknown type, 无法使用

Set is a raw type, which opts out of the generic type system.

The first two are safe and the last is not.

Term
Example

Parameterized type
List<String>

Actual type parameter
String

Generic type
List<E>

Formal type parameter
E

Unbounded wildcard type
List<?>

Raw type
List

Bounded type parameter
<E extends Number>

Recursive type bound
<T extends Comparable<T>>

Bounded wildcard type
List<? extends Number>

Generic method
static <E> List<E> asList(E[] a)

Type token
String.class


Item 24: Eliminate unchecked warnings

消灭warning……

Item 25: Prefer lists to arrays

数组是协变的,if Sub is a subtype of Super, then the array type Sub[] is a subtype of Super[].

如此相反的是:Generics, by contrast, are invariant: for any two distinct types Type1 and Type2, List<Type1> is neither a subtype nor a supertype of List<Type2>

泛型的类型更强

不能建立泛型数组,因为需要保证泛型的类型安全【略】

总体来说就是,数组和泛型结合的不是很好,如果你碰到这种情况,使用列表代替数组。

Item 26: Favor generic types

泛型数组的解决方案(泛型中不得不用到数组的情况):

1:字段类型是T[],使用Object数组转换

private E[] elements;

// The elements array will contain only E instances from push(E).
// This is sufficient to ensure type safety, but the runtime
// type of the array won't be E[]; it will always be Object[]!
@SuppressWarnings("unchecked")
public Stack() {
elements = (E[]) new Object[DEFAULT_INITIAL_CAPACITY];
}

2:字段类型是Object数组,每次取数组元素时转换

// Appropriate suppression of unchecked warning
public E pop() {
if (size==0)
throw new EmptyStackException();
// push requires elements to be of type E, so cast is correct
@SuppressWarnings("unchecked")

E result = (E) elements[--size];
elements[size] = null; // Eliminate obsolete reference
return result;
}

Item 27: Favor generic methods

Item 28: Use bounded wildcards to increase API flexibility

PECS 原则:if a parameterized type represents a T producer, use <? extendsT>;if it represents a T consumer, use <? superT>.

// Wildcard type for parameter that serves as an E consumer
public void popAll(Collection<? super E> dst) {
while (!isEmpty())
dst.add(pop());
}

// Wildcard type for parameter that serves as an E producer
public void pushAll(Iterable<? extends E> src) {
for (E e : src)
push(e);
}

Item 29: Consider typesafe heterogeneous containers

容器里面多种类型的情况:

// Typesafe heterogeneous container pattern - implementation
public class Favorites {
private Map<Class<?>, Object> favorites = new HashMap<Class<?>, Object>(); //以Class<?>作为键达到多种类型的目的。注意Class<?>这个特殊的形式参照Item23.
public <T> void putFavorite(Class<T> type, T instance) {
if (type == null)
throw new NullPointerException("Type is null");
favorites.put(type, instance);
}
public <T> T getFavorite(Class<T> type) {
return type.cast(favorites.get(type));//将Object安全的转为了绑定类型

Continue reading 读书笔记:Effective Java, Second Edition-5章

【转】面试官心得

以下一些问题及其答案,仅代表我个人观点,仅供参考,但是如果你遇到问这些问题的很可能就是我在面你。

      1.自我介绍

      其实我想要的不是姓名,年龄,工作经历这些,拜托这些简历上都有我不是文盲,我是想知道你的优点,特长这些信息,你可以很自豪的告诉我你擅长数据库,解决过****等无数难题就可以了。

      2.我们公司会有自己的一套框架,你是否很快速的接受它,如果不能适应改怎么办

      我想知道的是你的学习能力和适应能力,并且如果你对框架有你独到的见解,我会加分的

      3.能不能够加班,或者出差,如果加班没有工资的话是否能接受

      这个我想要知道的是,一是否能吃苦耐劳,与公司同进退,二是看你的应变能力,我不想听简单的能与不能,其实是想看你的应变,你能否处理好这件事,三如果你什么情况都能接受,我也不会要你的,记住什么都能接受是对自己水平的不自信。

       4.是否有职业规划

       如果没有这个的话,我会认为你不想在在这个行业干出一些成绩,只想混日子。

       5.继续上面的问题,如果你选择技术方面发展,我会问,怎么才算是合格的程序员,什么样的代码是好代码,如果选择管理方面发展,我会问,你过去开发程序的过程是怎么样的。

       这个纯粹是了解下你目前的能力,我觉得这个已经大概可以展现你部分的能力了。

       剩下还有5到技术问题,这个就不方便透露了,但是我会分为三个级别,初级,你答上来我会认为你合格,中级我会为你加分,高级我会为你加薪就是这么简单。

       希望会对大家有所帮助。

Continue reading 【转】面试官心得

openfire 插件开发

此blog可行http://www.blogjava.net/jyleon/articles/255623.html

补充几点:

下载的openfire包目录/openfire/documentation/plugin-dev-guide.html中介绍了怎么开发插件.

要将源代码放在openfire的源代码目录中用其build.xml来编译。

在3.6.3中,最终打成的包是.pack文件,似乎插件里面getResourseAsSream方法不能用。

在3.6.4中,最终打成的包是.jar( zip格式),penfire启动后会解压缩生成目录,可看到插件被作为一个jar包放在lib目录下。所以只要第一次使用build命令打包,在以后直接将工程打成jar包放到lib目录下即可:测试是可行的。

但是注意,不能将发布的插件jar包删除,删除了的话,对应的文件夹也会被openfire自动删除。

两个可能有用的方法:

JiveGlobals.getHomeDirectory()

Log.getLogDirectory()

 

再回过来详细介绍一下,之前做过的又忘了,好些东西都重来了一遍。

现在已目前最新的包openfire-3.7.1为例:

将源码下下来66M多,不知为什么一下增加这么多了。

期目录结构如下图:

Snap1

将我们的插件以文档(documentation\docs\plugin-dev-guide.html#Using the Openfire Build Script)规定的格式存放,

Plugin Structure

myplugin/
 |- plugin.xml      <- Plugin definition file
 |- readme.html     <- Optional readme file for plugin
 |- changelog.html  <- Optional changelog file for plugin
 |- logo_small.gif  <- Optional small (16x16) icon associated with the plugin (can also be a .png file)
 |- logo_large.gif  <- Optional large (32x32) icon associated with the plugin (can also be a .png file)
 |- classes/        <- Resources your plugin needs (i.e., a properties file)
 |- lib/            <- Libraries your plugin needs
 |- src/
     |- database    <- Optional database scripts for your plugin
     |- java        <- Java source code for your plugin
     |   |- com
     |       |- mycompany
     |           |- *.java
     |- web
         |- *.jsp      <- JSPs your plugin uses for the admin console
         |- images/    <- Any images your JSP pages need (optional)
         |- WEB-INF
             |- web.xml    <- Optional file where custom servlets can be registered

将myplugin整个文件夹放在src\plugins中。

然后在其build文件夹中可找到build.xml,使用如下命令可单独编译单个plugin,但应在编译单个plugin之前至少运行一次plugins任务,负责无法编译单个plugin,报错为lib文件夹找不到,webapp目录找不到 :

ant plugin -Dplugin=myplugin

运行命令即可在work\plugins中找到编译好的plugin。

如果你在eclipse中,可右键点击build.xml, run as/Ant Build …/ 注意是三个点的那个才有更多选项。

Snap3

Snap4

这样配置和上面的命令行方式效果一样。

 

openfire提供离线消息发送,但是不提供历史消息存储。因此需要写插件来保存历史记录。

Continue reading openfire 插件开发

[转csdn文章]学习HTML5不可错过的12家国外网站(组图)

学习HTML5不可错过的12家国外网站(组图)

2011-04-21 23:43 | 25977次阅读 | 来源:CSDN编译 【已有60条评论】发表评论

关键词:HTML5 | 作者:子曰 | 收藏这篇资讯

[CSDN编译]HTML5是近十年来Web开发标准最巨大的飞跃。和以前的版本不同,HTML5并非仅仅用来表示Web内容,它的新使命是将 Web带入一个成熟的应用平台,在HTML5平台上,视频、音频、图象、动画以及同电脑的交互都被标准化。对于广大开发人员和设计者,究竟该如何入手 HTML5及获取相关的国外最新资源。以下是广大HTML5技术爱好者学习和参考相关技术不可错过的12家外网,它们或是采用HTML5技术开发出的案例,或是HTML5相关的学习资源,供国内的开发人员参阅。

(1)HTML5 Labs

HTML5实验室,这里有HTML5标准、范型和应用规范的最新内容。

(2)HTML5 – Wikipedia

维基百科对HTML5的介绍包括了它的历史、特性、与HTML4.01和XHTML 1.X的异同、HTML5的LOGO、参考资料、深度阅读及相关的链接等等。

(3)Apple – HTML5

最新的苹果移动设备和每一款Mac,包括最新的Safari浏览器,都支持最新的HTML5、CSS3和JavaScript。这里有苹果关于HTML5的最新成果和案例。

(4)Youtube HTML5 Beta(需翻墙)

YouTube上推出了HTML5视频试用,用户可以选择是否参加。如果用户使用的是受支持的浏览器,则可以选择使用HTML5播放器而不是Flash播放器播放大多数视频。

(5)Dive into HTML5 by Mark Pilgrim

这是一本Mark Pilgrim写的介绍HTML5的畅销书籍,内容包括关于HTML5你不得不知的5件事、HTML5的历史、HTML5包含的元素、视频演示以及更多的使用技巧等等。

(6)HTML 5 Cheat Sheet (PDF) – Smashing Magazine(关于HTML5资料的PDF文档精华 )

(7)HTML5 Rocks(需翻墙)

HTML5 Rocks的内容包括了HTML5的演示、视频、如何使用HTML5的API、基础进阶教程等等。

(8)World’s Biggest PacMan

用HTML5开发出的在全球畅销的经典游戏。

(9)HTML5 Gallery

这里汇集了用HTML5开发出的各种应用和演示。

(10)HTML5 Demos

全球开发者用HTML5开发出的示范案例和演示。

(11)W3Schools HTML5

在W3Schools HTML5,“私人教师”会向你介绍HTML5最新的特性以及如何应用它们。此外,(12)Gury (需翻墙)也是HTML5爱好者不可错过的。

Continue reading [转csdn文章]学习HTML5不可错过的12家国外网站(组图)

it-e-08 Real-Time Operating System

A "Real-Time Operating System" or "RTOS" is an operating system that has been
developed for real-time applications. Typically used for embedded applications. Note that this type of operating system does not necessarily have high throughput — the specialized scheduling algorithm and a high clock-interrupt rate can both interfere with throughput. An early example of a large-scale real-time operating system was the so-called "control program" developed by American Airlines and IBM for the Sabre Airline Reservations System. Debate exists about what actually constitutes real-time.
Scheduling

In typical designs, a task has three states: running, ready and blocked. Most tasks are blocked for most of the time. Only one task per CPU is running. The ready list is usually short, two or three tasks at most. The real trick is designing the scheduler. Usually the data structure of the ready list in the scheduler is designed so that search, insertion and deletion require locking interrupts only for small periods of time, when looking at precisely defined parts of the list. This means that other tasks can operate on the list asynchronously, while it is being searched. A typical successful schedule is a bidirectional linked list of ready tasks, sorted in order by priority. Although not fast to search, the time taken is deterministic. Most ready lists are only two or three entries long, so a sequential search is usually the fastest, because it requires little set-up time. The critical response time, sometimes called the "flyback time" is the time it takes to queue a new ready task, and restore the state of the highest priority task. In a well-designed RTOS, readying a new task will take 3-20 instructions per ready queue entry, and restoration of the highest-priority ready task will take 5-30 instructions. On a 20MHz 68,000 processor, task switch times run about 20 microseconds with two tasks ready. 100 MHz ARM CPUs switch in a few microseconds.

Continue reading it-e-08 Real-Time Operating System

Pagination


Total views.

© 2013 - 2020. All rights reserved.

Powered by Hydejack v6.6.1