Sublime 3笔记

Package Control

Package Control


自动换行

1、打开 Preferences -> Setting - User(设置 - 用户)

2、在最后一个花括号(即“}”)前添加如下内容即可:

“word_wrap” : true

//上一行要加入,


evernote

sublime-evernote
keymap复制到Preferences ->key Bindings user

阅读全文 »

SpaceMonkey

###项目
Sprite Kit for Kids with Swift

###编译错误
编译环境:
Xcode Version 6.2 (6C131e)
OS X 10.9.5

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
override func viewWillLayoutSubviews() {
super.viewDidLoad()
let skView = self.view as! SKView
if skView.scene == nil {
let scene = GameScene(size:skView.frame.size)
skView.showsFPS = true
skView.showsNodeCount = true
skView.showsPhysics = true
skView.ignoresSiblingOrder = true
scene.scaleMode = .AspectFill
skView.presentScene(scene)
playBackgroundMusic("BackgroundMusic.mp3")
}

错误信息

Expected type after ‘as’

阅读全文 »

CSS Avengers Card with 3D rotation and neon effect

Avengers assemble an SVG scalable logo!
Sort of virtual hologram Marvel Avengers card with 3D rotate animation, SVG scalable Avengers logo and Iron Man colors (red and gold) and a nice neon effect.
Pure CSS and an SVG Avengers logo.

###HTML

1
2
3
<div class="card animate">
<img src="//upload.wikimedia.org/wikipedia/commons/thumb/0/0b/Symbol_from_Marvel%27s_The_Avengers_logo.svg/191px-Symbol_from_Marvel%27s_The_Avengers_logo.svg.png" width="191" height="223" />
</div>

阅读全文 »

Secret code in Ex Machina

###Code

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#BlueBook code decryption
import sys
def sieve(n):
x = [1] * n
x[1] = 0
for i in range(2,n/2):
j = 2 * i
while j < n:
x[j]=0
j = j+i
return x
def prime(n,x):
i = 1
j = 1
while j <= n:
if x[i] == 1:
j = j + 1
i = i + 1
return i - 1
x=sieve(10000)
code = [1206,301,384,5]
key =[1,1,2,2,]
sys.stdout.write("".join(chr(i) for i in [73,83,66,78,32,61,32]))
for i in range (0,4):
sys.stdout.write(str(prime(code[i],x)-key[i]))
print

阅读全文 »

When is Cheryl’s birthday?

When is Cheryl’s birthday?

推理

第一句话确定:July 14 July 16 August 14 August 15 August 17(告诉B日期不可能为18,19,==>告诉A的月份不可能为May,June)
第二句话确定:July 16 August 15 August 17(日期14有两个,B不可能确定,排除)
第三句话确定:July 16(月份August有两个,A不能确定,推出July16)

###Khanacademy

阅读全文 »

Code vs. Poetry

David Plotz did an interesting interview with Google engineer Nina Kang for the Working podcast. Here’s an excerpt (edited for clarity):
T:大卫.普拉茲向在Working podcast工作的Google工程师康芯寧做了一次有趣的采访。这是谈话摘录(经过后期编辑润色):

Q: What is it when you’re writing code that makes particular code really good?
T: 是什么让你写特定代码时做得很好?

A: It depends on the situation and the company. Google is a very collaborative company. There were almost a thousand programmers on Google Maps. To my mind, what makes code good is that it is almost anonymous. You shouldn’t be able to read that code and say, oh, Kevin down the hall wrote it. Because if it’s idiosyncratic in that way, it means that it’s not something that’s gonna be so easy for other people to modify. Everyone should write in a uniform enough style within a team that we can easily grasp each other’s code and modify it. And there are a couple of things that I look for when I’m looking at code. One of the things is how few lines would it take for it to be modified. Code that requires a lot of repetition, some people find that poetic, but I find that tedious. […]
T: 这要取决于所处的环境和所在的公司。Google是一家特别讲究合作的公司。Google地图的程序员差不多有一千多名。

Q: Great word there, poetic. What does that mean when you say, some people find it poetic?

A: Computer programmers pride ourselves on writing elegant code, or poetic code. But usually what that means is writing code the way the individual programmer thinks is good and that is incredibly subjective. … I think that poetic code is code that you can read [easily]. […]

Q: Will great coders come up with very different solutions to a problem than non-great coders?

A: Absolutely. Great coders come up with solutions that are usually more concise and more easily verified. I think that the key metric is, can someone else read this code and confirm that it works by building a mental model in their head of what the computer’s gonna do at different steps? There are certain things that are really simple, like finding out how many characters are in a line, that you could write in a way that would confuse everybody. But if your code is well written, people understand what it does and they can tell that it works right away.

Q: So elegance, to your mind, corresponds with clarity and concision?

A: Yes, absolutely, just like English.

阅读全文 »

\BGL\DSL\MDX\CD\ ===> OS X dictionary

###开源项目:PYGLOSSARY

###准备好以下环境:

  • BeautifulSoup4 required to sanitize html contents.
    sudo easy_install beautifulsoup4 html5lib
  • GNU make as part of Command Line Tools for Xcode.
  • Dictionary Development Kit as part of Auxillary Tools for Xcode.将Dictionary Development Kit解压到/Applications/Utilities/DictionaryDevelopmentKit/ (不含空格,中文名:应用程序/实用工具那里,也可以解压到其它地方。)
阅读全文 »

The Joel Test

1
2
3
4
5
6
7
8
9
10
11
12
Do you use source control?
Can you make a build in one step?
Do you make daily builds?
Do you have a bug database?
Do you fix bugs before writing new code?
Do you have an up-to-date schedule?
Do you have a spec?
Do programmers have quiet working conditions?
Do you use the best tools money can buy?
Do you have testers?
Do new candidates write code during their interview?
Do you do hallway usability testing?

用DSLConverter将Lingvo词典.DSL格式转换成MAC OSX可用的格式

###转换
下载.DSL to OS X/iOS dictionary converter
https://github.com/svintuss/DSLConverter

####windows xp环境下:

  • 安装Python3,(Python2.7会出现以下错误)

    import urllib.parse
    ImportError: No module named parse
    (The urllib.parse library is the Python 3 equivalent of the urlparse library used in Python 2.)

  • 安装pytidylib:下载pytidylib源文件,直接编译安装python setup.py install;或者用easy_install安装,直接在终端里输入安装命令:easy_install pytidylib
  • 下载tidylib.dll,将tidylib.dll文件放到到Python目录下(前提Python路径已添加到系统路径里),其他系统路径应该也可以如:system32目录。
  • 转换:
    python dslconverter_auto.py <dictionary.dsl>

####MAC OSX环境下:

  • 安装Python3 brew install python3
    (MAC OSX 10.9.4是默认安装了Python2.7,而DSLConverter里的代码是给Python3用的,python可以多版本并存)
  • 安装pytidylib,下载pytidylib源文件,直接用Python3编译安装, python3 setup.py install(注意:如果用easy_install pytidylib命令安装,pytidylib会被安装到Python2.7目录下。)
  • 转换:
    python3 dslconverter_auto.py <dictionary.dsl>

阅读全文 »

password generator

###CODE

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
// Playground - noun: a place where people can play
import UIKit
//Step 1.
var pwCharacters = ["a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z","1","2","3","4","5","6","7","8","9","0","A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z","!","@","#","$","%","^","&","*"]
//Step 2.
func randomPassword(passwordLength: Int) -> String {
var password = ""
var unsignedArrayCount = UInt32(pwCharacters.count)
for var i = 0; i < passwordLength; i++ {
var unsignedRandomNumber = arc4random_uniform(unsignedArrayCount)
var randomNumber = Int(unsignedRandomNumber)
password += pwCharacters[randomNumber]
}
return password
}
//Step 3
//任意生成1000位密码
randomPassword(1000)
//任意生成15密码
var password = "\(randomPassword(5))-\(randomPassword(5))-\(randomPassword(5))"


###References
One Thousand Character Password