Search Results

Search found 323 results on 13 pages for 'jian lin'.

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

  • It seems like the safest way to think of an Inner Join is to think of it as a Cross Join and then sa

    - by Jian Lin
    It seems like the safest way to think of an Inner Join is to think of it as a Cross Join and then satisfying some condition(s)? Because the equi-join can be obvious, but the non-equi-join can be a bit confusing. But if we always use the Cross Join, and then filter out the ones satisfying the condition, then we get the resulting table. In other words, we can always analyze it by using the first record on the left table, and then go through every single records on the right, and then repeat that for 2nd record on the left, and for the 3rd, 4th, ... etc. So in our mind, we can analyze it using this way, and it is like O(n^2), although what happens in the DBMS maybe that it is a lot faster (when an index is present). Is there another good way to think of it besides this method?

    Read the article

  • Why is the ( ) mandatory in the SQL statement select * from gifts INNER JOIN sentgifts using (giftID

    - by Jian Lin
    Why is the ( ) mandatory in the SQL statement select * from gifts INNER JOIN sentgifts using (giftID); ? The ( ) usually is for specifying grouping of something. But in this case, are we supposed to be able to use 2 or more field names... in the example above, it can be all clear that it is 1 field, is it just that the parser is not made to bypass the ( ) when it is all clear? (such as in the language Ruby).

    Read the article

  • setTimeout not working in windows script (jscript)

    - by Sibo Lin
    When I try to run the following code in my program setTimeout("alert('moo')", 1000); I get the following error Error: Object expected Code: 800A138F Source: Microsoft JScript runtime error Why? Am I calling the wrong function? What I want to do is delay the execution of the subsequent function.

    Read the article

  • How to do a comet long pulling with ActionScript3?

    - by Victor Lin
    I want to load data from my web server, I want it be the AJAX/Comet way, my web-server long holds the request, response it until something happened. Thus, I wrote some as3 code like this: private function load(): void { var request:URLRequest = new URLRequest(url); var variables:URLVariables = new URLVariables(); variables.tick = this.tick; request.data = variables; urlLoader = new URLLoader(request); urlLoader.addEventListener(Event.COMPLETE, onComplete); urlLoader.addEventListener(IOErrorEvent.IO_ERROR , onIOError); log.info("Loading info from {0}", request.url); } It works, if the waiting time is short, but however, it failed with IOError 2032, seems the waiting time is out. Here is the problem, how can I do a long-polling with as3 and avoid the timeout error? Thanks.

    Read the article

  • In SQL, in what situation do we want to Index a field in a table, or 2 fields in a table at the same

    - by Jian Lin
    In SQL, it is obvious that whenever we want to do a search on millions of record, say CustomerID in a Transactios table, then we want to add an index for CustomerID. Is another situation we want to add an index to a field when we need to do inner join or outer join using that field as a criteria? Such as Inner join on t1.custumerID = t2.customerID. Then if we don't have an index on customerID on both tables, we are looking at O(n^2) because we need to loop through the 2 tables sequentially. If we have index on customerID on both tables, then it becomes O( (log n) ^ 2 ) and it is much faster. Any other situation where we want to add an index to a field in a table? What about adding index for 2 fields combined in a table. That is, one index, for 2 fields together?

    Read the article

  • How can this closure test be written in other languages?

    - by Jian Lin
    I wonder how the following closure test can be written in other languages, such as C and Java. Can the same result be expected also in Perl, Python, and PHP? Ideally, we don't need to make a new local variable such as x and assign it the value of i inside the loop, but just so that i has a new copy in the new scope each time. (if possible). (some discussion is in this question.) The following is in Ruby, the "1.8.6" on the first line of result is the Ruby version which can be ignored. p RUBY_VERSION $foo = [] (1..5).each do |i| $foo[i] = lambda { p i } end (1..5).each do |j| $foo[j].call() end the print out is: [MacBook01:~] $ ruby scope.rb "1.8.6" 1 2 3 4 5 [MacBook01:~] $ Contrast that with another test, with i defined outside: p RUBY_VERSION $foo = [] i = 0 (1..5).each do |i| $foo[i] = lambda { p i } end (1..5).each do |j| $foo[j].call() end the print out: [MacBook01:~] $ ruby scope2.rb "1.8.6" 5 5 5 5 5 [MacBook01:~] $

    Read the article

  • In Ruby, how does coerce() actually work?

    - by Jian Lin
    It is said that when we have a class Point and knows how to perform point * 3 like the following: class Point def initialize(x,y) @x, @y = x, y end def *(c) Point.new(@x * c, @y * c) end end point = Point.new(1,2) p point p point * 3 Output: #<Point:0x336094 @x=1, @y=2> #<Point:0x335fa4 @x=3, @y=6> but then, 3 * point is not understood: Point can't be coerced into Fixnum (TypeError) So we need to further define an instance method coerce: class Point def coerce(something) [self, something] end end p 3 * point Output: #<Point:0x3c45a88 @x=3, @y=6> So it is said that 3 * point is the same as 3.*(point) that is, the instance method * takes an argument point and invoke on the object 3. Now, since this method * doesn't know how to multiply a point, so point.coerce(3) will be called, and get back an array: [point, 3] and then * is once again applied to it, is that true? point * 3 which is the same as point.*(3) and now, this is understood and we now have a new Point object, as performed by the instance method * of the Point class. The question is: 1) who invokes point.coerce(3) ? Is it Ruby automatically, or is it some code inside of * method of Fixnum by catching an exception? Or is it by case statement that when it doesn't know one of the known types, then call coerce? 2) Does coerce always need to return an array of 2 elements? Can it be no array? Or can it be an array of 3 elements? 3) And is the rule that, the original operator (or method) * will then be invoked on element 0, with the argument of element 1? (element 0 and element 1 are the two elements in that array returned by coerce) Who does it? Is it done by Ruby or is it done by code in Fixnum? If it is done by code in Fixnum, then it is a "convention" that everybody follows when doing a coerce? So could it be the code in * of Fixnum do something like this: if (something.typeof? ...) else if ... # other type else if ... # other type else # if it is not a type I know array = something.coerce(self) return array[0].*(array[1]) end

    Read the article

  • Did anyone have this issue with a simple Facebook app or know how to solve it?

    - by Jian Lin
    I have a really simple few lines of Facebook app, using the new Facebook API: <pre> <?php require 'facebook.php'; // Create our Application instance. $facebook = new Facebook(array( 'appId' => '117676584930569', 'secret' => '**********', // hidden here on the post... 'cookie' => true, )); var_dump($facebook); ?> but it is giving me the following output: http://apps.facebook.com/woolaladev/i2.php would give out object(Facebook)#1 (6) { ["appId:protected"]=> string(15) "117676584930569" ["apiSecret:protected"]=> string(32) "**********" <--- just hidden on this post ["session:protected"]=> NULL ["sessionLoaded:protected"]=> bool(false) ["cookieSupport:protected"]=> bool(true) ["baseDomain:protected"]=> string(0) "" } Session is NULL for some reason, but I am logged in and can access my home and profile and run other apps on Facebook (to see that I am logged on). I am following the sample on: http://github.com/facebook/php-sdk/blob/master/examples/example.php http://github.com/facebook/php-sdk/blob/master/src/facebook.php (download using raw URL: wget http://github.com/facebook/php-sdk/raw/master/src/facebook.php ) Trying on both hosting companies at dreamhost.com and netfirms.com, and the results are the same.

    Read the article

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

    - by Jian Lin
    We can create a closure p by capturing the arguments in the scope 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 p = console.log; works well in Firefox and IE 8 but not on Chrome.

    Read the article

  • how to handle it if the management just keep on giving me spec after spec non-stop?

    - by Jian Lin
    As a programmer, I feel burnt out if the management give me spec after spec, day after day. I think I can code 6 hours a day very focused, but non-stop coding does burn me out a little, especially it is 1 year or 18 months non-stop. A mere 1 week or 2 week vacation per year isn't going to help much. Sometimes I want to take some time to learn new things, or just to take a break for a month so as to re-charge, like back in college when we have holidays for 1 month during winter or 2.5 months during summer. What do you think?

    Read the article

  • In CSS, how to not float a 300px wide Div to the next line?

    - by Jian Lin
    Say, there is a bar that is styled at the bottom of the viewport, using position: fixed; bottom: 0; left: 0; width: 100%; height 50px; overflow: hidden and then there are 4 Divs inside it, each one floated to the left. Each Div is about 300px wide or can be more (depending on the content) Now, when the window is 1200 pixel wide, and we see all 4 Divs, but when the window is resize to be 1180 pixel wide (just 20 pixels less), then the whole 300px wide Div will disappear, because it is "floated" to the next line. So how can this be made so that, the Div will stay there and showing 280px of itself, rather than totally disappear? By the way, white-space: nowrap won't work as that probably has to do with not wrapping inline content. I was thinking of putting another Div inside this Div, having a fixed width of 1200px or 2000px, so that all Divs will float on the same level in this inner Div, and the outer Div will cut it off with the overflow: hidden. But this seems more like a hack... since the wide of all those Divs can be dynamic, and setting a fixed width of 1200px or 2000px seems like too much of a hack.

    Read the article

  • Multiple CSS Classes: Properties Overlapping based on the order defined.

    - by Jian Lin
    Is there a rule in CSS that determines the cascading order when multiple classes are defined on an element? (class="one two" vs class="two one") Right now, there seems to be no such effect. Example: both divs are orange in color on Firefox <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> <html> <head> <style> .one { border: 6px dashed green } .two { border: 6px dashed orange } </style> </head> <body> <div class="one two"> hello world </div> <div class="two one"> hello world </div>

    Read the article

  • Strange behaviour with mediaplayer and seekTo

    - by Mathias Lin
    I'm implementing a custom video player because I need custom video controls. I have an app with only one activity, which on startup shall start playing a video right away. Now, the problem I have is: I don't want the video to start from the beginning, but from a later position. Therefore I do a seekTo(16867). Since seekTo is asynchronous, I place the start call of the mediaplayer (player.start()) in the onSeekComplete of the onSeekCompleteListener. The strange behaviour I experience though is that I can see/hear the video playing from the beginning for a few millisecs before it actually plays from/jumps to the position I seeked to. But - on the other hand - the Log output I call before the player.start returns the correct position 16867, where I seeked to. Below is the relevant code section, the complete class is at http://pastebin.com/jqAAFsuX (I'm on Nexus One / 2.2 StageFright) private void playVideo(String url) { try { btnVideoPause.setEnabled(false); if (player==null) { player=new MediaPlayer(); player.setScreenOnWhilePlaying(true); } else { player.stop(); player.reset(); } url = "/sdcard/myapp/main/videos/main.mp4"; // <--- just for test purposes hardcoded here now player.setDataSource(url); player.setDisplay(holder); player.setAudioStreamType(AudioManager.STREAM_MUSIC); player.setOnCompletionListener(this); player.setOnPreparedListener(this); player.setOnSeekCompleteListener(new MediaPlayer.OnSeekCompleteListener() { public void onSeekComplete(MediaPlayer mediaPlayer) { Log.d("APP", "current pos... "+ player.getCurrentPosition() ); player.start(); // <------------------ start video on seek completed player.setOnSeekCompleteListener(null); } }); player.prepareAsync(); } catch (Throwable t) { Log.e(TAG, "Exception in btnVideoPause prep", t); } } public void onPrepared(MediaPlayer mediaplayer) { width=player.getVideoWidth(); height=player.getVideoHeight(); if (width!=0 && height!=0) { holder.setFixedSize(width, height); progressBar.setProgress(0); progressBar.setMax(player.getDuration()); player.seekTo(16867); // <------------------ seeking to position } btnVideoPause.setEnabled(true); }

    Read the article

  • In SQL, can we always write an inner join statement as a main query and subquery if we only want to

    - by Jian Lin
    In SQL, can we always write an inner join statement as a main query and subquery or vice versa if we only want to find the intersection? For example, select * from gifts g where g.giftID in (select giftID from sentGifts); can do a join and show the gifts sent in the sentGifts table, but it won't be able to show the sentTime because that is inside the subquery. But if all we care is to find the intersection, without caring what is being displayed, then we can always convert one to the other?

    Read the article

  • Using jQuery's animate(), if the clicked on element is "<a href="#" ...> </a>", the fucntion should

    - by Jian Lin
    I was reading jQuery's page for animate() http://api.jquery.com/animate/ Its examples don't mention about if using <a href="#" id="clickme">click me</a> ... $('#clickme').click(function() { $('#someDiv').animate({left: "+=60"}); }) we actually still have to return false like in the old days? $('#clickme').click(function() { $('#someDiv').animate({left: "+=60"}); return false; }) (but then, those examples didn't use a <a> for the "click me"... but used something else. Otherwise the page will jump back to the beginning of the page? Does jQuery have a more elegant or magical way of doing it?

    Read the article

  • Using Mercurial (hg), how to push just one file or one directory out?

    - by Jian Lin
    Using Mercurial, we can commit one file by using hg commit file.rb or 1 folder hg commit foldername But how can we push just 1 file or 1 folder out? The whole project can be pushed using hg push ssh://[email protected]//project/code/preliminary but there seems to be no way to push out just 1 file or 1 folder? I tried the following and they don't work: hg push ssh://[email protected]//project/code/preliminary app/views/index.html.erb or hg push ssh://[email protected]//project/code/preliminary/app/views/index.html.erb

    Read the article

  • What is a SQL statement that can tally up the counts even including the Zeros? (all in 1 statement)

    - by Jian Lin
    A SQL statement can give a list of the most popular gifts that are sent in a Social application, all the way to the ones that are sent 1, or 2 times, but it won't include the Zeros. I think the same goes for getting the list of the most popular Classes that students are registering for, when the registration process for all students is 10 days and now it is the 3rd day. Again, we get the count but the Zeros are not there. Is there a simple SQL statement that can show the whole list, including the zeros?

    Read the article

  • Firebug's "net" tab is not showing anything?

    - by Jian Lin
    I usually run Fiddler for net traffic monitoring and now am using a Mac machine. I thought Firebug's net tab can show the traffic that is fetched through AJAX (the net tab is enabled). But if I try google.com, and type in something, its "google suggest" will show a bunch of suggestions, but the Firebug's "net" tab is not showing anything?

    Read the article

  • is there a rule in CSS that says class="one two" vs class="two one" and the second will override the

    - by Jian Lin
    Right now, there seems to be no such effect. Example: both divs are orange in color on Firefox <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> <html> <head> <style> .one { border: 6px dashed green } .two { border: 6px dashed orange } </style> </head> <body> <div class="one two"> hello world </div> <div class="two one"> hello world </div>

    Read the article

  • An exception to avoid copy and paste code?

    - by Jian Lin
    There are many files in our project that would call a Facebook api. And the call is complicated, spanning usually 8 lines or more, just for the argument values. In this case, we can make it into a function, and place that function in a common_library.php, but doing so would just change the name of the function call from the Facebook API function to our name, and we still need to repeat the 8 lines of arguments. Each time, the call is very similar, but with slight variations to the argument values. In that case, would copy and paste be needed no matter what we do?

    Read the article

  • How to skip all the column names in MySQL when the table has auto increment primary key?

    - by Jian Lin
    A table is: mysql> desc gifts; +---------------+-------------+------+-----+---------+----------------+ | Field | Type | Null | Key | Default | Extra | +---------------+-------------+------+-----+---------+----------------+ | giftID | int(11) | NO | PRI | NULL | auto_increment | | name | varchar(80) | YES | | NULL | | | filename | varchar(80) | YES | | NULL | | | effectiveTime | datetime | YES | | NULL | | +---------------+-------------+------+-----+---------+----------------+ the following is ok: mysql> insert into gifts -> values (10, "heart", "heart_shape.jpg", now()); Query OK, 1 row affected (0.05 sec) but is there a way to not specify the "10"... and just let each one be 11, 12, 13... ? I can do it using mysql> insert into gifts (name, filename, effectiveTime) -> values ("coffee", "coffee123.jpg", now()); Query OK, 1 row affected (0.00 sec) but the column names need to be all specified. Is there a way that they don't have to be specified and the auto increment of primary key still works? thanks.

    Read the article

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