Submitted by gouki on 2014, December 16, 9:57 PM
小笔记
var dateFormatter = NSDateFormatter();
dateFormatter.dateFormat = ""; //时间格式,参考 :"yyyy'-'MM'-'dd'T'HH':'mm':'ss'Z'"
于是就可以:
dateFormatter.stringFromDate( NSDate 的值,比如 datePicker.date )
简易方法:
XML/HTML代码
- func dateformatterDate(date: NSDate) -> NSString
- {
- var dateFormatter: NSDateFormatterNSDateFormatter = NSDateFormatter()
- dateFormatter.dateFormat = "MM-dd-yyyy"
- dateFormatter.timeZone = NSTimeZone(abbreviation: "UTC")
-
- return dateFormatter.stringFromDate(date)
-
-
- }
-
- //--- Convert Date String to NSDate ---//
-
- func dateformatterDateString(dateString: NSString) -> NSDate?
- {
- var dateFormatter: NSDateFormatterNSDateFormatter = NSDateFormatter()
- dateFormatter.dateFormat = "MM-dd-yyyy"
- dateFormatter.timeZone = NSTimeZone(abbreviation: "UTC")
-
-
- return dateFormatter.dateFromString(dateString)
- }
Flutter | 评论:0
| 阅读:17476
Submitted by gouki on 2013, December 16, 10:45 AM
备份性的文章,所以先不管三七二十一就CP过来,最起码这篇文章是2012年的,短时间内应该还是有效的
原文来自:https://dong.io/201202/fix-your-macbook-pro-by-reset-hardware/
今天发现新买的MacBook Pro的一个USB口异常。具体表现是连接到移动硬盘之后,硬盘灯闪亮但是Mac无任何反映。而且,iPhone也无法通过此USB口充电或数据传输。经过Google,找到了下面的步骤来解决:
- 关闭电脑。
- 按住SHIFT+CTRL+OPTION+POWER十秒钟
- 按住OPTION+CMD+R+P+POWER,Mac会不断重启而不进入操作系统,四次(官方说三次)之后松开
- 正常开机即可
然后USB口就正常了。事后从Apple的官方文档中找到了这些组合键的作用,并且发现上述步骤其实是两个不同的重置操作。
SHIFT+CTRL+OPTION+POWER十秒钟:重置系统管理控制器(SMC)
- 关闭电脑。
- 将 MagSafe 电源适配器连接到电源和 Mac(如果尚未连接的话)。
- 在内建键盘上,同时按下(左侧)Shift-Control-Option 键和电源按钮。
- 同时松开所有键和电源按钮。
- 按电源按钮打开电脑。
注:重置 SMC 时,MagSafe 电源适配器上的 LED 指示灯可能会更改状态或暂时关闭。
在风扇、电源指示灯、系统性能、视频出现某些异常时候,可以通过上述方法进行重置来解决。具体的症状判断和说明可以参考"基于 Intel 的 Mac:重置系统管理控制器(SMC)"。
OPTION+CMD+R+P+POWER:重置NVRAM 或 PRAM
Mac 会将某些设置储存在特殊内存区域中,而且即使关机这些设置也不会丢失(除非存在电池问题)。 在基于 Intel 的 Mac 上,存储位置是称为 NVRAM 的内存;而在基于 PowerPC 的 Mac 上,存储位置则是称为 PRAM 的内存。操作步骤为:
- 关闭电脑。
- 在键盘上找到以下按键:Command、Option、P 和 R。您需要在步骤 4 中同时按下这些键。
- 启动电脑。
- 按住 Command-Option-P-R 键。必须在出现灰屏前按下此组合键。
- 按住上述键,直到电脑重新启动,您会再次听到启动声。
- 松开这些键。
在NVRAM和PRAM中保存着很多硬件的配置,并且不会因为关机而丢失。详细的信息可以参考"重置 Mac 的 PRAM 和 NVRAM","何时要重置 NVRAM 或 PRAM","Mac OS X:PRAM 中存储的是什么"。
当Mac遇到电源和硬件的异常的时候,如果不是外伤则可以考虑进行重置(谨慎,推荐事先咨询天才吧技术人员),如:不能打开、不能从睡眠状态中唤醒、不能给电池充电、不能看到AC适配器,在连接AC适配器后被电击,USB失灵等。另外Power系列和Intel系列还存在着操作上的差异。
但是目前不清楚哪个重置操作解决了USB口失灵的问题;其次不清楚这些重置是否有其他副作用。
-----
话说,这里还有一个英文版:http://www.ruddwire.com/1017/tech/macbook-pro-turns-on-but-screen-stays-black-my-solution/#.Uq5owmRF56A
解决了一个小问题:macbook pro turns on but screen stays black — my solution
The Apple Macbook Pro would turn on, but the screen would not. The screen would stay black. I could tell the computer was on because when I hit the “caps lock” key, the green light on the key would turn on and off.
- I fixed this the following way (this is basically resetting the Power Management Unit — PMU):
- I disconnected the computer from the power cord, and from all other cables.
- I held down the power button for several seconds to turn off the computer.
- I let it sit 5 minutes.
- I restarted the laptop while holding down the Shift key. This restarted the computer in Safe Mode, with the screen visible again.
- After I logged in (in Safe Mode) to make sure everything was ok, I simply restarted the computer the normal way, and the screen behaved normally again.
=================================
If that doesn’t work for you, you could try these steps, documented at apple.com:
Holding down Command, Option, P, and R to reset your PRAM and NVRAM
Resetting PowerBook and iBook Power Management Unit (PMU)
Flutter | 评论:0
| 阅读:35760
Submitted by gouki on 2013, October 12, 10:38 PM
最近不知道为什么,突然间dock喜欢上了假死这个状态。之前一直不知道怎么处理,因为看了下没有什么cpu占高的动作。cmd+tab也无效了。。
dock也点击不上去,于是我想,难道我杀掉dock就OK了?
于是利用spotlight打开终端(正好我finder窗口都关掉了。所以没有办法打开。而且spotlight速度更快)
输入:killall -KILL Dock
Dock自动重启。所有的不正常状态全部恢复 了。这TMD是怎么回事?因为它连cmd+tab也恢复 了,难道Dock接管了这么多的东西??
再看了一下,网上也有类似的问题和回复,比如:http://www.thxbye.de/mac/mac-restarting-the-mac-os-x-dock-finder-spaces-or-menubar.html
它里面也说了一些情况 ,好吧。我menubar没有死。不然我还没办法用spotlight。
XML/HTML代码
- Sometimes it just seems to happen, you're getting the spinning beachball on Mac OS X System Applications/Tools, like the Finder when connecting to a messed up network share. Luckily, most of the time it's easy (yet annoying) to fix via starting the Terminal and using following commands (beware, the names of the programs to kill are case sensitive!):
-
- The Finder crashed:
- killall -KILL Finder
- (you can also restart the Finder by option (=alt) + rightclicking the Finder icon in the Dock and selecting Relaunch. It doesn't always work though.)
-
- The Dock crashed:
- killall -KILL Dock
-
- Spaces crashed:
- killall -KILL Dock
-
- The Menubar crashed/refuses to be clickable:
- killall -KILL SystemUIServer
-
- All these services should automatically restart after they have been killed. If for some reason they won't, you're probably better off just rebooting (to be sure, the "Shut Down" option from the Finder/Menu bar will probably not help, just go to the Terminal and type: sudo shutdown -r now - provide your Admin password and your machine should be restarting).
-
- Good luck!
HOHO
Tags: dock, kill
Flutter | 评论:0
| 阅读:17620
Submitted by gouki on 2013, July 3, 10:36 AM
不要惊讶我将它放到PHP分类里,这是我在啄木鸟社区上看到的,看看那些在python上坚持了这么多年的人,在学习领会胡主席的八荣八耻后,对自己的要求:
以动手实践为荣 , 以只看不练为耻; 以打印日志为荣 , 以单步跟踪为耻; 以空格缩进为荣 , 以制表缩进为耻; 以单元测试为荣 , 以人工测试为耻; 以模块复用为荣 , 以复制粘贴为耻; 以多态应用为荣 , 以分支判断为耻; 以Pythonic为荣 , 以冗余拖沓为耻; 以总结分享为荣 , 以跪求其解为耻;
原文地址在:http://wiki.woodpecker.org.cn/moin/Py8Rong8Chi
我是觉得可以适用于任何语言。当然pythonic之类的就需要套用自己当前语言了。
Tags: python
PHP | 评论:0
| 阅读:16145
Submitted by gouki on 2013, June 8, 5:54 PM
说实话,关于存储过程的博客还真的不多,有几个是值得看一下的
1、官方;http://dev.mysql.com/doc/refman/5.1/zh/stored-procedures.html
2、http://www.netingcn.com/tag/%E5%AD%98%E5%82%A8%E8%BF%87%E7%A8%8B
3、http://blog.why100000.com/?p=711
也发现,如果不做复杂查询,存储过程对我来说几乎没有,本来是想解决查找GEO相关的信息的,但发现这样的SQL:
SQL代码
- SELECT userid,lat,lng,gender,
- ( 6371 * acos( cos( radians(31.000700) ) * cos( radians( lat ) ) * cos( radians( lng ) - radians(120.000099) ) + sin( radians(31.000700) ) * sin( radians( lat ) ) ) ) AS distance
- FROM `user_geo` WHERE last_activity_time > '2013-03-11 00:00:00'
- ORDER BY distance ASC limit 100
这其中的复杂度就在于distance每次都要计算,所以我尝试换成了存储过程:
SQL代码
- DROP PROCEDURE IF EXISTS search_around_user;
- DELIMITER //
- CREATE PROCEDURE search_around_user
- (
- s_lat float(10,6),
- s_lng float(10,6),
- s_last_act datetime,
- s_gender tinyint,
- s_number tinyint,
- s_page tinyint
- )
- LABEL_PROC:
- BEGIN
- if s_number <= 1 then
- set s_number = 20;
- end if;
- if s_page <= 0 then
- set s_page = 0;
- end if;
- if s_gender <= 0 then
- set @genderQuery = "";
- else
- set @genderQuery = concat(" and gender = " , s_gender , " ");
- end if;
- set @limitQuery = concat("LIMIT " , s_page * s_number , " , " , s_number , " ");
-
- set @strsql = CONCAT("select userid, ",
- "( 6371 * acos( cos( radians(",s_lat,") ) * cos( radians( lat ) ) * cos( radians( lng ) - radians( ",s_lng," ) ) ",
- "+ sin( radians( ",s_lat," ) ) * sin( radians( lat ) ) ) ) AS distance ",
- " FROM user_geo where last_activity_time >= '", s_last_act , "' " , @genderQuery , " ORDER BY distance " , @limitQuery) ;
-
- prepare stmtsql from @strsql;
- execute stmtsql;
-
-
- END LABEL_PROC;
- //
- DELIMITER ;
然后再次调用:
SQL代码
- call search_around_user(31.000700,120.000099,'2013-03-11 00:00:00',0,20,0)
所耗费的时间和上述直接写SQL的时间是几乎一样的。想来,这也是因为distance的计算不能被优化而导致的。。。于是乎,放弃用存储过程
Tags: mysql, 存储过程
Baby | 评论:0
| 阅读:18265