Search Results

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

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

  • In Javascript event handling, why "return false" or "event.preventDefault()" and "stopping the event

    - by Jian Lin
    It is said that when we handle a "click event", returning false or calling event.preventDefault() makes a difference, in which the difference is that preventDefault will only prevent the default event action to occur, i.e. a page redirect on a link click, a form submission, etc. and return false will also stop the event flow. Does that mean, if the click event is registered several times for several actions, using $('#clickme').click(function() { … }) returning false will stop the other handlers from running? I am on a Mac now and so can only use Firefox and Chrome but not IE, which has a different event model, and tested it on FF and Chrome and all 3 handlers ran without any stopping…. so what is the real difference, or, is there a situation where "stopping the event flow" is not desirable? this is related to http://stackoverflow.com/questions/3042036/using-jquerys-animate-if-the-clicked-on-element-is-a-href-a and http://stackoverflow.com/questions/2017755/whats-the-difference-between-e-preventdefault-and-return-false

    Read the article

  • How to convert TM-2 degree coordinate to lat lon on Android?

    - by Victor Lin
    I am writing a program that convert TM-2 degree to lat/lon on Android, but I can't find formula for that. I do find some example on internet, but most of them are convert with open source library, that I can't use on Android platform. I also find a java class that do convert from UTM to lat lon, but it seems no suitable for TM 2 degreen coordinate system. So my question is: how do I convert TM 2 degree coordinate to lat/lon? Where can I find formula?

    Read the article

  • In database table design, how does "Virtual Goods" affect table design -- should we create an instan

    - by Jian Lin
    When we design a database table for a DVD rental company, we actually have a movie, which is an abstract idea, and a physical DVD, so for each rental, we have a many-to-many table with fields such as: TransactionID UserID DvdID RentedDate RentalDuration AmountPaid but what about with virtual goods? For example, if we let a user rent a movie online for 3 days, we don't actually have a DVD, so we may have a table: TransactionID UserID MovieID RentedDate RentalDuration AmountPaid should we create a record for each instance of "virtual good"? For example, what if this virtual good (the movie) can be authorized to be watched on 3 devices (with 3 device IDs), then should we then create a virtual good record in the VirtualGoods table, each with a VirtualGoodID and then another table that has VirtualGoodID DeviceID to match up the movie with the DeviceIDs? We can also just use the TransactionID as the VirtualGoodID. Are there circumstances where we may want to create a record to record this "virtual good" in a VirtualGoods table?

    Read the article

  • On Ruby on Rails, <%= or <% should only matter whether it is show or no show, but why will it give

    - by Jian Lin
    The following code: <div id="vote_form"> <%= form_remote_tag :url => story_votes_path(@story) do %> <%= submit_tag 'shove it' %> <% end %> </div> gives compilation error while if the first <%= is replaced with <%, then everything works. I thought they only differ by "show" or "not show", but why will it actually cause a compile error? The error is: > SyntaxError in Stories#show > > Showing > app/views/stories/show.html.erb where > line #17 raised: > > compile error C:/Software > Projects/ror/shov12/app/views/stories/show.html.erb:17: > syntax error, unexpected ')' ... > story_votes_path(@story) do ).to_s); > @output_buffer.concat ... > ^ C:/Software > Projects/ror/shov12/app/views/stories/show.html.erb:23: > syntax error, unexpected kENSURE, > expecting ')' C:/Software > Projects/ror/shov12/app/views/stories/show.html.erb:25: > syntax error, unexpected kEND, > expecting ')'

    Read the article

  • After writing SQL statements in MySQL, how to measure the speed / performance of them?

    - by Jian Lin
    I saw something from an "execution plan" article: 10 rows fetched in 0.0003s (0.7344s) How come there are 2 durations shown? What if I don't have large data set yet. For example, if I have only 20, 50, or even just 100 records, I can't really measure how faster 2 different SQL statements compare in term of speed in real life situation? In other words, there needs to be at least hundreds of thousands of records, or even a million records to accurately compares the performance of 2 different SQL statements?

    Read the article

  • Cannot get a session with Facebook app? (using its Graph API)

    - by Jian Lin
    I have 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 <--- Session is NULL for some reason ["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

  • When actually is a closure created?

    - by Jian Lin
    Is it true that a closure is created in the following cases for foo, but not for bar? Case 1: <script type="text/javascript"> function foo() { } </script> foo is a closure with a scope chain with only the global scope. Case 2: <script type="text/javascript"> var i = 1; function foo() { return i; } </script> same as Case 1. Case 3: <script type="text/javascript"> function Circle(r) { this.r = r; } Circle.prototype.foo = function() { return 3.1415 * this.r * this.r } </script> in this case, Circle.prototype.foo (which returns the circle's area) refers to a closure with only the global scope. (this closure is created). Case 4: <script type="text/javascript"> function foo() { function bar() { } } </script> here, foo is a closure with only the global scope, but bar is not a closure (yet), because the function foo is not invoked in the code, so no closure goo is ever created. It will only exist if foo is invoked , and the closure bar will exist until foo returns, and the closure bar will then be garbage collected, since there is no reference to it at all anywhere. So when the function doesn't exist, can't be invoked, can't be referenced, then the closure doesn't exist yet (never created yet). Only when the function can be invoked or can be referenced, then the closure is actually created?

    Read the article

  • In SQL, if we rename INNER JOIN as INTERSECT JOIN, LEFT OUTER JOIN as LEFT UNION JOIN, and FULL OUTE

    - by Jian Lin
    In SQL, the name Join gives an idea of "merging" or a sense of "union", making something bigger. But in fact, as in the other post http://stackoverflow.com/questions/2706051/in-sql-a-join-is-actually-an-intersection-and-it-is-also-a-linkage-or-a-sidew it turns out that a Join (Inner Join) is actually an Intersection. So if we think of Join = Inner Join = Intersect Join Left Outer Join = Left Union Join Full Outer Join = Full Union Join = Union Join then we always get a feel of what's happening, and maybe never forget what they are easily. In a way, we can think of Intersect as "making it less", therefore it is excluding something. That's why the name "Join" won't go with the idea of "Intersect". But in fact, both Intersect and Union can be thought of as: Union: bringing something together and merge them unconditionally. Intersect: bringing something together and merge them based on some condition. so the "bringing something together" is probably what "Join" is all about. It is like, Intersection is a "half glass of water" -- we can thinking of it as "excluding something" or as "bringing something together and accepting the common ones". So if the word "Intersect Join" is used, maybe a clear picture is there, and "Union Join" can be a clear picture too. Maybe the word "Inner Join" and "Outer Join" is very clear when we use SQL a lot. Somehow, the word "Outer" tends to give a feeling that it is "outside" and excluding something rather than a "Union".

    Read the article

  • How to write a recursive function that returns a linked list of nodes, when given a binary tree of n

    - by Jian Lin
    I was once asked of this in an interview: How to write a recursive function that returns a linked list of nodes, when given a binary tree of nodes? (flattening the data) For some reason, I tend to need more than 3 to 5 minutes to solve any recursive problem. Usually, 15 to 20 minutes will be more like it. How could we attack this problem, such as a very systematic way of reaching a solution, so that they can be solved in 3 to 5 minute time frame?

    Read the article

  • In Ruby, what is good way to filter all the methods of an object that contain the word "time" in it?

    - by Jian Lin
    I tried the following and it was partly working: >> s.methods.map {|n| n if n =~ /time/} => [nil, nil, nil, nil, nil, nil, nil, nil, "skip_time_zone_conversion_for_attri butes", nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, ni l, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, ni l, "timestamped_migrations", nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, n il, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, n il, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, n il, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, n il, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, "time_zone_aware _attributes", nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, n il, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, "default_timezone", nil, n il, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, n il, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, n il, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, n il, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, "recor d_timestamps", nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil] >> s.methods.each {|n| p n if n =~ /time/} "skip_time_zone_conversion_for_attributes" "timestamped_migrations" "time_zone_aware_attributes" "default_timezone" "record_timestamps" => ["extended_by", "before_create", "vote_ids=", "save_without_dirty", "_delete" , "touch", "daemonize", "after_destroy", "skip_time_zone_conversion_for_attribut es", "methods", "send", "to_query", "becomes", "after_validation", "store_full_s ti_class?", "save_with_transactions!", "autosave_associated_records_for_votes", "require_library_or_gem", "enum_for", "taint", "instance_variable_defined?", "ac [...] and the rest of the whole array >> s.methods.filter {|n| n =~ /time/} NoMethodError: undefined method `filter' for #<Array:0x4de6b00> from (irb):93

    Read the article

  • differences between using wmode="transparent", "opaque", "window" for an embedded object on webpage

    - by Jian Lin
    when embedding a Flash object with the <object and <embed tag, there is an attribute called "wmode". It seems that most of the time, wmode="transparent" is the same as wmode="opaque" as the Flash doesn't actually have any transparent color so that the bottom HTML element is to be shown. As a result, "opaque" should be faster than "transparent" since it require less processing for transparency, yet most of the time i see Flash object embedded with "transparent" instead of "opaque". "opaque" is needed so that other HTML element won't be covered up by the Flash object. (such as a menu item that pops up an extra sub-menu won't be covered up by the Flash object). By the way, is there formal documentation for wmode's "opaque", "transparent", and "window"? I was only able to find blogs that describe it but not the formal documentation. thanks.

    Read the article

  • Position of builtInZoomControls in WebView and MapView

    - by Mathias Lin
    I noticed that the position of the builtInZoomControls in WebView (bottom, horizontal right) is not consistent with the default position in the MapView (bottom, horizontal center). 1) Why is that not consistent? (Probably a question to be asked to Google) 2) Is there a way to horizontal center the builtInZoomControls of the WebView without applying custom Zoom controls? Or is that the only way?

    Read the article

  • Disable themed Window Border

    - by Jimmie Lin
    In Windows XP's CMD, the Luna border isn't applied to it. Is it possible to do it in a similar way in Visual C# Winforms, for an application? I just wonder how it's done, of course I am not going to force any of my applications to not use the beautiful XP/Aero theme :P Thanks.

    Read the article

  • In languages which create a new scope each time in a loop block, a new local copy of the local loop

    - by Jian Lin
    It seems that in language like C, Java, and Ruby (as opposed to Javascript), a new scope is created for each iteration of a loop block, and the local variable defined for the loop is actually made into a local variable every single time and recorded in this new scope? For example, in Ruby: 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:~] $ So, it looks like when a new scope is created, a new local copy of i is also created and recorded in this new scope, so that when the function is executed at a later time, the "i" is found in those scope chains as 1, 2, 3, 4, 5 respectively. Is this true? (It sounds like a heavy operation). Contrast that with 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 This time, the i is defined before entering the loop, so Ruby 1.8.6 will not put this i in the new scope created for the loop block, and therefore when the i is looked up in the scope chain, it always refer to the i that was in the outside scope, and give 5 every time: [MacBook01:~] $ ruby scope2.rb "1.8.6" 5 5 5 5 5 [MacBook01:~] $ I heard that in Ruby 1.9, i will be treated as a local defined for the loop even when there is an i defined earlier? The operation of creating a new scope, creating a new local copy of i each time through the loop seems heavy, as it seems it wouldn't have matter if we are not invoking the functions at a later time. So when the functions don't need to be invoked at a later time, could the interpreter and the compiler to C / Java try to optimize it so that there is not local copy of i each time?

    Read the article

  • Looking for a better design: A readonly in-memory cache mechanism

    - by Dylan Lin
    Hi all, I have a Category entity (class), which has zero or one parent Category and many child Categories -- it's a tree structure. The Category data is stored in a RDBMS, so for better performance, I want to load all categories and cache them in memory while launching the applicaiton. Our system can have plugins, and we allow the plugin authors to access the Category Tree, but they should not modify the cached items and the tree(I think a non-readonly design might cause some subtle bugs in this senario), only the system knows when and how to refresh the tree. Here are some demo codes: public interface ITreeNode<T> where T : ITreeNode<T> { // No setter T Parent { get; } IEnumerable<T> ChildNodes { get; } } // This class is generated by O/R Mapping tool (e.g. Entity Framework) public class Category : EntityObject { public string Name { get; set; } } // Because Category is not stateless, so I create a cleaner view class for Category. // And this class is the Node Type of the Category Tree public class CategoryView : ITreeNode<CategoryView> { public string Name { get; private set; } #region ITreeNode Memebers public CategoryView Parent { get; private set; } private List<CategoryView> _childNodes; public IEnumerable<CategoryView> ChildNodes { return _childNodes; } #endregion public static CategoryView CreateFrom(Category category) { // here I can set the CategoryView.Name property } } So far so good. However, I want to make ITreeNode interface reuseable, and for some other types, the tree should not be readonly. We are not able to do this with the above readonly ITreeNode, so I want the ITreeNode to be like this: public interface ITreeNode<T> { // has setter T Parent { get; set; } // use ICollection<T> instead of IEnumerable<T> ICollection<T> ChildNodes { get; } } But if we make the ITreeNode writable, then we cannot make the Category Tree readonly, it's not good. So I think if we can do like this: public interface ITreeNode<T> { T Parent { get; } IEnumerable<T> ChildNodes { get; } } public interface IWritableTreeNode<T> : ITreeNode<T> { new T Parent { get; set; } new ICollection<T> ChildNodes { get; } } Is this good or bad? Are there some better designs? Thanks a lot! :)

    Read the article

  • Can Git or Mercurial be set to bypass the local repository and go straight to the central one?

    - by Jian Lin
    Using Git or Mercurial, if the working directory is 1GB, then the local repository will be another 1GB (at least), residing normally in the same hard drive. And then when pushed to a central repository, there will be another 1GB. Can Git or Mercurial be set to use only a working directory and then a central repository, without having 3 copies of this 1GB data? (actually, when the central repository also update, then there are 4 copies of the same data... can it be reduced? In the SVN scenario, when there are 5 users, then there will be 6GB of data total. With Distributed Version Control, then there will be 12GB of data?)

    Read the article

  • Recreation of MySQL DB using "mysql mydb < mydb.sql" is really slow when the table has tens of milli

    - by Jian Lin
    It seems that a MySQL database that has a table with tens of millions of records will get a big INSERT INTO statement when the following mysqldump some_db > some_db.sql is done to back up the database. (is it 1 insert statement that handles all the records?) So when reconstructing the DB using mysql some_db < some_db.sql then the CPU is hardly busy (about 1.8% usage by the mysql process... I don't see a mysqld either?) and also the hard disk doesn't seem to be too busy... Last time, the whole restore process took 5 hours. Is there a way to make it faster? Such as, when doing mysqldump, can it break the INSERT statement into shorter ones, so that the mysql doesn't need to parse the line so hard when restoring the DB?

    Read the article

  • In SQL / MySQL, can a Left Outer Join be used to find out the duplicates when there is no Primary ID

    - by Jian Lin
    I would like to try using Outer Join to find out duplicates in a table: If a table has Primary Index ID, then the following outer join can find out the duplicate names: mysql> select * from gifts; +--------+------------+-----------------+---------------------+ | giftID | name | filename | effectiveTime | +--------+------------+-----------------+---------------------+ | 2 | teddy bear | bear.jpg | 2010-04-24 04:36:03 | | 3 | coffee | coffee123.jpg | 2010-04-24 05:10:43 | | 6 | beer | beer_glass.png | 2010-04-24 05:18:12 | | 10 | heart | heart_shape.jpg | 2010-04-24 05:11:29 | | 11 | ice tea | icetea.jpg | 2010-04-24 05:19:53 | | 12 | cash | cash.png | 2010-04-24 05:27:44 | | 13 | chocolate | choco.jpg | 2010-04-25 04:04:31 | | 14 | coffee | latte.jpg | 2010-04-27 05:49:52 | | 15 | coffee | espresso.jpg | 2010-04-27 06:03:03 | +--------+------------+-----------------+---------------------+ 9 rows in set (0.00 sec) mysql> select * from gifts g1 LEFT JOIN (select * from gifts group by name) g2 on g1.giftID = g2.giftID where g2.giftID IS NULL; +--------+--------+--------------+---------------------+--------+------+----------+---------------+ | giftID | name | filename | effectiveTime | giftID | name | filename | effectiveTime | +--------+--------+--------------+---------------------+--------+------+----------+---------------+ | 14 | coffee | latte.jpg | 2010-04-27 05:49:52 | NULL | NULL | NULL | NULL | | 15 | coffee | espresso.jpg | 2010-04-27 06:03:03 | NULL | NULL | NULL | NULL | +--------+--------+--------------+---------------------+--------+------+----------+---------------+ 2 rows in set (0.00 sec) But what if the table doesn't have a Primary Index ID, then can an outer join still be used to find out duplicates?

    Read the article

  • If Inner Join can be thought of as Cross Join but filtering out the records satisfying the condition

    - by Jian Lin
    If an Inner Join can be thought of as a cross join and then getting the records that satisfy the condition, then a LEFT OUTER JOIN can be thought of as that, plus ONE record on the left table that doesn't satisfy the condition. In other words, it is not a cross join that "goes easy" on the left records (even when the condition is not satisfied), because then the left record can appear many times (as many as how many records there are in the right table). So the LEFT OUTER JOIN is the Cross JOIN with the records satisfying the condition, plus ONE record from the LEFT TABLE that doesn't satisfy the condition.

    Read the article

  • sqlcipher command line not working

    - by Min Lin
    I have a encrypted sqlite db and its key. (Which is generated by an android program). However, when I open the db in command line I can not read the db. The command line tool is installed by: brew install sqlcipher I open the database by: sqlcipher EnDB.db >pragma key="6b74fcd"; >select * from bizinfo; It keeps telling me "Error: file is encrypted or is not a database" However, if I open the database file with gui app sqlite database browser (which is a windows program and I run it in wine). It pops up a window for me to enter the key, with 6b74fcd as the key it successfully read the database. As I want to automatically process the db in the future, I can not depend on the GUI. Do you know why the command line is not working?

    Read the article

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