All posts tagged Share

Sublime Text 2 Upgrade Problem

搞了半天发现好还毕竟不是sublime本身的错,要不就完全毁了这几个星期来对之的美好印象了……

btw,sublime text 2着实是个相当promising的editor,各位看官有闲情雅致且有信心记住更多的key shortcuts的话不妨一试(其实也没有多少啦),鄙人highly recommended(路人甲:你算哪跟葱……;我:……),除了其License价格不菲之外(比textmate多1刀),其余很多feature都可圈可点,好消息是beta版可以免费使用,就是时不时会有dialog跳出来提醒抑或是恶心一下你,呵呵。

废话有点多,不过鉴于某些同学口味比较重比较独特只喜欢看本人的废话部分,所以现在我基本把重要的事情都放在废话部分讲……

anyway,本次遇到的问题是sublime无法启动,报出以下颇为technical的error dialog,然后便quit,想必是目前用此editor的大多还是developer居多,所以报这种样式的error通常会被认为更为friendly:

Unable to run package setup:

Traceback (most recent call last):
File "./PackageSetup.py", line 155, in upgrade
upgradePackage(pkg, pristinedir, datadir, backupdir)
File "./PackageSetup.py", line 148, in upgradePackage
os.path.join(backupdir, base), inhibitOverwrite)
File "./PackageSetup.py", line 31, in upgradeArchive
newar = zipfile.ZipFile(src)
File ".\zipfile.py", line 696, in __init__
File ".\zipfile.py", line 716, in _GetContents
File ".\zipfile.py", line 728, in _RealGetContents
zipfile.BadZipfile: File is not a zip file

Continue reading →

Felix’s Node.js Style Guide (Part 2)

接上篇:Felix’s Node.js Style Guide (Part 1)

创建Object / Array

逗号应放在行尾而不是行首,每一行放置简短的变量声明。只在你的解释器抱怨的时候才应该去给array的key上加上引号。

正确:

var a = ['hello', 'world'];
var b = {
  good: 'code',
  'is generally': 'pretty',
};

错误:

var a = [
  'hello', 'world'
];
var b = {"good": 'code'
        , is generally: 'pretty'
        };

Continue reading →

Felix’s Node.js Style Guide (Part 1)

本文为译文,翻译自原文 http://nodeguide.com/style.html

标题咱就不翻了吧,说实话guide这个词还真不好翻,不能显得很高深又不能显得很for dummy的样子,索性就不翻了……

本guide应该较上篇略有意思,作者泰国海滩度假的时候写出来的东西想来也不会多么干巴巴(海滩不是到处都是水吗……),当然本文所涉及的编程风格之类的选择应该完全是作者自己的opinion,不代表我台观点。

============================== 我是分割线 ==============================

本文不是node.js应用程序所应该遵循风格的官方文档。本guide只是试图带给你一整套instructions,虽说本人有点固执己见,但这套东西确实能让你创建美观且统一的软件。

本guide假设你只针对node.js。如果你的代码需要在浏览器或者其它环境里面运行,请勇敢的忽略其中一些部分。

另外请注意node.js和围绕node的其它很多package都有其自身略显不同的风格,所以如果你对那些项目感兴趣,请遵守他们那边的规则。(别到时被砍……译者注)
Continue reading →

Felix的Node.js初学者入门指南

本文为译文,翻译自原文 http://nodeguide.com/beginner.html

网上有很多关于node.js的资料,但鉴于其快速的开发进度,初学者可能会很难找到比较好且最新的入门资料。本文就是在力求提供这份资料,并且力求时刻和最新的node.js稳定版本保持同步。

本guide已经针对node 0.4.x的最新改动做过更新,node 0.4.x也是当前node的稳定分支。

学习JavaScript

本guide假设你已经对JavaScript有所熟悉。如果你不是很熟悉,你可以去读读:Marijn Haverbeke写的Eloquent JavaScript,它可以在网上免费阅读。
Continue reading →

SQL调优和SQL优化

本文为译文i,翻译自原文 http://beginner-sql-tutorial.com/sql-query-tuning.htm

sql语句可以用来从数据库取回数据。不同的sql查询语句有时可以得到相同的返回结果。如果考虑执行效率的话,选择使用最佳的查询语句至关重要,所以我们需要根据需求来优化sql查询。下面是一些我们平时经常使用的查询语句,以及如何优化它们以达到更好的执行效率。

SQL调优/SQL优化技巧:

1) 如果在SELECT语句里面用具体的column名而不是’*',sql查询会更快。

例如,查询语句写成:

SELECT id, first_name, last_name, age, subject FROM student_details;

比写成下面这样快:

SELECT * FROM student_details;

Continue reading →

[Footnotes]
  1. 翻译的主要目的在于强化记忆和加深理解 []

XXX != 3X

我记得去年还是前年什么时候广电总局开始禁止媒体使用XXX等外语缩略词,但似乎这几年还是频繁听到CPI,GDP等不得不逃避的敏感词,要不是美职篮停摆,估计NBA还是到处可见。

当然本文不是来讨论这个的……

本文只是为了列举加收集本人没事断章取义望文生义出来的缩略词另解 i,并且会持续更新。

VPN = Very Poor Network
SSD = Super Stupid Disk
NBA = National BadAss
SSO = Super Stupid Opinion

TBD ……

[Footnotes]
  1. 皆原创 []

天与弗取 反受其咎

天与弗取,反受其咎;时至不行,反受其殃

—— 《史记》

时不我待,终流于庸俗,鄙人也终干上了之前一直所为之不屑的放广告的勾当,这当然算不上什么出卖灵魂的事情,况且违心的事情我几乎每天都在干 i,就是一大俗人,没有必要也装不了清高;生活就像被强奸,反抗不得还不如闭眼好好享受吧;

广告永远是需要包装的,聪明的你也许已经发现,上篇文章 内容空泛,言不着意,却为了隐藏那一个 hyperlink 煞费苦心;标题曾特地包含的AD两字最终亦被要求remove,估计人家还想嘲笑我难道你连AD从来不说自己是AD这样简单的道理都不懂?

……

anyway,我已经开始享受了……

[Footnotes]
  1. 汗一把…… []

Why Linux?

Why Linux?

A lot of people know nothing at all about Linux, and there is a significant portion of the computer-using community who don’t even know of its existence. Sadly, this may be due to the fact that companies who aren’t open-source can’t afford the same marketing budgets as Apple and Microsoft. It’s a shame, because there’s a fair chance most people would switch, given the option.

Yes, you heard me correctly – it is an open-source operating system, and there are more versions of it than there are versions of Windows and Mac OS and OSX put together. Linux and Unbuntu are two of the most well known, and it is customiseable to the point where if you wanted an OS custom-built for you, it’s fully possible.

Open-source is also what it says on the tin – free code, which means that you’ll never pay a penny for the OS, or any of the software that works with it (unless you’re going out of the open-source bubble, which seems pointless when there are so many free alternatives that offer roughly the same features).

Installing it takes not long at all, as it’s quite a small OS in terms of memory, and it’s also nowhere near as CPU intensive as Windows or Mac OSX, so whether you’re running fifty programs at once or just a Twitter client and OnlinePoker.com, everything will feel smoother and more responsive.

All I can say is that if you’re running a netbook or a low spec PC, or even a powerhouse, you owe it to yourself to install it, even on a partition, and test it out. Who knows? You just might become one of the thousands, if not millions of people contributing to the most generous movement on the web – the open-source community.

StarCraft II配不在高可玩就行

山不在高,有仙则名
水不在深,有龙则灵

—— 唐·刘禹锡《陋室铭》

鄙人以及鄙人的爱机(在他们看来则是陋机)已经被到处各种无数次的鄙视过了,但是…… but…… 阿Q就是这么诞生的:

参照这里优化,除了模型和影片,其它都比较无限趋向于杯具(一个极限函数);

但是…… but……

南阳诸葛庐,西蜀子云亭;
孔子云,何陋之有?

Python NameError: name ‘readline’ is not defined

Python 2.6.×已经装了有一定时日了,已经完全不知道python的世界都更新到什么境界了;标题这个issue在我更新到Lion之前就已经存在了,所以这不能算是Lion里才introduce的issue,这个还是得有一句说一句;

之前我在Snow Leopard一直没有找到fix的办法,当然主要的原因还在于我也没有那么急切的想fix它,至少对于一个几个月都基本不碰python的家伙而言,它的急迫性显然没有解决starcraft2破解版一联机就自动更新不能玩这个issue来的高,xd:)

BTW, 我只玩战役模式,Blizzard及其各路partner已经完全将starcraft2的对战模式变成网游,虽然我很想支持暴雪买正版,但是网游的各种消耗对我来说是无法容忍的.

貌似又有跑题的趋势…… anyway……

这个issue就是下面这样的,注意倒数第二行:

~ ➔ python
Python 2.6.6 (r266:84292, Sep 13 2010, 20:53:06)
[GCC 4.2.1 (Apple Inc. build 5646) (dot 1)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
Module readline not available.
Traceback (most recent call last):
  File "/Users/samson/.pythonrc", line 22, in <module>
    readline.read_history_file(historyPath)
NameError: name 'readline' is not defined
>>>

Continue reading →