Search Results

Search found 38 results on 2 pages for 'eagle'.

Page 1/2 | 1 2  | Next Page >

  • 25 Secrets for Faster ASP.NET: the Eagle has landed!

    - by Michaela Murray
    On Friday we launched our new free eBook, 25 Secrets for Faster ASP.NET Applications! Heading for 1000 of you have picked it up already, but if you haven’t got your copy yet, you can grab it from http://www.red-gate.com/25secrets. It’s the follow up to the wildly successful 50 Ways to Avoid, Find and Fix ASP.NET Performance Issues, which we released back in January this year (you can download from www.red-gate.com/50ways). Once again, we collected tips from some of the smartest brains in the ASP.NET community, but this time around, we’ve covered the latest stuff in the .NET framework – async/await, Web API, and more. Houston, we have a winner… In my original blogpost, I offered a Microsoft Surface as a prize for the best tip. Now, after some serious deliberation, our judges have settled on a winner. By a unanimous verdict, the prize goes to… (wait for it!) … Jeffrey Richter, for this cheeky number, Tip #1 in the new book: Want to build scalable websites and services? Work asynchronously One of the secrets to producing scalable websites and services is to perform all your I/O operations asynchronously to avoid blocking threads. When your thread issues a synchronous I/O request, the Windows kernel blocks the thread. This causes the thread pool to create a new thread, which allocates a lot of memory and wastes precious CPU time. Calling xxxAsync method and using C#’s async/await keywords allows your thread to return to the thread pool so it can be used for other things. This reduces the resource consumption of your app, allowing it to use more memory and improving response time to your clients. Congratulations Jeffrey! Of course, I also owe a massive thank you to everyone who’s been involved in the book, especially all the authors. It’s a real treat to work with a developer community that’s so keen to collaborate and to share their hard-won nuggets of performance knowhow. If you haven’t read it yet, I can’t recommend it highly enough. You can get it for free at www.red-gate.com/25secrets The full backstory for both eBooks: https://www.simple-talk.com/blogs/2012/11/15/application-performance-the-best-of-the-web/ https://www.simple-talk.com/blogs/2012/11/27/application-performance-episode-2-announcing-the-judges/ https://www.simple-talk.com/blogs/2013/01/25/free-ebook-50-ways-to-avoid-find-and-fix-asp-net-performance-issues/ https://www.simple-talk.com/blogs/2013/03/22/50-ways-to-avoid-find-and-fix-asp-net-performance-issues-the-next-generation/

    Read the article

  • Some hint to program a webservice "by subscription"

    - by Eagle
    I have some web sites programmed, I know to do it with python and PHP basically. Normally they are simple web sites, but now I want to provide REST web services but only for allowed users (allowed by me). I saw that a lot of services uses the "KEY" and "SECRET_KEY" concepts, which seems to be what I need (if I understand it right). My suppositions are: If I only do a GET service to retrieve, e.g., all my clients, without anymore, anyone can retrieve my clients without limitations. I will need some KEY generator to provide keys for my allowed users, so they can use my webservices. Only with a KEY is not enough: someone can steal a KEY and supplant my user (and this is the reason because exists a SECRET_KEY, right?). If all this is right, how can I make/use a system like that in my web services? Some open source example? Or maybe there are another easy solutions I'm not considering? My objective is to allow some users to use my web services.

    Read the article

  • Desktop background will not load after performing aticonfig --adapter=all --ovt=opengl

    - by user1571959
    I am trying to get Eagle to work on ubuntu 14.04 LTS. When I run Eagle and open a schematic the display is not refreshing/redrawing correctly. One solution that I found was to install the flgrx drivers and do the aticonfig command to use opengl... So I did and rebooted. Now when I turn on my laptop I get all the way to the login screen, login, and then nothing happens, it just goes to the background image with no icons or anything... I tried deleting and copying the original xorg.conf file and no results... What do I do other than reinstalling Ubuntu? is there anyway to force the original driver?

    Read the article

  • how to configure Firefox to automatically reuse the login credentials like IE

    - by Black Eagle
    Multiple HTTP Authentication Prompts in Firefox We are currently working on porting our application from Internet Explorer to Firefox and the application currently uses HTTP Digest Authentication. In case of Internet Explorer, the popup dialog to enter the Username/password appears only once and the entered login credentials are reused for subsequent HTTP requests to the web server. However in case of Firefox, the Authentication popups appears whenever the request is made to the Web Server. The Web Server used is Emweb Server. We would like to know how to configure Firefox to automatically reuse the login credentials like IE.

    Read the article

  • The SSL certificate doesn't established

    - by Andrey Eagle
    situation following: Windows Server 2008 R2 platform. Certificate installation in the IIS Manager occurs successfully with *.cer file but if I refresh the manager (F5), the certificate vanishes from the list. And, respectively in the Bindings window, at https addition, the certificate is absent in the menu. Thus if to open certificates via the MMS console, it can be seen in the Personal store. Whether there is any possibility to make so that the web server could "see" this certificate or how to make so that it didn't disappear from the list? Prompt how to solve this problem, thanks in advance! P.S. The certificate is acquired in tawte. In total that to me provided, these are account data where it is possible simply with save-pastit the certificate in 2 options: PKCS#7 and X.509. Here is the manual I used. P.S.2 If Complete Certificate Request with *.p7b I get an error: Cannot find the certificate request that is associated with this certificate file. Acertificate request must be comleted on the computer where the request was created.

    Read the article

  • How can I run the latest version of Chrome on Mac OS X?

    - by eagle
    In a bug post I sent to the chrome developers, a developer sent me the message: We don't see this difference in the new builds of Chrome. Checked in 6.0.437.2 dev. Can you check and confirm again? I'm wondering how can I run the latest (development) version of Chrome for Mac OS X? Ideally I don't want to build the project.

    Read the article

  • Adding a UINavigationController as a subview of UIView

    - by eagle
    I'm trying to display a UILabel on top of a UINavigationController. The problem is that when I add the UILabel as a subview of UIWindow it will not automatically rotate since it is not a subview of UIViewController (UIViewController automatically handles updating subviews during rotations). This is the hierarchy I was using: UIWindow UILabel UINavigationController So I was thinking I could use the following hierarchy: UIWindow UIViewController UIView UILabel UINavigationController This way the label could be displayed on top of the UINavigationController's bar while also automatically being rotated since it is a subview of UIViewController. The problem is that when I try adding a UINavigationController as a subview of a view: [myViewController.view addSubview:myNavigationController.view]; it will appear 20 pixels downwards. Which I'm guessing is because it thinks it needs to make room for the status bar. But, since the UINavigationController is being placed inside a UIView which does not overlay on top of the status bar, it is incorrectly adding an additional 20 pixels. In other words, the top of the UINavigationBar is at the screen's 40 pixel mark instead of at 20 pixels. Is there any easy way to just shift the UINavigationController and all of its elements (e.g. navigation bar, tool bar, root view controller) up 20 pixels? Or to let it know that it shouldn't compensate for a status bar? If not, I guess I would need to use my first hierarchy mentioned above and figure out how to rotate the label so it is consistent with the navigation bar's rotation. Where can I find more information on how to do this? Note: by "displaying a label on top of the navigation bar", I mean it should overlay on top of the navigation bar... it can't simply be wrapped in a bar button item and placed as one of the items of the navigation bar.

    Read the article

  • Example of [NSDictionary getObjects:andKeys:]

    - by eagle
    I couldn't find a working example of the method [NSDictionary getObjects:andKeys:] on Google. The only link I could find, doesn't compile. I provided the errors/warnings here in case someone is searching for them. The documentation says that it returns a C array. NSDictionary *myDictionary = ...; id objects[]; // Error: Array size missing in 'objects' id keys[]; // Error: Array size missing in 'keys' [myDictionary getObjects:&objects andKeys:&keys]; for (int i = 0; i < count; i++) { id obj = objects[i]; id key = keys[i]; } . NSDictionary *myDictionary = ...; NSInteger count = [myDictionary count]; id objects[count]; id keys[count]; [myDictionary getObjects:&objects andKeys:&keys]; // Warning: Passing argument 1 of 'getObjects:andKeys:' from incompatible pointer type. for (int i = 0; i < count; i++) { id obj = objects[i]; id key = keys[i]; } Please provide a working example of this method.

    Read the article

  • How to simulate a mouse click on a UIWebView in Cocoa for the iPhone?

    - by eagle
    I'm trying to setup automated unit tests for an iPhone application. I'm using a UIWebView and need to simulate clicks on different links. I've tried doing this with JavaScript, but it doesn't produce the same result as when I manually click on the links. The main problem is with links that have their target property set. I believe the only way for this automated unit test to work correctly is to simulate a mouse click at a specific x/y coordinate (i.e. where the link is located). Since the unit testing will only be used internally, private API calls are fine. It seems like this should be possible since the iPhone app isimulate seems to do something similar. Is there any way to do this in the framework?

    Read the article

  • Algorithm for converting hierarchical flat data (w/ ParentID) into sorted flat list w/ indentation l

    - by eagle
    I have the following structure: MyClass { guid ID guid ParentID string Name } I'd like to create an array which contains the elements in the order they should be displayed in a hierarchy (e.g. according to their "left" values), as well as a hash which maps the guid to the indentation level. For example: ID Name ParentID ------------------------ 1 Cats 2 2 Animal NULL 3 Tiger 1 4 Book NULL 5 Airplane NULL This would essentially produce the following objects: // Array is an array of all the elements sorted by the way you would see them in a fully expanded tree Array[0] = "Airplane" Array[1] = "Animal" Array[2] = "Cats" Array[3] = "Tiger" Array[4] = "Book" // IndentationLevel is a hash of GUIDs to IndentationLevels. IndentationLevel["1"] = 1 IndentationLevel["2"] = 0 IndentationLevel["3"] = 2 IndentationLevel["4"] = 0 IndentationLevel["5"] = 0 For clarity, this is what the hierarchy looks like: Airplane Animal Cats Tiger Book I'd like to iterate through the items the least amount of times possible. I also don't want to create a hierarchical data structure. I'd prefer to use arrays, hashes, stacks, or queues. The two objectives are: Store a hash of the ID to the indentation level. Sort the list that holds all the objects according to their left values. When I get the list of elements, they are in no particular order. Siblings should be ordered by their Name property. Update: This may seem like I haven't tried coming up with a solution myself and simply want others to do the work for me. However, I have tried coming up with three different solutions, and I've gotten stuck on each. One reason might be that I've tried to avoid recursion (maybe wrongly so). I'm not posting the partial solutions I have so far since they are incorrect and may badly influence the solutions of others.

    Read the article

  • How to use iPhone SDK Private APIs

    - by eagle
    I haven't found a comprehensive list of the steps that are required to use a private API from the iPhone Library. In particular, I would like to know how to get header files, if they are even required, how to get it to compile (when I simply add the header, it complains that the functions aren't defined), and what resources one can use to learn about private APIs (e.g. from other user's experiences, such as http://iphonedevwiki.net/ which has a few). I've read in other places that people recommend using class-dump to get the headers. Are there any alternative methods? I've noticed that there are some repositories of iPhone Private SDKs, what are the most up to date resources you would recommend? Most of the previous questions about documentation of private APIs, have all linked to Erica Sadun's website, which doesn't seem to have documentation anymore (all the links on the left are crossed out). Please save the comments about not using private API's... I know of the biggest risks: App will get rejected by Apple. App will break in future updates to the OS. I'm talking about legitimate uses, such as: Private application use (e.g. for unit testing, or messing around to see what's possible)

    Read the article

  • What's the proper way to setup different objects as delegates using Interface Builder?

    - by eagle
    Let's say I create a new project. I now add two text fields to the view controller in Interface Builder. I want to respond to delegate events that the text fields create, however, I don't want to have the main view controller to act as the delegate for both text fields. Ideally I want a separate file for each text field that acts as the delegate. Each of these objects also needs to be able to interact with the main view controller. My question is how I would set this up and link everything correctly? I tried creating a new class that inherits from NSObject and implements UITextFieldDelegate. I then added an instance variable called "viewController" of the same type of my view controller and marked it with IBOutlet (this required me to add #import "myViewcontroller.h"). I then went to Interface Builder and opened up my view controller which contains the two edit boxes. I added an NSObject to the form and changed it's type to be of the new class I created. I set its viewController property to the File's Owner, and set one of the textbox's delegate properties to point to this new object I created. Now when I run the program, it crashes when I touch the text box. It gives the error EXC_BAD_ACCESS. I'm guessing I didn't link stuff correctly in IB. Some things I'm not sure about which might be the problem: Does IB automatically know to create an instance of the class just by placing the NSObject in the ViewController? Can it properly assign the viewController property to an instance of itself even though it is creating itself at the same time?

    Read the article

  • Determining what frequencies correspond to the x axis in aurioTouch sample application

    - by eagle
    I'm looking at the aurioTouch sample application for the iPhone SDK. It has a basic spectrum analyzer implemented when you choose the "FFT" option. One of the things the app is lacking is X axis labels (i.e. the frequency labels). In the aurioTouchAppDelegate.mm file, in the function - (void)drawOscilloscope at line 652, it has the following code: if (displayMode == aurioTouchDisplayModeOscilloscopeFFT) { if (fftBufferManager->HasNewAudioData()) { if (fftBufferManager->ComputeFFT(l_fftData)) [self setFFTData:l_fftData length:fftBufferManager->GetNumberFrames() / 2]; else hasNewFFTData = NO; } if (hasNewFFTData) { int y, maxY; maxY = drawBufferLen; for (y=0; y<maxY; y++) { CGFloat yFract = (CGFloat)y / (CGFloat)(maxY - 1); CGFloat fftIdx = yFract * ((CGFloat)fftLength); double fftIdx_i, fftIdx_f; fftIdx_f = modf(fftIdx, &fftIdx_i); SInt8 fft_l, fft_r; CGFloat fft_l_fl, fft_r_fl; CGFloat interpVal; fft_l = (fftData[(int)fftIdx_i] & 0xFF000000) >> 24; fft_r = (fftData[(int)fftIdx_i + 1] & 0xFF000000) >> 24; fft_l_fl = (CGFloat)(fft_l + 80) / 64.; fft_r_fl = (CGFloat)(fft_r + 80) / 64.; interpVal = fft_l_fl * (1. - fftIdx_f) + fft_r_fl * fftIdx_f; interpVal = CLAMP(0., interpVal, 1.); drawBuffers[0][y] = (interpVal * 120); } cycleOscilloscopeLines(); } } From my understanding, this part of the code is what is used to decide which magnitude to draw for each frequency in the UI. My question is how can I determine what frequency each iteration (or y value) represents inside the for loop. For example, if I want to know what the magnitude is for 6kHz, I'm thinking of adding a line similar to the following: if (yValueRepresentskHz(y, 6)) NSLog(@"The magnitude for 6kHz is %f", (interpVal * 120)); Please note that although they chose to use the variable name y, from what I understand, it actually represents the x-axis in the visual graph of the spectrum analyzer, and the value of the drawBuffers[0][y] represents the y-axis.

    Read the article

  • Optimized OCR black/white pixel algorithm

    - by eagle
    I am writing a simple OCR solution for a finite set of characters. That is, I know the exact way all 26 letters in the alphabet will look like. I am using C# and am able to easily determine if a given pixel should be treated as black or white. I am generating a matrix of black/white pixels for every single character. So for example, the letter I (capital i), might look like the following: 01110 00100 00100 00100 01110 Note: all points, which I use later in this post, assume that the top left pixel is (0, 0), bottom right pixel is (4, 4). 1's represent black pixels, and 0's represent white pixels. I would create a corresponding matrix in C# like this: CreateLetter("I", new List<List<bool>>() { new List<bool>() { false, true, true, true, false }, new List<bool>() { false, false, true, false, false }, new List<bool>() { false, false, true, false, false }, new List<bool>() { false, false, true, false, false }, new List<bool>() { false, true, true, true, false } }); I know I could probably optimize this part by using a multi-dimensional array instead, but let's ignore that for now, this is for illustrative purposes. Every letter is exactly the same dimensions, 10px by 11px (10px by 11px is the actual dimensions of a character in my real program. I simplified this to 5px by 5px in this posting since it is much easier to "draw" the letters using 0's and 1's on a smaller image). Now when I give it a 10px by 11px part of an image to analyze with OCR, it would need to run on every single letter (26) on every single pixel (10 * 11 = 110) which would mean 2,860 (26 * 110) iterations (in the worst case) for every single character. I was thinking this could be optimized by defining the unique characteristics of every character. So, for example, let's assume that the set of characters only consists of 5 distinct letters: I, A, O, B, and L. These might look like the following: 01110 00100 00100 01100 01000 00100 01010 01010 01010 01000 00100 01110 01010 01100 01000 00100 01010 01010 01010 01000 01110 01010 00100 01100 01110 After analyzing the unique characteristics of every character, I can significantly reduce the number of tests that need to be performed to test for a character. For example, for the "I" character, I could define it's unique characteristics as having a black pixel in the coordinate (3, 0) since no other characters have that pixel as black. So instead of testing 110 pixels for a match on the "I" character, I reduced it to a 1 pixel test. This is what it might look like for all these characters: var LetterI = new OcrLetter() { Name = "I", BlackPixels = new List<Point>() { new Point (3, 0) } } var LetterA = new OcrLetter() { Name = "A", WhitePixels = new List<Point>() { new Point(2, 4) } } var LetterO = new OcrLetter() { Name = "O", BlackPixels = new List<Point>() { new Point(3, 2) }, WhitePixels = new List<Point>() { new Point(2, 2) } } var LetterB = new OcrLetter() { Name = "B", BlackPixels = new List<Point>() { new Point(3, 1) }, WhitePixels = new List<Point>() { new Point(3, 2) } } var LetterL = new OcrLetter() { Name = "L", BlackPixels = new List<Point>() { new Point(1, 1), new Point(3, 4) }, WhitePixels = new List<Point>() { new Point(2, 2) } } This is challenging to do manually for 5 characters and gets much harder the greater the amount of letters that are added. You also want to guarantee that you have the minimum set of unique characteristics of a letter since you want it to be optimized as much as possible. I want to create an algorithm that will identify the unique characteristics of all the letters and would generate similar code to that above. I would then use this optimized black/white matrix to identify characters. How do I take the 26 letters that have all their black/white pixels filled in (e.g. the CreateLetter code block) and convert them to an optimized set of unique characteristics that define a letter (e.g. the new OcrLetter() code block)? And how would I guarantee that it is the most efficient definition set of unique characteristics (e.g. instead of defining 6 points as the unique characteristics, there might be a way to do it with 1 or 2 points, as the letter "I" in my example was able to). An alternative solution I've come up with is using a hash table, which will reduce it from 2,860 iterations to 110 iterations, a 26 time reduction. This is how it might work: I would populate it with data similar to the following: Letters["01110 00100 00100 00100 01110"] = "I"; Letters["00100 01010 01110 01010 01010"] = "A"; Letters["00100 01010 01010 01010 00100"] = "O"; Letters["01100 01010 01100 01010 01100"] = "B"; Now when I reach a location in the image to process, I convert it to a string such as: "01110 00100 00100 00100 01110" and simply find it in the hash table. This solution seems very simple, however, this still requires 110 iterations to generate this string for each letter. In big O notation, the algorithm is the same since O(110N) = O(2860N) = O(N) for N letters to process on the page. However, it is still improved by a constant factor of 26, a significant improvement (e.g. instead of it taking 26 minutes, it would take 1 minute). Update: Most of the solutions provided so far have not addressed the issue of identifying the unique characteristics of a character and rather provide alternative solutions. I am still looking for this solution which, as far as I can tell, is the only way to achieve the fastest OCR processing. I just came up with a partial solution: For each pixel, in the grid, store the letters that have it as a black pixel. Using these letters: I A O B L 01110 00100 00100 01100 01000 00100 01010 01010 01010 01000 00100 01110 01010 01100 01000 00100 01010 01010 01010 01000 01110 01010 00100 01100 01110 You would have something like this: CreatePixel(new Point(0, 0), new List<Char>() { }); CreatePixel(new Point(1, 0), new List<Char>() { 'I', 'B', 'L' }); CreatePixel(new Point(2, 0), new List<Char>() { 'I', 'A', 'O', 'B' }); CreatePixel(new Point(3, 0), new List<Char>() { 'I' }); CreatePixel(new Point(4, 0), new List<Char>() { }); CreatePixel(new Point(0, 1), new List<Char>() { }); CreatePixel(new Point(1, 1), new List<Char>() { 'A', 'B', 'L' }); CreatePixel(new Point(2, 1), new List<Char>() { 'I' }); CreatePixel(new Point(3, 1), new List<Char>() { 'A', 'O', 'B' }); // ... CreatePixel(new Point(2, 2), new List<Char>() { 'I', 'A', 'B' }); CreatePixel(new Point(3, 2), new List<Char>() { 'A', 'O' }); // ... CreatePixel(new Point(2, 4), new List<Char>() { 'I', 'O', 'B', 'L' }); CreatePixel(new Point(3, 4), new List<Char>() { 'I', 'A', 'L' }); CreatePixel(new Point(4, 4), new List<Char>() { }); Now for every letter, in order to find the unique characteristics, you need to look at which buckets it belongs to, as well as the amount of other characters in the bucket. So let's take the example of "I". We go to all the buckets it belongs to (1,0; 2,0; 3,0; ...; 3,4) and see that the one with the least amount of other characters is (3,0). In fact, it only has 1 character, meaning it must be an "I" in this case, and we found our unique characteristic. You can also do the same for pixels that would be white. Notice that bucket (2,0) contains all the letters except for "L", this means that it could be used as a white pixel test. Similarly, (2,4) doesn't contain an 'A'. Buckets that either contain all the letters or none of the letters can be discarded immediately, since these pixels can't help define a unique characteristic (e.g. 1,1; 4,0; 0,1; 4,4). It gets trickier when you don't have a 1 pixel test for a letter, for example in the case of 'O' and 'B'. Let's walk through the test for 'O'... It's contained in the following buckets: // Bucket Count Letters // 2,0 4 I, A, O, B // 3,1 3 A, O, B // 3,2 2 A, O // 2,4 4 I, O, B, L Additionally, we also have a few white pixel tests that can help: (I only listed those that are missing at most 2). The Missing Count was calculated as (5 - Bucket.Count). // Bucket Missing Count Missing Letters // 1,0 2 A, O // 1,1 2 I, O // 2,2 2 O, L // 3,4 2 O, B So now we can take the shortest black pixel bucket (3,2) and see that when we test for (3,2) we know it is either an 'A' or an 'O'. So we need an easy way to tell the difference between an 'A' and an 'O'. We could either look for a black pixel bucket that contains 'O' but not 'A' (e.g. 2,4) or a white pixel bucket that contains an 'O' but not an 'A' (e.g. 1,1). Either of these could be used in combination with the (3,2) pixel to uniquely identify the letter 'O' with only 2 tests. This seems like a simple algorithm when there are 5 characters, but how would I do this when there are 26 letters and a lot more pixels overlapping? For example, let's say that after the (3,2) pixel test, it found 10 different characters that contain the pixel (and this was the least from all the buckets). Now I need to find differences from 9 other characters instead of only 1 other character. How would I achieve my goal of getting the least amount of checks as possible, and ensure that I am not running extraneous tests?

    Read the article

  • Naming convention for non-virtual and abstract methods

    - by eagle
    I frequently find myself creating classes which use this form (A): abstract class Animal { public void Walk() { // TODO: do something before walking // custom logic implemented by each subclass WalkInternal(); // TODO: do something after walking } protected abstract void WalkInternal(); } class Dog : Animal { protected override void WalkInternal() { // TODO: walk with 4 legs } } class Bird : Animal { protected override void WalkInternal() { // TODO: walk with 2 legs } } Rather than this form (B): abstract class Animal { public abstract void Walk(); } class Dog : Animal { public override void Walk() { // TODO: do something before walking // custom logic implemented by each subclass // TODO: walk with 4 legs // TODO: do something after walking } } class Bird : Animal { public override void Walk() { // TODO: do something before walking // custom logic implemented by each subclass // TODO: walk with 2 legs // TODO: do something after walking } } As you can see, the nice thing about form A is that every time you implement a subclass, you don't need to remember to include the initialization and finalization logic. This is much less error prone than form B. What's a standard convention for naming these methods? I like naming the public method Walk since then I can call Dog.Walk() which looks better than something like Dog.WalkExternal(). However, I don't like my solution of adding the suffix "Internal" for the protected method. I'm looking for a more standardized name. Btw, is there a name for this design pattern?

    Read the article

  • Hiding a navigation bar via scrolling (safari style)

    - by eagle
    After a page is loaded in Safari on the iPhone, when you begin scrolling down, the navigation bar is also scrolled out of view. When you scroll back up, the navigation scrolls back into view. I'm looking to implement this same behavior using a UIWebView underneath the UINavigationBar, but I'm guessing it should be possible with any UIScrollView descendant. How can this behavior be implemented?

    Read the article

  • C++: compute a number's complement and its number of possible mismatches

    - by Eagle
    I got a bit stuck with my algorithm and I need some help to solve my problem. I think an example would explain better my problem. Assuming: d = 4 (maximum number of allowed bits in a number, 2^4-1=15). m_max = 1 (maximum number of allowed bits mismatches). kappa = (maximum number of elements to find for a given d and m, where m in m_max) The main idea is for a given number, x, to compute its complement number (in binary base) and all the possible combinations for up to m_max mismatches from x complement's number. Now the program start to scan from i = 0 till 15. for i = 0 and m = 0, kappa = \binom{d}{0} = 1 (this called a perfect match) possible combinations in bits, is only 1111 (for 0: 0000). for i = 0 and m = 1, kappa = \binom{d}{1} = 4 (one mismatch) possible combinations in bits are: 1000, 0100, 0010 and 0001 My problem was to generalize it to general d and m. I wrote the following code: #include <stdlib.h> #include <iomanip> #include <boost/math/special_functions/binomial.hpp> #include <iostream> #include <stdint.h> #include <vector> namespace vec { typedef std::vector<unsigned int> uint_1d_vec_t; } int main( int argc, char* argv[] ) { int counter, d, m; unsigned num_combination, bits_mask, bit_mask, max_num_mismatch; uint_1d_vec_t kappa; d = 4; m = 2; bits_mask = 2^num_bits - 1; for ( unsigned i = 0 ; i < num_elemets ; i++ ) { counter = 0; for ( unsigned m = 0 ; m < max_num_mismatch ; m++ ) { // maximum number of allowed combinations num_combination = boost::math::binomial_coefficient<double>( static_cast<unsigned>( d ), static_cast<unsigned>(m) ); kappa.push_back( num_combination ); for ( unsigned j = 0 ; j < kappa.at(m) ; j++ ) { if ( m == 0 ) v[i][counter++] = i^bits_mask; // M_0 else { bit_mask = 1 << ( num_bits - j ); v[i][counter++] = v[i][0] ^ bits_mask } } } } return 0; } I got stuck in the line v[i][counter++] = v[i][0] ^ bits_mask since I was unable to generalize my algorithm to m_max1, since I needed for m_max mismatches m_max loops and in my original problem, m is unknown until runtime.

    Read the article

  • Determining the magnitude of a certain frequency on the iPhone

    - by eagle
    I'm wondering what's the easiest/best way to determine the magnitude of a given frequency in a sound. It's my understanding that a FFT function will return the magnitudes of all frequencies in a signal. I'm wondering if there is any shortcut I could use if I'm only concerned about a specific frequency. I'll be using the iPhone mic to record the audio. My guess is that I'll be using the Audio Queue Services for recording since I don't need to record the audio to a file. I'm using SDK 4.0, so I can use any of the functions defined in the Accelerate framework (e.g. FFT functions) if needed. Update: I updated the question to be more clear as per Conrad's suggestion.

    Read the article

  • How to simulate a mouse click in Cocoa for the iPhone?

    - by eagle
    I'm trying to setup automated unit tests for an iPhone application. I'm using a UIWebBrowser and need to simulate clicks on different links. I've tried doing this with JavaScript, but it doesn't produce the same results as when the I manually click on the links. The main problem is with links that have their target property set. I believe the only way for this automated unit test to work correctly is to simulate a mouse click at a specific x/y coordinate (i.e. where the link is located). Since the unit testing will only be used internally, private API calls are fine. It seems like this should be possible since the iPhone app isimulate seems to do something similar. Is there any way to do this in the framework?

    Read the article

  • C++ - dynamic pointer of array

    - by Eagle
    Hi to all, first i would like to say i am Newbie in C++. As part of my master thesis i am writing a program in C++ which also get as parameters the variables m and d (both integers). Were d is the power of 2 (this means 2^d elements). Parameter m define the number of possible interactions between one element and the total group (2^d elements). The number of possible interactions is computed as following: \kappa = \sum_{i=0}^m\binom{d}{i} (at present i generate vector of vectors for 2^d x \kappa, but my Prof. would like me to create different statistics to different m's. My first though was to to generate a dynamic array of m arrays of different sizes... Then i though of defining a 3-dim array with the biggest needed 2d array, but also program speed is important (e.g d = 20). i would like to ask for your advice how to define such kind of dynamic array that will also be fast. Regards

    Read the article

  • How do I use data from the main window in a sub-window?

    - by eagle
    I've just started working on a photo viewer type desktop AIR app with Flex. From the main window I can launch sub-windows, but in these sub-windows I can't seem to access the data I collected in the main window. How can I access this data? Or, how can I send this data to the sub-window on creation? It doesn't need to be dynamically linked. myMain.mxml <?xml version="1.0" encoding="utf-8"?> <s:WindowedApplication xmlns:fx="http://ns.adobe.com/mxml/2009" xmlns:s="library://ns.adobe.com/flex/spark" xmlns:mx="library://ns.adobe.com/flex/mx" width="260" height="200" title="myMain"> <fx:Declarations> </fx:Declarations> <fx:Script> <![CDATA[ public function openWin():void { new myWindow().open(); } public var myData:Array = new Array('The Eiffel Tower','Paris','John Doe'); ]]> </fx:Script> <s:Button x="10" y="10" width="240" label="open a sub-window" click="openWin();"/> </s:WindowedApplication> myWindow.mxml <?xml version="1.0" encoding="utf-8"?> <mx:Window name="myWindow" title="myWindow" xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" width="640" height="360"> <mx:Script> <![CDATA[ ]]> </mx:Script> <mx:Label id="comment" x="10" y="10" text=""/> <mx:Label id="location" x="10" y="30" text=""/> <mx:Label id="author" x="10" y="50" text=""/> </mx:Window> I realize this might be a very easy question but I have searched the web, read and watched tutorials on random AIR subjects for a few days and couldn't find it. The risk of looking like a fool is worth it now, I want to get on with my first app!

    Read the article

  • Maven compile plugin

    - by phanikiran
    Hi every body, in pom of a project, i have added dependency with scope compile . which is a jar file which contains some class file and jar's as well. my current java file needs internal jars of dependent jar to compile. But maven compile goal returning compilation error . :banghead: All the jar's needed to compile are in the single jar file which is added in dependency............................. Please help me! my pom: <dependency> <groupId>eagle</groupId> <artifactId>zkui</artifactId> <version>360LTS</version> <type>jar</type> <scope>compile</scope> </dependency> <build> <sourceDirectory>./src/main/java/</sourceDirectory> <outputDirectory>./target/classes/</outputDirectory> <finalName>${project.groupId}-${project.artifactId}</finalName> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> <version>2.2</version> <configuration> <source>1.6</source> <target>1.6</target> </plugin> </plugins> </build> </project> error: package org.zkoss.zk.ui does not exist this package org.zkoss.zk.ui is in jar file zkex.jar which is in dependency jar eagle:zkui:360LTS jar file Please Help ME!!!! :jumpingjoy: Advance Thanks

    Read the article

  • Get data on jquery ajax success

    - by jbatson
    anyone know how i would get from opening <table> to </table> in this data that is returned from ajax with jquery. // BEGIN Subsys_JsHttpRequest_Js Subsys_JsHttpRequest_Js.dataReady( '3599', // this ID is passed from JavaScript frontend '<table border=\"0\" width=\"100%\" cellspacing=\"0\" cellpadding=\"0\">\n <tr>\n <td>\n <script type=\"text/javascript\" language=\"javascript\" src=\"includes/ajax_sc.js\"></script>\n <div id=\"divShoppingCard\">\n\n <div class=\"infoBoxHeading\"><a href=\"shopping_cart.php\">Shopping Cart</a></div>\n\n <div>\n <div class=\"boxText\">\n<script language=\"javascript\" type=\"text/javascript\">\nfunction couponpopupWindow(url) {\n window.open(url,\"popupWindow\",\"toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,copyhistory=no,width=450,height=280,screenX=150,screenY=150,top=150,left=150\")\n}\n//--></script><table width=\"100%\" cellspacing=\"0\" cellpadding=\"0\"><tr><td align=\"left\" valign=\"top\" class=\"infoBoxContents\"><span class=\"infoBoxContents\">1&nbsp;x&nbsp;</span></td><td valign=\"top\" class=\"infoBoxContents\"><a href=\"http://beta.vikingwholesale.com/catalog/eagle-vanguard-limited-edition-p-3769.html\"><span class=\"infoBoxContents\">192 Eagle Vanguard Limited Edition</span></a></td></tr><tr><td align=\"left\" valign=\"top\" class=\"infoBoxContents\"><span class=\"newItemInCart\">4&nbsp;x&nbsp;</span></td><td valign=\"top\" class=\"infoBoxContents\"><a href=\"http://beta.vikingwholesale.com/catalog/family-traditions-adrenaline-avid-black-p-3599.html\"><span class=\"newItemInCart\">085 Family Traditions Adrenaline - Avid, Black</span></a></td></tr><tr><td align=\"left\" valign=\"top\" class=\"infoBoxContents\"><span class=\"infoBoxContents\">1&nbsp;x&nbsp;</span></td><td valign=\"top\" class=\"infoBoxContents\"><a href=\"http://beta.vikingwholesale.com/catalog/painted-pony-paradigm-p-4022.html\"><span class=\"infoBoxContents\">336 Painted Pony Paradigm</span></a></td></tr></table></div>\n\n\n <div class=\"boxText\"><img src=\"images/pixel_black.gif\" width=\"100%\" height=\"1\" alt=\"\"/></div>\n\n\n <div class=\"boxText\">$940.00</div>\n\n\n</div>\n\n\n \n </div><!--end of divShoppingCard-->\n </td>\n </tr></table>', null ) // END Subsys_JsHttpRequest_Js

    Read the article

1 2  | Next Page >