开发杂记:如何使用google字体

by kevin 26. 六月 2013 13:56 >
前段时间,65emall上请设计公司设计的活动页面使用了google字体,效果是挺好看的,问题是google字体只提供woff文件,所以在ie浏览器下无法正常浏览,要兼容ie的各个版本需要将woff文件转换成eot,tff等文件,找了很多个网站或是技术问题,或者是版权问题,都无法直接转换woff文件,最后在颠_颠帮助下找到了everythingfonts。问题就可以解决了。 1 将google字体下载下来 2 通过everythingfonts将woff文件转换成tff文件 3 再通过其他的在线字体转换网站转换成eot等文件格式 4 然后是@font-face来搞定   PS: 1 everythingfonts可能需要翻墙。 2 转换后的字体,字宽可能会不一样,可以使用font-weight来调整一下。 3 版权问题,谁要知道怎么处理,更我说一下。 4 http://www.zhuan-huan.com/font-converter.php 这里好像也可以转换,未验证。 实例下载

SQL Server 语法小技巧-持续更新

by kevin 20. 六月 2013 16:46 >
获取今天零点时间 1: DECLARE @Today DateTime 2:  3: SET @Today = DATEADD(dd, DATEDIFF(dd,0,GETDATE()), 0)   更好的支持模糊搜索 很多时候,我们会 LIKE 查询的做法是这样的。 1: select * from TableName where ColumnName LIKE '%Input%' 但如果上面的Input是这样的 keyword1 keyword2 ,那么数据库中包含keyword1 XXXXX keyword2 的记录就不会被查询出来,这里可以稍微的改进一下。 1: select * from TableName where ColumnName LIKE '%keyword1%keyword2%' 简单实用的技巧,另外还是要记得防止SQL注入。 多行合并为一行,类似string.join google了一下,基本上都说用 for xml path 1: SELECT OrderItemDesc FROM #OrderItem WHERE OrderId=O.OrderId FOR XML Path('') 如果OrderItemDesc中包含xml转义字符,会被转义,比如 “<” 转义为 “&lt” 所以要小加工一下 1: (SELECT OrderItemDesc FROM #OrderItem WHERE OrderId=O.OrderId FOR XML Path(''), type).value('.','nvarchar(max)')

fluentdata的ExpandoObject异常

by kevin 4. 六月 2013 21:42 >
现在开发的项目中使用fluentdata进行数据访问,简单易用,但是,也是有坑爹的bug。 先记录2个: 1 IStoredProcedureBuilderDynamic StoredProcedure(string storedProcedureName, ExpandoObject item) 参数类型明明是ExpandoObject,还是需要做一次显示转换。 A.  Bad 1: var command = DefaultContext.StoredProcedure("InsertSPName", Entity) 2: .AutoMap().ParameterOut("EntityId", DataTypes.Int32, 4); 3: command.Execute(); 4: return command.ParameterValue<int>("EntityId"); B.  OK 1: var command = DefaultContext.StoredProcedure("InsertSPName", (ExpandoObject)DanymicObject) 2: .AutoMap().ParameterOut("EntityId", DataTypes.Int32, 4); 3: command.Execute(); 4: return command.ParameterValue<int>("EntityId"); 2. IStoredProcedureBuilder Parameter(string name, object value); 参数类型是object , 但是如果传入的参数是ExpandoObject的一个属性,返回值就变成object了。需要将传入的参数显示转换成简单类型。 A. Bad 1: public int Update(dynamic entity) 2: { 3: IStoredProcedureBuilder iStoredProcedureBuilder = DefaultContext.StoredProcedure("EntityUpdate") 4: .Parameter("Title", entity.Title) 5: .Parameter("Entity_Id", entity.EntityId); 6: return iStoredProcedureBuilder.Execute(); 7: } B. OK 1: public int Update(dynamic entity) 2: { 3: IStoredProcedureBuilder iStoredProcedureBuilder = DefaultContext.StoredProcedure("EntityUpdate") 4: .Parameter("Title", entity.Title as string) 5: .Parameter("Entity_Id", (int)entity.EntityId); 6: return iStoredProcedureBuilder.Execute(); 7: }

开发杂记:chrome下只用做background的td标签width-height偏差

by kevin 3. 六月 2013 13:54 >
这几天,在写CSS的时候,碰到两个问题。 1. 对chrome下只用做background的td标签height设置为5px,但实际显示的效果是6px。 解决的方法是:在td内添加一个div,设置div的height为5px; 原始代码: 1: <td class="top" colspan="6"></td> 2: <style> 3: .top {width: 1183px; padding: 0px; height:5px; background-image: url(/Content/Image/UI/Order/myorder_top.png); background-repeat: no-repeat; } 4: </style>   改进后: 1: <td class="top" colspan="6"> 2: <div class="topContent"></div> 3: </td> 4: <style> 5: .top {width: 1183px; padding: 0px; height: 5px;} 6: #myOrder .item .top { height: 5px \9;} /*ie8*/ 7: .topContent {padding: 0px;height: 5px; background-image: url(/Content/Image/UI/Order/myorder_top.png); background-repeat: no-repeat; } 8: </style>   2. 对chrome下只用做background的td标签height设置为5px,但实际显示的效果是6px。 解决的方法是:利用webkit的css hack,将width设置为4px. 原始代码: 1: #myOrder .item .right { width: 5px; padding: 0px;background-image: url(/Content/Image/UI/Order/myorder_left.png); background-repeat: repeat-y;} 改进后: 1: #myOrder .item .right { width: 5px; padding: 0px;background-image: url(/Content/Image/UI/Order/myorder_left.png); background-repeat: repeat-y;} 2: @media screen and (-webkit-min-device-pixel-ratio:0){#myOrder .item .right{ width: 4px; } }   width偏差的原因:google了下,说是自动表格布局下,各个浏览器对最小单元格宽度(MCW)的表现不一样。猜想height偏差估计也是相同的道理。 参考资料: 自动表格布局:http://www.w3.org/TR/CSS21/tables.html#auto-table-layout width偏差:http://w3help.org/zh-cn/causes/RE8018          http://w3help.org/zh-cn/causes/RE9019

开发杂记:作为背景的div的高度宽度无法自适应

by kevin 27. 五月 2013 11:08 >
很多时候,我们希望给div加个圆角的边框,或者图片边框。很自然,我们想到九宫格的布局。这时,不应该考虑使用div来实现九宫格,而要使用table来实现,因为作为背景的div的高度宽度无法自适应。如下: auto width auto height   auto height   auto width  

开发杂记:iis7下配置ftp passive端口

by kevin 8. 五月 2013 00:09 >
把Windows翻译成“晕到死”,绝对是一个不错的翻译。服务器配置起来是这么的坑爹。 已经安装好IIS7也配置了FTP,奈何因为安全问题,数据端口只能使用固定的端口。 google了下,看到各种说法。终于找到一个靠谱的。 Configure the FTP service to only use a limited number of ports for passive mode FTP In the IIS 7.0 Manager, in the Connections pane, click the top node for your server. In the details pane, double-click FTP Firewall Support. Enter the range of port numbers that you want the FTP service to use. For example, 41000-41099 allows the server to support 100 passive mode data connections simultaneously. Enter the external IPv4 address of the firewall through which the data connections arrive. In the Actions pane, click Apply to save your settings. 注意黄色的 top node,对,是服务器级别的,不是站点级别的,进入某个具体的站点,你根本改不了。 这个一定要吐槽一下。 再注意,土红色的那段,那个根本就不需要配置,丫的,还是服务器级别和站点级别都可以配置的,其实根本就没什么影响。这个也让人很无语。 再来,这些配置好了,还要配置防火墙,你去google下,有n中配置方案,有的还是相反的配置方法。最简单的,自己手工开放相应端口(21和相关的数据端口)。 不要以为,这样就可以了,找个ftp客户端连上,发现还不能用,提示无法传输数据。或许,你还能马上想到,是不是要重启站点,好吧,重启了,还不能用,那就重启IIS,居然还不能用,晕到死了吧。还是问谷歌吧,在某个偏僻的角落找到答案了,打开windows服务(services.msc),将Microsoft FTP Service 重启,再试一下,居然可以了。 对于这种东西,哥表示无语。。。。。。。。。。。。。。。 写在这里,后用。

开发杂记:SQL Server 2008 Management Studio记住密码失效

by kevin 6. 五月 2013 21:48 >
忘了是哪一天,使用了不同用户名登陆SQL Server,同样是勾选了“记住密码”,只是密码出错了。MS果然很坑爹,从那以后,不过连接哪台Server,都无法记住密码,就连之前保存的也不行。忍了一个月,终于受不了。问了google,解决方案很简单: 清除SQL Server Management Studio的历史记录,很简单,然后重新“记住密码”,只要删除或重命名文件SqlStudio.bin即可。该文件通常在以下目录: C:\Documents and Settings\Administrator\Application Data\Microsoft\Microsoft SQL Server\100\Tools\Shell\   果然凑效。

开发杂记:jquery事件绑定

by kevin 27. 四月 2013 10:38 >
几对绑定事件和解绑的方法: live和die bind和unbind delegate和undelegate 他们的差别 英文版: http://www.alfajango.com/blog/the-difference-between-jquerys-bind-live-and-delegate/ 中文版: http://kb.cnblogs.com/page/94469/ 重要的是他们是一一对应的,不要搞混。 就是用bind绑定,就用unbind解除,不要用die和undelegate。

开发杂技:double和decimal

by kevin 26. 四月 2013 13:53 >
(1)double是双精度浮点型,精确计算中使用浮点数是非常危险的。 (2)decimal类型并不是C#中的基础类型,所以使用的时候会对计算时的性能有影响。 还有两个非常危险的错误认识!!   1、decimal不是浮点型、decimal不存在精度损失。 decimal是一个不折不扣的浮点型,不论它精度有多高,精度损失依然存在! 2、decimal所能储存的数比double大,从double到decimal的类型转换不会出现任何问题。 只有从整形到decimal的转换才是扩大转换,decimal的精度比double大,但所能储存的最大数却比double要小。

开发杂记:好用的linux命令

by kevin 13. 四月 2013 21:16 >
du -ah --max-depth=1 查看当前目录下所有文件和文件夹的大小 查找指定模式的文件或者文件夹所在的目录 查找目录:find /(查找范围) -name '查找关键字' -type d 查找文件:find /(查找范围) -name 查找关键字 -print

打赏请我喝果汁咯

支付宝 微信

关于我

80后,单身,平庸的程序员。

喜欢看书,乐于交友,向往旅游。

遇建Kevin

FluentData交流群:477926269

Fluentdata