1 / 3
Caption Text
2 / 3
Caption Two
3 / 3
Caption Three margin testing

Thursday, July 30, 2009

Create a Stunning Website with Flex Applications

Create a Stunning Website with Flex Applications

Published on: July 30th, 2009 12:05am by: netultimate

(OPENPRESS) July 30, 2009 -- Flex is a free, open source framework for building highly interactive web applications that deploy consistently on all major browsers, desktops, and operating systems. Flex creates SWF files that are rendered by Flash Player. Flex applications are delivered on the web via the Flash Player or to the desktop via Adobe AIR.

Apart from this, web developments are quite commonly known in the world of Internet. It is actually the development of various web applications to form a website and includes all the components that are required to precede with the task, like web designing and e-commerce, content development of a website, web server configuration and server-side/client-side coding.

Flex application development is a newly introduced term and may not be known by many. It basically relates to Adobe flex, which is the cross-platform, that is based on the Macromedia flash software, which is a development framework and a comprehensive application advancement tool. It is also a solution for the development and delivery of RIAs (Rich Internet Applications) within the enterprise and also throughout the web to enhance the interactivity for the Internet.

Benefits of using Flex on your website
Here are some reasons for deciding to put a Flex application on your website:

• To have a very robust application that attractively visualizes complex data sets
• To engage your users or visitors and let them feel empowered
• Flex is the technology the future - it shows your organization is modern
• It works on all major platforms and users don't need to install anything
• Audio and video can be integrated, allowing even greater interaction
• Data synchronization allows real-time data push from back-end to application

Developing a Flex application
Free open source Flex software is available but many serious developers like to use Adobe Flex Builder software for quick, professional development and maintenance of applications. If you don't have a Flex development expert in your team, outsourcing to specialist offshore Flex developer may be the solution.

Adobe Flex Builder 3 Professional offers all of the powerful features included Adobe Flex Builder 3 Standard plus powerful memory and performance profiling tools, the new Advanced Data grid, support for automated functional testing, and extensible charting components for rich data visualization.

ImgBurn - a lightweight CD / DVD / HD DVD / Blu-ray burning application

The Official ImgBurn Website

ImgBurn is a lightweight CD / DVD / HD DVD / Blu-ray burning application that everyone should have in their toolkit!

It has several 'Modes', each one for performing a different task:

  • Read - Read a disc to an image file
  • Build - Create an image file from files on your computer or network - or you can write the files directly to a disc
  • Write - Write an image file to a disc
  • Verify - Check a disc is 100% readable. Optionally, you can also have ImgBurn compare it against a given image file to ensure the actual data is correct
  • Discovery - Put your drive / media to the test! Used in combination with DVDInfoPro, you can check the quality of the burns your drive is producing
ImgBurn supports a wide range of image file formats - including BIN, CUE, DI, DVD, GI, IMG, ISO, MDS, NRG and PDI.

It can burn Audio CD's from any file type supported via DirectShow / ACM - including AAC, APE, FLAC, M4A, MP3, MP4, MPC, OGG, PCM, WAV, WMA and WV.

You can use it to build DVD Video discs (from a VIDEO_TS folder), HD DVD Video discs (from a HVDVD_TS folder) and Blu-ray Video discs (from a BDAV / BDMV folder) with ease.

It supports Unicode folder/file names, so you shouldn't run in to any problems if you're using an international character set.

ImgBurn supports all the Windows OS's - Windows 95, 98, Me, NT4, 2000, XP, 2003, Vista, 2008 and 7 (including all the 64-bit versions). If you use Wine, it should also run on Linux and other x86-based Unixes.

It's a very flexible application with several advanced features that are often lacking in other tools, especially when it comes to burning DVD Video discs. It supports all the latest drives without the need for updates (including booktype / bitsetting / advanced settings on many of the major ones - i.e. BenQ, LiteOn, LG, NEC, Plextor, Samsung, Sony).

There is an image queue system for when you're burning several images (which you can automatically share between multiple drives if you have more than one) and an easy-to-use layer break selection screen for double layer DVD Video jobs. The Automatic Write Speed feature allows you store your favourite burn speed settings on a per 'Media ID' basis, right down to a drive by drive level. Data captured during the burn (write speed, buffer levels etc) can be displayed / analysed using DVDInfoPro.

Whilst ImgBurn is designed to work perfectly straight out of the box, advanced users will appreciate just how configurable it is.

Oh and let's not forget the best thing about it.... it's 100% FREE ;-)

Wednesday, July 29, 2009

Games in Education

Games in Education: Information

2008 Resources:

U.C. Berkeley plans open source software for lecture distribution

U.C. Berkeley plans open source software for lecture distribution - San Francisco Business Times:
Tuesday, July 28, 2009, 11:35am PDT | Modified: Tuesday, July 28, 2009, 11:40am
San Francisco Business Times - by Steven E.F. Brown

The University of California, Berkeley, plans to set up an open source software project for widespread distribution of automatically made video and audio recordings of lectures and other events on campus.

Cal was the first university to put full-length videos of its lectures on YouTube in 2007. Audio podcasts of many of the school's lectures, like Marian Diamond's hugely popular introduction to human anatomy, have been available online for years.

The university has already spent $220,000 this year on this project, named "Opencast Matterhorn." Now grants totaling $1.5 million from the Andrew W. Mellon and William and Flora Hewlett foundations will cover that expense and pay for further development of the system.

Cal will work with ETH Zürich in Switzerland, the University of Osnabrück in Germany, Cambridge University in the United Kingdom and Canada's University of Saskatchewan on the project.

Money from these grants will pay for open source software that automates the recording and posting of academic content, cutting the cost of recording and uploading material. Cal says until now universities have been "stymied by high technical barriers and costs" even when they have wanted to distribute such content.

The software will be aimed at popular services like YouTube (based in San Bruno and owned by giant Google Inc.) and Apple Inc.'s online store, iTunes.

Adam Hochman is U.C. Berkeley's project manager for the program.

An open source system is in keeping with the university's traditions and its sense of its place as a public school, paid for by the public and doing research and teaching in the public interest. Many Cal researchers welcome questions from people who aren't students at the school, and reach out to them as part of their academic mission.

The university counts the open source Unix operating system, with its roots in Cal's 1970s research, as one of its achievements.

What the Microsoft-Yahoo-Bing Deal Means for You

What the Microsoft-Yahoo-Bing Deal Means for You - PC World
Todd R. Weiss
Jul 29, 2009 7:21 am

microsoft bing yahoo
So what's it mean for computer users now that Microsoft and Yahoo today finally are announcing their long-anticipated marriage of Microsoft's Bing search engine and Yahoo's premium search advertising tools? Will this change our lives?

microsoft bing yahooActually, I think this partnership will mean far more for Microsoft and Yahoo and their corporate balance sheets than it will for those of us who are technology consumers, and here's why.

1) Will search get better due to the deal between the two companies? Now I don't have a crystal ball, but I tried Bing, I played with Bing, I experienced Bing, but Bing, you're no Google search. Yes, it has some cool features, like bringing up found items in new and useful lists that are highly targeted for users, but there's this little problem that no amount of money and advertising can change -- people's habits. And my habit, like the habit of tens of millions of computer users around me, is to call up Google whenever and wherever I have to search, every time. It's like a mother's love -- it's there forever.

2) Will Yahoo go to the dogs now that it's linked itself in a partnership deal with the slow, hard-to-steer, behemoth known as Microsoft? I do think there are more risks for Yahoo here than there are for Microsoft. Remember when the huge cable TV conglomerate Time Warner Inc. merged with the original America Online (AOL) Internet provider back in 2000, thinking it was the wave of the future and all of humanity would follow in a sea of dollar signs and goodwill? And do you know where they are now? Time Warner is spinning off AOL, which has been struggling for years, as it continues to try to figure out just what to do with it. Before teaming with Time Warner, AOL was the king of the Internet, as we all clamored to have slow, software-laden Internet access at $2.99 an hour like the good consumer lemmings we were in those days. But then cheaper, faster access arrived with DSL, cable and all-you-can-use plans, but AOL and stodgy Time Warner couldn't react quickly enough. There's a lesson here. Bigger isn't always better. I read that in a fortune cookie. I could have saved Time Warner and AOL a lot of money if I'd have told them that. Hey, Microsoft and Yahoo, are you listening?

3) Are there privacy concerns I should be worried about from this deal? That depends on the fine print, and that we'll have to have to check carefully to be sure what Microsoft and Yahoo want to do with all the consumer data they'll be able to collect from our searches. This is already an issue with Google and other search engines as we continue to make our way through this still relatively new global Internet adventure. When we use "free" services like search on the Internet, whether through Google or Yahoo or Bing or whatever, there really is no "free." Someone somewhere is using the spoils of the search - our preferences about what we are looking for - for marketing, for potential revenue enhancement and to help them in their businesses. It's an acceptable risk to us as consumers only when we know what the rules are. Somehow, though, we usually don't ask what those rules are ahead of time. Maybe we should get that information up front this time.

4) Will this Microsoft-Yahoo partnership be enough to knock Google from its perch as the king of search for savvy consumers? I doubt it, and here's why - I just don't see Microsoft and Yahoo, even with the new Bing search engine as its mascot, coming anywhere near Google with the kinds of innovations that make us all excited and Googly. There's Google Earth. Could Microsoft or Yahoo have thought of that? And there's Google Voice. OK, it's still a fledgling effort, but it is interesting and innovative, and users are lining up early to try to get a Google invite to test it out and take it for a ride. What always amazes me is how the Google tech folks are always introducing fascinating new technologies that they can bring to users in ways that no one has else has yet imagined. OK, they haven't found an answer for world peace or the vaccine for swine flu yet, but you never know. I'm just not sure that Microsoft still has any of that kind of turn-on-a-dime mentality anymore. And that's why this partnership may not help search-loving consumers or Yahoo as much as the new partners believe it will.

(Todd R. Weiss is a freelance technology journalist who formerly wrote for Computerworld.com . Follow him on Twitter at www.twitter.com/TechManTalking )

Start Building Your Perfect Desktop with Samurize

Samurize.com - News

Samurize is an advanced system monitoring and desktop enhancement engine for Windows 2000/XP/2003/Vista. IT professionals, overclockers, gamers and desktop modders alike use Samurize for system information, weather reports, news headlines and much much more. And best of all, Samurize is 100% free!

Samurize's rich feature set includes:

• an unrivalled set of built-in meters (Disk utilization, CPU usage, network traffic, system temperatures...)
• ultimate customizing and skinning possibilities with no programming knowledge required
• monitoring your own computer or others over a network
• tiny memory footprint and CPU usage
• the first system monitoring tool with a true WYSIWYG editor
• full extensibility via scripts and plugins with a powerful plugin SDK/API
• minimal software requirements (no .NET or Service Packs necessary)
• multimonitor support
• many usage options (desktop, taskbar and clock clients, server outputting to XML or image formats, screensaver)

Samurize: The Only Limit Is Your Imagination.

Download Samurize Right Now! Start enjoying your desktop again! Download Samurize v1.64.3 Final

Tuesday, July 28, 2009

Open-Source Backers March on Washington

Open-Source Backers March on Washington - Bits Blog - NYTimes.com
July 23, 2009, 2:03 pm
By Ashlee Vance

Update | 7:43 p.m. Correcting spelling of Roger Burkhardt's name.

Look out, lobbyists: Here come the open-source zealots.

Policy and Law

Some of the world's largest technology companies have banded together in a bid to push open-source software on the United States government. They've formed a group called Open Source for America, which seeks to make sure that government agencies at least consider open-source software as an option in their buying decisions. The big, rather timely pitch behind this move is that open-source applications can help save the government money.

"The market for open-source software is growing dramatically, but there still needs to be education around understanding how to get the most out of it," said Roger Burkhardt, the chief executive of Ingres, a maker of an open-source database, who is on the Open Source for America board of advisers. "There are quirks to the government procurement process that need to be addressed."

Open-source companies often give away their base product and then charge customers for support and other services. This model, according to Mr. Burkhardt, can perplex government bodies used to buying software upfront. In addition, the group hopes to make sure that open-source software receives the necessary federal nods for use in things like drug approvals and high-security computing projects.

Some of the initial members of the organization include Google, Oracle, Red Hat, Advanced Micro Devices, Novell and Canonical. A host of smaller open-source software makers are involved as well.

The board of advisers is more or less a Who's Who of open-source advocates, including Eben Moglen, a prominent lawyer; Mark Shuttleworth, the chief executive of Canonical; Michael Tiemann, a vice president at Red Hat; and Jim Zemlin, the executive director of the Linux Foundation.

The government has aimed a large amount of its stimulus money at technology projects, and the open-source backers hope to get their fair share of that cash. More broadly, they would like the United States to follow countries in Europe and Asia with better defined guidelines around buying software.

The open-source "movement," if you will, continues to have some grass-roots momentum, with developers working without charge to improve projects like the Linux operating system and Mozilla Web browser. That said, large companies have come to dominate the open-source world. I.B.M., Google, Intel and others employ many of the best known open-source programmers and have made the software a key part of their internal operations as well as their business strategies.

Regardless of their affiliation, open-source types have demonstrated a fondness for backing free software in a vocal, often argumentative manner. They're sure to give the lobbyists working for proprietary software companies a run for their vocal cords and money.

OLPC software to power ageing PCs

BBC NEWS | Technology | OLPC software to power ageing PCs
Page last updated at 19:01 GMT, Wednesday, 24 June 2009 20:01 UK
XO laptop and Intel Classmate both running Sugar
Sugar runs on the XO and rival Intel Classmate PC

Software originally developed for the One Laptop per Child (OLPC) project can now be used on any old PC.

Sugar on a stick, as it is known, can be run from a USB drive to give ageing PCs a new interface and access to collaborative educational software.

The software, designed for use by children, was launched at the LinuxTag conference in Berlin.

It has been developed by Sugar Labs, a breakaway organisation from OLPC.

"[Sugar on a stick] is a great new opportunity to breathe new life into these old machines," Walter Bender, founder of Sugar Labs, told BBC News.

The release could dramatically increase the use of the free software, which has until now been predominantly distributed with the XO laptop, the machine sold be OLPC.

The child-friendly computers, originally marketed as the $100 (£60) laptop, currently cost $199 (£120) each. Sugar on a stick, however, can be used on any machine.

"It runs on Asus, Dell, HP - it runs on anything," said Mr Bender. "It even runs on phones."

It has already been shown working on an Intel Classmate PC, one of the main rivals to the OLPC machines.

Sweet release

Mr Bender was formerly second in command at OLPC. He left in April 2008 after it was announced that the low-cost laptops would be offering Microsoft Windows software.

Sugar on a stick
The software can be run from a 1GB USB stick

"I didn't leave OLPC because of the Microsoft deal - it was a symptom rather than the cause," he told BBC News at the time.

"I left OLPC because I think the most important thing it is doing is defining a learning ecosystem."

Mr Bender went on to found Sugar Labs, an independent effort to develop the software and interface used on the OLPC machines.

The interface emphasises collaborative learning, allowing children to share material between different machines. For example, they can write documents or make music together.

The open source software also contains a journal and automatically saves and backs up all data.

It has been used by more than one million children on the XO laptop and has also been released as part of other operating systems. For example, it was bundled with releases of the Ubuntu and Fedora Linux systems.

The latest release - Sugar on a Stick - allows anyone to run the software from a 1GB USB stick. It includes 40 programs, including a word processor, drawing application and games.

Mr Bender said the ability to transport the software and plug it into any computer would allow children to have a "consistent experience" wherever they worked.

"No matter what computer you have at home or at the library you're going to have the same use experience because you have sugar on a stick," he said.

The software can be downloaded for free from the Sugar Labs website.

It can be run on Linux machines, as well as Macs and Windows PCs. Recent Mac users and older Windows machines must use an additional "helper CD" to allow the computer to boot-up from the USB stick.

The software will also be used to power newer versions of the XO laptop, shipped in the autumn. However, the new machines will not use Sugar as the primary interface.

Instead, they will have a traditional desktop and allow children to run Sugar as a separate application.

"Our current belief is that Sugar should have always been on a stick," an OLPC spokesperson told BBC News. "In our case it should have been an application on top of a native Linux.

"We have been working on decoupling Sugar from our hardware since [Mr Bender] left."

Mr Bender said that the statement from OLPC was based on a misunderstanding by Nicholas Negroponte - head of OLPC - about how Sugar worked.

"What I think he meant was that Sugar should co-exist with traditional desktops," he told BBC News.

"Sugar always has and still does and will continue to do be able to co-exist with traditional desktops. He just never quite understood that."

Monday, July 27, 2009

Perl中三個使用=~ 符號的運算子

http://www.cyut.edu.tw/~ckhung/b/pl/idiom.ph

三個使用 =~ 符號的運算子

  1. $var =~ tr/.../.../; 把變數 $var 內的 ... 字元都逐一代換成 ... 字元 兩串 ... 通常長度一樣. 想成是查 "字元典" 翻譯。 (較不常用)
  2. $var =~ s/.../.../; 把變數 $var 內的第一個 ... 子字串整個代換成 ... 子字串。
  3. if ($var =~ m/.../) { ... } 詢問變數 $var 裡面有沒有 ... 這個子字串呢?

注意:

  1. 前兩項功能是破壞性的 (destructive), $var 的內容可能因而改變; 第三項是非破壞性的 (non-destructive)。
  2. 後兩項功能在現實生活中較常用到; 兩者都支援 regular expression
  3. 其實可以用其他標點符號來取代斜線, 只要一句話內前後一致就好。
  4. 其實第三項功能的 m 可以省略掉
  5. 如果 $var 是 $_ 則可以用簡寫, 把 $var =~ 全部省略掉。

代換字串 ... =~ s/.../.../ 時, 可以加上一些選項, 例如

i (ignore) 表示忽略大小寫 (比對成功的條件變得更寬鬆);
g (global) 表示全面代換, 不只代換第一個比對成功的子字串。

神奇的內定參數 $_

在很多場合下, 參數可以省略不寫, 而此時 perl 自動以 $_ 作為內定參數. 例如:

  1. 用 <FH> 從檔案讀入的一列, 自動存在 $_ 中.
  2. 許多運算子的參數, 例如 tr, s, m.
  3. 許多函數的參數, 例如 print, chomp, split, ...
  4. foreach 的 dummy variable.



Sunday, July 26, 2009

处理 UTF-8 编码文件时输出和写入乱码问题

解决处理 UTF-8 编码XML文件时,输出和写入乱码问题

以前用 Perl 处理 UTF-8 编码的 XML 文件时,总是遇到奇怪的问题:

单独输出读取的中文 XML 信息,没有问题,但是一旦和其他中文字符(比如定义的中文变量)混合输出就会出现乱码

eg:
$xml->{"chunk"}{"comment"} 包含了中文信息
my $cnstr="变量中的中文信息";

## 出现乱码
print $xml->{"chunk"}{"comment"} . $cnstr ;

## 正常
print $xml->{"chunk"}{"comment"};
print $cnstr;


仔细研究了下 UTF8 下中文处理 [转载]Perl中的unicode问题及解决办法(译),现在总算找到原因了:

UTF-8 编码的 XML 文件默认就含有 utf8 标记,而一般自定义的变量不含,两者混合输出时,Perl 会认为两者都不含或都含(看谁在前) utf8 标记,于是乱码就产生了。

解决办法:
读取 XML 文件后,用 Encode::_utf8_off($str) 来去掉 utf8 标记
写入 XML 文件前,用 Encode::_uft8_on($str) 加上 utf8 标记

如:
### 读取
$comment = $xml->{"chunk"}{"comment"};
Encode::_utf8_off($comment);
...

### 写入
$comment= param('comment'); ## 获取网页提交的信息
Encode::_utf8_on($comment);
$xml->{"chunk"}{"comment"} = $comment;
....

Perl笔记: UTF8下中文处理

Perl笔记: UTF8下中文处理

发信人: happierbee (吾生也有涯,而知也无涯), 信区: Perl
标 题: UTF8下中文处理
发信站: 水木社区 (Mon Sep 11 21:22:53 2006), 站内

我来总结一下吧。先建一个文件test.txt, 写上 中文 两个字。运行下面一个程序:

use strict;
use warnings;
use Encode;
my $str_code = "中文";
my $file = "test.txt";

open(my $fh, $file) || die "Can't open file $file: $!";
chomp(my $str_file = <$fh>);
close $fh;

open(my $fh_utf8, "<:utf8", $file) || die "Can't open file $file: $!";
chomp(my $str_fileu = <$fh_utf8>);
close $fh_utf8;

test_utf8($str_code, "code");
test_utf8($str_file, "file");
test_utf8($str_fileu, "file(utf8 layer)");
# print $str_code, "\n";
# print $str_file, "\n";
# print $str_fileu, "\n";

Encode::_utf8_on($str_code);
Encode::_utf8_on($str_file);
test_utf8($str_code, "code");
test_utf8($str_file, "file");

sub test_utf8 {
my ($str, $type) = @_;
if ( Encode::is_utf8($str) ) {
print "String from $type, utf8 flag is on."
} else {
print "String from $type, utf8 flag is off."
}
my @chars = split('', $str);
# print join("\t", @chars), "length: ", scalar(@chars);
if (scalar(@chars)==2) {
print " Can match chinese character.";
} else {
print " Can't match chinese character.";
}
print "\n";
}

结果如下:
String from code, utf8 flag is off. Can't match chinese character.
String from file, utf8 flag is off. Can't match chinese character.
String from file(utf8 layer), utf8 flag is on. Can match chinese character.
Turn on utf flag:
String from code, utf8 flag is on. Can match chinese character.
String from file, utf8 flag is on. Can match chinese character.

所以如果要想使用汉字作为一个字符的特性,就要在 open 里指明 io layer 为
utf8,同样,输出指明 utf8,然后在脚本里写 use utf8。
这样你就不用担心 utf8 下的乱码,又能享受汉字做为一个字符来写正则表达式的
的畅快。

如果不知道我上面说的意思,我就给一个例子:

use strict;
use warnings;
use Encode;
use utf8;

my $file = "test.txt";
my $outfile = "test-out.txt";

# open(my $fh, $file) || die "Can't open file $file: $!";
# open(my $out, '>:utf8', $outfile) || die "Can't open file $outfile: $!";

# select $out;

open(my $fh, '<:utf8', $file) || die "Can't open file $file: $!";

binmode STDOUT, ":utf8";

while (<$fh>) {

if (/[汉]/) {
unless (Encode::is_utf8($_)) {

Encode::_utf8_on($_);
}
print $_;

}

}

test.txt 中的内容是:"求\n汉\n汁\n汗\n汕\n江\n"(每个汉字一行的意思)。
这个例子中,有好几个组合:
1. 不使用 utf8 指令,open 中也不使用 utf8。
这时所有行都匹配。因为正则表达式中是三个字节(我假定你也用 utf8 来编码
代码,如果不是,可以不匹配任何行),而所有输入的行中都含有这三个字节中
的一个,事实上 test.txt 是我精心挑选的,前两个字节都相同的汉字。
2. 不使用 utf8 指令, open 中使用 utf8.
不能匹配任何行。因为输入文件中是汉字,而正则表达式是三个字节。
3. 使用 utf8 指令,open 中不使用 utf8
也不能匹配任何行。因为正则表达式中是一个汉字,而输入文件是一个个的字节。
4. 使用 utf8 指令,open 中也使用 utf8
正确匹配一行。

至于输出的 warning,这确实这是一个小小的 warning,不会影响结果。如果不
想有这个 warning,最好的办法是用 binmode 或者在 open 中指定使用 utf8
layer。或者对于 warning 的字符串用 Encode 模块中 _utf8_on 函数,强制
加上 utf8 flag.

perl 中文处理技巧

perl 中文处理技巧

Perl从5.6开始已经开始在内部使用utf8编码来表示字符,也就是说对中文以及其他语言字符的处理应该是完全没有问题的。我们只需要利用好Encode这个模块便能充分发挥Perl的utf8字符的优势了。

下面就以中文文本的处理为例进行说明,比如有一个字符串"测试文本",我们想要把这个中文字符串拆成单个字符,可以这样写:

use Encode;
$dat="测试文本";
$str=decode("gb2312",$dat);
@chars=split //,$str;
foreach $char (@chars) {
print encode("gb2312",$char),"\n";
}

结果大家试一试就知道了,应该是令人满意的。

这里主要用到了Encode模块的decode、encode函数。要了解这两个函数的作用我们需要清楚几个概念:
  1. Perl字符串是使用utf8编码的,它由Unicode字符组成而不是单个字节,每个utf8编码的Unicode字符占1~4个字节(变长)。
  2. 进入或离开Perl处理环境(比如输出到屏幕、读入和保存文件等等)时不是直接使用Perl字符串,而需要把Perl字符串转换成字节流,转换过程中使用何种编码方式完全取决于你(或者由Perl代劳)。一旦Perl字符串向字节流的编码完成,字符的概念就不存在了,变成了纯粹的字节组合,如何解释这些组合则是你自己的工作。

我们可以看出如果想要Perl按照我们的字符概念来对待文本,文本数据就需要一直用Perl字符串的形式存放。但是我们平时写出的每个字符一般都被作为纯ASCII字符保存(包括在程序中明文写出的字符串),也就是字节流的形式,这里就需要encode和decode函数的帮助了。

encode函数顾名思义是用来编码Perl字符串的。它将Perl字符串中的字符用指定的编码格式编码,最终转化为字节流的形式,因此和Perl处理环境之外的事物打交道经常需要它。其格式很简单:
$octets = encode(ENCODING, $string [, CHECK])
$string:  Perl字符串
encoding: 是给定的编码方式
$octets:  是编码之后的字节流
check:   表示转换时如何处理畸变字符(也就是Perl认不出来的字符)。一般不需使用
编码方式视语言环境的不同有很大变化,默认可以识别utf8、ascii、ascii-ctrl、 iso-8859-1等。

decode函数则是用来解码字节流的。它按照你给出的编码格式解释给定的字节流,将其转化为使用utf8编码的Perl字符串,一般来说从终端或者文件取得的文本数据都应该用decode转换为Perl字符串的形式。它的格式为:
$string = decode(ENCODING, $octets [, CHECK])
$string、ENCODING、$octets和CHECK的含义同上。

现在就很容易理解上面写的那段程序了。因为字符串是用明文写出的,存放的时候已经是字节流形式,丧失了本来的意义,所以首先就要用 decode函数将其转换为Perl字符串,由于汉字一般都用gb2312格式编码,这里decode也要使用gb2312编码格式。转换完成后Perl 对待字符的行为就和我们一样了,平时对字符串进行操作的函数基本上都能正确对字符进行处理,除了那些本来就把字符串当成一堆字节的函数(如vec、 pack、unpack等)。于是split就能把字符串切成单个字符了。最后由于在输出的时候不能直接使用utf8编码的字符串,还需要将切割后的字符用encode函数编码为gb2312格式的字节流,再用print输出。

Friday, July 24, 2009

Perl String Functions

String Functions

Perl provides a very useful set of string handling functions:

The first set of functions that we'll look at are those that deal with strings. These functions let you determine a string's length, search for a sub-string, and change the case of the characters in the string, among other things.

Here are Perl's string functions:

  • chomp(STRING) OR chomp(ARRAY) -- Uses the value of the $/ special variable to remove endings from STRING or each element of ARRAY. The line ending is only removed if it matches the current value of $/.
  • chop(STRING) OR chop(ARRAY)-- Removes the last character from a string or the last character from every element in an array. The last character chopped is returned.
  • chr(NUMBER) -- Returns the character represented by NUMBER in the ASCII table. For instance, chr(65) returns the letter A.
  • crypt(STRING1, STRING2) -- Encrypts STRING1. Unfortunately, Perl does not provide a decrypt function.
  • index(STRING, SUBSTRING, POSITION) -- Returns the position of the first occurrence of SUBSTRING in STRING at or after POSITION. If you don't specify POSITION, the search starts at the beginning of STRING.
  • join(STRING, ARRAY) -- Returns a string that consists of all of the elements of ARRAY joined together by STRING. For instance, join(">>", ("AA", "BB", "cc")) returns "AA>>BB>>cc".
  • lc(STRING) -- Returns a string with every letter of STRING in lowercase. For instance, lc("ABCD") returns "abcd".
  • lcfirst(STRING) -- Returns a string with the first letter of STRING in lowercase. For instance, lcfirst("ABCD") returns "aBCD".
  • length(STRING) -- Returns the length of STRING.
  • rindex(STRING, SUBSTRING, POSITION) -- Returns the position of the last occurrence of SUBSTRING in STRING at or after POSITION. If you don't specify POSITION, the search starts at the end of STRING.
  • split(PATTERN, STRING, LIMIT) -- Breaks up a string based on some delimiter. In an array context, it returns a list of the things that were found. In a scalar context, it returns the number of things found.
  • substr(STRING, OFFSET, LENGTH) -- Returns a portion of STRING as determined by the OFFSET and LENGTH parameters. If LENGTH is not specified, then everything from OFFSET to the end of STRING is returned. A negative OFFSET can be used to start from the right side of STRING.
  • uc(STRING) -- Returns a string with every letter of STRING in uppercase. For instance, uc("abcd") returns "ABCD".
  • Ucfirst(STRING) -- Returns a string with the first letter of STRING in uppercase. For instance, ucfirst("abcd") returns "Abcd".

Note As a general rule, if Perl sees a number where it expects a string, the number is quietly converted to a string without your needing to do anything.

Note Some of these functions use the special variable $_ as the default string to work with. More information about $_ can be found in Chapter on Files, and the Chapter Special Variables.

The next few sections demonstrate some of these functions. After seeing some of them work, you'll be able to use the rest of them.

Example: Changing a String's Value

Frequently, I find that I need to change part of a string's value, usually somewhere in the middle of the string. When this need arises, I turn to the substr() function. Normally, the substr() function returns a sub-string based on three parameters: the string to use, the position to start at, and the length of the string to return.

$firstVar = substr("0123BBB789", 4, 3);
print("firstVar = $firstVar\n");

This program prints:

firstVar = BBB

The substr() function starts at the fifth position and returns the next three characters. The returned string can be printed like in the above example, as an array element, for string concatention, or any of a hundred other options.

Things become more interesting when you put the substr() function on the left-hand side of the assignment statement. Then, you actually can assign a value to the string that substr() returns.

$firstVar = "0123BBB789"; substr($firstVar, 4, 3) = "AAA";
print("firstVar = $firstVar\n");

This program prints:

firstVar = 0123AAA789

Example: Searching a String

Another useful thing you can do with strings is search them to see if they have a given sub-string. For example if you have a full path name such as

"C:\\WINDOWS\TEMP\WSREWE.DAT",

you might need to extract the file name at the end of the path. You might do this by searching for the last backslash and then using substr() to return the sub-string.

Note The path name string has double backslashes to indicate to Perl that we really want a backslash in the string and not some other escape sequence, search.pl

$pathName = "C:\\WINDOWS\\TEMP\\WSREWE.DAT";
$position = rindex($pathName, "\\") + 1;
$fileName = substr($pathName, $position);
print("$fileName\n");

This program prints:

WSREWE.DAT

If the third parameter-the length-is not supplied to substr(), it simply returns the sub-string that starts at the position specified by the second parameter and continues until the end of the string specified by the first parameter.

Thursday, July 23, 2009

Adobe Releases Beta Text Layout Framework

Adobe Releases Beta Text Layout Framework
by Jennifer Farley

logo_flashplayerThis week, Adobe announced the beta release of the Text Layout Framework, an extensible library, built on the new text engine in Adobe Flash Player 10. This will allow developers and designers to use more sophisticated typography layouts in Web applications. The framework is intended for use with Adobe Flash CS4 Professional or Adobe Flex, and is included in the next version of Flex, code named Gumbo.

Layout

The Text Layout Framework delivers multi-lingual, print-quality typography for the web, including support for:

  • Bidirectional text, vertical text and over 30 writing systems including Arabic, Hebrew, Chinese, Japanese, Korean, Thai, Lao, the major writing systems of India, and others
  • Selection, editing and flowing text across multiple columns and linked containers, and around inline images
  • Vertical text, Tate-Chu-Yoko (horizontal within vertical text) and justifier for East Asian typography
  • Rich typographical controls, including kerning, ligatures, typographic case, digit case, digit width and discretionary hyphens
  • Cut, copy, paste, undo and standard keyboard and mouse gestures for editing
  • Rich developer APIs to manipulate text content, layout, markup and create custom text components

While this might be especially of interest to developers (because it looks like there is a bit of hard work behind the scenes to use it), for designers it means that online typography design is coming closer to what can be achieved in print. On the Adobe website you can test out eight examples of how you can manipulate and control text. Examples include working with columns, text effects, linked containers, ligatures and graphics. On first impression, the ability to work with text like this feels a little bit like InDesign "lite," which is very exciting if you love type and are frustrated with current limitations on the web. You can play with the examples here.

LayoutEffects

You can also try out the Text Editor Layout Demo
.
To see Text Layout Framework in action, some sites that are using the technology are the New York Times Reader demo, the Boston Globe Reader and Makebook.

Aspell and Kevin's English Word List

GNU Aspell is a Free and Open Source spell checker designed to eventually replace Ispell. It can either be used as a library or as an independent spell checker. Its main feature is that it does a superior job of suggesting possible replacements for a misspelled word than just about any other spell checker out there for the English language. Unlike Ispell, Aspell can also easily check documents in UTF-8 without having to use a special dictionary. Aspell will also do its best to respect the current locale setting. Other advantages over Ispell include support for using multiple dictionaries at once and intelligently handling personal dictionaries when more than one Aspell process is open at once.

Try it out for your self using the Aspell Spell Helper or see some Test Results Comparing Aspell with other spell checkers.

Kevin's Word List Page contains links to various Word Lists and related information. They are intended to be suitable for use in spell checkers. However, I am sure they will have numerous other uses as well.

Links to other General Word Lists

Links to Online Dictionaries

Links to Slang Word Lists and Dictionaries

Links to Specialty Word Lists and Dictionaries

Other Links

Wednesday, July 22, 2009

New Coalition To Promote OSS To Feds

Slashdot Linux Story | New Coalition To Promote OSS To Feds

"Red Hat, Mozilla, Novell, Oracle, and Sun are among the 50-plus member Open Source for America coalition that will be officially announced today by Tim O'Reilly at OSCON. The OSA will be a strong advocate for free and open source software, and plans to boost US Federal government support and adoption of FOSS. From their website: 'The mission of OSA is to educate decision makers in the US Federal government about the advantages of using free and open source software; to encourage the Federal agencies to give equal priority to procuring free and open source software in all of their procurement decisions; and generally provide an effective voice to the US Federal government on behalf of the open source software community, private industry, academia, and other non-profits.'"

Tuesday, July 21, 2009

Google Expert Tips: How to Find Anything Fast

Google Expert Tips: How to Find Anything Fast
July 21, 2009 10:30 AM ET

PC World - The nice people at Google have invented multiple ways to make their core product --Internet search--even better. The tips and tricks below will help you improve the precision of the search results Google provides--and use far fewer keystrokes to get them.

Get to know search operators: Google made its name by delivering powerful search results in response to queries of any level of sophistication, but learning to use Google's search operators can really hone your Google-fu. The Google Help Cheat Sheet rounds up some of the finest, such as define: (for quick dictionary lookups), site: (to return results from a specific Web site), and OR (as in 'pc OR world').

Convert nearly any measurement: Aside from working as a simple calculator, Google is also a great tool for converting units of measure. Need to know how many ounces are in a cup? Enter ounces in a cup in Google. Or try something exotic, like how many furlongs are in a league. Google can handle it.

Narrow down your results: Usually you can find what you're looking for on the first page of Google results, but if you need something very specific--say, a page that was published in the last 24 hours--click the new Show Options link above your search results. Among other features available is the interactive Wonder Wheel, a spidering graphical representation of queries related to yours.

Navigate results from your keyboard: Google's Experimental Search page is full of fun experiments from the search giant. One of the best is the Keyboard shortcuts experiment, which adds Gmail-like keyboard shortcuts to Google search results; for example, pressing 'j' or 'k' moves you up or down, respectively, between results.

Find a killer desktop wallpaper: Google Image Search is a familiar go-to resource for users seeking new wallpaper, but finding wallpaper that fits your desktop is much easier than you may realize. Go to the Google Advanced Image Search page, and click Use my desktop size link to automatically search for images that exactly fit your desktop dimensions.

Square your results: If you're a hardcore data nerd, give Google Squared a try. This new search tool returns results as structured data in a spreadsheet to help you get a bird's-eye view of the data contained in the results. Search for 'DSLR cameras', for example, to compare and contrast prices and resolutions for digital SLRs.

Developer's Choice: Quick Local Searches

"I'm really happy with how easy it is to use local search on Google. Just search for the kind of store you want--restaurants, for example. We guess your location, and show restaurants near you. It's one of my favorite of our lesser known search tips: www.google.com/landing/searchtips."

--Jim Muller, Google software engineer

国产MYSQL数据库开源备份利器—帝国备份王

占奇博客
作者:admin 发表时间:07月 - 21 - 2009 5 views

写博客的同学都知道,MYSQL数据库备份这项工作既十分麻烦但又非常重要。麻烦的是要在phpmyadmin上点击一大堆按钮。重要的是保证在你的主机提供商跑路的那一天,你手里还一分数据库备份。但是用phpmyadmin备份数据通常有下面几个缺点:
1、如果你的MYSQL数据库太大了,phpmyadmin将很难导出你的数据库;
2、备份的数据重新导入新的数据库后通常会出现编码乱码问题;
3、不同MYSQL版本数据不能互导问题,万一你的新空间和你的老空间MYSQL版本不同的话,你可能会很麻烦了。

然而这个三个大问题,都让国产的开源软件——帝国备份王给完美解决了,废话少说,下面教大家怎么在你的空间上安装《帝国备份王》:

第1步:上传程序包
点击这里下载帝国备份王安装包,解压。在你的空间的根目录建立一个backup文件夹。将安装包的 upload 目录中的"全部文件和目录"全部上传到backup文件夹。

第2步:设置服务器777属性
设置目录属性您在正式使用以前,需要设置相关的目录属性,以便数据文件可以被《帝国备份王》正确的读写。使用 FTP 软件登录您的服务器,将服务器backup文件夹里的以下文件或目录属性设置为 777,见下:
目录文件名称
说明
bdata 备份目录
bdata/safemod 安全模式下数据备份目录
class/config.php 配置文件
setsave 保存设置目录
setsave/def 默认备份设置文件
zip 压缩包存放目录
tmp 临时文件目录

第3步:登陆后台
在浏览器中访问 http://您的域名/backup/index.php,就可以安装成功并可以立即访问后台了。
(后台默认的管理员帐号与密码分别为:admin , 123456)
登陆后自己修改帐号密码与数据库设置即可完成安装。

错误纠正:安装的过程中,如果你的空间没有开启"short-tag"支持的话,会出错,请开启这个服务。

后台使用说明
登录后台后即可轻松使用轻松备份和恢复数据
1.备份数据:备份数据 -> 选择备份的数据库 -> 选择备份的表与设定备份参数 -> 备份完毕
2.恢复数据:恢复数据 -> 选择恢复源目录,数据库 -> 恢复完毕
3.下载备份文件:下载备份目录下相应的备份目录即可。默认的备份目录为"bdata"。(对于文件少的也可直接到"管理备份目录"打包下载)

相关信息和演示
帝国备份王官方网站:http://www.phome.net/
本人安装成功的帝国备份王:http://zhanqi.s202.xrea.com/backup/index.php

Monday, July 20, 2009

Offisync - Using Google Docs from MS Office 2007



The idea behind OffiSync

The idea to build OffiSync came to me when I was told that many Google Docs and Google Apps users also use Microsoft Office.

I decided to learn more about why would people use both products at the same time? Why not switch from the expensive Microsoft Office to the free / Cheap Google Docs / Google Apps alternative?

So I started asking around, I talked to a Gartner analyst, a general manager in a fortune 500 company, a good friend that is a CEO of a start up company and about a dozen other users who all gave me more or less the same answer:

"We like using Office for content creation and editing, but then, when we need to collaborate with others we upload the document to Google Docs so we can work with others and see changes and edits in real time. We also like keeping the files online so we can access them when we are not in front of our own computer"

So I decided to try it myself and do the same. It is then that I realized 2 very important facts:
- Google Docs is an amazing service
- Working with Office and Google docs in the scenario mentioned above seemed to almost be impossible and was very cumbersome. It took so much time to take a file I created in PowerPoint or Word and make it available online so I could collaborate with my co-workers....

So being an adventurous person, I decided to solve the problem for myself and for all those who use both Microsoft Office and Google docs and started OffiSync.

The idea we had when we started was very simple: enable users to keep using the leading desktop productivity suite, MS Office, and super charge it with the online and collaborative power of Google. We envisioned the integration between Office and Google Docs to feel very natural and almost as if they came from the same vendor.

So that's what we did....

Once you install OffiSync, you will get a tight integration between Office and Google Docs that will help you do the following:

* Save your Office files on Google docs just as if you were saving them locally. From that moment, you can access them from any computer using the browser only OR use Office to access those files when you use your own computer, just as if they were stored locally
* Use Google Search, integrated into the OffiSync toolbar, to find your documents in seconds (I love this feature!! )
* Share and collaborate with others by combining Office and Google Docs collaboration features. OffiSync will let you save a document online and add collaborators right from within the Office toolbar.


But then I started thinking, why stop here, why not build more "google features into MS Office" and that became the longer term plan for this product. We are now working to put more Google features such as Google maps integration, Google images and Google App Engine to make some magic with Office.

Let us know what you think! contact@offisync.com

You can also follow us on www.twitter.com/offisync
Posted by Oudi Antebi at 12:11 PM 16 comments

Saturday, July 18, 2009

The grand Google plan against the whole Microsoft stack

ZDNet July 15th, 2009

Posted by Dana Blankenhorn @ 7:17 am

With its release of a NeatX server, however buggy and primitive it may be, Google has signaled its effort to go after the entire Microsoft software stack.

Critics may call this more of a Grand Guignol plan, a horror show meant only to immunize both Google and Microsoft from antitrust scrutiny, but it’s a mistake to confuse investment size and intent. In the end Grand Guignol was only a puppet theater.

This looks as serious as a heart attack

With NeatX in the enterprise, Chrome OS on the desktop and Android in the hand, Google is challenging the whole relationship between client and server, offering what might be called a client and cloud paradigm.

As Google’s blog notes, NeatX is an X Window implementation originally created by No Machine of Italy under the GPL in 2003. The No Machine business model included a proprietary server. NeatX is an open source alternative, also offered under GPL V2.

In a client-server environment, PCs on the desk are networked to servers in the back office. The server manages the clients, but it’s still pretty complex and expensive.

In the client-cloud paradigm, all complexity is stripped-out and the server work is farmed-out to the cloud. It costs less, a lot less, but is it secure and reliable? Would you trust your business to it? How about your life? Your privacy?

This is the question Google must answer, at all levels of its stack. Functions must be balanced, between what’s on your desk, your lap, or in your hand, and what’s synced to the cloud. The cloud must also provide a host of software and services we presently assume will remain totally under our personal control. That control must be guaranteed.

There is much to be done, but even at the start the vision seems clear.

Dana BlankenhornDana Blankenhorn has been a business journalist for 30 years, a tech freelancer since 1983. You can follow Dana on Twitter. See his full profile and disclosure of his industry affiliations.

Friday, July 17, 2009

Microsoft, Google Take Aim at Each Other


16 July 2009

This is the VOA Special English Economics Report.

Google, the Internet search leader, will now offer a free operating system for personal computers. The company hopes to loosen Microsoft's hold on the market. Microsoft Windows is on more than ninety percent of PCs.

Google is basing the new product on its Chrome Web browser and the Linux open-source operating system. The Google Chrome OS is expected to be available in the second half of next year.

At first, it will be aimed at netbooks. These are smaller, simpler machines designed mainly for Internet use.

Google CEO Eric Schmidt, left, and Microsoft Chairman Bill Gates laughing together at a media conference in Idaho earlier this month
Google CEO Eric Schmidt, left, and Microsoft Chairman Bill Gates laughing together at a media conference in Idaho earlier this month
Google's chief executive, Eric Schmidt, says Chrome will pay for itself. It will do that, he says, by reducing the cost of computers and increasing the number of people who search the Internet. Google earns most of its money from sales of advertising on its search engine.

But the recession has hurt the advertising market. And now Microsoft has targeted Google's main business. Microsoft says its new Bing search engine offers a better way to search the Internet. Ads for it make fun of how Web searches often give people a lot of useless results.

COMMERCIAL: "Find a cure at bing.com. It's not just a search engine. It's the first-ever decision engine. From Microsoft."

A Web traffic report last Friday from StatCounter said Bing twice passed Yahoo in usage in the United States in its first few weeks. Yahoo is the second biggest search engine.

But no one has the answer to how much market share Bing will claim from Yahoo or Google in the long term. Microsoft, in its struggle against Google, tried unsuccessfully last year to buy Yahoo for more than forty billion dollars.

Google and Microsoft are also competing in business software. Google offers Google Docs. These applications are free and on the Web. They compete with Microsoft Office, a hugely popular product. Next year, Microsoft plans a new version of Office that is both Web-based and free.

Also, Microsoft plans to launch its seventh version of Windows this October. And the company is preparing to open its own stores, like its competitor Apple. In fact, some Microsoft stores could open right next to Apple stores in the coming months.

The recession has cut sales of PCs and software. But there may be hopeful signs for the industry. Intel is the leading maker of computer processors. This week Intel reported that its results for the past three months were better than expected. And it predicted more good news in the current quarter.

And that's the VOA Special English Economics Report, written by Mario Ritter. Transcripts and MP3s are at voaspecialenglish.com. I'm Steve Ember.

Thursday, July 16, 2009

MySQL Commands

Posted on 07-25-2007 00:13:00 UTC | Updated on 01-23-2009 16:29:23 UTC
Section: /software/mysql/ | Permanent Link

This is a list of handy MySQL commands that I use time and time again. At the bottom are statements, clauses, and functions you can use in MySQL. Below that are PHP and Perl API functions you can use to interface with MySQL. To use those you will need to build PHP with MySQL functionality. To use MySQL with Perl you will need to use the Perl modules DBI and DBD::mysql.

Below when you see # it means from the unix shell. When you see mysql> it means from a MySQL prompt after logging into MySQL.

To login (from unix shell) use -h only if needed.

# [mysql dir]/bin/mysql -h hostname -u root -p

Create a database on the sql server.

mysql> create database [databasename];

List all databases on the sql server.

mysql> show databases;

Switch to a database.

mysql> use [db name];

To see all the tables in the db.

mysql> show tables;

To see database's field formats.

mysql> describe [table name];

To delete a db.

mysql> drop database [database name];

To delete a table.

mysql> drop table [table name];

Show all data in a table.

mysql> SELECT * FROM [table name];

Returns the columns and column information pertaining to the designated table.

mysql> show columns from [table name];

Show certain selected rows with the value "whatever".

mysql> SELECT * FROM [table name] WHERE [field name] = "whatever";

Show all records containing the name "Bob" AND the phone number '3444444'.

mysql> SELECT * FROM [table name] WHERE name = "Bob" AND phone_number = '3444444';

Show all records not containing the name "Bob" AND the phone number '3444444' order by the phone_number field.

mysql> SELECT * FROM [table name] WHERE name != "Bob" AND phone_number = '3444444' order by phone_number;

Show all records starting with the letters 'bob' AND the phone number '3444444'.

mysql> SELECT * FROM [table name] WHERE name like "Bob%" AND phone_number = '3444444';

Show all records starting with the letters 'bob' AND the phone number '3444444' limit to records 1 through 5.

mysql> SELECT * FROM [table name] WHERE name like "Bob%" AND phone_number = '3444444' limit 1,5;

Use a regular expression to find records. Use "REGEXP BINARY" to force case-sensitivity. This finds any record beginning with a.

mysql> SELECT * FROM [table name] WHERE rec RLIKE "^a";

Show unique records.

mysql> SELECT DISTINCT [column name] FROM [table name];

Show selected records sorted in an ascending (asc) or descending (desc).

mysql> SELECT [col1],[col2] FROM [table name] ORDER BY [col2] DESC;

Return number of rows.

mysql> SELECT COUNT(*) FROM [table name];

Sum column.

mysql> SELECT SUM(*) FROM [table name];

Join tables on common columns.

mysql> select lookup.illustrationid, lookup.personid,person.birthday from lookup left join person on lookup.personid=person.personid=statement to join birthday in person table with primary illustration id;

Creating a new user. Login as root. Switch to the MySQL db. Make the user. Update privs.

# mysql -u root -p
mysql> use mysql;
mysql> INSERT INTO user (Host,User,Password) VALUES('%','username',PASSWORD('password'));
mysql> flush privileges;

Change a users password from unix shell.

# [mysql dir]/bin/mysqladmin -u username -h hostname.blah.org -p password 'new-password'

Change a users password from MySQL prompt. Login as root. Set the password. Update privs.

# mysql -u root -p
mysql> SET PASSWORD FOR 'user'@'hostname' = PASSWORD('passwordhere');
mysql> flush privileges;

Recover a MySQL root password. Stop the MySQL server process. Start again with no grant tables. Login to MySQL as root. Set new password. Exit MySQL and restart MySQL server.

# /etc/init.d/mysql stop
# mysqld_safe --skip-grant-tables &
# mysql -u root
mysql> use mysql;
mysql> update user set password=PASSWORD("newrootpassword") where User='root';
mysql> flush privileges;
mysql> quit
# /etc/init.d/mysql stop
# /etc/init.d/mysql start

Set a root password if there is on root password.

# mysqladmin -u root password newpassword

Update a root password.

# mysqladmin -u root -p oldpassword newpassword

Allow the user "bob" to connect to the server from localhost using the password "passwd". Login as root. Switch to the MySQL db. Give privs. Update privs.

# mysql -u root -p
mysql> use mysql;
mysql> grant usage on *.* to bob@localhost identified by 'passwd';
mysql> flush privileges;

Give user privilages for a db. Login as root. Switch to the MySQL db. Grant privs. Update privs.

# mysql -u root -p
mysql> use mysql;
mysql> INSERT INTO user (Host,Db,User,Select_priv,Insert_priv,Update_priv,Delete_priv,Create_priv,Drop_priv) VALUES ('%','databasename','username','Y','Y','Y','Y','Y','N');
mysql> flush privileges;

or

mysql> grant all privileges on databasename.* to username@localhost;
mysql> flush privileges;

To update info already in a table.

mysql> UPDATE [table name] SET Select_priv = 'Y',Insert_priv = 'Y',Update_priv = 'Y' where [field name] = 'user';

Delete a row(s) from a table.

mysql> DELETE from [table name] where [field name] = 'whatever';

Update database permissions/privilages.

mysql> flush privileges;

Delete a column.

mysql> alter table [table name] drop column [column name];

Add a new column to db.

mysql> alter table [table name] add column [new column name] varchar (20);

Change column name.

mysql> alter table [table name] change [old column name] [new column name] varchar (50);

Make a unique column so you get no dupes.

mysql> alter table [table name] add unique ([column name]);

Make a column bigger.

mysql> alter table [table name] modify [column name] VARCHAR(3);

Delete unique from table.

mysql> alter table [table name] drop index [colmn name];

Load a CSV file into a table.

mysql> LOAD DATA INFILE '/tmp/filename.csv' replace INTO TABLE [table name] FIELDS TERMINATED BY ',' LINES TERMINATED BY '\n' (field1,field2,field3);

Dump all databases for backup. Backup file is sql commands to recreate all db's.

# [mysql dir]/bin/mysqldump -u root -ppassword --opt >/tmp/alldatabases.sql

Dump one database for backup.

# [mysql dir]/bin/mysqldump -u username -ppassword --databases databasename >/tmp/databasename.sql

Dump a table from a database.

# [mysql dir]/bin/mysqldump -c -u username -ppassword databasename tablename > /tmp/databasename.tablename.sql

Restore database (or database table) from backup.

# [mysql dir]/bin/mysql -u username -ppassword databasename < /tmp/databasename.sql

Create Table Example 1.

mysql> CREATE TABLE [table name] (firstname VARCHAR(20), middleinitial VARCHAR(3), lastname VARCHAR(35),suffix VARCHAR(3),officeid VARCHAR(10),userid VARCHAR(15),username VARCHAR(8),email VARCHAR(35),phone VARCHAR(25), groups VARCHAR(15),datestamp DATE,timestamp time,pgpemail VARCHAR(255));

Create Table Example 2.

mysql> create table [table name] (personid int(50) not null auto_increment primary key,firstname varchar(35),middlename varchar(50),lastnamevarchar(50) default 'bato');



MYSQL Statements and clauses

ALTER DATABASE ALTER TABLE ALTER VIEW ANALYZE TABLE BACKUP TABLE CACHE INDEX CHANGE MASTER TO CHECK TABLE CHECKSUM TABLE COMMIT CREATE DATABASE CREATE INDEX CREATE TABLE CREATE VIEW DELETE DESCRIBE DO DROP DATABASE DROP INDEX DROP TABLE DROP USER DROP VIEW EXPLAIN FLUSH GRANT HANDLER INSERT JOIN KILL LOAD DATA FROM MASTER LOAD DATA INFILE LOAD INDEX INTO CACHE LOAD TABLE...FROM MASTER LOCK TABLES OPTIMIZE TABLE PURGE MASTER LOGS RENAME TABLE REPAIR TABLE REPLACE RESET RESET MASTER RESET SLAVE RESTORE TABLE REVOKE ROLLBACK ROLLBACK TO SAVEPOINT SAVEPOINT SELECT SET SET PASSWORD SET SQL_LOG_BIN SET TRANSACTION SHOW BINLOG EVENTS SHOW CHARACTER SET SHOW COLLATION SHOW COLUMNS SHOW CREATE DATABASE SHOW CREATE TABLE SHOW CREATE VIEW SHOW DATABASES SHOW ENGINES SHOW ERRORS SHOW GRANTS SHOW INDEX SHOW INNODB STATUS SHOW LOGS SHOW MASTER LOGS SHOW MASTER STATUS SHOW PRIVILEGES SHOW PROCESSLIST SHOW SLAVE HOSTS SHOW SLAVE STATUS SHOW STATUS SHOW TABLE STATUS SHOW TABLES SHOW VARIABLES SHOW WARNINGS START SLAVE START TRANSACTION STOP SLAVE TRUNCATE TABLE UNION UNLOCK TABLES USE

String Functions

AES_DECRYPT AES_ENCRYPT ASCII BIN BINARY BIT_LENGTH CHAR CHAR_LENGTH CHARACTER_LENGTH COMPRESS CONCAT CONCAT_WS CONV DECODE DES_DECRYPT DES_ENCRYPT ELT ENCODE ENCRYPT EXPORT_SET FIELD FIND_IN_SET HEX INET_ATON INET_NTOA INSERT INSTR LCASE LEFT LENGTH LOAD_FILE LOCATE LOWER LPAD LTRIM MAKE_SET MATCH AGAINST MD5 MID OCT OCTET_LENGTH OLD_PASSWORD ORD PASSWORD POSITION QUOTE REPEAT REPLACE REVERSE RIGHT RPAD RTRIM SHA SHA1 SOUNDEX SPACE STRCMP SUBSTRING SUBSTRING_INDEX TRIM UCASE UNCOMPRESS UNCOMPRESSED_LENGTH UNHEX UPPER

Date and Time Functions

ADDDATE ADDTIME CONVERT_TZ CURDATE CURRENT_DATE CURRENT_TIME CURRENT_TIMESTAMP CURTIME DATE DATE_ADD DATE_FORMAT DATE_SUB DATEDIFF DAY DAYNAME DAYOFMONTH DAYOFWEEK DAYOFYEAR EXTRACT FROM_DAYS FROM_UNIXTIME GET_FORMAT HOUR LAST_DAY LOCALTIME LOCALTIMESTAMP MAKEDATE MAKETIME MICROSECOND MINUTE MONTH MONTHNAME NOW PERIOD_ADD PERIOD_DIFF QUARTER SEC_TO_TIME SECOND STR_TO_DATE SUBDATE SUBTIME SYSDATE TIME TIMEDIFF TIMESTAMP TIMESTAMPDIFF TIMESTAMPADD TIME_FORMAT TIME_TO_SEC TO_DAYS UNIX_TIMESTAMP UTC_DATE UTC_TIME UTC_TIMESTAMP WEEK WEEKDAY WEEKOFYEAR YEAR YEARWEEK

Mathematical and Aggregate Functions

ABS ACOS ASIN ATAN ATAN2 AVG BIT_AND BIT_OR BIT_XOR CEIL CEILING COS COT COUNT CRC32 DEGREES EXP FLOOR FORMAT GREATEST GROUP_CONCAT LEAST LN LOG LOG2 LOG10 MAX MIN MOD PI POW POWER RADIANS RAND ROUND SIGN SIN SQRT STD STDDEV SUM TAN TRUNCATE VARIANCE

Flow Control Functions

CASE IF IFNULL NULLIF

Command-Line Utilities

comp_err isamchk make_binary_distribution msql2mysql my_print_defaults myisamchk myisamlog myisampack mysqlaccess mysqladmin mysqlbinlog mysqlbug mysqlcheck mysqldump mysqldumpslow mysqlhotcopy mysqlimport mysqlshow perror

Perl API - using functions and methods built into the Perl DBI with MySQL

available_drivers begin_work bind_col bind_columns bind_param bind_param_array bind_param_inout can clone column_info commit connect connect_cached data_sources disconnect do dump_results err errstr execute execute_array execute_for_fetch fetch fetchall_arrayref fetchall_hashref fetchrow_array fetchrow_arrayref fetchrow_hashref finish foreign_key_info func get_info installed_versions last_insert_id looks_like_number neat neat_list parse_dsn parse_trace_flag parse_trace_flags ping prepare prepare_cached primary_key primary_key_info quote quote_identifier rollback rows selectall_arrayref selectall_hashref selectcol_arrayref selectrow_array selectrow_arrayref selectrow_hashref set_err state table_info table_info_all tables trace trace_msg type_info type_info_all Attributes for Handles

PHP API - using functions built into PHP with MySQL

mysql_affected_rows mysql_change_user mysql_client_encoding mysql_close mysql_connect mysql_create_db mysql_data_seek mysql_db_name mysql_db_query mysql_drop_db mysql_errno mysql_error mysql_escape_string mysql_fetch_array mysql_fetch_assoc mysql_fetch_field mysql_fetch_lengths mysql_fetch_object mysql_fetch_row mysql_field_flags mysql_field_len mysql_field_name mysql_field_seek mysql_field_table mysql_field_type mysql_free_result mysql_get_client_info mysql_get_host_info mysql_get_proto_info mysql_get_server_info mysql_info mysql_insert_id mysql_list_dbs mysql_list_fields mysql_list_processes mysql_list_tables mysql_num_fields mysql_num_rows mysql_pconnect mysql_ping mysql_query mysql_real_escape_string mysql_result mysql_select_db mysql_stat mysql_tablename mysql_thread_id mysql_unbuffered_query

Related stories

Tuesday, July 14, 2009

Computers and Eye Strain

Computers and Eye Strain
July 13, 2009

Do you find yourself squinting more? Maybe you are having more difficulty driving at night? Do your eyes get irritated or drier than usual? It could be how you are looking at the computer. Our eyes were designed for hunting or looking at long distances. Now with computers in schools, homes, laps and video games and iPods, more people are staring at smaller and smaller screens in wrong lighting and incorrect positions. You can relieve some of this strain yourself.

Position Screen
The computer or video screen should be slightly below eye level (about 20 degrees). Now with laptops, it is easy to place your computer on your lap which makes it way below eye level. Use a lap pillow or position yourself so the screen is no more than 30 degrees velow eye level.

Use Good lighting
Avoid working in rooms that are dark or too dim. Use an adjustable table lamp that can be aimed by you without causing screen reflections. Eliminate glare and screen reflections by moving or tilting the computer or getting an anti-glare screen. Try not to face toward windows or bright light source. Make sure the light in the room is about equal to the brightness of the display. Movie theaters are okay because the huge screen fills up the room with light.

Adjust Brightness
Viewing a dark screen is better than a bright, white screen. If you are staring at a white background, adjust the screen brightness and contrast so it is not as bright. Try searching with Blackle instead of Google. Search results are the same. You might want to clean your screen regularly since screens attract dust.

Take Breaks
If you spend hours starting at a computer or play video games, try to take a break every 20 minutes. Set a timer using an online stopwatch. Computer use results in a decrease in blinking to almost one third of normal. Stop occasionally and blink. Look away from the monitor at least 20 minutes but if you can it is even better to look away every 10 minutes.

Do Eye Exercises
Close your eyes tightly for 5 seconds and then open them. Repeat this 5 or 6 times every 10-20 minutes. This will relieve some of your strain. You can even use a warm washcloth lightly pressed to your eyes. Don't rub your eyes too hard because it can break blood vessels. And like I wrote in the last paragraph, blink. During your break, focus on something far away for a minute or two.

eyestrain1

Consider Using Reading Glasses
Even if you have prescription glasses, your prescription may not work for the computer. Position yourself at least 15 inches away from the screen and try different readers. If you have to strain with or without your prescription glasses, you can try some fun readers that help you read small text and sit farther away from the screen.

Make Text Bigger
You can increase the text size on any web page. Some sites give you the option with A AA. If they don't have that option, you can increase the size yourself by pressing Ctrl - + (add) once or more times depending on the size you want the text. To make it smaller, press Ctrl - - (subtract).

Resources
Cartoons on Eye Strain (copyrighted)
http://www.cartoonstock.com/directory/e/eye-strain.asp

How to relieve eye strain
http://www.visionworksusa.com/computereyestrain.htm

Home remedies for eye strain
http://www.nativeremedies.com/ailment/eye-strain-symptoms.html

Barbara Bray, barbara@my-ecoach.com http://my-ecoach.com Blog: http://barbarabray.my-ecoach.com

Featured Post

Windows和Ubuntu双系统完全独立的安装方法

http://www.ubuntuhome.com/windows-and-ubuntu-install.html  | Ubuntu Home Posted by Snow on 2012/06/25 安装Windows和Ubuntu双系统时,很多人喜欢先安装windows,然...