Flutter

浏览模式: 标准 | 列表 | 图文
转:How can I trigger a notification from a remote terminal in OS X

转:How can I trigger a notification from a remote terminal in OS X

其实这篇文章中的内容在之前我已经有引用过了,就是早先的监控ltc的脚本。当然现在ltc已经堕落了。。

看标题也可以知道我们想做些什么。所以看看老外们是怎么做的好了,原文在:http://superuser.com/questions/645036/how-can-i-trigger-a-notification-from-a-remote-terminal-in-os-x

You have not specified what kind of notification you want nor what OS the remote server is running so I am going to have to make some assumptions here. I will assume you don't really care what type of notification it is as long as you are notified and that the remote server is running some flavor of *nix.

  1. Send yourself an email. If sendmail is configured on the server, you could do

    ./long_process && echo "Job done" | sendmail pnj@yourdomain.com 
  2. ssh back to your local machine (assuming this is possible) and make it talk to you. See here for more cool ways of making OSX beep at you.

    ./long_process && ssh you@local.ip say "Yo! All done" 

    or

    ./long_process && ssh you@local.ip terminal-notifier -message "Job finished!" -title "Info" 

    If you are connecting from a dynamic IP and you have configured your router so that you can ssh to that dynamic IP, you can do this (assuming you are only currently connected from your remote machine):

    ip=$(who | grep $USER | perl -lne 's/\\((.+?)\\)\s*$//; print "$1"' | tail -n 1) &&  ./long_process && ssh you@$ip terminal-notifier -message "Job finished!" -title "Info" 

    You can set up password-less ssh in the normal way. It should not be affected by the dynamic IP. Once you have done so, the code above will work.

  3. Use pushover and send a notification to your Android or iOS device (if you have one)

    ./long_process && pushover.pl "All done"

---EOF--

这里面有很多方便,但其中的一种就是terminal-notifier。

转:使用 MacBook Pro 的硬件重置功能解决故障

转:使用 MacBook Pro 的硬件重置功能解决故障

备份性的文章,所以先不管三七二十一就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.

  1. I fixed this the following way (this is basically resetting the Power Management Unit — PMU):
  2. I disconnected the computer from the power cord, and from all other cables.
  3. I held down the power button for several seconds to turn off the computer.
  4. I let it sit 5 minutes.
  5. I restarted the laptop while holding down the Shift key. This restarted the computer in Safe Mode, with the screen visible again.
  6. 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)

转:30秒钟做一个ipa

转:30秒钟做一个ipa

起因来自,有人说我打包的phonegap的APP没有ituneArtwork,于是网上找了下,发现了一篇文章,来自:http://bbs.weiphone.com/read-htm-tid-144479.html

作者说的很简单,3步走即可

1、下载附件里的rar,解压

找到你想要做ipa的*.app,把*.app放入Payload里

用xp自带的记事本编辑Info.plist,找到<string> </string> 把中间的空格填入程序的名字 有4处要改

CFBundleDisplayName下面可以随便填,中文也行,这个是在iphone里显示的名字

CFBundleExecutable下面不能随便填,这是执行名字,也就是*.app下的执行文件名是123,那么这里必须填123

CFBundleIconFile这是iphone里显示的图标,一般*.app文件夹里是icon.png,如果是12b.png,请把CFBundleIconFile下面的icon.png改为12b.png

否则图标显示不正确,但是可以程序运行

CFBundleIdentifier和CFBundleName这个随便填,最好用程序名,比如12b.app 你就在那两个下面改为12b

保存并退出后,把Info.plist放入*.app里

2、把Payload和iTunesArtwork用标准zip格式压缩 在winrar里选择标准zip

iTunesArtwork是一个标准的jpg文件,你给他加个jpg扩展名后就可以打开看了。随便用什么jpg图片都可以,这个是显示在itunes里的图片,与iphone程序的图标无关。iphone程序图标只与*。app里的icon,png有关

iTunesArtwork像素一般要求是512X512.,你要是有兴趣也可以设别的试试

在这里我用的是itunes默认的黑色图标

3、把zip扩展名改为ipa扩展名

ok,ipa程序做好

-----

附件就是那个info.plist和payload的打包

PD 9 的一些小问题

PD 9 的一些小问题

PD是我第一个mac上的正版软件。最近刚升到10.9,发现我原来的7不能用了。而我事实上用pd的时间已经没有原来多了。所以我就很纠结。所幸,网上有人提供了一些Beta版,我就下载来测试了一下

本站不提供下载,请围观此贴:http://mac.pcbeta.com/thread-144172-1-1.html
下载好后,如果你没有软件查看sha1的话,你可以直接php -r "echo sha1_file('/Users/???/Downloads/Parallels_Desktop_9.0.23136.932290_%5BHIOb%5D_Fix.dmg');"

可以看一下sha1是否正确。当然你还是有可能会出现1个CPU,0M内存的BUG,翻到第13页,有人回复:

If anyone faced with the problem of failing to start a virtual machine, because she has "more than 1 MB of memory and can not be started", then try this solution (I helped)

1) Close the Parallels Desktop

2) Remove the Parallels folder from / Library / Preferences (namely from the system Library, and not from the user!)

3) Start Parallels Desktop and select "Add existing virtual machine", then enter the path to your virtual machine

OK,就这么愉快的解决了

java惊魂

java惊魂

安装完10.9,打开我的phpstorm时。无法启动了。。。

到命令行下重新打开,结果给我这么一行文字:

/Volumes/Macintosh\ HD/Applications/PhpStorm\ EAP.app/Contents/MacOS/phpstorm

No Java runtime present, requesting install.

于是去oracle网站下载了jre。。还是不行,网址:http://www.java.com/zh_CN/download/manual.jsp ,下载的时候,我还在纠结,不能在chrome下使用就不能在chrome下使用吧。。结果。是根本 就没法使用

一想,jre不行。那jdk总OK的吧?于是又跑到:http://www.oracle.com/technetwork/cn/java/javase/downloads/index.html ,下载了jdk,不料,虽然环境里面有java了,但phpstorm和idea都无法启动

gouki:Applications gouki$ java -version
java version "1.7.0_45"
Java(TM) SE Runtime Environment (build 1.7.0_45-b18)
Java HotSpot(TM) 64-Bit Server VM (build 24.45-b08, mixed mode)
gouki:Applications gouki$ /Volumes/Macintosh\ HD/Applications/PhpStorm\ EAP.app/Contents/MacOS/phpstorm
No Java runtime present, requesting install.

这。。。。太纠结了。最后,不得已。下载官方的包吧:http://support.apple.com/kb/DL1572?viewlocale=zh_CN,下载好,运行。一切OK了。

当然在这之前,我还是卸载了旧版的java。。

参考文档:

  1. http://support.apple.com/kb/HT5559?viewlocale=zh_CN&locale=zh_CN
  2. http://www.java.com/zh_CN/download/help/mac_uninstall_java.xml 【如何卸载 Mac 上的 Java 7】

---

后记,几个朋友都说在点击phpstorm的时候,直接就提示让安装java环境了。为什么我就没遇到?难道是因为我用的是phpstormEAP的版本?

邮件APP崩溃打不开

邮件APP崩溃打不开

今天终于升级到了10.9,感谢苹果的免费。我也可以升级了。本来我还担心要128,现在。。省心了

结果,升级完。邮件一打开就崩溃。在Vampire的指点下,使用命令行打开,结果发现:

/Applications/Mail.app/Contents/MacOS/Mail

2013-10-23 22:27:45.724 Mail[1644:507] *** Assertion failure in -[MailboxesOutlineViewController keyForItem:], /SourceCache/Mail/Mail-1816/Mail/Mail/Mailboxes/MailboxOutlineView/MailboxesOutlineViewController.m:1246

MailboxOutlineItemController key is nil for item <MFMailbox:0x7fdf03557b80 (relative path=, attributes=0x12, displayName=163邮件 uuid=(null))>. This probably means a nil UUID

怎么回事?a nil uuid?

既然错误这么明显,我就先禁用163邮件吧。于是去了“系统偏好设置”中,打开 "internet 帐号",将163的帐号对应的mail先暂停,然后启动mail

正常了。

这时候再启用163mail,一切正常。

经vampire解释,可能是邮件有空标题,导致了这个错误。目前没有细看,但要学会看LOG。老是偷懒不看log是不行的。

mac 下面为了端口开放而吃的药

mac 下面为了端口开放而吃的药

早上下载了sudochina的源码,在go 里面编译。结果发现了很多错误

1、用自带的build.sh编译的app,一运行就报:Segmentation fault: 11
2、自己go build一下吧,一运行就自动退出:

Starting...

Database struct sync successfully

3、用go run 吧。又读不到配置文件

为了这个折腾了很久很久,问了@正雄(sudochina的作者)。他也表示不清楚,然后给了份最新的代码我测试,问题依旧

他问我,是否端口被占用?我想了想81端口应该没有被占用吧,为以防万一,我用了8888进行了测试,结果居然OK了。这个时候我纳闷了,原来真是端口的问题啊?

试了几下,发现在1000以下的端口都不可以以普通用户绑定。好吧,我不管了,我还是用高端口进行测试吧。为了这个代码折腾了一个上午。

然后我又试了一下,sudo ./app 可以运行,证明小端口还是要有权限的。因为用之前的一个程序试的时候报这个错:2013/10/21 13:58:40 [Client Listener Error : listen tcp4 0.0.0.0:81: permission denied]

怪不得我启动nginx的命令是:sudo nginx。我以为是什么原因,原来还是端口的关系啊?

OK做个笔记 ,以后也尽量不用小端口

用phonegap打包项目

用phonegap打包项目

说实话我一直以为phonegap打包项目很麻烦,直到今天早上我试了一下。从头至尾花了大约10分钟左右,在mac下确实也比较容易

1、brew install npm ,会自动安装nodejs环境,这我不管,我只要npm就OK了
2、npm install -g phonegap 注意参数 -g,如果没有它,安装的phonegap无法加入到path里,也就无法直接在路径里输入phonegap运行
3、phonegap create /path/项目路径 -n 名称 -i com.xxx.xxx 创建一个项目
4、进行项目,再次运行 phonegap run ios ,会自动下载ios需要的包
5、进入 platforms/ios 目录,将你的程序cp到www目录下
6、双击 xxx. xcodeproj ,用xcode 打开这个项目
7、。。。。剩下的就和正常打包APP至ipa一样了

----
1、设置横竖屏,这个在plist里面进行设置(还算比较方便)
2、状态条,网上可以搜索,在plist里面也可以设置(注意ios7和以前不一样,以前只要写代码就OK了。ios7一定要在plist里面进行设置)
这两个一般就是现在需要设置的东西
如何禁用消息中心

如何禁用消息中心

10.8.x开始就多了一个通知中心,其实我个人感觉用处并不大,而且自从上一篇博客开始,我才发现,原来Dock假死的罪魁祸首就是通知中心。不知道什么时候我的通知中心出问题了,可能就是最新的一个补丁包的问题。

只要一点击通知中心的图标。Dock就假死。于是我要解决这个问题

有两种方法,1不推荐,还是使用2吧

1、将通知中心.app改名。只是恢复的时候, 不能叫通知中心,而是叫:NotificationCenter.app,这个APP在哪里?打开finder,输入cmd+shift+g(其实就是菜单中的跳到指定路径),输入:/System/Library/CoreServices/,你就可以看到了

2、命令:

launchctl unload -w /System/Library/LaunchAgents/com.apple.notificationcenterui.plist

还是第二种安全。

参考:

1.http://www.macx.cn/thread-2058406-1-1.html

2.http://www.macx.cn/thread-2064801-1-1.html

DOCK假死??

DOCK假死??

最近不知道为什么,突然间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。
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