开心是一天,不开心也是一天,为何要不开心
为视网膜显示屏优化网页上的图片
现在 iPad 也有视网膜屏幕(retina display)了。正是依赖这视网膜显示屏,iPhone 4 的分辨率达到了640×960 pixel,iPad 的分别率达到了 1536 x 2048 pixel。不过为了保持向下兼容性,iOS 在网页上仍然是 320 × 480 point 和 768 x 1024 point。
也就是说,在不进行缩放的情况下,显示普通图片时,它会用4个像素来显示图片中的1个像素;而在显示retina图片时,每个像素都对应图片中的1个像素。这样网页上面的图片就会模糊了。文字却没有这个问题,因为文字是适量的。也就是说要解决图片模糊这个问题可以用 svg 适量图片来替换。
iOS 用 SDK 开发 iOS 应用时,只要将图片名加上“@2x”后缀,就能让支持retina display的设备自动显示这个解析度更高的图片。但 Safari 等使用 UIWebView 的应用在展示图片时,却无法利用这个特性,因为这样会造成大量没必要的HTTP请求。
不过解决这个问题的方两种一种是用大小为原图的 2 倍尺寸的图片来缩小来显示,另外一种就是直接使用 svg 适量图片。
方法一:先来看看用原图大小2倍缩小的方法:
如果图片是直接用 HTML 的 img 标签显示,假如 图片的大小是 60 x 60 px 的那么在 img 标签里面的尺寸就不能是 60 x 60 px,而必须是30 x 30 px。
请看下面的演示效果:
HTML:
图1
图1 为原始30×30 的图片。
图2
图2 为原始 60×60 的图片缩小后的预览。
CSS:
如果是用做 CSS 背景图片那么就要设置 background-size 属性了,如:
background-size:30px 30px;
示例如下:
图3 为原始30×30 的背景图片。
图4 为原始 60×60 的背景图片设置 background-size 后的效果。
使用 iPhone 4或者 新款的iPod 浏览本文就很清晰的发现这两个图片的显示问题了。
方法2: 就是直接使用 svg 格式的适量图片了。
使用方法:
<img src="icon.svg" width="30px" height="30px" alt="" />
或
background: url(icon.svg) no-repeat;
如果你是为了节约流量那么只准备一套大尺寸的图片就行了,然后直接使用方法一中的方法缩小图片显示尺寸就行了。
要是你想面面俱到的话那就准备2两套图片吧。
在网页中,pixel 与 point 比值称为 device-pixel-ratio,普通设备都是1,iPhone 4是2,有些Android机型是1.5。你就可以用 css 的media 查询来做判断加载哪套图片了。css media 查询的代码如下:
<link rel="stylesheet" href="retina.css" media="only screen and (-webkit-min-device-pixel-ratio: 2), only screen and (min-device-pixel-ratio: 2)"/>
或者:
@media only screen and (-webkit-min-device-pixel-ratio: 2), only screen and (min-device-pixel-ratio: 2) { }
另外推荐一个制作 svg 的软件,那就是 Linux 下大名鼎鼎的 GIMP。这个软件 也有 Windows 和 Mac 的版本,下载地址为:http://www.gimp.org/downloads/
这个软件被称之为 Linux 下的 PhotoShop。也可把图片转换为 svg 适量图。
补充:做图和切图的时候,图片最好为 2 的倍数,也就是说切图的时候尽量使用偶数。基数不能被整除,坐标这些会出问题。
引自:xuui.net
WebApp 开发技巧总结
自 Iphone 和 Android 这两个牛逼的手机操作系统发布以来,在互联网界从此就多了一个新的名词 WebApp (意为基于 Web 形式的应用程序,运行在高端的移动终端设备)。
开发者们都知道在高端智能手机系统中有两种应用程序:一种是基于本地(操作系统)运行的 App;一种是基于高端机的浏览器运行的 WebApp,本文将主要讲解后者。
Web App 与 Native App 有何区别呢?
Native App:
1、开发成本非常大。
一般使用的开发语言为 JAVA、C++、Objective-C。
2、更新体验较差、同时也比较麻烦
每一次发布新的版本,都需要做版本打包,且需要用户手动更新(有些应用程序即使不需要用户手动更新,但是也需要有一个恶心的提示)。
3、非常酷
因为 native app 可以调用 IOS 中的 UI 控件及 UI 方法,它可以实现 WebApp 无法实现的一些非常酷的交互效果
4、Native app 是被 Apple 认可的
Native app可以被Apple认可为一款可信任的独立软件,可以放在Apple Stroe出售,但是Web app却不行。
Web App:
1、开发成本较低
使用web开发技术就可以轻松的完成web app的开发
2、升级较简单
升级不需要通知用户,在服务端更新文件即可,用户完全没有感觉
3、维护比较轻松
和一般的web一样,维护比较简单,它其实就是一个站点
Webapp说白了就是一个针对Iphone、Android优化后的web站点,它使用的技术无非就是HTML或HTML5、CSS3、JavaScript,服务端技术JAVA、PHP、ASP。
当然,因为这些高端智能手机(Iphone、Android)的内置浏览器都是基于webkit内核的,所以在开发WEBAPP时,多数都是使用 HTML5和CSS3技术做UI布局。当使用HTML5和CSS3l做UI时,若还是遵循着一般web开发中使用HTML4和CSS2那样的开发方式的 话,这也就失去了WEBAPP的本质意义了,且有些效果也无法实现的,所以在此又回到了我们的主题–webapp的布局方式和技术。
在此所说的移动平台前端开发是指针对高端智能手机(如Iphone、Android)做站点适配也就是WebApp,并非是针对普通手机开发 Wap 2.0,所以在阅读本篇文章以前,你需要对webkit内核的浏览器有一定的了解,你需要对HTML5和CSS3有一定的了解。如果你已经对此有 所了解,那现在就开始往下阅读吧……
1、首先我们来看看webkit内核中的一些私有的meta标签,这些meta标签在开发webapp时起到非常重要的作用
1 <meta content=”width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0;” name=”viewport” />
2 <meta content=”yes” name=”apple-mobile-web-app-capable” />
3 <meta content=”black” name=”apple-mobile-web-app-status-bar-style” />
4 <meta content=”telephone=no” name=”format-detection” />
第一个meta标签表示:强制让文档的宽度与设备的宽度保持1:1,并且文档最大的宽度比例是1.0,且不允许用户点击屏幕放大浏览;
第二个meta标签是iphone设备中的safari私有meta标签,它表示:允许全屏模式浏览;
第三个meta标签也是iphone的私有标签,它指定的iphone中safari顶端的状态条的样式;
第四个meta标签表示:告诉设备忽略将页面中的数字识别为电话号码
2、HTML5标签的使用
在开始编写webapp时,哥建议前端工程师使用HTML5,而放弃HTML4,因为HTML5可以实现一些HTML4中无法实现的丰富的WEB应用程序 的体验,可以减少开发者很多的工作量,当然了你决定使用HTML5前,一定要对此非常熟悉,要知道HTML5的新标签的作用。比如定义一块内容或文章区域 可使用section标签,定义导航条或选项卡可以直接使用nav标签等等。
3、放弃CSS float属性
在项目开发过程中可以会遇到内容排列排列显示的布局(见下图),假如你遇见这样的视觉稿,哥建议你放弃float,可以直接使用display:block;
4、利用CSS3边框背景属性
这个按钮有圆角效果,有内发光效果还有高光效果,这样的按钮使用CSS3写是无法写出来的,当然圆角可以使用CSS3来写,但高光和内发光却无法使用 CSS3编写,这个时候你不妨使用-webkit-border-image来定义这个按钮的样式。-webkit-border-image就个很复杂 的样式属性。
5、块级化a标签
请保证将每条数据都放在一个a标签中,为何这样做?因为在触控手机上,为提升用户体验,尽可能的保证用户的可点击区域较大。
6、自适应布局模式
在编写CSS时,我不建议前端工程师把容器(不管是外层容器还是内层)的宽度定死。为达到适配各种手持设备,我建议前端工程师使用自适应布局模式(支付宝 采用了自适应布局模式),因为这样做可以让你的页面在ipad、itouch、ipod、iphone、android、web safarik、 chrome都能够正常的显示,你无需再次考虑设备的分辨率。
7、学会使用webkit-box
上一节,我们说过自适应布局模式,有些同学可能会问:如何在移动设备上做到完全自适应呢?很感谢webkit为display属性提供了一个webkit-box的值,它可以帮助前端工程师做到盒子模型灵活控制。
8、如何去除Android平台中对邮箱地址的识别
看过iOS webapp API的同学都知道iOS提供了一个meta标签:用于禁用iOS对页面中电话号码的自动识别。在iOS中是不自动识别邮件地 址的,但在Android平台,它会自动检测邮件地址,当用户touch到这个邮件地址时,Android会弹出一个框提示用户发送邮件,如果你不想 Android自动识别页面中的邮件地址,你不妨加上这样一句meta标签在head中 1 <meta content=”email=no” name=”format-detection” />
9、如何去除iOS和Android中的输入URL的控件条
你的老板或者PD或者交互设计师可能会要求你:能否让我们的webapp更加像nativeapp,我不想让用户看见那个输入url的控件条?
答案是可以做到的。我们可以利用一句简单的javascript代码来实现这个效果
1 setTimeout(scrollTo,0,0,0);
请注意,这句代码必须放在window.onload里才能够正常的工作,而且你的当前文档的内容高度必须是高于窗口的高度时,这句代码才能有效的执行。
10、如何禁止用户旋转设备
我曾经也想禁止用户旋转设备,也想实现像某些客户端那样:只能在肖像模式或景观模式下才能正常运行。但现在我可以很负责任的告诉你:别想了!在移动版的webkit中做不到!
至少Apple webapp API已经说到了:我们为了让用户在safari中正常的浏览网页,我们必须保证用户的设备处于任何一个方位 时,safari都能够正常的显示网页内容(也就是自适应),所以我们禁止开发者阻止浏览器的orientationchange事件,看来苹果公司的出 发点是正确的,苹果确实不是一般的苹果。
iOS已经禁止开发者阻止orientationchange事件,那Android呢?对不起,我没有找到任何资料说Android禁止开发者阻止浏览器orientationchange事件,但是在Android平台,确实也是阻止不了的。
11、如何检测用户是通过主屏启动你的webapp
看过Apple webapp API的同学都知道iOS为safari提供了一个将当前页面添加主屏的功能,按下 iphoneipodipod touch底部工具中的小加号,或者ipad顶部左侧的小加号,就可以将当前的页面添加到设备的主屏,在设备的主屏会自动 增加一个当前页面的启动图标,点击该启动图标就可以快速、便捷的启动你的webapp。从主屏启动的webapp和浏览器访问你的webapp最大的区别 是它清除了浏览器上方和下方的工具条,这样你的webapp就更加像是nativeapp了,还有一个区别是window对像中的navigator子对 象的一个standalone属性。iOS中浏览器直接访问站点时,navigator.standalone为false,从主屏启动webapp 时,navigator.standalone为true, 我们可以通过navigator.standalone这个属性获知用户当前是否是从主屏访 问我们的webapp的。在Android中从来没有添加到主屏这回事!
12、如何关闭iOS中键盘自动大写
我们知道在iOS中,当虚拟键盘弹出时,默认情况下键盘是开启首字母大写的功能的,根据某些业务场景,可能我们需要关闭这个功能,移动版本webkit为 input元素提供了autocapitalize属性,通过指定autocapitalize=”off”来关闭键盘默认首字母大写。
13、iOS中如何彻底禁止用户在新窗口打开页面
有时我们可能需要禁止用户在新窗口打开页面,我们可以使用a标签的target=”_self“来指定用户在新窗口打开,或者target属性保持空,但 是你会发现iOS的用户在这个链接的上方长按3秒钟后,iOS会弹出一个列表按钮,用户通过这些按钮仍然可以在新窗口打开页面,这样的话,开发者指定的 target属性就失效了,但是可以通过指定当前元素的-webkit-touch-callout样式属性为none来禁止iOS弹出这些按钮。这个技 巧仅适用iOS对于Android平台则无效。
14、iOS中如何禁止用户保存图片\复制图片
我们在第13条技巧中提到元素的-webkit-touch-callout属性,同样为一个img标签指定-webkit-touch-callout为none也会禁止设备弹出列表按钮,这样用户就无法保存\复制你的图片了。
15、iOS中如何禁止用户选中文字
我们通过指定文字标签的-webkit-user-select属性为none便可以禁止iOS用户选中文字。
16、iOS中如何获取滚动条的值
桌面浏览器中想要获取滚动条的值是通过document.scrollTop和document.scrollLeft得到的,但在iOS中你会发现这两 个属性是未定义的,为什么呢?因为在iOS中没有滚动条的概念,在Android中通过这两个属性可以正常获取到滚动条的值,那么在iOS中我们该如何获 取滚动条的值呢?
通过window.scrollY和window.scrollX我们可以得到当前窗口的y轴和x轴滚动条的值。
17、如何解决盒子边框溢出
当你指定了一个块级元素时,并且为其定义了边框,设置了其宽度为100%。在移动设备开发过程中我们通常会对文本框定义为宽度100%,将其定义为块级元 素以实现全屏自适应的样式,但此时你会发现,该元素的边框(左右)各1个像素会溢了文档,导致出现横向滚动条,为解决这一问题,我们可以为其添加一个特殊 的样式-webkit-box-sizing:border-box;用来指定该盒子的大小包括边框的宽度。
18、如何解决Android 2.0以下平台中圆角的问题
如果大家够细心的话,在做wap站点开发时,大家应该会发现android 2.0以下的平台中问题特别的多,比如说边框圆角这个问题吧。
在对一个元素定义圆角时,为完全兼容android 2.0以下的平台,我们必须要按照以下技巧来定义边框圆角:
1\-webkit这个前缀必须要加上(在iOS中,你可以不加,但android中一定要加);
2\如果对针对边框做样式定义,比如border:1px solid #000;那么-webkit-border-radius这属性必须要出现在border属性后。
3\假如我们有这样的视觉元素,左上角和右上角是圆角时,我们必须要先定义全局的(4个角的圆角值)-webkit-border- radius:5px;然后再依次的覆盖左下角和右下角,-webkit-border-bottom-left-radius:0;-webkit- border-bottom-right-border:0;否则在android 2.0以下的平台中将全部显示直角,还有记住!-webkit这个前 缀一定要加上!
19、如何解决android平台中页面无法自适应
虽然你的html和css都是完全自适应的,但有一天如果你发现你的页面在android中显示的并不是自适应的时候,首先请你确认你的head标签中是否包含以下meta标签:
1 <meta name=”viewport” content=”width=device-width,initial-scale=1.0,maximum-scale=1.0,user-scalable=0;” />
如果有的话,那请你再仔细的看清楚有没有这个属性的值width=device-width,如果没有请立即加上吧!
20、如何解决iOS 4.3版本中safari对页面中5位数字的自动识别和自动添加样式
新的iOS系统也就是4.3版本,升级后对safari造成了一个bug:即使你添加了如下的meta标签,safari仍然会对页面中的5位连续的数字进行自动识别,并且将其重新渲染样式,也就是说你的css对该标签是无效的。
1 <meta name=”format-detection” content=”telphone=no” />
我们可以用一个比较龌龊的办法来解决。比如说支付宝wap站点中显示金额的标签,我们都做了如下改写:
1 <button class=”t-balance”style=”background:none;padding:0;border:0;”>95009.00</button>元
(转载文章,不知原作者,转自mhtml5.com)
Objective-C 获得毫秒数
-(long)getMilliseconds{
struct timeval t;
gettimeofday(&t,NULL);
return t.tv_sec*1000+t.tv_usec/1000;
}
关闭 VMware 虚拟机的自动挂起
其实自动挂起并不是虚拟机的功能,而是虚拟机内系统的自动休眠功能引起的。
知道了原因解决方法也简单,通常出现自动挂起现象的是 win7 系统,以此为例:
依次打开:控制面板=>硬件和声音=>更改计算机休眠时间。
将“使计算机进入休眠状态”改为“从不”保存修改即可。
Mac 关闭 Google Software Update
# 关闭方法
defaults write com.google.Keystone.Agent checkInterval 0
# 打开方法
defaults write com.google.Keystone.Agent checkInterval 18000
# 手动更新方法
在终端运行 /Library/Google/GoogleSoftwareUpdate/GoogleSoftwareUpdate.bundle/Contents/Resources/CheckForUpdatesNow.command
MySQL 笔记
#安装服务 mysqld -install # 卸载服务 mysqld -remove # 创建用户 create user 用户名@'主机' identified by '密码'; 主 机: 登录范围,例:localhost(只能本地登录), %(可远程登录), 110.100.20.%(允许IP段内的远程登录) 用户名: 登录帐号 密 码: 登录密码 # 修改密码 SET PASSWORD FOR 用户名@"主机"=PASSWORD('密码'); # 用户授权 grant 权限 on 数据库.表 to 用户名@'主机' identified by '密码'; # 修改表名 alter table 旧表 rename to 新表; # 查看用户权限 show grants for 用户名[@主机]; 主机: 如果缺省则默认为 % # 用户销权 revoke 权限 on 数据库.表 from 用户名@'主机' # 查看指定数据库的所有用户 select user from mysql.db where db="数据库" # 查看当前用户 select user(); # 删除用户及权限 drop user 用户名@'主机'; # 立即生效 flush privileges; # 修改自增值 alter table 表名 auto_increment=数值
Windows 中有些软件中文显示乱码
多数原因是因为“区域和语言”出现故障造成的,解决方法如下:
依次打开:开始 => 控制面板 => 时钟、语言和区域 => 区域和语言
将所有选项卡里的区域全改为美国后注销并登录,然后再改回中国注销并登录即可。
Mac hdid
hdid(8) hdid(8) NAME hdid - HDI driver backing store service SYNOPSIS hdid [ options ] image DESCRIPTION Historically, hdid has been the user-level process handling the loading and decompression of disk image data for the hard disk image (HDI) driver in the Mac OS X kernel. With Mac OS X version 10.2 and later, certain read/write images and 10.2+-generated zlib-compressed (UDZO) images attach in-kernel without a persistent user process. With Mac OS X version 10.3, hdid calls the DiskImages.framework and its helpers take care of any out-of-kernel image serving duties. As of Mac OS X 10.4, hdid calls through to hdiutil attach. hdid exists primarily for backwards compatibility. Generally, hdiutil attach should be used instead of hdid. This man page continues to document certain DiskIm- ages features that are not tool-specific. The DiskImages framework supports a variety of flat-file and dual-fork image formats, including read/write, read-only, and read-only com- pressed formats (which it decompresses on the fly). It automatically decodes AppleSingle and MacBinary file formats and is capable of mount- ing most images directly from http:// URLs. hdiutil detach or diskutil eject should be used to detach (aka "eject") images attached to the system via hdid. Beware that an image you have created and attached is considered an unknown removable device. For HFS filesystems on such a device, being unknown to the system means that the on-disk ownership of files and directories are initially ignored. On 10.2, the owner values were dynamically replaced with the owner of /dev/console and the group unknown (gid 99). On 10.3, the group remains unknown, but the owner is whoever is currently accessing the file (joe sees that he owns files when he looks at the volume; mary sees that she owns files when she looks). Owners can be enabled for a particular volume permanently (see disktool/"get info" in the Finder) or temporarily (see EXAMPLES section of hdiutil(1)). Aside from whether owners are enabled, being removable means that disk arbitration will mount any volumes with special options such as nosuid. The error "no mountable filesystems" generally means that there is no filesystem in the image or that any filesystem is corrupt. Unfortu- nately, read-only device images made from mounted journaled volumes will not mount because the journal can't be replayed. It should be noted, however, that the error was common on older systems when remotely logged in to a machine with no one logged in on console. Disk arbitration wouldn't mount removable media until the SystemUIServer process was running. On 10.2 systems, 'disktool -c `id -u`' would allow image-based volumes to mount in such situations. With 10.3, vol- umes automatically mount on non-managed systems regardless of whether anyone is logged in on console. Image-based filesystems can also be manually mounted after attaching the image with -nomount. Please see the section below on setting up HTTP image servers if you plan to regularly mount images from web servers or are wondering why a particular image isn't mounting over HTTP. ARGUMENTS -help show available options -shadow [ ] Use a shadow file in conjunction with the data in the image. This prevents modification of the original image and allows read-only images to be attached read/write. When blocks are being read from the image, blocks present in the shadow file override blocks in the base image. When blocks are being writ- ten, the writes will be redirected to the shadow file. If not specified, -shadow defaults to .shadow. If the shadow file does not exist, it is created. -readonly Attach the image read only. Has no effect on read-only images. -readwrite Attach the image read/write. Has no effect on read-only (or compressed) images. Used in some cases where a read/write image might default to being attached read-only. -nomount Suppress automatic mounting of any filesystems in the image. This will result in /dev entries being created and (for non-ker- nel-attached images) a process in the background, but no volumes will be mounted. -notremovable Make the image appear to the system as a fixed disk. A reboot will be required to cleanly detach the image, though filesystems can be unmounted and remounted. This option requires root access, e.g. via sudo(8). -encryption [ ] This option specifies a particular encrypted encoding. The default CEncryptedEncoding automatically recognizes its images so this option should rarely be needed. Be careful what you are asking for if the argument to -encryption comes directly before the image name on the command line. -stdinpass causes hdid to read a null-terminated passphrase from its stan- dard input. ^@ (control-@) can be typed to explicitly insert the terminator. This option is designed for automation in which standard input would be attached to a file or pipe. -passphrase This option is provided for automation purposes but is very insecure as the passphrase value will be visible in the output of ps(1) (and thus to other users). -passphrase has been deprecated. -imagekey = Specify a key/value pair for the disk image recognition and cre- ation system. See hdiutil(1) for more information. -drivekey = Specify a key/value pair for the IOHDIXHDDrive object created (shows up in the IOKit registry of devices which is viewable with ioreg(8)). -section subspec Attach a subset of the disk image. subspec is any of , , or . All sector numbers are zero- based and ranges are inclusive. -kernel hand the image directly to the IOHDIXController module in the kernel even if this image would not normally be sent "in-ker- nel." If the image cannot be attached, no attempt will be made to attach it with a user process. -nokernel attach the image with a persistent process instead of attaching in-kernel, even if the default for this type of image is to attach in-kernel. Use hdiutil(1)'s imageinfo verb to determine if an image will default to mounting in-kernel. -plist output a plist describing the image and system entities (dev entries, mount points, etc) that were created as a result of attaching the given image. -verbose verbose output when attaching an image -debug diagnostic output when attaching an image -quiet Don't print out resulting /dev entries and filesystems. Also do not print any errors. hdid's exit status will indicate whether the attach was successful. EXAMPLES $ hdid funstuff.img Present funstuff.img as a device so that its filesystems can be mounted. $ hdid master.dmg -shadow Present master.dmg to the filesystems for potential mounting, redirect- ing all write operations to the shadow file master.dmg.shadow. $ hdid http://my.webserver.com/master.img -shadow /tmp/master- shadowfile Present master.img to the filesystems for potential mounting, redirect- ing all write operations to the shadow file mastershadowfile in /tmp. The shadow file can be on any mounted read/write filesystem -- keep in mind the consequences of using a remote filesystems (NFS, AFP) for such shadow files. hdid -nomount ram:// will attach a ram disk that can be mounted and used after being format- ted with a newfs utility or Disk Utility.app. A sector is 512 bytes. A small shell script to create and mount a ram disk: #!/bin/sh NUMSECTORS=128000 mydev=`hdid -nomount ram://$NUMSECTORS` newfs_hfs $mydev mkdir /tmp/mymount mount -t hfs $mydev /tmp/mymount OUTPUT Unless -plist is specified, hdid returns one line of output per /dev entry created. Each line contains up to three tab-delimited columns. The first column always contains the full path to the /dev entry cre- ated. The second column will contain the partition type if the image contained a partition map. The third column will contain the mount- point if the particular /dev entry was mounted. If hdid is asked to attach an image that is already attached, it will attempt to return the usual information for the attached image, as if it had just been attached. However, if there are unmounted partitions on the attached image, they will not be remounted. Mounting Images via HTTP In addition to mounting images from local or remote mounted filesys- tems, one can also mount images from HTTP servers without downloading the entire image. For flat images (UDIF images, or AppleSingle/MacBi- nary encoded NDIF image files) mounting an image is a matter of passing the http:// URL to hdid: hdid http://server.company.com/Images/stuff.dmg It should be noted that some web servers (Apache in particular) do not support byte-range requests beyond 2 (Apache 1.x) or 4 GB (Apache 2.x) and thus image files larger than those sizes will not be accessible over HTTP. Read/write images may attach, but will not be fully acces- sible. Segmented images do work correctly over HTTP (assuming they are named properly) and can be used to work around the file size limita- tion. Browsing images via HTTP is much more pleasant if the server settings are modified to be more friendly to highly-persistent clients. In par- ticular for Apache, MaxKeepAliveRequests should be increased signifi- cantly beyond 100 or set to 0 (unlimited) and KeepAliveTimeout should be boosted to at least 30 (seconds). Increasing the number of simulta- neous clients may also be desirable because of the increased delay before clients are forcibly disconnected. If the image to be served via HTTP is a dual fork NDIF image that is not encoded into a flat-file format such as AppleSingle and the HTTP server is running on Mac OS X, dual fork files may be detected and sup- ported. Such dual-fork files must be moved or copied using the Finder, or some other resource-fork-aware tool. Properly copied dual-fork files on a UFS volume have a ._filename file in addition to the file- name you see in the Finder (i.e. stuff.img would also have ._stuff.img in the same directory). In either case, one would specify the URL to the data fork, and DiskIm- ages will determine if it is necessary to access the secondary file. Accessing dual fork images on HFS+ filesystems via HTTP is only sup- ported if the HTTP server is on a Mac OS X system. It is possible that the web server's configuration could prevent access to the resource fork. For example, Mac OS X 10.3 security updates have disabled access to the /..namedfork/ paths necessary to access resource forks on HFS. Thus it may be necessary to tweak web server settings to successfully serve dual-fork images. While it is not directly related to mounting via hdid(1), informing your web server that '.dmg' (and others) are extensions associated with the MIME type application/octet-stream will allow web browsers to down- load the files rather than try to display them. For apache, you add the extensions to the appropriate line in /etc/httpd/mime.types. SEE ALSO hdiutil(1), load_hdi(8), ditto(8), diskutil(8), diskarbitrationd(8), ioreg(8) 25 June 2002 hdid(8)
mac mdworker
当在 Mac OS X 中做任何磁盘操作时,mdworker 会在后台默默收集这些信息服务于 Spotlight。这是一个非常强大的工具,但有些信息我们并不希望它收集并占用太多的 CPU,这时我们可以使用如下命令关闭它:
sudo mdutil -i off /
如果您喜欢并常用 Spotlight 功能,请记得在完成重要工作后重新打开它:
sudo mdutil -i on /