坚信科学,分享技术

perl笔记

[文章作者:陈臻 本文版本:v1.2 最后修改:2008.11.5 转载请注明原文链接:http://www.54chen.com/c/75] 系统学习perl,基础问题复习期间,先提问题,再回答 1.@和$和%以及&的区别是什么? @=== 在数组名前加@(后没有中括号)来引用整个数; $=== 标量变量可以存放一个标量值。标量变量的名字由一个美圆符号($)后接Perl 标识符:由字母或下划线开头,后接字母,数字,或者下划线。或者说由字母,数字和下划线组成,但不能由数字开头。大小写是严格区分的:变量$Fred 和变量$fred是不同的; %=== 要引用整个hash,使用百分号(“%”)作为前缀。 %some_hash = (“foo”, 35, “bar”, 12.4, 2.5, “hello”, “wilma”, 1.72e30, “betty”, “bye\n”); my %last_name = ( “fred” => “flintstone”, “dino” => undef, “barney”=> “rubble”; “betty”=> “rubble”, ); &=== 可以使用子程序的名字(前面带&)来调用子程序. 2.qw()做什么用的? qw 表示“quoted words”或者“quoted by whitespace”,作用是将一串包含空格的字符串以空格拆分为字符列表。 3.两种上下文环境分别是? 标量和列表上下文 4.$_等默认的变量名都有哪些及用处? $_---------------- 如果在fo

Continue reading

Posted in 生活备份 | 2 Comments

[中秋零献续集] 神州数码802.1x局域网UDP拔号软件MyNet-Gnome源代码大分析(Part4)getaccess线程内的故事

/*** * Author: cc0cc * E-mail: cc0cc@126.com * WebSite: http://www.54chen.com * Date: 11 01 2008 * FileName: Mythread.c * 这个文件要从Access_Thread看起,因为在上一章节里,我们了解了 pthread_create(&getaccess,NULL,Access_Thread,NULL);创建了一个叫getaccess的线程,正是运行的Access_Thread,在Access_Thread里,将完成一系列的过程,802.1x从这里才真正开始了。 ***/ #include <gnome.h> #include <sys/select.h> #include "Mythread.h" #include "connect.h" #include "support.h" #include "interface.h" int i=0; typedef struct{                   long    tv_sec;                           long    tv_uec;                      }timeval;             gint keeplink(gpointer data) { pthread_t keeptest;     fd_set readfds;     timeval timeout={5,0};//设置超时     BYTE

Continue reading

Posted in linux | Tagged , , | Leave a comment

[中秋零献] 神州数码802.1x局域网UDP拔号软件MyNet-Gnome源代码大分析(Part3)关键逻辑

/*** * Author: cc0cc * E-mail: cc0cc@126.com * WebSite: http://www.54chen.com * Date: the Mid-Autumn Festival of 2008 * FileName: callbacks.c * Description: callbacks.c为事件处理的核心逻辑,是MyNet的中心 ***/ #ifdef HAVE_CONFIG_H # include <config.h> #endif #include <gnome.h> #include "Mythread.h" #include "connect.h" #include "callbacks.h" #include "interface.h" #include "support.h" gchar line2[255];//用来存去掉回车后的字符串 void write_config(gchar *usr,gchar *pwd);//remember pwd void write_new_config();//first time to write config gchar * scape(gchar *line);//escapse the enter like '\n' /* * 关于mac和ip的:http://hi.baidu.com/cc0cc/blog/item/403cbb25a0cd9a6435a80fa7.html */ char *get_mac();//return the mac

Continue reading

Posted in linux | Tagged , | Leave a comment

[中秋零献] 神州数码802.1x局域网UDP拔号软件MyNet-Gnome源代码大分析(Part2)

/*** * Author: cc0cc * E-mail: cc0cc@126.com * WebSite: http://www.54chen.com * Date: the Mid-Autumn Festival of 2008 * FileName: main.c ***/ /* * Initial main.c file generated by Glade. Edit as required. * Glade will not overwrite this file. */ #ifdef HAVE_CONFIG_H # include <config.h> #endif #include <stdio.h> #include <gtk/gtk.h> #include <pthread.h> #include <gnome.h> /*如果没记错的话eggtrayicon.h/tray.h都是在Linux用来做系统托盘的头文件,参见 *http://hi.baidu.com/cc0cc/blog/item/26da147a4a428ce92f73b3da.html */ #include "eggtrayicon.h" #include "tray.h" #include "interface.h" #include "support.h" #include "connect.h" /*系统托盘*/ static void activate_action (GtkAction * action); stati

Continue reading

Posted in linux, php | Tagged , , , | Leave a comment

[中秋零献] 神州数码802.1x局域网UDP拔号软件MyNet-Gnome源代码大分析(Part1)

/*** * Author: cc0cc * E-mail: cc0cc@126.com * WebSite: http://www.54chen.com * Date: the Mid-Autumn Festival of 2008 ***/ 概要:这个软件是三年前的时候在学校里写的,主要目的是给广大的Linuxers一个上网的机会,不过后来在我推出后官方又出了个Linux下的拔号二进制包。 PS:神州数码的局域网拔号软件在各大高校使用很多,有不少小区也是,一般官方发布的会有一定的限制。。。 熟悉802.1x协议的过程,对网络编程的学习也有一定的提高。 代码中的ASM汇编部分代码取自北航的高手xdkui(目前在MS就职),在此一并感谢他的努力hack。 声明:本代码只供学习使用,完全遵循计算机软件保护条例。 1.开发环境: gtk+/gnome Anjuta+Glade 2.文件树(截图): /*** * Author: cc0cc * E-mail: cc0cc@126.com * WebSite: http://www.54chen.com * Date: the Mid-Autumn Festival of 2008 ***/

Continue reading

Posted in linux | Tagged , , | 1 Comment

flex实时换肤术-动态切换CSS样式表文件

HTML中有一个非常好的特性就是可以动态切换页面链接的CSS样式表,而FLEX并不具备动态导入CSS的特性,因为FLEX的所有的UI外观都是在后台SERVER生成在发布到前台的(当然,通过AS可以实时更改UI外观setStyle,这是单个更改的方式,并不是实时的CSS文件切换),一直觉得挺不爽的,今天在mannu看到一个使用_global.styles来实现动态切换CSS文件的非常巧妙的方式: 首先,因为FLEX是将CSS编译进SWF文件的,所有我们将我们需要切换的CSS编译成SWF文件; green.css Label{ color:#00FF00; fontSize:20px; } green.mxml <?xml version="1.0" encoding="utf-8"?> <mx:Application xmlns:mx="http://www.macromedia.com/2003/mxml"> <mx:Style source="green.css"></mx:Style> </mx:Application> 类似的还有red.css/red.mxml,blue.css/blue.mxml。 然后,我们要切换到相应的CSS就直接LOAD相应的SWF文件; 最后,将_global.styles设置为所导入的SWF文件的_global.styles 。 这里有一个工具封装好的工具类: RuntimeStyle.as import mx.controls.Loader; import mx.core.MXM

Continue reading

Posted in WEB相关 | Tagged , | 1 Comment

PHP“收发”邮件的一个程序

<?php if ($EMAIL_INC) return; $EMAIL_INC=   "defined"; define( "SmtpPort",25); class Pop3 { var $subject;                           // 邮件主题 var $from_email;                        // 发件人地址 var $from_name;                         // 发件人姓名 var $to_email;                          // 收件人地址 var $to_name;                           // 收件人姓名 var $body;                              // 邮件内容 var $filename;                          // 文件名 var $socket;                  // 当前的 socket var $Line; var $Status; function pop3_open($server, $port) { $this->Socket = fsockopen($server, $port); if ($this->Socket <= 0){ return false; } $this->Line = fgets($this->Socket, 1024); $this->Status[ "

Continue reading

Posted in php | Tagged , | 2 Comments

全角半角判断

半角范围:u0000 - u00FF, uFF61 - uFF9F, uFFE8 - uFFEE 全角范围: 全角数字(0-9) uFF10 - uFF19 全角大文字(A-Z): uFF21 - uFF3A 全角小文字(a-z): uFF41 - uFF5A 全角平仮名:u3040 - u309F 全角片仮名:u30A0 - u30FF 全角Latin: uFF01 - uFF5E 全角Symbol: uFFE0 - uFFE5 以下是判断全角半角混合字符串的字节数是否超过指定的字节数。(半角被认为是一个字节) function isOverBytes(s, maxbytes) {     var i = 0;     var bytes = 0;     var uFF61 = parseInt("FF61", 16);     var uFF9F = parseInt("FF9F", 16);     var uFFE8 = parseInt("FFE8", 16);     var uFFEE = parseInt("FFEE", 16);     while (i < s.length)      {         var c = parseInt(s.charCodeAt(i));         if (c < 256) {              bytes = bytes + 1;          }         else {             if ((uFF61 <= c) && (c <=

Continue reading

Posted in WEB相关 | Tagged , , | Leave a comment

Flex加载图片的常用的几种方式

<?xml version="1.0" encoding="utf-8"?> <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" applicationComplete="InitApp()">     <mx:Script>         <![CDATA[                      //第一种方式 这种方式编译以后1.jpg 会直接编译进swf文件中 所以swf可以独立存在              [Bindable]              [Embed(source="1.jpg")]              private var imgClass:Class;                          //第2种方式              private var _loader:Loader;                           private function InitApp():void{                                  //第一种方式的代码                  _img.source = imgClass;                                  //第二种方式的代码                  _loader = new Loader();                 //这里需要注

Continue reading

Posted in WEB相关 | Tagged | Leave a comment

64位ubuntu wine1.0 安装qq

环境比较特殊 注意是64的i386就不要看了 {安装wine:} 1.添加签名 wget -q http://wine.budgetdedicated.com/apt/387EE263.gpg -O- | sudo apt-key add - 2.更新WINE源 sudo wget http://wine.budgetdedicated.com/apt/sources.list.d/hardy.list -O /etc/apt/sources.list.d/winehq.list 3.更新软件包 sudo apt-get update 4.安装WINE sudo apt-get install wine {设置wine:} Wine快速设置 deb包 for amd64的下载地址是: http://ubuntu-tweak.googlecode.com/files/wine-ubuntu_amd64.deb 顺便再加上之前的for i386的: http://ubuntu-tweak.googlecode.com/files/wine-ubuntu.deb {使用QQ} Wine的版本: Wine 1.0 (默认中文补丁,有打过补丁的Wine1.0下载,见下面) windowssux已经把8.04-32bits的deb包(包括中文补丁)做出来了,在http://ftp.ubuntu.org.cn/home/windowssux/Wine-CN/。 登录的用户名和密码在http://forum.ubuntu.org.cn/viewtopic.php?t=9685。 Wine的

Continue reading

Posted in linux | Tagged , , | Leave a comment
Page 42 of 45« First...1020304041424344...Last »
54chen on Twitter
Connect with 54chen on
Twitter sina微博V GMAIL Profile
54chen,真名:陈臻。
2010年加入小米科技。
关键词:
rose,riak,rabbitmq,zookeeper,thrift,nuclear,
senseidb,hadoop,hive,dynamo,
php extension,nginx module

天下风云出我辈,一入江湖岁月催.
鸿图霸业谈笑中,不胜人生一场醉.
提剑跨骑挥鬼域,白骨如山鸟惊飞.
尘世如潮人如水,只叹江湖几人回.

过去的经历:
人人网分布式研究人员(nuclear系统开发者)
雅虎、淘宝搜索开发工程师
金山词霸开发工程师
曾用代号有:cc0cc、零蛋。

SEARCH

Comments

  • tank: 请教哈表单验证是如何做的?不采用a...
  • nodexy: 开启系统最大句柄数是前提,但就算...
  • 54chen: 最好用hive的load file去hdfs,scribe的hdfs...
  • 剑舞: 利用scribe写入hdfs的时候,是否有遇到...
  • 54chen: 代码公开在 https://github.com/54chen/MyNe...
  • 未来之风: 您好,不知道您这个是否支持神州数...
  • 54chen: 是的...
  • heroqt: 哦,是不是可以加上@Path("/")指定作为...
  • heroqt: 那么处理http://github.com/topic的函数必...
  • afei: 陈老师威武!哈...