Search Results

Search found 4252 results on 171 pages for 'david 85'.

Page 107/171 | < Previous Page | 103 104 105 106 107 108 109 110 111 112 113 114  | Next Page >

  • Updating the launcher icon at run-time

    - by david
    Is it possible to update the launcher icon dynamically? Currently it seems that it can only be set statically at build time using the android:icon attribute in the AndroidManifest.xml file. For example, to display a unique icon based on the device's location? Is this something that can be achieved using aliases? If so, can an alias's launcher icon be enabled/disabled dynamically?

    Read the article

  • Ruby: Why is Array.sort slow for large objects?

    - by David Waller
    A colleague needed to sort an array of ActiveRecord objects in a Rails app. He tried the obvious Array.sort! but it seemed surprisingly slow, taking 32s for an array of 3700 objects. So just in case it was these big fat objects slowing things down, he reimplemented the sort by sorting an array of small objects, then reordering the original array of ActiveRecord objects to match - as shown in the code below. Tada! The sort now takes 700ms. That really surprised me. Does Ruby's sort method end up copying objects about the place rather than just references? He's using Ruby 1.8.6/7. def self.sort_events(events) event_sorters = Array.new(events.length) {|i| EventSorter.new(i, events[i])} event_sorters.sort! event_sorters.collect {|es| events[es.index]} end private # Class used by sort_events class EventSorter attr_reader :sqn attr_reader :time attr_reader :index def initialize(index, event) @index = index @sqn = event.sqn @time = event.time end def <=>(b) @time != b.time ? @time <=> b.time : @sqn <=> b.sqn end end

    Read the article

  • Is there a good argument for software patents?

    - by David Nehme
    Now that it looks like software patents are going to be severely limited, does anyone have a good argument for keeping them. It seems like copyright law serves software fine and patents just add overhead to what should be an almost frictionless process. Are there any examples of software that wouldn't have been written if not for patents?

    Read the article

  • Null-free "maps": Is a callback solution slower than tryGet()?

    - by David Moles
    In comments to "How to implement List, Set, and Map in null free design?", Steven Sudit and I got into a discussion about using a callback, with handlers for "found" and "not found" situations, vs. a tryGet() method, taking an out parameter and returning a boolean indicating whether the out parameter had been populated. Steven maintained that the callback approach was more complex and almost certain to be slower; I maintained that the complexity was no greater and the performance at worst the same. But code speaks louder than words, so I thought I'd implement both and see what I got. The original question was fairly theoretical with regard to language ("And for argument sake, let's say this language don't even have null") -- I've used Java here because that's what I've got handy. Java doesn't have out parameters, but it doesn't have first-class functions either, so style-wise, it should suck equally for both approaches. (Digression: As far as complexity goes: I like the callback design because it inherently forces the user of the API to handle both cases, whereas the tryGet() design requires callers to perform their own boilerplate conditional check, which they could forget or get wrong. But having now implemented both, I can see why the tryGet() design looks simpler, at least in the short term.) First, the callback example: class CallbackMap<K, V> { private final Map<K, V> backingMap; public CallbackMap(Map<K, V> backingMap) { this.backingMap = backingMap; } void lookup(K key, Callback<K, V> handler) { V val = backingMap.get(key); if (val == null) { handler.handleMissing(key); } else { handler.handleFound(key, val); } } } interface Callback<K, V> { void handleFound(K key, V value); void handleMissing(K key); } class CallbackExample { private final Map<String, String> map; private final List<String> found; private final List<String> missing; private Callback<String, String> handler; public CallbackExample(Map<String, String> map) { this.map = map; found = new ArrayList<String>(map.size()); missing = new ArrayList<String>(map.size()); handler = new Callback<String, String>() { public void handleFound(String key, String value) { found.add(key + ": " + value); } public void handleMissing(String key) { missing.add(key); } }; } void test() { CallbackMap<String, String> cbMap = new CallbackMap<String, String>(map); for (int i = 0, count = map.size(); i < count; i++) { String key = "key" + i; cbMap.lookup(key, handler); } System.out.println(found.size() + " found"); System.out.println(missing.size() + " missing"); } } Now, the tryGet() example -- as best I understand the pattern (and I might well be wrong): class TryGetMap<K, V> { private final Map<K, V> backingMap; public TryGetMap(Map<K, V> backingMap) { this.backingMap = backingMap; } boolean tryGet(K key, OutParameter<V> valueParam) { V val = backingMap.get(key); if (val == null) { return false; } valueParam.value = val; return true; } } class OutParameter<V> { V value; } class TryGetExample { private final Map<String, String> map; private final List<String> found; private final List<String> missing; public TryGetExample(Map<String, String> map) { this.map = map; found = new ArrayList<String>(map.size()); missing = new ArrayList<String>(map.size()); } void test() { TryGetMap<String, String> tgMap = new TryGetMap<String, String>(map); for (int i = 0, count = map.size(); i < count; i++) { String key = "key" + i; OutParameter<String> out = new OutParameter<String>(); if (tgMap.tryGet(key, out)) { found.add(key + ": " + out.value); } else { missing.add(key); } } System.out.println(found.size() + " found"); System.out.println(missing.size() + " missing"); } } And finally, the performance test code: public static void main(String[] args) { int size = 200000; Map<String, String> map = new HashMap<String, String>(); for (int i = 0; i < size; i++) { String val = (i % 5 == 0) ? null : "value" + i; map.put("key" + i, val); } long totalCallback = 0; long totalTryGet = 0; int iterations = 20; for (int i = 0; i < iterations; i++) { { TryGetExample tryGet = new TryGetExample(map); long tryGetStart = System.currentTimeMillis(); tryGet.test(); totalTryGet += (System.currentTimeMillis() - tryGetStart); } System.gc(); { CallbackExample callback = new CallbackExample(map); long callbackStart = System.currentTimeMillis(); callback.test(); totalCallback += (System.currentTimeMillis() - callbackStart); } System.gc(); } System.out.println("Avg. callback: " + (totalCallback / iterations)); System.out.println("Avg. tryGet(): " + (totalTryGet / iterations)); } On my first attempt, I got 50% worse performance for callback than for tryGet(), which really surprised me. But, on a hunch, I added some garbage collection, and the performance penalty vanished. This fits with my instinct, which is that we're basically talking about taking the same number of method calls, conditional checks, etc. and rearranging them. But then, I wrote the code, so I might well have written a suboptimal or subconsicously penalized tryGet() implementation. Thoughts?

    Read the article

  • [iText] Inserting Image onCloseDocument

    - by David
    I'm trying to insert an image in the footer of my document using iText's onCloseDocument event. I have the following code: public void onCloseDocument(PdfWriter writer, Document document) { PdfContentByte pdfByte = writer.getDirectContent(); try { // logo is a non-null global variable Image theImage = new Jpeg(logo); pdfByte.addImage(theImage, 400.0f, 0.0f, 0.0f, 400.0f, 0.0f, 0.0f); } catch (Exception e) { e.printStackTrace(); } } The code throws no exceptions, but it also fails to insert the image. This identical code is used onOpenDocument to insert the same logo. The only difference between the two methods are the coordinates in pdfByte.addImage. However, I've tried quite a few different coordinations in onCloseDocument and none of them appear anywhere in my document. Is there any troubleshooting technique for detecting content which is displayed off-page in a PDF? If not, can anyone see the problem with my onCloseDocument method? Edit: As a followup, it seems that onDocumentClose puts its content on page document.length() + 1 (according to its API). However, I don't know how to change the page number back to document.length() and place my logo on the last page.

    Read the article

  • C inline assembly of x96 fbstp instruction

    - by David HUnter
    Was wondering how to inline a usage of fbstp on a 32 bit I86 architecture. I tried something like int main( ) { double foo = 100.0; long bar = 0; asm( "pushl %1; fbstp %0" : "=m"(bar) : "r"(foo) ); ... But bar is unchanged. I have tried reading everything I can find on this but most example simply do things like add two integers together. I can’t find any that talk about pushing operands onto the stack and what I should be doing when an instruction like fbstp writes 80 bits of data back to memory ( i.e. what C type to use ) and how to specify it in the asm syntax. Also on x86-64 there seems to be a pushq and no pushl but fbstp still exists whereas fbstq does not. Is there some other magic for 64 bit.

    Read the article

  • A follow up on type coercion in C++, as it may be construed by type conversion

    - by David
    This is a follow up to my previous question. Consider that I write a function with the following prototype: int a_function(Foo val); Where foo is believed to be a type defined unsigned int. This is unfortunately not verifiable for lack of documentation. So, someone comes along and uses a_function, but calls it with an unsigned int as an argument. Here the story takes a turn. Foo turns out to actually be a class, which can take an unsigned int as a single argument of unsigned int in an explicit constructor. Is it a standard and reliable behavior for the compiler to render the function call by doing a type conversion on the argument. I.e. is the compiler supposed to recognize the mismatch and insert the constructor? Or should I get a compile time error reporting the type mismatch.

    Read the article

  • Parsing Complex Text File with C#

    - by David
    Hello, I need to parse a text file that has a lot of levels and characters. I've been trying different ways to parse it but I haven't been able to get anything to work. I've included a sample of the text file I'm dealing with. Any suggestions on how I can parse this file? I have denoted the parts of the file I need with TEXTINEED. (bean name: 'TEXTINEED context: (list '/text '/content/home/left-nav/text '/content/home/landing-page) type: '/text/types/text module: '/modules/TEXTINEED source: '|moretext| ((contents (list (list (bean type: '/directory/TEXTINEED ((directives (bean ((chartSize (list 600 400)) (showCorners (list #f)) (showColHeader (list #f)) (showRowHeader (list #f))))))) (bean type: '/directory/TEXTINEED ((directives (bean ((displayName (list "MTD")) (showCorners (list #f)) (showColHeader (list #f)) (showRowLabels (list #f)) (hideDetailedLink (list #t)) (showRowHeader (list #f)) (chartSize (list 600 400))))))) (bean type: '/directory/TEXTINEED ((directives (bean ((displayName (list "QTD")) (showCorners (list #f)) (showColHeader (list #f)) (showRowLabels (list #f)) (hideDetailedLink (list #t)) (showRowHeader (list #f)) (chartSize (list 600 400)))))))) Thanks!

    Read the article

  • Detecting GWT RichTextArea 'dirty' state

    - by David
    I want to detect when the contents of my GWT RichTextArea become 'dirty' (have been changed by the user) in order to enable a 'save' button accordingly. I suppose I could listen for key presses that are likely to have changed the contents; but browser support for key presses is notoriously quirky. I suppose I could, before editing begins, save the original contents in a variable, and upon key press, compare the current contents against that variable, but doing that on each key press is going to be really slow. Is there some neat way to achieve RichTextArea dirty-detection?

    Read the article

  • How to bind to localStorage change event using jQuery for all browsers?

    - by David Glenn
    How do I bind a function to the HTML5 localStorage change event using jQuery? $(function () { $(window).bind('storage', function (e) { alert('storage changed'); }); localStorage.setItem('a', 'test'); }); I've tried the above but the alert is not showing. Update: It works in Firefox 3.6 but it doesn't work in Chrome 8 or IE 8 so the question should be more 'How to bind to localStorage change event using jQuery for all browsers?'

    Read the article

  • Clickonce redirect

    - by David Hagan
    Is it possible to deploy an application (using an existing clickonce deployment URL, such that users update to that version) which changes the deployment URL of the deployed application? The scenario is that I have a deployed client (A), which is stable and has been in use for over a year, and a new client (B), which is in development and will be used. However, B and A have different UIDs so that they can both be deployed on the same system together. At some point in the future, I'd like to automatically migrate users who have been using A to B, but I'd hope that Clickonce is well-designed enough to not upgrade A to B if I place B's install files in A's install directory (because it should be checking those UIDs). I know that a C# application that's been deployed through clickonce has some access to its own deployment method, and I'm wondering whether I'm able to change the upgrade-location. I'm hoping to do this quietly without much involvement of the user (and I understand that quiet redirects are heavily frowned upon, for good reasons) and am wondering whether anyone has any experience of trying to modify an installed clickonce's deployment/upgrade information with an update.

    Read the article

  • Python: How do I pass a variable by reference?

    - by David Sykes
    The Python documentation seems unclear about whether parameters are passed by reference or value, and the following code produces the unchanged value 'Original' class PassByReference: def __init__(self): self.variable = 'Original' self.Change(self.variable) print self.variable def Change(self, var): var = 'Changed' Is there something I can do to pass the variable by actual reference? Update: I am coming to the conclusion that while Andrea answered my actual question (Can you... No but you can...), on the subject of pass by reference Blair Conrad is more technically correct. As I understand it the crux is that a copy of a reference is being passed. If you assign that copy, as in my example, then you lose the reference to the original and it remains unchanged. If, however, you 'use' that reference, for example append on a passed list, then the original is changed. I will see how the comments and votes go before choosing the answer people think is the best

    Read the article

  • F# - core benefits

    - by David Neale
    Since the release of VS 2010 I've seen F# more strongly advertised by Microsoft. What are the core benefits of using this language? What problems does it most naturally lend itself to? What is the learning curve like?

    Read the article

  • var in C# - Why can't it be used as a member variable?

    - by David Neale
    Why is it not possible to have implicitly-typed variables at a class level within C# for when these variables are immediately assigned? ie: public class TheClass { private var aList = new List<string>(); } Is it just something that hasn't been implemented or is there a conceptual/technical reason for why it hasn't been done?

    Read the article

  • Getting specific values with regex [JAVA, ANDROID]

    - by David
    I need to knowingly isolate each row of the vcard and get its value. For instance, I want to get "5555" from X-CUSTOMFIELD. So far, my thoughts are: "X-CUSTOMFIELD;\d+" I have been looking at some tutorials and I am a little confused with what function to use? What would my regex above return? Would it give me the whole line or just the numerical part (5555)? I was thinking I i get the whole row, I can use substring to get the digits? BEGIN:VCARD VERSION:2.1 N:Last;First; FN:First Last TEL;HOME;VOICE:111111 TEL;MOBILE;VOICE:222222 X-CUSTOMFIELD;5555 END:VCARD

    Read the article

  • Are all public read/write members serialized with XmlSerializer?

    - by David
    I have a handful of public read/write members that are not being serialized and I can't figure out why. Reviewing some code, and my root class is marked serializable: [Serializable] public class MyClass I have a default constructor that initializes 10-15 string members. There are about 50 public read/write string members in MyClass with get and set--no explicit serialization attributes are set on any of these. Serialization looks like this: XmlSerializer x = new XmlSerializer(typeof(MyClass)); TextWriter twWriter = new StreamWriter(sFileName); x.Serialize(twWriter, this); twWriter.Close(); only a handful (20-30) of these members are actually seralized to my xml file. what am i missing or misunderstanding about the XmlSerializer class?

    Read the article

  • Need this VB code changed into Python.

    - by David
    I wrote this code in VB to label columns in a table but now im writting a python script to automate the process and i can't make it work. Any thoughts?? Static v1 as variant Static v2 as variant Dim Output as double Dim Start as double Start = 1 If v2 = [XMIN] Then Output = v1 Else Output = v1 + 1 End If v1 = Output v2 = [XMIN]

    Read the article

  • facebook messages result set like part 2

    - by David
    Hey guys, I don't think I'm getting it right. Here is my most recent query that I believe is almost working. SELECT max(sender_id) as sender_id, subject, MAX(id) as message_id, MAX(created_at) as updated_at FROM messages where (recipient_id = #{current_user} and recipient_deleted = 'f') or sender_id = #{current_user} GROUP BY subject ORDER BY max(created_at) DESC ; Basically the goal is to fetch all recent messages of a user, group them by subject, and make sure that the photo that is showing up is the other party's photo, never the current user. (also need the most recent message body and message count but that is for another time) Here is what I think is wrong. doing max(sender_id) is wrong, since the current_user id could be higher than the sender's id. I am using the sender_id in the html page to fetch the user's photo.

    Read the article

  • How do i generate a random integer between min and max in java?

    - by David
    What method returns a random int between a min and max? Or does no such method exist? what i'm looking for is something like this: NAMEOFMETHOD (min, max) (where min and max are ints) that returns soemthing like this: 8 (randomly) if such a method does exist could you please link to the relevant documentation with your answer. thanks.

    Read the article

  • Reply to specific socket client.

    - by David
    hi, I am using C#. I have one socket server in PC A and three socket clients in PC B,PC C,and PC D.When PC A receives data, I want to send this data to either PC B or PC C or PC D. I mean i don't want to send this data to all PC.I just want to send the PC i need to send. Now, when server receives data from one client PC, it sends back to all clients PC. Thank you.

    Read the article

  • Optimal sorting algorithm with modified cost... [closed]

    - by David
    The numbers are in a list that is not sorted and supports only one type of operation. The operation is defined as follows: Given a position i and a position j the operation moves the number at position i to position j without altering the relative order of the other numbers. If i j, the positions of the numbers between positions j and i - 1 increment by 1, otherwise if i < j the positions of the numbers between positions i+1 and j decreases by 1. This operation requires i steps to find a number to move and j steps to locate the position to which you want to move it. Then the number of steps required to move a number of position i to position j is i+j. Design an algorithm that given a list of numbers, determine the optimal(in terms of cost) sequence of moves to rearrange the sequence.

    Read the article

  • Akima interpolation of an array of doubles

    - by David Rutten
    Assuming I have an array of doubles, what's a good algorithm to sample this series using Akima interpolation? I'm too stupid to translate that mathematical description into code. // values is an array of doubles // idx is the index of the left-hand value for the current interpolation // t is the normalized parameter between values[idx] and values[idx+1] // Don't worry about array bounds, I'll handle that separately. public double InterpolateAkima(double[] values, int idx, double t) { ...? }

    Read the article

  • MySQL join problem

    - by David
    Table1 has u_name, Table2 has u_name, u_type and u_admin Table1.u_name is unique. But neither of the 3 fields in Table2 is unique. For any value of Table1.u_name, there are 0 to many entries in Table2 that Table2.u_name equals to that value. For any value of Table1.u_name, there are 0 to 1 entries in Table2 that Table2.u_name equals to that value AND Table2.u_type='S' What I want: Use Table1.u_name to get Table1.*, Table2.u_admin where Table1.u_name=Tabl2.u_name and Table2.u_type='S'. If there is no such entry in Table2 we still need to get Table1.* Please help give me some hints. Thank you so much!

    Read the article

< Previous Page | 103 104 105 106 107 108 109 110 111 112 113 114  | Next Page >