Search Results

Search found 6 results on 1 pages for 'tcurdt'.

Page 1/1 | 1 

  • jquery plugin with multiple functions

    - by tcurdt
    According to the developer documentation jquery plugins are supposed to have only one namespace for all functions they make available. Which is straight forward as long as you only expose a single function per context (static/element). (function($){ var state_a = 0, $.myplugin = function(in_options) { // static return this; } $.fn.myplugin = function(in_options) { // element return this; } })(jQuery); This makes calls like this possible: $("elem").myplugin(options); jQuery.myplugin(options); What's the best approach if you have more than one function and need to share state? I would like to call into my plugin like this: $("elem").myplugin.start(options); $("elem").myplugin.stop(); jQuery.myplugin.start(options); jQuery.myplugin.stop();

    Read the article

  • maintaing a sorted list that is bigger than memory

    - by tcurdt
    I have a list of tuples. [ "Bob": 3, "Alice: 2, "Jane": 1, ] When incrementing the counts "Alice" += 2 the order should be maintained: [ "Alice: 4, "Bob": 3, "Jane": 1, ] When all is in memory there rather simple ways (some more or some less) to efficiently implement this. (using an index, insert-sort etc) The question though is: What's the most promising approach when the list does not fit into memory. Bonus question: What if not even the index fits into memory? How would you approach this?

    Read the article

  • get next/previous month from a Time object

    - by tcurdt
    I have a Time object and would like to find the next/previous month. Adding subtracting days does not work as the days per month vary. time = Time.parse('21-12-2008 10:51 UTC') next_month = time + 31 * 24 * 60 * 60 Incrementing the month also falls down as one would have to take care of the rolling time = Time.parse('21-12-2008 10:51 UTC') next_month = Time.utc(time.year, time.month+1) time = Time.parse('01-12-2008 10:51 UTC') previous_month = Time.utc(time.year, time.month-1) The only thing I found working was time = Time.parse('21-12-2008 10:51 UTC') d = Date.new(time.year, time.month, time.day) d >>= 1 next_month = Time.utc(d.year, d.month, d.day, time.hour, time.min, time.sec, time.usec) Is there a more elegant way of doing this that I am not seeing? How would you do it?

    Read the article

  • Customizing UISlider look

    - by tcurdt
    To customize the visual look of a UISlider you can set the thumb and track images. Part of the track images gets stretched to the appropriate with. From the documentation: A stretchable region sits between two end cap regions. The end caps define the portions of the image that remain as is and are not stretched. The stretchable region is a 1-point wide area between the end caps that can be replicated to make the image appear longer. Now the problem I have is that my stretchable region needs to be more than 1-point wide. (It's a pattern) Unfortunately the 1-point width seems to be hard coded in the SDK. Anyone having an idea how to work around this? Or will I have to write my own slider from scratch for this?

    Read the article

  • top-k selection/merge

    - by tcurdt
    I have n sorted lists. These lists are quite long (300000+ tuples). Selecting the top 10 of the individual lists is of course trivial - they are right at the head of the lists. Where it gets more interesting is when I want the top 10 of all the sorted lists. The question is whether there is an algorithm to calculate the combined top 10 having the correct order while cutting off the long tail of the lists. The goal is to reduce the required space. And if there is: How does one find the limit where is is safe to cut? Note: The actual counts are not important. Only the order is.

    Read the article

  • dropping characters from regular expression groups

    - by tcurdt
    The goal: I want to convert a number from the format "10.234,56" to "10234.56" Using this simple approach almost gets us there /([\d\.]+),(\d\d)/ => '\1.\2' The problem is that the first group of the match (of course) still contains the '.' character. So questions are: Is it possible to exclude a character from the group somehow? How would you solve this with a single regexp (I know this is a trivial problem when not using a single regexp)

    Read the article

1