IE6 div的高度小于12px设置办法
在IE6下如果设置一个div的高度小于12px的话,会显示12px,必须要加上overflow:hidden才会显示你实际设置的高度
linux下允许或禁止外部ip访问mysql数据库
Struts2中的传值方式
c语言播放影音代码
android获取sdk版本
有时候为了兼容各种版本,需要获取android sdk版本,根据版本做对应的处理:
android开机完成广播消息(android.intent.action.BOOT_COMPLETED)
Android系统启动结束时,会发出 android.intent.action.BOOT_COMPLETED 消息。如想要在Android开机时自动启动应用程序,可以通过响应这个广播消息来实现, 具体步骤如下:
1. 定义一个Broadcast Receiver ,比如:BootupReceiver
public class BootupReceiver extends BroadcastReceiver{
mysql避免使用用临时表的设计原则
MySQL官方手册:
http://dev.mysql.com/doc/refman/5.1/en/internal-temporary-tables.html
临时表存储
MySQL临时表分为"内存临时表"和"磁盘临时表",其中内存临时表使用MySQL的MEMORY存储引擎,磁盘临时表使用MySQL的MyISAM存储引擎;
一般情况下,MySQL会先创建内存临时表,但内存临时表超过配置指定的值后,MySQL会将内存临时表导出到磁盘临时表。
android关掉所有activity完全退出应用程序
如果Activity只有一个,直接调用finish()函数,就可以退出android应用程序。
如果Activity有很多个,就要把把所有的Activity都加载到一个List<>里面。注意加进List<>后,当某个窗口消毁后,一定要remove()掉,不然内存不够用。
javascript判断变量是否已经定义
if(typeof(var) != 'undefined') alert(var);
注意undefined的单引号
php文件上传安全检查
相应的参数改就就可以
if(substr($_FILES['data']['name'],-3,3) !== strtolower('zip')){//后缀名检查
$this->error->add('sys_error', $this->t->get('file_type_error'));
return false;
}
if($_FILES['data']['size'] > 1024*1024*10){//文件大小检查
$this->error->add('sys_error', $this->t->get('file_size_error'));
return false;
}
php数据(如数组)直接下载
ob_start();
header("Content-Type: application/octet-stream ; charset=UTF-8");
$filename = $_REQUEST['optid'] . ‘==’ . date(‘Y-m-d’, $_SERVER['REQUEST_TIME']) . '.zip';
header("Content-Disposition: attachment; filename=$filename");
$content = "<?php\nreturn ".var_export($data, true).";\n?>";
echo $content;
ob_end_flush();
java oscache ehcache对比
java常用的2个缓存框架oscache、ehcache主要的区别:
oscache 主要是对页面的缓存,可以整页或者指定网页某一部分缓存,同时
指定他的过期时间,这样在此时间段里面访问的数据都是一样的
1.log4j-1.2.8.jar,oscache-2.3.2.jar,commons-logging.jar,jgroups-all.jar
2.拷贝cach\etc\下的oscache.tld,oscache.properties 到WEB-INF\classes
基于Win32的Hello, World应用程序
android无标题栏全屏
//无标题栏
requestWindowFeature(Window.FEATURE_NO_TITLE);
//全屏模式
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
注意在setContentView()之前调用,否则无效。
android通过HttpClient从指定server获取数据
DefaultHttpClient httpClient = new DefaultHttpClient();
HttpGet method = new HttpGet(“http://www.baidu.com/1.html”);
HttpResponse resp;
Reader reader = null;
android建立GPRS连接
//Dial the GPRS link.
private boolean openDataConnection() {
// Set up data connection.
DataConnection conn = DataConnection.getInstance();
if (connectMode == 0) {
ret = conn.openConnection(mContext, “cmwap”, “cmwap”,“cmwap”);
} else {
ret = conn.openConnection(mContext, “cmnet”, “”, “”);
}
}
android清空手机上Cookie
CookieSyncManager.createInstance(getApplicationContext());
CookieManager.getInstance().removeAllCookie();
android发送彩信
StringBuilder sb = new StringBuilder();
sb.append(”file://”);
sb.append(fd.getAbsoluteFile());
Intent intent = newIntent(Intent.ACTION_SENDTO, Uri.fromParts(”mmsto”, number, null));
// Below extra datas are alloptional.
android发送短信
String body=”this is mms demo”;
Intent mmsintent = newIntent(Intent.ACTION_SENDTO, Uri.fromParts(”smsto”, number, null));
mmsintent.putExtra(Messaging.KEY_ACTION_SENDTO_MESSAGE_BODY,body);
mmsintent.putExtra(Messaging.KEY_ACTION_SENDTO_COMPOSE_MODE,true);
mmsintent.putExtra(Messaging.KEY_ACTION_SENDTO_EXIT_ON_SENT,true);
startActivity(mmsintent);