Daily Archives

Articles indexed Sunday March 21 2010

Page 12/85 | < Previous Page | 8 9 10 11 12 13 14 15 16 17 18 19  | Next Page >

  • How to get contacts in order of their upcoming birthdays?

    - by Pentium10
    I have code to read contact details and to read birthdays. But how do I get a list of contacts in order of their upcoming birthday? For a single contact identified by id, I get details and birthday like this: Cursor c = null; try { Uri uri = ContentUris.withAppendedId( ContactsContract.Contacts.CONTENT_URI, id); c = ctx.getContentResolver().query(uri, null, null, null, null); if (c != null) { if (c.moveToFirst()) { DatabaseUtils.cursorRowToContentValues(c, data); } } c.close(); // read birthday c = ctx.getContentResolver() .query( Data.CONTENT_URI, new String[] { Event.DATA }, Data.CONTACT_ID + "=" + id + " AND " + Data.MIMETYPE + "= '" + Event.CONTENT_ITEM_TYPE + "' AND " + Event.TYPE + "=" + Event.TYPE_BIRTHDAY, null, Data.DISPLAY_NAME); if (c != null) { try { if (c.moveToFirst()) { this.setBirthday(c.getString(0)); } } finally { c.close(); } } return super.load(id); } catch (Exception e) { Log.v(TAG(), e.getMessage(), e); e.printStackTrace(); return false; } finally { if (c != null) c.close(); } and the code to read all contacts is: public Cursor getList() { // Get the base URI for the People table in the Contacts content // provider. Uri contacts = ContactsContract.Contacts.CONTENT_URI; // Make the query. ContentResolver cr = ctx.getContentResolver(); // Form an array specifying which columns to return. String[] projection = new String[] { ContactsContract.Contacts._ID, ContactsContract.Contacts.DISPLAY_NAME }; Cursor managedCursor = cr.query(contacts, projection, null, null, ContactsContract.Contacts.DISPLAY_NAME + " COLLATE LOCALIZED ASC"); return managedCursor; }

    Read the article

  • How to I create an HQL query to return objects in a many to many relationship?

    - by Dave
    Hi there. I have an application that includes 2 classes Club and Article. These are mapped in Hibernate as a many to many relationship. As a result, hibernate has created a table called CLUB_ARTICLE which it uses to manage the many to many relation ship. The CLUB and ARTILCE tables have no direct reference to each other and the mapping is only represented in the CLUB_ARTICLE table. I need to create an HQL query that returns a list of articles for a particlular club. So I need to supply the club id and get back a list of Article objects that belong to it. For some reason, I just can't work out how to do this. Any help would be very much appriciated! Thanks.

    Read the article

  • Why does this thumbnail generation code throw OutOfMemoryException on large files?

    - by tsilb
    This code works great for generating thumbnails, but when given a very large (100MB+) TIFF file, it throws OutOfMemoryExceptions. When I do it manually in Paint.NET on the same machine, it works fine. How can I improve this code to stop throwing on very large files? In this case I'm loading a 721MB TIF on a machine with 8GB RAM. The Task Manager shows 2GB used so something is preventing it from using all that memory. Specifically it throws when I load the Image to calculate the size of the original. What gives? /// <summary>Creates a thumbnail of a given image.</summary> /// <param name="inFile">Fully qualified path to file to create a thumbnail of</param> /// <param name="outFile">Fully qualified path to created thumbnail</param> /// <param name="x">Width of thumbnail</param> /// <returns>flag; result = is success</returns> public static bool CreateThumbnail(string inFile, string outFile, int x) { // Validation - assume 16x16 icon is smallest useful size. Smaller than that is just not going to do us any good anyway. I consider that an "Exceptional" case. if (string.IsNullOrEmpty(inFile)) throw new ArgumentNullException("inFile"); if (string.IsNullOrEmpty(outFile)) throw new ArgumentNullException("outFile"); if (x < 16) throw new ArgumentOutOfRangeException("x"); if (!File.Exists(inFile)) throw new ArgumentOutOfRangeException("inFile", "File does not exist: " + inFile); // Mathematically determine Y dimension int y; using (Image img = Image.FromFile(inFile)) { // OutOfMemoryException double xyRatio = (double)x / (double)img.Width; y = (int)((double)img.Height * xyRatio); } // All this crap could have easily been Image.Save(filename, x, y)... but nooooo.... using (Bitmap bmp = new Bitmap(inFile)) using (Bitmap thumb = new Bitmap((Image)bmp, new Size(x, y))) using (Graphics g = Graphics.FromImage(thumb)) { g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality; g.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.High; g.CompositingQuality = System.Drawing.Drawing2D.CompositingQuality.HighQuality; System.Drawing.Imaging.ImageCodecInfo codec = System.Drawing.Imaging.ImageCodecInfo.GetImageEncoders()[1]; System.Drawing.Imaging.EncoderParameters ep2 = new System.Drawing.Imaging.EncoderParameters(1); ep2.Param[0] = new System.Drawing.Imaging.EncoderParameter(System.Drawing.Imaging.Encoder.Quality, 100L); g.DrawImage(bmp, new Rectangle(0,0,thumb.Width, thumb.Height)); try { thumb.Save(outFile, codec, ep2); return true; } catch { return false; } } }

    Read the article

  • How do you install Console2 on Windows 7

    - by Brian Boatright
    I downloaded the source and binaries from http://sourceforge.net/projects/console/files/ In the binaries help file it makes reference to a setup file but there is none. The list of files included in the Console-2.00b145-Beta.zip is: Microsoft.VC90.CRT (folder) console.chm Console.exe console.xml ConsoleHook.dll FreeImage.dll FreeImagePlus.dll How do I setup Console2 on Windows 7?

    Read the article

  • Ungrounded laptop (Macbook Pro) buzzes in headphones, weird feeling when fingers brush lightly

    - by donut
    I've got a nearly 3-year-old MacBook Pro 15" 2.16GHz (MacBookPro2,2). When I have am not using the extended, grounded adapter for the power supply, just using the simple, two-prong plug I can hear a buzzing when I use very sensitive earbuds. This goes away if I touch a metal part of the laptop. Also, I can feel a weird, fuzzy feeling when I brush the metal parts of the laptop lightly with my fingers/skin. Somewhat similar to feeling of a touching hair or a balloon that's charged with static electricity. But I'm not getting sparks or anything. And if I'm touching a metal part of my laptop solidly (not just brushing it) and then I touch someone else's skin I can feel the same effect and so can my victim. I've noticed similar effects with an ungrounded electric blanket. But with that the buzzing can be easily heard without headphones. Is this a defect, normal, or something else? And what exactly is happening?

    Read the article

  • best method to update the SQL table data from c# .NET 2005

    - by Jebli
    Hi , I have a dataset with some 30 records in it. I want to update it to the database tables. which is the best method to update the table. I am unable to use dataadapter.update() since i am using a procedure to populate the dataset. is there any efficient way to update other than iterating through EACH record and updating it Please help. Thanks.

    Read the article

  • [android] Activity group throw ActivityNotFoundException?

    - by Mak Sing
    Hi, I want to change the current activity inside a tab in a tab activity, after some research, I know that I need to use activity group to go this. then I created a new class extends ActivityGroup with the code below: public class FavShop extends ActivityGroup{ protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); LocalActivityManager m = getLocalActivityManager(); Intent i = new Intent(this, fav_shops.class); Window window = m.startActivity("favourite shop",i); setContentView(window.getDecorView()); } } then I run the program, the program throw the ActivityNotFoundException when the intent for the tab is launched I have no idea how to solve this problem, could anyone help me?

    Read the article

  • Is ACE reactor timer managment thread safe?

    - by idimba
    I have a module that manages timers in my aplication. This class has basibly three functions: Instance of ACE_Reactor is used internally by the module to manage the timers. schedule timer - calls ACE_Reactor::schedule_timer(). One of the arguments is a callback, called upon timer experation. cancel timer - calls ACE_Reactor::cancel_timer() The reactor executed in private timer of execution, so schedule/cancel and timeout callback are executed in different threads. ACE_Reactor::schedule_timer() receives a heap allocatec structure ( arg argument). This structure later deleted when canceling timer or when timeout handler is called. But since cancel and timeout handler are executed in different threads it looks like there's cases that the structure is deleted twice. Isn't it responsibility of reactor to ensure that timer is canceled when timeout handler is called?

    Read the article

  • GWT RequestBuilder - Changin URLs

    - by Joe
    Hi ! I'm using GWT to dynamically load html snippets from php script. I define the snippet i want the php script to return in the url (test.php?snippet=1). Now in GWT i have a function "getSnippet(int snippet id)" that uses a RequestBuilder to retrieve the snippet. It works perfectly fine, but it bothers me that i have to create a new RequestBuilder everytime getSnippet gets called. I'd rather have one ReqestBuilder and just change the url when getSnippet is called... Is there a way to do this ? Thank you !

    Read the article

  • How to read registry correctly for multiple values in c?

    - by kampi
    Hi! I created a .dll which should work like the RunAs command. The only difference is, that it should read from registry. My problem is, that i need to reed 3 values from the registry, but i can't. It reads the first, than it fails at the second one (Password) with error code 2, which means "The system cannot find the file specified". If i query only for domain and username then it is ok, if i query only for password then it it still succeeds, but if i want to query all three then it fails. Can someone tell me, what i am doing wrong? Heres my code: HKEY hKey = 0; DWORD dwType = REG_SZ; DWORD dwBufSize = sizeof(buf); TCHAR szMsg [MAX_PATH + 32]; HANDLE handle; LPVOID lpMsgBuf; if( RegOpenKeyEx( HKEY_CURRENT_USER, TEXT("SOFTWARE\\Kampi Corporation\\RunAs!"), 0, KEY_QUERY_VALUE, &hKey ) == ERROR_SUCCESS ) { if( RegQueryValueEx( hKey, TEXT("Username"), 0, &dwType, (LPBYTE)buf, &dwBufSize ) == ERROR_SUCCESS ) { memset( szMsg, 0, sizeof( szMsg ) ); wsprintf ( szMsg, _T("%s"), buf ); mbstowcs( wuser, szMsg, 255 ); RegCloseKey( hKey ); } else { MessageBox ( pCmdInfo->hwnd, "Can not query for Username key value!", _T("RunAs!"), MB_ICONERROR ); RegCloseKey( hKey ); return -1; } } else { CSimpleShlExt::showerror( GetLastError(), pCmdInfo->hwnd, "RegOpenKeyEx failed for Username with error code :: " ); return -1; } if( RegOpenKeyEx( HKEY_CURRENT_USER, TEXT("SOFTWARE\\Kampi Corporation\\RunAs!"), 0, KEY_QUERY_VALUE ,&hKey ) == ERROR_SUCCESS ) { if( RegQueryValueEx( hKey, TEXT("Password"), 0, &dwType, (LPBYTE)buf, &dwBufSize ) == ERROR_SUCCESS ) { memset( szMsg, 0, sizeof( szMsg ) ); wsprintf ( szMsg, _T("%s"), buf ); mbstowcs( wpass, szMsg, 255 ); RegCloseKey( hKey ); } else { char test[200]; sprintf(test,"Can not query for Password key value! EC: %d",GetLastError() ); MessageBox ( pCmdInfo->hwnd, test, _T("RunAs!"), MB_ICONERROR ); RegCloseKey( hKey ); return -1; } } else { CSimpleShlExt::showerror( GetLastError(), pCmdInfo->hwnd, "RegOpenKeyEx failed for Password with error code :: " ); return -1; } if( RegOpenKeyEx( HKEY_CURRENT_USER, TEXT("SOFTWARE\\Kampi Corporation\\RunAs!"), 0, KEY_QUERY_VALUE ,&hKey ) == ERROR_SUCCESS ) { if( RegQueryValueEx( hKey, TEXT("Domain"), 0, &dwType, (LPBYTE)buf, &dwBufSize ) == ERROR_SUCCESS ) { memset( szMsg, 0, sizeof( szMsg ) ); wsprintf ( szMsg, _T("%s"), buf ); mbstowcs( wdomain, szMsg, 255 ); RegCloseKey( hKey ); } else { char test[200]; sprintf(test,"Can not query for Password key value! EC: %d",GetLastError() ); MessageBox ( pCmdInfo->hwnd, test, _T("RunAs!"), MB_ICONERROR ); RegCloseKey( hKey ); return -1; } } else { CSimpleShlExt::showerror( GetLastError(), pCmdInfo->hwnd, "RegOpenKeyEx failed for Domain with error code :: " ); return -1; }

    Read the article

  • document.getElementById() returns null when using mozrepl (but not in firebug)

    - by teamonkey
    I'm trying to use the mozrepl Firefox extension to give me a Javascript REPL from within emacs. I think I've got it set up correctly. I can interact with the REPL from emacs and can explore the document pretty much as described in the tutorial pages. The problem comes when I try to do something really simple, like get a context to a canvas element: repl> document.getElementById("mycanvas").getContext("2d") !!! TypeError: document.getElementById("mycanvas") is null Details: message: document.getElementById("mycanvas") is null fileName: chrome://mozrepl/content/repl.js -> file:///C:/Users/teamonkey/AppData/Roaming/Mozilla/Firefox/Profiles/chfdenuz.default/mozrepl.tmp.js lineNumber: 1 stack: @chrome://mozrepl/content/repl.js -> file:///C:/Users/teamonkey/AppData/Roaming/Mozilla/Firefox/Profiles/chfdenuz.default/mozrepl.tmp.js:1 name: TypeError It's not just that particular instance: any call to getElementById will just return null. If I start up firebug I can enter the same thing and it will return a valid context, but I'd really like to get the REPL working in emacs. I don't think this is a bug but I've probably not configured mozrepl correctly. Can anyone help? Mozrepl 1.0, Firefox 3.6

    Read the article

  • Android: Determine when app is being finalized

    - by Matt
    Hi all, I posted a question yesterday about determining when an app is being finalized vs destroyed for screen orientation change. Thanks to the answers I received I was able to resolve my problem with the screen orientation change. However, I am still running into a roadblock. This app I am working on logs into a website with an HttpClient. As long as the app remains in memory the HttpClient will retain the cookies from logging in. However, once it is killed, it would need to log in again. My question: How can I determine when the app is being killed from memory so I can set a boolean to false telling the app it has been removed from memory so the next time it starts it will read this and determine is must log in again? Or is it possible to serialize an HttpClient and put that in the savedInstanceState bundle? May extract the cookies from the client and put those in the savedInstanceState bundle? Is there something I'm completely missing here maybe? Any help or a point in the right direction is greatly appreciated because this one has me stumped. Thank you!

    Read the article

  • Dynamic State Machine in Ruby? Do State Machines Have to be Classes?

    - by viatropos
    Question is, are state machines always defined statically (on classes)? Or is there a way for me to have it so each instance of the class with has it's own set of states? I'm checking out Stonepath for implementing a Task Engine. I don't really see the distinction between "states" and "tasks" in there, so I'm thinking I could just map a Task directly to a state. This would allow me to be able to define task-lists (or workflows) dynamically, without having to do things like: aasm_event :evaluate do transitions :to => :in_evaluation, :from => :pending end aasm_event :accept do transitions :to => :accepted, :from => :pending end aasm_event :reject do transitions :to => :rejected, :from => :pending end Instead, a WorkItem (the main workflow/task manager model), would just have many tasks. Then the tasks would work like states, so I could do something like this: aasm_initial_state :initial tasks.each do |task| aasm_state task.name.to_sym end previous_state = nil tasks.each do |tasks| aasm_event task.name.to_sym do transitions :to => "#{task.name}_phase".to_sym, :from => previous_state ? "#{task.name}_phase" : "initial" end previous_state = state end However, I can't do that with the aasm gem because those methods (aasm_state and aasm_event) are class methods, so every instance of the class with that state machine has the same states. I want it so a "WorkItem" or "TaskList" dynmically creates a sequence of states and transitions based on the tasks it has. This would allow me to dynamically define workflows and just have states map to tasks. Are state machines ever used like this?

    Read the article

  • Problem with qTip - Tips not showing because elements load after the script

    - by msvalkon
    Hey, I'm not very experienced with javascript, jQuery or it's plugins but usually I manage. Anyways, my client is building a site and one of its purposes is to pick up news articles from different sites and show the titles in unordered html lists. I don't have access to his code, the news articles load up rather slow(much after the site has loaded). I'm using qTIP and the idea is that once you hover over a news title, it will generate a tooltip. This works fine in my dev environment, because I have dummy title's that are not generated from anywhere. The problem is that once the client sets the site up in his test environment, the scripts that load the news titles into the lists are so slow, that the qTIP-script loads before there are any elements in the lists. Hence it's not aware of any <li>'s to pick up and generate tooltips from. Is there a way make sure that ALL of the news articles are loaded before the tooltip-script loads? I think that a simple delay in loading the script is not very smart because some of the titles seem to take longer to load than others, so the delay would have to be rather long.

    Read the article

  • Hosted full text search solutions?

    - by James Cooper
    Does anyone know of companies offering SaaS full text search? I'm looking for something that uses Lucene, solr, or sphinx on the backend, and provides a REST API for submitting documents to index, and running searches. I could build my own EC2 AMI, but I'd have to configure EBS and other stuff, monitor it, etc. Curious if someone has already done all this and would charge per MB/GB indexed. thank you. -- James

    Read the article

  • Computer science final year project ideas

    - by roul
    I'm a Computer Science undergraduate student in UK and should be deciding the subject of my final year project soon. The school is pretty flexible with the subject... "The topic can be any area of the subject which is of mutual interest to both the student and supervisor. Topics can range from purely theoretical studies to practical work building a system for some third party, although most projects aim to provide a balance between the theoretical and practical aspects of the subject." ...so I'm a bit lost since I want to do something in software engineering but have no idea what (subject) or with what (languages)! :) a) Languages: I've had experience with Java, C# and ASP.NET mostly but I would definitely be interested in learning new languages/frameworks. I'm kind of drawn by the idea of dynamic languages at the moment so IronPython seems likely. b) Subject: Anything that will keep me interested through the year and will give me the opportunity to learn a lot of stuff. Maybe something that has to do with music, or a fancy website, or a website about music :P anything really. Open to any thoughts/ideas, geeky or cool! Edit: Professors do usually supervise projects in their research areas but I currently have the choice to approach any of them according to my interest - whatever that is.

    Read the article

  • 404 Error Behavior on Godaddy

    - by liciousx
    My goDaddy account for hosting and on that host i have multiple domains. goDaddy offers me only one 404 redirect for all of my domains: domain1.com/gadfgsdf (nonexistent link) is redirected to domain1.com domain2.com/gadf (nonexistent link) is redirected to domain1.com domain.com/sagsdg (nonexistent link) is redirected to domain1.com I need for one of my domains to make the redirect on the same domain: domain4.com/gsdhgfhf (nonexistent link) to be redirected to domain4.com I am on Windows and i am using Wordpress on all of my domains. I looked for the web.config file but didn't find it. I new at this and i would really appreciate it if you can explain more detailed. Thanks

    Read the article

  • SharePoint solution package not deploying to all front-ends

    - by Alex
    I have a WSP that contains a web part. It's being built using WSPBuilder. Most of the time, the WSP deploys perfectly. However, in two of our test environments (and sadly, in production, too) the WSP doesn't deploy properly to all the web front ends. The assemblies make it into the GAC, and the .webpart files get provisioned. The problem is that a tool part that the web part relies on for configuration simply fails to appear. I've determined that every time this has happened, it has been isolated to a single web front end. I've been able to resolve the issue by doing an stsadm -o deploysolution to re-deploy the solution, and in one instance it was resolved by the end user deactivating/reactivating the feature. Unfortunately, though, this has made it impossible to determine if the control isn't being deployed properly, or if it's some other issue. Any thoughts on this? Could it be a problem with the WSP, or is it likely to be environmental?

    Read the article

  • How/Where do you install Console2 on Windows 7

    - by Brian Boatright
    I downloaded the source and binaries from http://sourceforge.net/projects/console/files/ In the binaries help file it makes reference to a setup file but there is none. The list of files included in the Console-2.00b145-Beta.zip is: Microsoft.VC90.CRT (folder) console.chm Console.exe console.xml ConsoleHook.dll FreeImage.dll FreeImagePlus.dll How do I setup or place the files for Console2 on Windows 7?

    Read the article

< Previous Page | 8 9 10 11 12 13 14 15 16 17 18 19  | Next Page >