面试小记

  1. js this的作用域
    A function’s this keyword behaves a little differently in JavaScript compared to other languages. It also has some differences between strict mode and non-strict mode.

  2. 内连接&左连接的区别
    例子:


a表 id name b表 id job parent_id
1 张3 1 23 1
2 李四 2 34 2
3 王武 3 34 4
a.id同parent_id 存在关系


1) 内连接
select a.,b. from a inner join b on a.id=b.parent_id
结果是
1 张3 1 23 1
2 李四 2 34 2

2)左连接
select a.,b. from a left join b on a.id=b.parent_id
结果是
1 张3 1 23 1
2 李四 2 34 2
3 王武 null

3) 右连接
select a.,b. from a right join b on a.id=b.parent_id
结果是
1 张3 1 23 1
2 李四 2 34 2
null 3 34 4

4) 完全连接
select a.,b. from a full join b on a.id=b.parent_id

结果是
1 张3 1 23 1
2 李四 2 34 2
null    3 34 4
3 王武 null

  1. => in coffee script
    The fat arrow => can be used to both define a function, and to bind it to the current value of this, right on the spot. This is helpful when using callback-based libraries like Prototype or jQuery, for creating iterator functions to pass to each, or event-handler functions to use with bind. Functions created with the fat arrow are able to access properties of the this where they’re defined.

  2. 浅拷贝和深拷贝
    这个问题我跟面试官聊,感觉他是不是有对这个概念理解有点过头了。
    Shallow copies duplicate as little as possible. A shallow copy of a collection is a copy of the collection structure, not the elements. With a shallow copy, two collections now share the individual elements.

Deep copies duplicate everything. A deep copy of a collection is two collections with all of the elements in the original collection duplicated.

以上为一次阿里小记

Mongodb本质存储的是什么

http://stackoverflow.com/questions/337878/var-self-this

Classifying data note/practice

Example: a handwriting recognition system

Example: using kNN on a handwriting recognition system.

  1. Collect: Text file provided.
  2. Prepare: Write a function to convert from the image format to the list format
    used in our classifier, classify0().
  3. Analyze: We’ll look at the prepared data in the Python shell to make sure it’s
    correct.
  4. Train: Doesn’t apply to the kNN algorithm.
  5. Test: Write a function to use some portion of the data as test examples. The test examples are classified against the non-test examples. If the predicted class doesn’t match the real class, you’ll count that as an error.
  6. Use: Not performed in this example. You could build a complete program to extract digits from an image, such a system used to sort the mail in the United States.

天朝上网手册(持续更新)

本文写给我的妹妹。

墙内的互联网有如大屎缸。
推荐把时间浪费在以下网站。

  • ​玩玩社交网络,国外玩facebook, pinterest, twitter, 国内没办法只能玩renren了,多认识些有共同爱好的人。还能防寂寞
  • Google 如果你想得到最好的搜索质量,请用英文搜索。baidu的搜索质量极其low。
  • Quora quora is the best source of knowledge 提提问题,交交朋友,练习英语还有老外帮你改语法错误和单词拼写错误。​ 玩法是先关注些你喜欢的话题。
  • https://speakerdeck.com/http://www.slideshare.net/ 好的 slide给你大方向的指导。​
  • https://www.coursera.org/ 在网上免费学习全世界最好的课程。
  • www.zhihu.com 中国版quora。玩法是先关注些你喜欢的话题。
  • www.reddit.com 找​开心
  • 豆瓣 标记你每看过的一本书或电影。

! 网址打不开的时候用~云梯~ https://www.yunti.me 如果这个都打不开,我帮你买。

Meteor™ Learning Note

Dependency Tracking in Meteor: Computations
While Meteor is a real-time, reactive framework, not all of the code inside a Meteor app is reactive. If this were the case, your whole app would re-run every time anything changed. Instead, reactivity is limited to specific areas of your code, and we call these areas computations.
/client
Any files here are only served to the client. This is a good place to keep your HTML, CSS, and UI-related JavaScript code.

When Should We Use observe()?
Using the above pattern is sometimes necessary, especially when dealing with third-party widgets. For example, let’s imagine we want to add or remove pins on a map in real time based on Collection data (say, to show the locations of currently logged in users).
In such cases, you’ll need to use observe() callbacks in order to get the map to “talk” with the Meteor collection and know how to react to data changes. For example, you would rely on the added and removed callbacks to call the map API’s own dropPin() or removePin() methods.

/server
Any files in this directory are only used on the server, and are never sent to the client. Use /server to store source files with sensitive logic or data that should not be visible to the client.

/public
Files in /public are served to the client as-is. Use this to store assets such as images. For example, if you have an image located at /public/background.png, you can include it in your HTML with or in your CSS with background-image:
url(/background.png). Note that /public is not part of the image URL.

/private
These files can only be accessed by server code through Assets API and are not accessible to the client.

http://docs.meteor.com/

slack作为团队交流工具的好处

我觉得程序员们先进性的一个很大体现在于沟通工具,方式的先进。
团队一旦变大,沟通成本就会明显bigger than bigger

我认为在线沟通和异步沟通 是最长久和有效率的方法。

slack与普通工具例如bqq相比的好处:

场景1:讨论组里 拉了一个人 他需要知道上下文,人们一般都是找一个人发一下聊天历史记录。如果slack 他直接可以看到聊天历史

场景2 : 有人说错话了 想要收回那句话,用slack可以直接编辑,而且有一个小细节我特别喜欢的是,如果一个人迅速发了好几句碎言碎语,slack会把这些话作为一句话。

场景3:公司里有想主动找事做的人,想要知道大家在做什么。slack里有各种channel可以建立,比如我之前看过一篇holman的博客,Github有好几十个频道,每一个channel可以代表一个正在做的项目,public的channel是大家都可以参加的项目。
How GitHub Works: Be Asynchronous
http://zachholman.com/posts/how-github-works-asynchronous
吐血打滚推荐这篇文章

Have a cup of coffee

From an outside look of it, I think it’s like a mixture of Python and Ruby. —Nango

1
2
greet = (message) ->
alert message

Advantages

  • Least amount of code to solve problems
  • Readable and Understandable
  • Easy to Maintain
1
2
message = "Ready for some Coffee?"
alert(message)

=>

1
2
3
var message;
message = "Ready for some Coffee?";
alert(message);

All the code is wrapped up in a closure to prevent variable pollution

Use a default value of ‘Stranger’ for the name parameter

1
greet = (name='Stranger') -> alert name

=>

1
2
3
4
5
6
7
var greet;
greet = function(name) {
if (name == null) {
name = 'Stranger';
}
return "Hello, " + name;
};

Kind of Like Ruby ha, But In this field, it is called CoffeeScript-style string interpolation.

1
2
greet = (name='Stranger') ->
"Hello, #{name}"
1
2
sum = (a, b) ->
a + b

One thing I like it is, you can be 任性 like this:

1
2
3
4
5
coffee()
coffee("Yo")
coffee "Yo"
coffee("Yo", 2)
coffee "Yo", 2

Array

1
2
3
4
5
6
7
8
9
storeLocations = ['Orlando', 'Winter Park', 'Sanford']
Can use new lines instead of commas
storeLocations = [
'Orlando'
'Winter Park'
'Sanford'
]

Loop

1
2
3
4
5
6
storeLocations.forEach (location, index) ->
alert "Location: #{location}
alert "Location: #{location}" for location in storeLocations
for location in storeLocations
alert "Location: #{location}"

Indent

There are things I don’t like like this.

1
2
3
coffee =
name: 'French'
strength: 1

=>

1
2
3
4
5
6
coffee = {
name: 'French'
};
({
strength: 1
})

一行流 (one line combo)

If u do python, you familiar with this.

1
2
3
filteredFlights =
(flight for flight in currentFlights when stops is '2+' or
flight.routing is 0)

OOP

the great extend keyword
My friend Teddy has a great post about this.

1
2
3
class Animal
class Snake extends Animal

= >

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
// Generated by CoffeeScript 1.8.0
(function() {
var Animal, Snake,
__hasProp = {}.hasOwnProperty,
__extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; };
Animal = (function() {
function Animal() {}
return Animal;
})();
Snake = (function(_super) {
__extends(Snake, _super);
function Snake() {
return Snake.__super__.constructor.apply(this, arguments);
}
return Snake;
})(Animal);
}).call(this);

TODO

Others

With the character ->, it can lower the possibility of missing braces or brackets.

There’re lots of other stuff, like automatically hoisting for u to check out.

Install

1
2
3
1. Install Node.js http://nodejs.org/
2. Install npm http://npmjs.org/
3. $ npm install -g coffee-script
1
2
3
4
5
6
7
coffee -c test.coffee Creates test.js
coffee -cw test.coffee Every time test.coffee is
updated re-compile.
coffee -c src -o js Compile all .coffee files in the
src dir into the js dir.
coffee -wc src -o js Every time a file is updated
re-compile

Link:
http://teddy1004.github.io/2014/12/04/class-inheritance-in-JavaScript/
http://coffeescript.codeschool.com/levels/1/challenges/1
http://courseware.codeschool.com/coffeescript_slides.pdf

Instapaper™ VS Pocket™

I’ve been migrating from Instapaper to Pocket recently.

Instapaper Pocket
stackoverflow nope support
code viewing better Content in the second column
SNS find your friend(although I don’t think this is useful) your friend(although I don’t think this is useful)
PDF probably not support support