Daily Archives

Articles indexed Saturday May 8 2010

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

  • Why Microsoft not provide for C# a static Win32 class with the most native functions and structures

    - by Oleg
    Everybody who used P/Invoke of Windows API knows a long list of declarations of static functions with attributes like [DllImport ("kernel32.dll", SetLastError = true, CharSet = CharSet.Auto)] The declaration of structures copied from Windows headers like WinNT.h or from web sites like www.pinvoke.net take also a lot of place in our programs. Why we all have to spend our time for this? Why Microsoft not give us a simple way to include a line like in old unmanaged programs #include <windows.h> and we would be have access to a static class Native with all or the most Windows functions and structures inside?

    Read the article

  • Finding N contiguous zero bits in an integer to the left of the MSB position of another integer

    - by James Morris
    The problem is: given an integer val1 find the position of the highest bit set (Most Significant Bit) then, given a second integer val2 find a contiguous region of unset bits, with the minimum number of zero bits given by width to the left of the position (ie, in the higher bits). Here is the C code for my solution: typedef unsigned int t; unsigned const t_bits = sizeof(t) * CHAR_BIT; _Bool test_fit_within_left_of_msb( unsigned width, t val1, t val2, unsigned* offset_result) { unsigned offbit = 0; unsigned msb = 0; t mask; t b; while(val1 >>= 1) ++msb; while(offbit + width < t_bits - msb) { mask = (((t)1 << width) - 1) << (t_bits - width - offbit); b = val2 & mask; if (!b) { *offset_result = offbit; return true; } if (offbit++) /* this conditional bothers me! */ b <<= offbit - 1; while(b <<= 1) offbit++; } return false; } Aside from faster ways of finding the MSB of the first integer, the commented test for a zero offbit seems a bit extraneous, but necessary to skip the highest bit of type t if it is set. I have also implemented similar algorithms but working to the right of the MSB of the first number, so they don't require this seemingly extra condition. How can I get rid of this extra condition, or even, are there far more optimal solutions? Edit: Some background not strictly required. The offset result is a count of bits from the high bit, not from the low bit as maybe expected. This will be part of a wider algorithm which scans a 2D array for a 2D area of zero bits. Here, for testing, the algorithm has been simplified. val1 represents the first integer which does not have all bits set found in a row of the 2D array. From this the 2D version would scan down which is what val2 represents. Here's some output showing success and failure: t_bits:32 t_high: 10000000000000000000000000000000 ( 2147483648 ) --------- ----------------------------------- *** fit within left of msb test *** ----------------------------------- val1: 00000000000000000000000010000000 ( 128 ) val2: 01000001000100000000100100001001 ( 1091569929 ) msb: 7 offbit:0 + width: 8 = 8 mask: 11111111000000000000000000000000 ( 4278190080 ) b: 01000001000000000000000000000000 ( 1090519040 ) offbit:8 + width: 8 = 16 mask: 00000000111111110000000000000000 ( 16711680 ) b: 00000000000100000000000000000000 ( 1048576 ) offbit:12 + width: 8 = 20 mask: 00000000000011111111000000000000 ( 1044480 ) b: 00000000000000000000000000000000 ( 0 ) offbit:12 iters:10 ***** found room for width:8 at offset: 12 ***** ----------------------------------- *** fit within left of msb test *** ----------------------------------- val1: 00000000000000000000000001000000 ( 64 ) val2: 00010000000000001000010001000001 ( 268469313 ) msb: 6 offbit:0 + width: 13 = 13 mask: 11111111111110000000000000000000 ( 4294443008 ) b: 00010000000000000000000000000000 ( 268435456 ) offbit:4 + width: 13 = 17 mask: 00001111111111111000000000000000 ( 268402688 ) b: 00000000000000001000000000000000 ( 32768 ) ***** mask: 00001111111111111000000000000000 ( 268402688 ) offbit:17 iters:15 ***** no room found for width:13 ***** (iters is the count of iterations of the inner while loop)

    Read the article

  • BindData to ITemplate for GridView in code behind

    - by tbischel
    How do I programmatically bind data to a custom item template column for a GridView? So far, I've done something similar to this: TemplateField foo = new TemplateField(); foo.ItemTemplate = new bar(); this.GridView1.Columns.Add(foo); where bar is like this: public class bar : ITemplate { public bar() { } public void InstantiateIn(Control container) { DropDownList ddl = new DropDownList(); container.Controls.Add(ddl); } } (the actual dropdownlist is populated) But ITemplate doesn't contain any kind of data binding properties to implement, and the TemplateField class doesn't seem to have any either... What do I do?

    Read the article

  • Best way to validate a WinCE OS image (.bin) file?

    - by Ryan Clark
    We have a Windows CE 6.0 based product that allows for firmware upgrades through a web interface. I want to perform a sanity check on the new firmware image to be sure that it is valid. How should I perform the validation? I see in the BIOSLOADER code, there is support code for decoding a BIN file. I suppose I could massage that to perform the validation. Is there a better way? Thanks!

    Read the article

  • Learning JavaScript... Should I skip straight to the good stuff (the frameworks)?

    - by Grogs
    I learnt HTML/CSS a good few years back, then PHP a little later. I've recently become interesting in web development again, just started playing with frameworks like Django and RoR. I'm curious as to how much time/effort I should spend learning straight JS before looking at frameworks. I've been reading through a let of articles called Mastering AJAX by Brett McLaughlin which seems quite good, but I'm seeing a lot of stuff (such as cross browser compatibility - even for things like XMLHttpRequest) coming up which look like they would be non-issues if using a framework. So, should I keep reading through these articles and try to build stuff using basic JS, or should I just start looking into jQuery and the like? Also, I've been watching a few videos regarding GWT from Google I/O. I've been learning Java over the last year, built a few medium sized apps in it. I'm wondering if GWT is something that's worth going straight to, along with gQuery?

    Read the article

  • How to enable commenting on the Facebook Like Button

    - by digitaldreamer
    I'm integrating the Facebook Like Button into a site. The likeing functionality is working fine except that you cannot add comments to your like after you've clicked the like button. Several sites including CNN has this working so this should be possible. The docs mention that you need to use the JavaScript SDK to get commenting to work, which I am doing; however I cannot get commenting to show up. A fuller-featured Like button is available via the XFBML tag and requires you use the new JavaScript SDK. The XFBML version allows users to add a comment to their like as it is posted back to Facebook. I cannot find details on which options are available for this more "fully-featured" XFBML like button. I'm wondering if there is a setting that I need to add, an option that I'm not passing in, or anything that I've overlooked. I am on a dev server, and I'm linking back to the live site for now. Perhaps the ContactURL and the base URL of the liked page need to be the same in order to get commenting to work? Here's how I'm embedding the facebook like button: <!-- facebook --> <div id="fb-root"></div> <script type="text/javascript"> window.fbAsyncInit = function() { FB.init({appId: 'XXXXXXXXXXXXXX', status: true, cookie: true, xfbml: true}); }; (function() { var e = document.createElement('script'); e.async = true; e.src = document.location.protocol + '//connect.facebook.net/en_US/all.js'; document.getElementById('fb-root').appendChild(e); }()); </script> <!-- facebook --> ... <fb:like href="example.com" layout="button_count" show_faces="false" width="100" colorscheme="dark"></fb:like>

    Read the article

  • Double paging definition

    - by Albinoswordfish
    This is not a programming question but more of an operating system question Right now I'm trying to learn what exactly Double paging means. I see two different terms, double paging on disk and double paging in memory. Apparently this problem arises when we introduce a buffer cache to store disk blocks when doing File I/O But I'm not really sure what exactly this term means. If anybody could specify it would be very helpful.

    Read the article

  • Linux needs to do more for programmers

    <b>Cyber Cynic: </b>"Much as I hate to admit it, Microsoft does some things better, much better, than Linux. Number one with a bullet is how Microsoft helps programmers and ISVs (independent software vendors). MSDN (Microsoft Software Developer Network) is a wonderful online developer resource. Linux has had nothing to compare."

    Read the article

  • Dreamweaver Files uploaded to Win 2008 server cause login prompt

    - by Lil
    I have a customer who uses a 4 year old version of Dreamweaver to edit her webpages. My hosting reseller account is with a company that uses Windows Server 2008. Every time my customer edits a page and uploads it, I have to set the permissions for that file to be readable, manually from the site's control panel. The customer is furious with me because her files cause the login prompt. I am able to upload files myself that remain readable to the site with both Filezilla and with Frontpage. I am assuming that her Dreamweaver settings are the cause of the problem but I don't have that program myself and don't know what to advise her. Any suggestions?

    Read the article

  • Customize the Windows 7 Games Explorer

    - by musicfreak
    So I just upgraded my system to the Windows 7 RTM, and I've noticed they took away the ability to customize the shortcuts in the Games Explorer. Is there a third-party application that would allow me to customize the shortcuts without having to do so manually? I know how to do it, but it's a pain, and I'd rather have a GUI do the dirty work for me.

    Read the article

  • OS X Enclosing folder shortcut?

    - by Nano8Blazex
    This may have been asked before, but I'm wondering whether there is a shortcut for navigating to the enclosing folder in OS X (Snow Leopard)? I find navigating Finder particularly frustrating since it's hard navigating back to the enclosing folder (especially when you jump to a folder and realize the back button is disabled)... I'm hoping for something other than Command+Up, since that's the key combination I use to navigate Spaces.

    Read the article

  • Error while compiling the Xcode project (IPhone)

    - by Sridhar
    Hello, I added ffmpeg iphone port into my library and I can able to use a few of its functions like avcodec_init(),.. without any errors. But when I include this function call "avcodec_register_all" Xcode is giving error after compilation The error message is : *--------------- ld: ldr 12-bit displacement out of range (4276 max +/-4096) in _CFRelease$stub in _CFRelease$stub from /Users/foxit/Documents/CameraTest/build/CameraTest.build/Debug-iphoneos/CameraTest.build/Objects-normal/armv6/CameraTest Command /Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/gcc-4.2 failed with exit code 1 *------------- Does anyone know whats wrong with this ? Regards, Raghu

    Read the article

  • Dispatcher.CurrentDispatcher?

    - by Mark
    If I do this... public PriorityQueue(Dispatcher dispatcher = null) { this.dispatcher = dispatcher ?? Dispatcher.CurrentDispatcher; } And then use it in a ViewModel (without passing any args) that is created through the XAML, this.dispatcher will point to the UI thread right?

    Read the article

  • Entity Framework Update Entity along with child entities (add/update as necessary)

    - by Jorin
    I have a many-to-many relationship between Issues and Scopes in my EF Context. In ASP.NET MVC, I bring up an Edit form that allows the user to edit a particular Issue. At the bottom of the form, is a list of checkboxes that allow them to select which scopes apply to this issue. When editing an issue, it likely will always have some Scopes associated with it already--these boxes will be checked already. However, the user has the opportunity to check more scopes or remove some of the currently checked scopes. My code looked something like this to save just the Issue: using (var edmx = new MayflyEntities()) { Issue issue = new Issue { IssueID = id, TSColumn = formIssue.TSColumn }; edmx.Issues.Attach(issue); UpdateModel(issue); if (ModelState.IsValid) { //if (edmx.SaveChanges() != 1) throw new Exception("Unknown error. Please try again."); edmx.SaveChanges(); TempData["message"] = string.Format("Issue #{0} successfully modified.", id); } } So, when I try to add in the logic to save the associated scopes, I tried several things, but ultimately, this is what made the most sense to me: using (var edmx = new MayflyEntities()) { Issue issue = new Issue { IssueID = id, TSColumn = formIssue.TSColumn }; edmx.Issues.Attach(issue); UpdateModel(issue); foreach (int scopeID in formIssue.ScopeIDs) { var thisScope = new Scope { ID = scopeID }; edmx.Scopes.Attach(thisScope); thisScope.ProjectID = formIssue.ProjectID; if (issue.Scopes.Contains(thisScope)) { issue.Scopes.Attach(thisScope); //the scope already exists } else { issue.Scopes.Add(thisScope); // the scope needs to be added } } if (ModelState.IsValid) { //if (edmx.SaveChanges() != 1) throw new Exception("Unknown error. Please try again."); edmx.SaveChanges(); TempData["message"] = string.Format("Issue #{0} successfully modified.", id); } } But, unfortunately, that just throws the following exception: An object with the same key already exists in the ObjectStateManager. The ObjectStateManager cannot track multiple objects with the same key. What am I doing wrong?

    Read the article

  • use qt and django to create desktop apps

    - by sandra
    Hi guys, I had this idea of creating desktop apps using django. The principe being: - Write the django app, and use something like cherrypy to serve it. - Write a Qt app in C++ to access it and this by using QtWebview (webkit) I'd like to "bundle" this in a single app. The lighter, the better :) So here are my questions and if you have better ideas and suggestions, please share them :) Is it possible to serve a django app with a c++ one? (a c++ server embedding python)? anyone did this before? Do you have some articles, blog posts? Thanks a lot!

    Read the article

  • 2-byte (UCS-2) wide strings under GCC

    - by Seva Alekseyev
    Hi all, when porting my Visual C++ project to GCC, I found out that the wchar_t datatype is 4-byte UTF-32 by default. I could override that with a compiler option, but then the whole wcs* (wcslen, wcscmp, etc.) part of RTL is rendered unusable, since it assumes 4-byte wide strings. For now, I've reimplemented 5-6 of these functions from scratch and #defined my implementations in. But is there a more elegant option - say, a build of GCC RTL with 2-byte wchar-t quietly sitting somewhere, waiting to be linked? The specific flavors of GCC I'm after are Xcode on Mac OS X, Cygwin, and the one that comes with Debian Linux Etch.

    Read the article

  • SET game odds simulation (MATLAB)

    - by yuk
    Here is an interesting problem for your weekend. :) I recently find the great card came - SET. Briefly, there are 81 cards with the four features: symbol (oval, squiggle or diamond), color (red, purple or green), number (one, two or three) or shading (solid, striped or open). The task is to find (from selected 12 cards) a SET of 3 cards, in which each of the four features is either all the same on each card or all different on each card (no 2+1 combination). In my free time I've decided to code it in MATLAB to find a solution and to estimate odds of having a set in randomly selected cards. Here is the code: %% initialization K = 12; % cards to draw NF = 4; % number of features (usually 3 or 4) setallcards = unique(nchoosek(repmat(1:3,1,NF),NF),'rows'); % all cards: rows - cards, columns - features setallcomb = nchoosek(1:K,3); % index of all combinations of K cards by 3 %% test tic NIter=1e2; % number of test iterations setexists = 0; % test results holder % C = progress('init'); % if you have progress function from FileExchange for d = 1:NIter % C = progress(C,d/NIter); % cards for current test setdrawncardidx = randi(size(setallcards,1),K,1); setdrawncards = setallcards(setdrawncardidx,:); % find all sets in current test iteration for setcombidx = 1:size(setallcomb,1) setcomb = setdrawncards(setallcomb(setcombidx,:),:); if all(arrayfun(@(x) numel(unique(setcomb(:,x))), 1:NF)~=2) % test one combination setexists = setexists + 1; break % to find only the first set end end end fprintf('Set:NoSet = %g:%g = %g:1\n', setexists, NIter-setexists, setexists/(NIter-setexists)) toc 100-1000 iterations are fast, but be careful with more. One million iterations takes about 15 hours on my home computer. Anyway, with 12 cards and 4 features I've got around 13:1 of having a set. This is actually a problem. The instruction book said this number should be 33:1. And it was recently confirmed by Peter Norvig. He provides the Python code, but I didn't test it. So can you find an error?

    Read the article

  • kerio load balance

    - by Azzam
    I use kerio winroute 6.5 , for week ago, i got a second adsl link (2 mbps), i tried to configue the load balancing in kerio , but always , kerio directs the traffic to one route without the other , i enabled NAT for firewall and change the rate between 2 links but always kerio takes the system route to one link , is there a solution for that ?

    Read the article

  • How do you remove a site from Sharepoint Designer?

    - by xpda
    I would like to use Sharepoint Designer 2007 as an html editor. I have a web site with a lot of files in a folder on my hard drive. I do not want Sharepoint Designer to make a web site out of this. I just want to use Sharepoint Designer to edit the html files, locally. If I ever make a mistake and click on a tool for Sites, such as summary or report, Sharepoint Designer will decide that my folder is now a web site. From that point on, Sharepoint Designer is painfully slow whenever I open a file contained in the folder that Sharepoint decided is my web site, instead of being instantaneous like it was before. I can resolve this situation by renaming the folder containing my web site -- everything gets fast again. I can also fix it by uninstalling and reinstalling Sharepoint Designer. Neither of these is a good solution. Is there a place in Sharepoint Designer, or in application data or the registry that I can kill off the Sharepoint Designer web site that's associated with a folder on my hard drive?

    Read the article

  • What primitive data type is time_t?

    - by thyrgle
    I do not know the data type of time_t. Is it a float double or something else? Because if I want to display it I need the tag that corresponds with it for printf. I can handle the rest from there for displaying time_t but I need to know the data type that corresponds with it.

    Read the article

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