Navins' NoteBook Information, Code, Programming, Java/C/C++/C# …

php接口远程调用url方法

Posted on December 6, 2011

示例代码1: 用file_get_contents 以get方式获取内容
<?php

$url='http://www.baidu.com/';

$html = file_get_contents($url);
//print_r($http_response_header);
ec($html);
printhr();

printarr($http_response_header);

printhr();
?>

示例代码2: 用fopen打开url, 以get方式获取内容
<?

$fp = fopen($url, 'r');

printarr(stream_get_meta_data($fp));

printhr();
while(!feof($fp)) {
$result .= fgets($fp, 1024);
}
echo "url body:    $result";
printhr();

fclose($fp);
?>

Filed under: Skills Continue reading

SimpleDateFormat格式化日期

Posted on July 31, 2011
1
2
3
4
5
6
7
8
9
10
11
12
13
14
import java.text.SimpleDateFormat;
import java.util.Date;
public class test {
 public static void main(String []aa){
  SimpleDateFormat dateformat1=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss E");
  String a1=dateformat1.format(new Date());
  System.out.println("时间2:"+a1);
  System.out.println(new Date().getYear()+1900);
  
  SimpleDateFormat dateformat2=new SimpleDateFormat("yyyy年MM月dd日 HH时mm分ss秒 E ");   
        String a2=dateformat2.format(new Date());
        System.out.println("时间2:"+a2); 
 }
}

执行结果:
时间2:2006-12-21 14:40:59 星期四
2006
时间2:2006年12月21日 14时40分59秒 星期四

Filed under: Skills Continue reading

python初学教程(转载)

Posted on July 6, 2011

Lesson 1 准备好学习Python的环境
下载的地址是:
www.python.org
为了大家的方便,我在校内作了copy:

http://10.1.204.2/tool/compiler&IDE/Python-2.3.2-1.exe

linux版本的我就不说了,因为如果你能够使用linux并安装好说明你可以一切自己搞定的。
运行环境可以是linux或者是windows:
1、linux
redhat的linux安装上去之后一定会有python的(必须的组件),在命令行中输入python回车。这样就可以进入一个
>>>的提示符
2、windows
安装好了python之后,在开始菜单里面找到Python2.3->IDLE,运行也会进入一个有
>>>提示符的窗口
开始尝试Python
1、输入:
welcome = "Hello!"
回车
然后又回到了>>>
2、输入:
print welcome
回车
然后就可以看到你自己输入的问候了。
Lesson 2 搞定环境之后的前行
Python有一个交互式的命令行,大家已经看到了吧。所以可以比较方便的学习和尝试,不用“新建-存档-编译-调试”,非常适合快速的尝试。
一开始从变量开始(其实说变量,更准确的是对象,Python中什么都可以理解为对象)。
变量
welcome = "hello!"
welcome就是变量名,字符串就是变量的类型,hello!就是变量的内容,""表示这个变量是字符串,""中间的是字符串的内容。
熟悉其他语言的人,特别是编译类型的语言,觉得没有变量的声明很奇怪。在python中用赋值来表示我要这么一个变量,即使你不知道要放什么内容,只是要先弄一个地方来放你的东西,也要这么写:
store = ""
不过这个还是说明了store是字符串,因为""的缘故。
have a try

Filed under: Skills Continue reading

C# 选择文件对话框代码

Posted on January 18, 2011

OpenFileDialog fileDialog1 = new OpenFileDialog();
fileDialog1.InitialDirectory = "d:\\";
fileDialog1.Filter = "xls files (*.xls)|*.xls|All files (*.*)|*.*";
fileDialog1.FilterIndex = 1;
fileDialog1.RestoreDirectory = true;
if (fileDialog1.ShowDialog() == DialogResult.OK)
{
textBox1.Text = fileDialog1.FileName;
}
else
{
textBox1.Text = "";
}

Filed under: Skills No Comments

Asp.Net2.0 web.config配置文件之connectionStrings用法

Posted on January 9, 2011
以前写Asp.net代码,用的Web.Config配置文件中连接字符串多是         <appSettings>
           <add key="ConnectionString" value="Server=.;Integrated Security=SSPI;Database=Message;" />
         </appSettings>

        在Asp.Net 2.0 中新加了<connectionStrings>这一节

       <connectionStrings >
          <add />
          <clear />
          <remove />
       </connectionStrings>

        现在用起来就方便些了

Filed under: Skills Continue reading

VS2010 帮助文档本地安装

Posted on December 19, 2010

本地MSDN文档需要另外安装:

     安装完成vs2010后,可以打开Start\Programs\Microsoft Visual Studio 2010\Visual Studio Tools\Manage Help Settings来安装。先选择安装位置,然后选择是在线还是离线,然后选择Install from disk,找到光盘中\ProductDocumentation\HelpContentSetup.msha,然后选择安装哪些项目的 library,然后开始安装。

如果你想要更改安装位置,执行以下操作。

你先手动删除HelpLibrary啊!你到C:\Program Files\Microsoft Help Viewer 删除里面的说有东西,然后到安装文件VS2010.iso\WCU\Help\执行HelpSetup和HelpSetupLP,32位机器执行x86,64位就是x64,然后你就能重选目录了。我真的就是这样就能重选目录了,这样就能安装在C盘外的所有盘里啊!我开始时候是误删文件了,导致HelpLibrary无法打开。

Filed under: Skills No Comments

Ubuntu输入su提示认证失败的解决方法

Posted on December 16, 2010

启动ubuntu服务时竟然提示权限不够,用su切换,输入密码提示认证失败,这下搞了吧,后来一经查阅原来Ubuntu安装后,root用户默认是被锁定了的,不允许登录,也不允许 su 到 root ,对于桌面用户来说这个可能是为了增强安全性,但是服务器版上的没这个还真不行,赶紧设置下吧。

终端下

studiogang@studiogang:~$ sudo passwd

Password: <--- 输入安装时那个用户的密码

Enter new UNIX password: <--- 新的Root用户密码

Retype new UNIX password: <--- 重复新的Root用户密码

passwd:已成功更新密码

Filed under: Skills No Comments

在Ubuntu桌面上显示我的电脑等图标

Posted on December 12, 2010

在Ubuntu桌面上显示我的电脑等图标
在 GNOME 中显示 计算机,用户主文件夹 和 回收站等桌面图标。
在终端中运行以下命令:
打开配置编辑器
gconf-editor

* 选择 apps → nautilus → desktop

* 勾选 computer_icon_visible、home_icon_visible 和 trash_icon_visible 边上的复选框。

这些更改会立即生效。

Filed under: Skills No Comments

linux查看内核版本和发行版本

Posted on December 3, 2010

查看内核版本:
方法一:uname -r
输出:
2.6.32-23-generic
方法二:cat /proc/version
输出:
Linux version 2.6.32-23-generic (buildd@rothera) (gcc version 4.4.3 (Ubuntu 4.4.3-4ubuntu5) ) #37-Ubuntu SMP Fri Jun 11 07:54:58 UTC 2010

Filed under: Skills Continue reading

PHP如何创建Session

Posted on September 30, 2010

  开始介绍如何创建 session。非常简单,真的。

  启动 session 会话,并创建一个 $admin 变量:

  // 启动 session

  session_start();

  // 声明一个名为 admin 的变量,并赋空值。

  $_session["admin"] = null;

  ?>

Filed under: Skills Continue reading