Search Results

Search found 310 results on 13 pages for 'lin xiangyu'.

Page 10/13 | < Previous Page | 6 7 8 9 10 11 12 13  | Next Page >

  • In SQL / MySQL, what is the difference between "On" and "Where" in a join statement?

    - by Jian Lin
    The following statements give the same result (one is using "on", and the other using "where"): mysql> select * from gifts INNER JOIN sentGifts on gifts.giftID = sentGifts.giftID; mysql> select * from gifts INNER JOIN sentGifts where gifts.giftID = sentGifts.giftID; I can only see in a case of a Left Outer Join finding the "unmatched" cases: (to find out the gifts that were never sent by anybody) mysql> select name from gifts LEFT OUTER JOIN sentgifts on gifts.giftID = sentgifts.giftID where sentgifts.giftID IS NULL; In this case, it is first using "on", and then "where". Does the "on" first do the matching, and then "where" does the "secondary" filtering? Or is there a more general rule of using "on" versus "where"? Thanks.

    Read the article

  • Sort database entries via a dropdown list

    - by Lin
    Hello! I'm curious if anyone could possibly help me, because I can't find anything exactly related to it anywhere, and it's driving me nuts. I'd like to have a dropdown list on a page, that will give the visitor the option to sort all entries by year. I have entries from i.e. 2001, 2005, 2009, 2010. The years should be displayed in the dropdown, so the visitor can easily just select all entries dated 2001 if they want. The year for each entry is located in the one database table I have. In other words, I simply want a "sort by" dropdown that you can see on pretty much any shopping site nowadays. But with set years. Thanks in advance for any replies!

    Read the article

  • What are some practical uses of generating all permutations of a list, such as ['a', 'b', 'c'] ?

    - by Jian Lin
    I was asked by somebody in an interview for web front end job, to write a function that generates all permutation of a string, such as "abc" (or consider it ['a', 'b', 'c']). so the expected result from the function, when given ['a', 'b', 'c'], is abc acb bac bca cab cba Actually in my past 20 years of career, I have never needed to do something like that, especially when doing front end work for web programming. What are some practical use of this problem nowadays, in web programming, front end or back end, I wonder? As a side note, I kind of feel that expecting a result in 3 minutes might be "either he gets it or he doesn't", especially I was thinking of doing it by a procedural, non-recursive way at first. After the interview, I spent another 10 minutes and thought of how to do it using recursion, but expecting it to be solved within 3 minutes... may not be a good test of how qualified he is, especially for front end work.

    Read the article

  • Does any Version Control System like SVN, Git, or Mercurial let you "keep latest version" but not th

    - by Jian Lin
    In our project files, if there are binary files, such as .doc, .xls, .jpg, and we choose to not keep their past revisions (just keeping a latest version is ok), is there a way to tell SVN, Git, or Mercurial or some other tool to skip the revisions for these files or for a particular folder? Say, there is a 4MB .doc file that I need to check in hundred of times, but I don't really care so much about its past versions. So if the system keeps 100 revisions of it, that's already 400MB... checking in 300 times means 1.2GB for 1 file and that's not good. Only the latest version is good so that everybody can sync to it.

    Read the article

  • How to change a primary key in SQL to auto_increment?

    - by Jian Lin
    I have a table in MySQL that has a primary key: mysql> desc gifts; +---------------+-------------+------+-----+---------+-------+ | Field | Type | Null | Key | Default | Extra | +---------------+-------------+------+-----+---------+-------+ | giftID | int(11) | NO | PRI | NULL | | | name | varchar(80) | YES | | NULL | | | filename | varchar(80) | YES | | NULL | | | effectiveTime | datetime | YES | | NULL | | +---------------+-------------+------+-----+---------+-------+ but I wanted to make it auto_increment. The following statement failed. How can it be modified so that it can work? thanks mysql> alter table gifts modify giftID int primary key auto_increment; ERROR 1068 (42000): Multiple primary key defined

    Read the article

  • It is said that Mercurial's "hg clone" is very cheap... but it is 400MB on my hard drive? (on Mac OS

    - by Jian Lin
    I have a project I cloned over the network to the Mac hard drive (OS X Snow Leopard). The project is about 1GB in the hard drive du -s 2073848 . so when I hg clone proj proj2 then when I MacBook-Pro ~/development $ du -s proj 2073848 proj MacBook-Pro ~/development $ du -s proj2 894840 proj2 MacBook-Pro ~/development $ du -s 2397928 . so the clone seems not so cheap... probably around 400MB... is that so? also, the whole folder grew by about 200MB, which is not the total of proj and proj2 by the way... are there some links and some are not links, that's why the overlapping is not counted twice?

    Read the article

  • In Javascript, a function starts a new scope, but we have to be careful that the function must be in

    - by Jian Lin
    In Javascript, I am sometimes too immerged in the idea that a function creates a new scope, that sometimes I even think the following anonymous function will create a new scope when it is being defined and assigned to onclick: <a href="#" id="link1">ha link 1</a> <a href="#" id="link2">ha link 2</a> <a href="#" id="link3">ha link 3</a> <a href="#" id="link4">ha link 4</a> <a href="#" id="link5">ha link 5</a> <script type="text/javascript"> for (i = 1; i <= 5; i++) { document.getElementById('link' + i).onclick = function() { var x = i; alert(x); return false; } } </script> but in fact, the anonymous function will create a new scope, that's right, but ONLY when it is being invoked, is that so? So the x inside the anonymous function is not created, no new scope is created. When the function was later invoked, there is a new scope alright, but the i is in the outside scope, and the x gets its value, and it is all 6 anyways. The following code will actually invoke a function and create a new scope and that's why the x is a new local variable x in the brand new scope each time, and the invocation of the function when the link is clicked on will use the different x in the different scopes. <a href="#" id="link1">ha link 1</a> <a href="#" id="link2">ha link 2</a> <a href="#" id="link3">ha link 3</a> <a href="#" id="link4">ha link 4</a> <a href="#" id="link5">ha link 5</a> <script type="text/javascript"> for (var i = 1; i <= 5; i++) { (function() { var x = i; document.getElementById('link' + i).onclick = function() { alert(x); return false; } })(); // invoking it now! } </script> If we take away the var in front of x, then it is a global x and so no local variable x is created in the new scope, and therefore, clicking on the links get all the same number, which is the value of the global x.

    Read the article

  • Is it true that in most Object Oriented Programming Languages, an "i" in an instance method always r

    - by Jian Lin
    In the following code: <script type="text/javascript"> var i = 10; function Circle(radius) { this.r = radius; this.i = radius; } Circle.i = 123; Circle.prototype.area = function() { alert(i); } var c = new Circle(1); var a = c.area(); </script> What is being alerted? The answer is at the end of this question. I found that the i in the alert call either refers to any local (if any), or the global variable. There is no way that it can be the instance variable or the class variable even when there is no local and no global defined. To refer to the instance variable i, we need this.i, and to the class variable i, we need Circle.i. Is this actually true for almost all Object oriented programming languages? Any exception? Are there cases that when there is no local and no global, it will look up the instance variable and then the class variable scope? (or in this case, are those called scope?) the answer is: 10 is being alerted.

    Read the article

  • TextMate can show definition of a function easily?

    - by Jian Lin
    I am using TextMate on a Ruby on Rails project and wonder if you can put the mouse on link_to, and then press a key and it will show the definition of link_to, or does this for any other helper functions? Or, click open a box and type in a function name and it will show you the definition?

    Read the article

  • How to create a function and pass in variable length argument list?

    - by Jian Lin
    We can create a function p in the following code: var p = function() { }; if (typeof(console) != 'undefined' && console.log) { p = function() { console.log(arguments); }; } but the arguments are passed like an array to console.log, instead of passed one by one as in console.log(arguments[0], arguments[1], arguments[2], ... Is there a way to expand the arguments and pass to console.log like the way above? Note that if the original code were var p = function() { }; if (typeof(console) != 'undefined' && console.log) { p = console.log; } then it works well on Firefox and IE 8 but not on Chrome.

    Read the article

  • In SQL, why is "Distinct" not used in a subquery, when looking for some items "not showing up" in th

    - by Jian Lin
    Usually when looking for some items not showing up in the other table, we can use: select * from gifts where giftID not in (select giftID from sentgifts); or select * from gifts where giftID not in (select distinct giftID from sentgifts); the second line is with "distinct" added, so that the resulting table is smaller, and probably let the search for "not in" faster too. So, won't using "distinct" be desirable? Often than not, I don't see it being used in the subquery in such a case. Is there advantage or disadvantage of using it? thanks.

    Read the article

  • In CSS, does it make sense or is it legal to nest an id in another id -- such as "#main #display img

    - by Jian Lin
    In CSS, if it is #main #display img { height: 80px } that means all images within an element with id display that is within another element with id main. But does it make sense or is it legal since id seems to be just global names. It is because SASS actually allow nesting and some code may nest it like #main width: 700px #display img height: 80px which is "id within id".

    Read the article

  • In MVC framworks (such as Ruby on Rails), do usually Model spell as singular and controller and view

    - by Jian Lin
    I usually see Ruby on Rails books using script/generate model Story name:string link:string which is a singular Story, while when it is controller script/generate controller Stories index then the Story now is Stories, which is plural. Is this a standard on Ruby on Rails? Is it true in other MVC frameworks too, like CakePHP, Symfony, Django, or TurboGears? I see that in the book Rails Space, the controller is also called User, which is the same as the model name, and it is the only exception I see.

    Read the article

  • In Ruby, why is a method invocation not able to be treated as a unit when "do" and "end" is used?

    - by Jian Lin
    The following question is related to the question "Ruby Print Inject Do Syntax". My question is, can we insist on using do and end and make it work with puts or p? This works: a = [1,2,3,4] b = a.inject do |sum, x| sum + x end puts b # prints out 10 so, is it correct to say, inject is an instance method of the Array object, and this instance method takes a block of code, and then returns a number. If so, then it should be no different from calling a function or method and getting back a return value: b = foo(3) puts b or b = circle.getRadius() puts b In the above two cases, we can directly say puts foo(3) puts circle.getRadius() so, there is no way to make it work directly by using the following 2 ways: a = [1,2,3,4] puts a.inject do |sum, x| sum + x end but it gives ch01q2.rb:7:in `inject': no block given (LocalJumpError) from ch01q2.rb:4:in `each' from ch01q2.rb:4:in `inject' from ch01q2.rb:4 grouping the method call using ( ) doesn't work either: a = [1,2,3,4] puts (a.inject do |sum, x| sum + x end) and this gives: ch01q3.rb:4: syntax error, unexpected kDO_BLOCK, expecting ')' puts (a.inject do |sum, x| ^ ch01q3.rb:4: syntax error, unexpected '|', expecting '=' puts (a.inject do |sum, x| ^ ch01q3.rb:6: syntax error, unexpected kEND, expecting $end end) ^ finally, the following version works: a = [1,2,3,4] puts a.inject { |sum, x| sum + x } but why doesn't the grouping of the method invocation using ( ) work in the earlier example? What if a programmer insist that he uses do and end, can it be made to work?

    Read the article

  • If the "with" statement in Javascript creates a new scope, why does the following code not work as e

    - by Jian Lin
    If the "with" statement in Javascript creates a new scope, shouldn't clicking on the links show a different x which are in different scopes? It doesn't. <a href="#" id="link1">ha link 1</a> <a href="#" id="link2">ha link 2</a> <a href="#" id="link3">ha link 3</a> <a href="#" id="link4">ha link 4</a> <a href="#" id="link5">ha link 5</a> <script type="text/javascript"> for (i = 1; i <= 5; i++) { with({foo:"bar"}) { var x = i; document.getElementById('link' + i).onclick = function() { alert(x); return false; } } } </script>

    Read the article

< Previous Page | 6 7 8 9 10 11 12 13  | Next Page >