2012 年 08 月

浏览模式: 标准 | 列表 | 图文
mac下安装brew和git

mac下安装brew和git

自从升级到了ml,GIT无效了,我晕啊,怎么办?跑到code.google.com上面,却发现,居然只有snowleopard版的git,这可让人怎么办啊。
问群里,回复说直接:brew install git就完事了。有这么简单?
于是直接运行brew install git。告诉我Brew是不存在的问题。
google了一下,原来有一句简单的命令:

sudo su
curl -L http://github.com/mxcl/homebrew/tarball/master | tar xz --strip 1 -C /usr/local

一下子就安装完了。。
然后brew install git :
bash-3.2# brew install git
Warning: It appears you have MacPorts or Fink installed.
Software installed with other package managers causes known problems for
Homebrew. If a formula fails to build, uninstall MacPorts/Fink and try again.
==> Downloading http://git-core.googlecode.com/files/git-1.7.11.4.tar.gz
######################################################################## 100.0%
==> make prefix=/usr/local/Cellar/git/1.7.11.4 CC=/Developer/usr/bin/llvm-gcc CFLAGS=-Os -w -pipe -march=core2 -msse4 -mmacosx-version-min=10.8 LDFLAGS=-L/usr/local/lib install
GIT_VERSION = 1.7.11.4
* new build flags or prefix

。。。。。
Over

手工安装GCC

这是一个关于GCC安装的笔记。虽然说装了Xcode之后,GCC就会默认安装成功的,但是我安装之后。。并未发现GCC在哪里。可能是因为我用的xcode是预览版,包不全吧?
所以我只能找mac下的gcc安装攻略。
有个网站叫做HPC: High Performance Computing for Mac OS X ,这两天终于可以打开了,它是sf上的一个开源项目(sf.net也会被封,我晶啊,sf,不是私服。拜托。。。)
直接在首页你就会发现有三组链接:
gcc-lion.tar.gz (4.8), gfortran-lion.tar.gz (4.8) (gfortran only), updated April 2012 (10.7 Lion only).
gcc-mlion.tar.gz (4.8), gfortran-mlion.tar.gz (4.8) (gfortran only), updated July 2012 (10.8 M. Lion only).
gcc-4.7-bin.tar.gz (4.7.1), gfortran-4.7-bin.tar.gz (4.7.1) (gfortran only), updated July 2012 (Lion & M. Lion).

如果你已经升级到了mlion,当然是下载中间那组链接了。。。不过我想你不会用fortran的。所以。。。随便你了。

OK,如果你下载回来,眼睛闭着就直接双击解压,那你是肯定不能运行的。怎么办?
两步操作:
1、gunzip gcc-mlion.tar.gz ,解压到一个目录下
2、tar -xvf gcc-mlion.tar -C / (这一步一定要用sudo权限哦,否则无法解压到根目录下哦。。)

如果还不行。参考:http://www.memoryz.info/install-gcc-on-mac.html
他说:

如果遇到问题请进行这一步(感谢 Haozhan)。

打开.bash_profile(没有的话就创建一个)
vi ~/.bash_profile

输入以下内容并保存
export PATH=/usr/local/bin:$PATH

他还说了。。。如果你不习惯命令行操作,还有pkg的安装包:

不过上面的方法由于需要输入命令,略显麻烦,特别是对于不太习惯代码的朋友。后来发现了 OSX GCC Installer 这个玩意儿,比起前面的步骤轻松很多。

上面提供了两种方法,一种是使用作者事先编译好的安装包;另一种是自己编译,需要用到 Xcode 的安装程序。不过鉴于下载 Xcode 这个“庞然大物”需要不少时间,特别是对于使用小水管的朋友,我们就采用第一种方法了。可以前往官网下载,也可以使用下面的链接直接下载。

不过,我推测这种方法安装的 gcc 会更好些,毕竟是从 Xcode 中提取出来的,理由如下:

[MacIdea] 我专业也不是 CS,所以不一定分析得全面。这里提下这个 gcc 和 Xcode 安装的 gcc 最大区别是 Xcode 的 gcc 可以用 llvm(我也不知道是什么,据说是 low level visualize…)。这个对汇编的优化做得很好,所以是用最新得 gcc 还是用 Apple 直属系得 gcc,取舍由你吧。对于一般编译,没有区别。

----EOF----

不过因为那个PKG文件中没有mlion的安装包,所以我还是选择了自己解压缩的方式

第一次打屁股

第一次打屁股

其实也不算是什么大事,但还是狠狠的打了几下屁股
先是在娱乐的时候抽了他老妈一巴掌,和他说了,请道歉。结果死不认错,因为不涉及我,而且挨打的人也没有强烈要求,所以先忍着了。
然后要求妈妈陪睡、外婆陪睡,告诉他需要一个人睡(以前也有一个人睡的情况),不听。
在床上翻来覆去,不睡,然后突然从床上站起来,在床上直接开门,差点摔下床。经教育不听。。
最后说了几句很纠结的话:我一定要XXX,我就是要XXX。屡次教育不听,好说歹说不听,最终忍无可忍,抽了几屁股。

外婆看不下去了。然后就过来陪他睡了。这点非常不爽,以前每次都是这样。一旦说教开始了,他总会拉上外公外婆。
------
这是第一次打,实在不想打的。没办法,现在越来越放肆了。出去的时候,看到长辈不叫人;到人家家里玩的时候,如果对方有阻止的行为,居然还敢用脚踢;等等等等。虽然都不是大毛病,但终究不是好事。所以,偶尔打一下还是必须的。
------
顺便说一下,前天看电影的事情
手机上买了三张电影票,我爱灰太狼。。。我晶啊。海报上都是动画片,结果一看居然是真人版的。。。
电影院这玩意,还真不能深究啊。影院外面看上去不错,结果,因为找不到位置,打开电筒,靠,这个位子上。。全是斑斑点点。好象是以前的装修污渍。。。。实在受不了

这个要转:酒精能让IT公司更富有创造力吗?

这个要转:酒精能让IT公司更富有创造力吗?

这个文章一定要转啊,难得说有推荐喝酒的文章。当然也只是说说了,毕竟真的在公司里喝酒,恐怕是任何公司都不能接受的吧?
不过。我还是要转一下下哦。我总认为写程序的时候喝少量的酒,可以使得人从单核 变双核。哈哈。在非IT公司,是坚决不能接受喝酒的吧?
原文这么说:

在硅谷这个云集了各大IT公司和IT精英的地方,似乎对酗酒这一行为不会表现出特别反感的情绪。虽然的确是有一小群人认为酒精就是将人拖入 黑暗边缘的邪恶之液。《经济学家》杂志就指出也许我们会在周末喝醉,但那完全没关系。但是现在似乎这样的情况越来越多都是发生在我们的商务时间。另外, 《消费者心理学》也曾指出如果一位政要候选人如果在一个晚宴采访中喝酒,那么人们就会认为他没有另外一个候选人睿智。
不过,有些人认为适度饮酒可以舒缓精神上的压力。对于笔者我来说,一点Saracina的黑皮诺或者是一小杯Idle Cellars的2008解百纳可以让我能够清除掉一些障碍,从而重新理清我的思路。

不过,这种情况还是需要科学理论来支持。

近日,一篇来自《意识与认知》的一篇论文中解释了为什么酒精可以让人们的精神可以得到舒缓的原因。在文中,研究人员将研究对象对位中毒酒精中毒的人群-- 酒精在血液中的含量0.075mg/mL/h。在研究过程中,被研究对象接受了远程合作测试,从而检测出他们是否能够在解决问题的时候表现出一定的创造 性。而研究最终得出的结论是醉酒程度越轻的人则在同样的时间内解决的问题越多、越快。当被问及他们是怎么想到问题解决方法的时候,他们纷纷表示当时就是有 一种灵光乍现的感觉。

也许,在硅谷的产生的好想法也都是在这样的情况下产生的。
---EOF---
原文来自:http://www.cnbeta.com/articles/201130.htm,你如果是老板,你会怎么样?偶尔可以还是一直可以?你会提供酒吗?黑黑

儿童博物馆

昨天带小朋友去逛儿童博物馆了。本以为是一个相对较大的地方,结果,原来只有很小的两层楼。在这两层楼里有三四个方面的知识点:航海、航空、信息、视听(娱乐例外)

航海,介绍了一些船只,还有一个小潜艇可以爬,嗯,还有一个造浪机+一个灯塔+吊着的几条鱼的模型。
造浪机就是让你拼命的转一个小转轮来形成大浪,将船打翻。其他就没啥了。在船只介绍的地方有一个电视机不停的在详解各种船只,只是小孩子们都没有兴趣 坐下来看,反而是和我老婆两个人在那里看了半天。。。

航空,有一些拼图,能够拼出卫星、地球等,还有一些火箭的模型等。最后还看了一下模拟卫星发射,以及月球表面的体验,月球那个屋里好象有荧光哦。所以我的 裤子就会发光了。哈,有意思,不过小朋友还是觉得没劲。不过在下午看了360度的屋顶投影的电影。只有20分钟。。反而他倒是过瘾了

25082d5bcf4de2857ec240a9b3b19691
ee0e66909ea7c8344580a63185f195b8

信息区,这里才是比较有劲的地方,小朋友在一台小电脑里画了画,然后就成为101010到墙壁上。只要挡住这些10101,图片就会显示出来。肖佑阳是玩 的乐此不彼;再走过去就是一些节能的介绍(有小游戏);还有地球 污染的介绍(同样是小游戏);还有捡垃圾的小游戏 。小朋友也是玩的很开心

视听区:有电影可看,上午是飞屋环游记(英文的。。。。),下午是大闹天宫,看了一小会,觉得没劲。。旁边倒是有不少小人书,过去一看,全是200x年出的书,害我激动一下,以为是旧书呢。。
8b5e903f2d038c7f402be925c3a16067
娱乐区就不玩了,无非就是一些过家家的游戏,小朋友对这几乎没啥兴趣。
f76ed4db10681f784a7a288456cf198a

TextMate高端黑引发开源“圣战”????

TextMate高端黑引发开源“圣战”????

前两天好象听说。textmate 开源了?不知道是否听错,但传闻是在st(sublime Text2)的压力下开源的。。。(没有亲见,只是听闻而已)
结果又在cnbeta上看到标题所在的新闻了。。。
cnbeta上这么写着:

感谢中国 Linux 公社的投递
最近,一位 ID 为 ieure 的用户在文本编辑器 TextMate 的 GitHub 上提交了一个 patch,号称“修复了许多 bug”。在描述中,他说自己尝试使用 TextMate2,但是遇到了很多不可接受的错误。于是他制作了这个可以解决一切问题的 patch。

但这个 patch 的改动量实在是太大了,大到令人怀疑:算下来这个 patch 一共执行了几百万次代码改动。果然,这是一个来自高端黑 Emaser 的作品:这个 patch 会把 TextMate 删除干净之后安装上 Emacs.

于是这 patch 自然又是引起了一次已经让大家习以为常的“圣战”,Vim 用户也积极插上来一脚责问作者为什么不把它换成 Vim。但亮点根本不在于这场圣战本身,而是在于围观群众。

大量的中文用户观光团(包括但不限于豆瓣、煎蛋)跑到了这页面下面围观并留下脚印。现在,这个页面上绝大多数的留言都是中文的,内容也大多都是“XX观光团”。这还真是一则相当不错的黑色幽默呢。

截至发稿时,这个页面已经基本被中文回复占领,用户大多是来自豆瓣/人人/新浪微博/煎蛋的围观群众。

围观地址:GitHub

---EOF--
果然看到了很多类似“<豆瓣观光团> ”这样的内容。。。。中国人真多,这是我的感慨 .其他没了。

PHPer下一步应该学go?

PHPer下一步应该学go?

其实看到现在,很多人都在推荐go语言,理由有很多种,但对于PHPer来说,不一定就是适合的。go是google推出的语言,到现在为止也已经有很长时间了,再加上go又能底层,又能WEB,所以。。。
但是,究竟应该不应该学,还是会有点想法,所以看到这篇全英文的介绍的时候就蛋定不了了。
原文是来自于:Why you PHP guys should learn Golang

Go or Golang, is a open source, community supported, fast, consistent, scalable, productive language, and conceived by Google. More and more applications were build with it. Although Rob Pike has said that “… we expected C++ programmers to see Go as an alternative …”, but I really think of that: You PHP guys should learn Golang! Let’s talk about WHY.

Easy to learn

PHP is easy to learn. Golang is as easy as PHP!

The syntax of PHP is similar to C family’s programming languages(C/C++/Java etc.). If you have some experiences with those languages, it is not too hard to write some codes when you first met PHP.

Golang is also a C family’s programming language. Eh… with a litte syntax difference. For example, the keyword “for” is similar with PHP’s, but without the pair of parentheses. And the condition keyword “if” is without the pair of parentheses either. You can read Effective Go for more things.

Golang has only 30 keywords and 47 operators, delimiters or other special tokens. There is no need to work hard for remembering all the literals. The type system is exquisite and easy to use. No huge OO but a practical struct type with methods on it. The interface design is one of my favorate parts of Golang. When you have finished this A Tour of Go, based on your PHP experiences, some jobs could be done with Golang immediately.

Easy to Use

Your PHP scripts will be evaluated by SAPI components: web server module, PHP-fpm or CLI. All needed for PHP deploying is a SAPI environment. Deployment of the environment is the most difficult part to understand for a PHP beginner.

All the Golang’s codes will be compiled and linked into native code. So there is no need to deploy a environment for it executing but a build environment. Compaire with deployment of the PHP environment, it is not so much complex. Do you really think of the deployment of the PHP environment is really complex? I don’t think so. Really!

To deploy the build environment, just need 3 steps:

  • Download Golang‘s source code.
  • Setup the environment variables. Here’s a great blog post: Go environment setup
  • Run the ‘all.bash’ in the ‘src’ directory.

Or only one step: Use the binary package to setup.

Then a toolset called “go” can be used. Using the go tool is as easy as using PHP’s CLI tool. “The Go Tool” has already explained it.

A myth of PHP

If a programming language is easy to learn and use, shall we learn and use it? Lots of programming languages are easy to learning and use. Shall we learn and use all of them? The answer is straightforward: NO!

But why you PHP guys should learn Golang? Just because it is cool! Ja, I’m kidding, but it is true. Anyway, let’s talk about PHP itself first.

PHP is “a general-purpose server-side scripting language originally designed for Web development to produce dynamic Web pages.(Wikipedia)”. The most important feature of PHP is embedding with HTML. PHP code write in “<?php … ?>” tag; HTML write outside. It also has a powerful extension system. The extension can be writen by C with Zend API. Data processing was actually done by those extensions. IMO, PHP must be the best template programming language.

But if you have years experiences with PHP and began face to some complex web application. You must have already felt some powerlessness to PHP. It dosen’t have concurrent mechanism build-in, no threads, multiprocessing or X-routines. A slow data source will be blocked entire page’s processing. A powerful web server in the front of PHP is always needed. Backend programes were writen to process data. Message Queue, Cache, Proxy … The system is not only about PHP, but also about a lot of services and system components. This time, PHP is really be a template language with few logical jobs.

PHPers are always looking for solutions, like “PHP multithread” or a concurrent RPC framework for PHP. I could not say witch one is better. But I’m sure that you must choose an other programming language for the backend job. In my own case, I tried C(struggle with malloc/free)/Java(stumble in the jar hell)/Python(never be pythonic but type lost)..If I get profermance, I must struggle with the memory management; If I use GC, I must deploy and turning VM; If I get convenient, careless would kill me….Eche has advantages, each also has a problem.

OK! Let’s back to Golang now!

Golang has GC, there is no need to care about memory management(or could pay less attention to it). And the code are compiled into native machine code. So, “cp” and “mv” are all needed for deploying the application writen by Golang. Oh, as I just said, Golang is a compiled language with a static type system. You have no chance to confuse veriable types. Of course, one of the most important thing is PHPer who moves to Golang “don’t have to surrender much expressiveness, but gain performance and get to play with concurrency(by Rob Pike)”. “Why Not Go?” talked about this deeply.

I would show parts of my own experience: a Gearman worker works for us to process backend data. PHP connected to the worker though Gearman Job Server with its Gearman API. The original worker was writen by python. There are lots of problems with that version(They are our own problems, but python’s). But it works for us. Then we rewrite the worker with Golang. It was amazing. I wrote a Gearman API for Golang, and a Golang package using Zend API(cgo is another amazing thing) for evaluating the PHP script in Golang. Then combined them together – A Gearman worker witch can execute PHP scripts. It works about 3 mounth in our production enverionment and looks great! Oh, I also wrote a RPC-combinator for combining the RPC call in PHP script. It will be used in our next product.

Everything goes right. Thanks Golang!

In any case, most of PHPers alwasy need to learn other languages for the backend development. If you have began looking for, or already tasted some of other languages. Why don’t you try Golang? It would make your life happy and easy. You could spend more time with your family and friends, eat your favorite foods and visit the places you love.

That’s why you PHP guys should learn Golang! Is it enough? I think so!

This is my writing exercise. If you find any grammatical or spelling error, plz tell me!

---EOF---

其实我也挺纠结的,要知道当时我刚跟着tour做了30多篇的时候,突然golang的网页就再也打不开了。再苦了,墙就是我们学习的最大障碍。想想这些年我们遇到了什么。。
sf.net被墙
groups.google.com被墙
python.org被墙
很多。。。。。这些都是我们的障碍啊

程序员遇到BUG怎么办?

程序员遇到BUG怎么办?

这是微博上的一小段内容:
【程序猿被提bug之后的反应】1.怎么可能;2.在我这是好的,不信你来看看;3.真是奇怪,刚刚还好好的;4.肯定是数据问题;5.你清下缓 存试试;6.重启下电脑试试;7.你装的什么版本的类库(jdk)8.这谁写的代码;9.尼玛怎么还在用360安全浏览器;10.用户不会像你这么操作 的。
原微博在这里:http://weibo.com/1577794853/ywgaHrmRE

哈哈。有好多次都是以5来处理。但现在没有很好的缓存清理工具。一般不会说10.。。说10的话太恶心了
45ec222c9f14a329dee4fb65660f7b49

重拾扔了两年的scala

重拾扔了两年的scala

Scala被我扔了很久了。没办法,项目中根本用不到。而且说真的,不是相对较大的公司,以及项目很多很杂的公司,混合编程真的很少用的到。一般来说用用C和PHP就能解决N多事情了。当然C我也是垃圾。。。。可是如果你并不深入,C用的也很少。不是吗?

现在很多项目中越来越追求一些其他的特性,不得已,重新拾起来。原来我在学scala的时候,只是简单的折腾了几下就完事了,现在可能要深入一下下了。。亚力山大啊

Scala大家都知道啦,其实说白了,Scala就是一种针对 JVM 将函数和面向对象技术组合在一起的编程语言。Scala编程语言近来抓住了很多开发者的眼球。它看起来像是一种纯粹的面向对象编程语言,而又无缝地结合了 命令式和函数式的编程风格。Scala的名称表明,它还是一种高度可伸缩的语言。Scala的设计始终贯穿着一个理念:创造一种更好地支持组件的语言。 Scala融汇了许多前所未有的特性,而同时又运行于JVM之上。这两年,随着开发者对Scala的兴趣日增,以及越来越多的工具支持,无疑Scala语言将成为手上一件必不可少的工具。

因为资料确实不多,所以就找了51cto上面的一个专题来看:http://developer.51cto.com/art/200906/127830.htm,不过可能更多的还是需要看官网的手册了。否则真的没有办法深入。

专题上有不少链接还是有用的,其他的就当看新闻吧,不过也是旧闻了。。。

还有三个较长的玩意。。。

A Scala Tutorial for Java programmers(完结)

本文源自Michel Schinz和Philipp Haller所写的A Scala Tutorial for Java programmers(面向Java程序员的Scala教程),由Bearice成中文。本系列面向有一定Java开发经验的程序员。

走读Kestrel,了解Scala(完结)

Kestrel是一个Scala代码实例,是Twitter核心中使用的的消息转发机制,其原型来自于Ruby的Starling。本系列通过Kestrel进行Scala实例代码的讲解,对于实际使用Scala进行开发有相当的借鉴意义。

IBMDW的《从Java走进Scala》系列(更新中)

本系列由Neward & Associates的主管Ted Neward主持。本系列从08年初开始连载,可以说是早期Scala教程中的比较精彩的一个系列,对Scala语言中的很多细节都进行了描述。

-------

如果你兴趣不大就当看我这边也是一个新闻 吧。

一不小心又把数据库折腾挂了

一不小心又把数据库折腾挂了。你妹啊。我只是移动了一点文件,居然就直接挂了,无法启动
再启动的时候,居然直接说。。。mysql启动文件找不到了。什么mysqld_safe之类都在。就是没有mysql。。。
当时心里就郁闷了。用repair修复的时候说。。。plugin表没权限 又说host表没权限 .
苦。最后在vampire的帮助下才搞定了。

苦。