Search Results

Search found 666 results on 27 pages for 'berlin brown'.

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

  • Using Mergesort to calculate number of inversions in C++

    - by Brown
    void MergeSort(int A[], int n, int B[], int C[]) { if(n > 1) { Copy(A,0,floor(n/2),B,0,floor(n/2)); Copy(A,floor(n/2),n-1,C,0,floor(n/2)-1); MergeSort(B,floor(n/2),B,C); MergeSort(C,floor(n/2),B,C); Merge(A,B,0,floor(n/2),C,0,floor(n/2)-1); } }; void Copy(int A[], int startIndexA, int endIndexA, int B[], int startIndexB, int endIndexB) { while(startIndexA < endIndexA && startIndexB < endIndexB) { B[startIndexB]=A[startIndexA]; startIndexA++; startIndexB++; } }; void Merge(int A[], int B[],int leftp, int rightp, int C[], int leftq, int rightq) //Here each sub array (B and C) have both left and right indices variables (B is an array with p elements and C is an element with q elements) { int i=0; int j=0; int k=0; while(i < rightp && j < rightq) { if(B[i] <=C[j]) { A[k]=B[i]; i++; } else { A[k]=C[j]; j++; inversions+=(rightp-leftp); //when placing an element from the right array, the number of inversions is the number of elements still in the left sub array. } k++; } if(i=rightp) Copy(A,k,rightp+rightq,C,j,rightq); else Copy(A,k,rightp+rightq,B,i,rightp); } I am specifically confused on the effect of the second 'B' and 'C' arguments in the MergeSort calls. I need them in there so I have access to them for Copy and and Merge, but

    Read the article

  • Combining a web application with another (larger).

    - by Kevin Brown
    I'm writing a web app, initially meant to be stand-alone--it's essentially a survey with user-management/authentication built on Codeigniter. The company I'm doing this for wants to merge it with their main system so that it acts like a feature, or a sub-app of their website. What is the best thing for me to do? I think I could do one of two things: Finish my application, as I had planned to initially, and let them handle the merging.It would probably save me a headache. Stop where I am in development, and migrate my authentication system to theirs, migrate the payment system to use theirs, and then finish the app. In your opinion, or experience, what is the best thing to do?

    Read the article

  • Hyperlink in Silverlight AccordionItem HeaderTemplate

    - by Charlie Brown
    I have created a HeaderTemplate for my accordions where I want to display a text block on one side of the header and a hyperlink on the right side. The display is working correctly, but the click event is not called when the user clicks, I'm guessing b/c the header itself is trapping the click for expand/contract. <layoutToolkit:Accordion> <layoutToolkit:AccordionItem IsSelected="True"> <layoutToolkit:AccordionItem.HeaderTemplate> <DataTemplate> <StackPanel Orientation="Horizontal" Height="20"> <TextBlock Margin="0,0,700,0">Cancel Postcards</TextBlock> <HyperlinkButton Content="Next Call" Foreground="Blue" Click="NextCancel_Click" /> </StackPanel> </DataTemplate> </layoutToolkit:AccordionItem.HeaderTemplate> ..... more code .... Is there a way to get the hyperlink to respond to events without practically creating a new control?

    Read the article

  • Find all the child node of specific value in C#

    - by sara brown
    <main> <myself> <pid>1</pid> <name>abc</name> </myself> <myself> <pid>2</pid> <name>efg</name> </myself> </main> that is my XML file named simpan. I have two button. next and previous. What i want to do is, all the info will shows off on the TextBox when the user click the button. The searching node will be based on the pid. Next button will adding 1 value of pid (let's say pid=2) and it will search on the node that have the same value of pid=2. it also will show the name for the pid=2. (showing name=abc) Same goes to the previous button where it will reduce 1value of pid (pid=1). Does anybody knows how to do this? //-------------EDIT------------------ thanks to L.B, im trying to use his code. however i got an error. is my implementation of code correct? private void previousList_Click(object sender, EventArgs e) { pid = 14; XDocument xDoc = XDocument.Parse("C:\\Users\\HDAdmin\\Documents\\Fatty\\SliceEngine\\SliceEngine\\bin\\Debug\\simpan.xml"); var name = xDoc.Descendants("myself") .First(m => (int)m.Element("PatientID") == pid) .Value; textETA.Text = name; //////////////////// }

    Read the article

  • How do I create a custom network connection entry?

    - by David Brown
    I have a Sprint MiFi 3G router that exposes its current signal strength over HTTP. I've developed a very simple tray application that displays this. However, what I would really like to do is create a custom network connection entry so the router's 3G signal strength (along with the current network version) displays when clicking on the network connections tray icon (in Windows 7, at least). Is it possible to do this with a shell extension or something (preferably in C#)? If so, how?

    Read the article

  • Is there a "Language-Aware" diff?

    - by JS
    (Appologies for the poor title. I'm open to suggestions for a better one. "Language-gnostic", perhaps?) Does there exist a diff utility (preferably *nix-based) that will diff files based on how a (selectable) language compiler would view the code? For example, to a Python compiler, these two 'graphs are identical: # The quick brown fox jumped vs: # The quick brown # fox jumped Telling most diffs (at least the one's I'm familiar with) to ignore spaces and linebreaks still causes them to flag a difference due to the extra '#'. "Language-sensitivity" would sure help to cut down on the "noise". Ideally, it would work in xemacs....(<-- probably pushing my luck? :-)

    Read the article

  • intersection of three sets in python?

    - by Phil Brown
    Currently I am stuck trying to find the intersection of three sets. Now these sets are really lists that I am converting into sets, and then trying to find the intersection of. Here's what I have so far: for list1 in masterlist: list1=thingList1 for list2 in masterlist: list2=thingList2 for list3 in masterlist: list3=thingList3 d3=[set(thingList1), set(thingList2), set(thingList3)] setmatches c= set.intersection(*map(set,d3)) print setmatches and I'm getting set([]) Script terminated. I know there's a much simpler and better way to do this, but I can't find one...

    Read the article

  • Codeigniter: Library function--I'm stuck

    - by Kevin Brown
    I have a library function that sets up my forms, and submits data. They're long, and they work, so I'll spare you reading my code. :) I simply need a way for my functions to determine how to handle the data. Until now, the function did one thing: Submit a report for the current user. NOW, the client has requested that an administrator also be able to complete a form--this means that the form would be filled out, and it would CREATE a user at the same time, whereas the current function EDITS and is accessed by an EXISTING user. Do I need a separate function to do essentially the same thing? How do I make one function perform two tasks? One to update a user, and if there is no user, create one. Current controller: function survey() { $id = $this->session->userdata('id'); $data['member'] = $this->home_model->getUser($id); //Convert the db Object to a row array $data['manager'] = $data['member']->row(); $manager_id = $data['manager']->manager_id; $data['manager'] = $this->home_model->getUser($manager_id); $data['manager'] = $data['manager']->row(); $data['header'] = "Home"; $this->survey_form_processing->survey_form($this->_container,$data, $method); } Current Library: function survey_form($container) { //Lots of validation stuff $this->CI->validation->set_rules($rules); if ( $this->CI->validation->run() === FALSE ) { // Output any errors $this->CI->validation->output_errors(); } else { // Submit form $this->_submit(); } $this->CI->load->view($container,$data); The submit function is huge too. Basically says, "Update table with data where user_id=current user" I hope this wasn't too confusing. I'll create two functions if need be, but I'd like to keep redundancy down! }

    Read the article

  • Is it possible to use multiple languages in .NET resource files?

    - by Gabe Brown
    We’ve got an interesting requirement that we’ll want to support multiple languages at runtime since we’re a service. If a user talks to us using Japanese or English, we’ll want to respond in the appropriate language. FxCop likes us to store our strings in resource files, but I was curious to know if there was an integrated way to select resource string at runtime without having to do it manually. Bottom Line: We need to be able to support multiple languages in a single binary. :)

    Read the article

  • ERROR: unable to load AX Bundle: MapKitFramework.axbundle. Help?

    - by Josh Brown
    I'm using MapKit in an iPad app with the Base SDK set to iOS 4.2 in Xcode 3.2.5. When I run the app in the iPad Simulator 4.2, the app works fine. When I run it in the iPad Simulator 3.2, it crashes on startup with the following error: ERROR: unable to load AX Bundle: /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator3.2.sdk/System/Library/AccessibilityBundles/MapKitFramework.axbundle What am I doing wrong?

    Read the article

  • Reading an XML file and store data to mysql database.

    - by Jack Brown
    Hi I need the following php script to do a currency conversion using a different XML file. Its a script from white-hat design http://www.white-hat-web-design.co.uk/articles/php-currency-conversion.php The script needs to be amended to do the following: 1, The php script downloads every 24 hours an xml file from rss.timegenie.com/foreign_exchange_rates_forex rss.timegenie.com/forex.xml rss.timegenie.com/forex2.xml 2, It then stores the xml file data/contents to a mysql database file ie currency and rate. Any advice would be appreciated.

    Read the article

  • Bootstrap Modal & rails remote

    - by Kevin Brown
    Using this bootstrap modal extension and animate.css for fun, how can I take a make an easy ajax modal using :remote => true to fill in the modal box? Also, how would I use the bootstrap modal default "submit/cancel" buttons to interact with a form that's loaded? I'm looking for a more dynamic solution instead of hard-html-ing every modal into the page or using a bunch of jquery ajax calls for each dialog. I've done a few quick searches, but they've turned up nil for this particular solution.

    Read the article

  • Simple jquery console log

    - by Kevin Brown
    I'm trying to log the change of a value in the console (Firefox/Firefly, mac). if(count < 1000) { count = count+1; console.log(count); setTimeout("startProgress", 1000); } This is only returning the value 1. It stops after that. Am I doing something wrong or is there something else affecting this?

    Read the article

  • Custom Server to communicate with my software?

    - by Zachary Brown
    I am working on a major project that I need for work. I am working on a project that requires software validation. I would like this to be handled by a custom server I will write in Python, this server will be the "gateway" between the user and product activation. The software program will be purchased from other companies in volume licensing. So this is what I need the server to do: 1). The user clicks to activate their software. (easy, all is good so far) 2). The software gets the distributor's id from another online server. ( this is also easy, and already coded.) 3). Then, the software asks my custom server if the distributor is allowed to activate anymore copies of the software. 4). The server will then check ( an online encoded text file ) to see if the distributor can or can't. If they can, it will tell the software that registration can proceede, at which point the software will pass the software serial number to the server. I have done my best to explain what I am trying to accomplish, but if something is not quite sensible, please let me know. Thanks to all members of Stackoverflow.com for the help in the past, and those who will help me now. I am using Python 2.6 Win. XP Home Edition

    Read the article

  • Fluent / NHibernate Collections of the same class

    - by Charlie Brown
    I am new to NHibernate and I am having trouble mapping the following relationships within this class. public class Category : IAuditable { public virtual int Id { get; set; } public virtual string Name{ get; set; } public virtual Category ParentCategory { get; set; } public virtual IList<Category> SubCategories { get; set; } public Category() { this.Name = string.Empty; this.SubCategories = new List<Category>(); } } Class Maps (although, these are practically guesses) public class CategoryMap : ClassMap<Category> { public CategoryMap() { Id(x => x.Id); Map(x => x.Name); References(x => x.ParentCategory) .Nullable() .Not.LazyLoad(); HasMany(x => x.SubCategories) .Cascade.All(); } } Each Category may have a parent category, some Categories have many subCategories, etc, etc I can get the Category to Save correctly (correct subcategories and parent category fk exist in the database) but when loading, it returns itself as the parent category. I am using Fluent for the class mapping, but if someone could point me in the right direction for just plain NHibernate that would work as well.

    Read the article

  • Codeigniter: simple form function

    - by Kevin Brown
    I'm stuck writing a simple form...I feel dumb. Here's my controller: function welcome_message(){ //Update welcome message $id = $this->session->userdata('id'); $profile['welcome_message'] = $this->input->post('welcome_message'); $this->db->update('be_user_profiles',$profile, array('user_id' => $id)); } And the html: <?php print form_open('home/welcome_message')?> <input type="checkbox" value="0" checked="false">Don't show me this again</input> <p> <input class="button submit" type="submit" class="close-box" value="Close" /> </p> <?php print form_close()?> Edit I simply need it to submit to a private function and return to the home page (page submitted from).

    Read the article

  • Avoiding explicit recursion in Haskell

    - by Travis Brown
    The following simple function applies a given monadic function iteratively until it hits a Nothing, at which point it returns the last non-Nothing value. It does what I need, and I understand how it works. lastJustM :: (Monad m) => (a -> m (Maybe a)) -> a -> m a lastJustM g x = g x >>= maybe (return x) (lastJustM g) As part of my self-education in Haskell I'm trying to avoid explicit recursion (or at least understand how to) whenever I can. It seems like there should be a simple non-explicitly recursive solution in this case, but I'm having trouble figuring it out. I don't want something like a monadic version of takeWhile, since it could be expensive to collect all the pre-Nothing values, and I don't care about them anyway. I checked Hoogle for the signature and nothing shows up. The m (Maybe a) bit makes me think a monad transformer might be useful here, but I don't really have the intuitions I'd need to come up with the details (yet). It's probably either embarrassingly easy to do this or embarrassingly easy to see why it can't or shouldn't be done, but this wouldn't be the first time I've used self-embarrassment as a pedagogical strategy. Background: Here's a simplified working example for context: suppose we're interested in random walks in the unit square, but we only care about points of exit. We have the following step function: randomStep :: (Floating a, Ord a, Random a) => a -> (a, a) -> State StdGen (Maybe (a, a)) randomStep s (x, y) = do (a, gen') <- randomR (0, 2 * pi) <$> get put gen' let (x', y') = (x + s * cos a, y + s * sin a) if x' < 0 || x' > 1 || y' < 0 || y' > 1 then return Nothing else return $ Just (x', y') Something like evalState (lastJustM (randomStep 0.01) (0.5, 0.5)) <$> newStdGen will give us a new data point.

    Read the article

  • Get screenshot on Windows with Python?

    - by Zachary Brown
    Hello, I am creating a Beta Testers reporting module so they can send in thier comments on my software, but I would like to have the option to include a screenshot with the report. How do I take a screenshot of the screen with Python on Windows? I have found several examples on Linux, but haven't had much luck on Windows.

    Read the article

  • How does Sentry aggregate errors?

    - by Hugo Rodger-Brown
    I am using Sentry (in a django project), and I'd like to know how I can get the errors to aggregate properly. I am logging certain user actions as errors, so there is no underlying system exception, and am using the culprit attribute to set a friendly error name. The message is templated, and contains a common message ("User 'x' was unable to perform action because 'y'"), but is never exactly the same (different users, different conditions). Sentry clearly uses some set of attributes under the hood to determine whether to aggregate errors as the same exception, but despite having looked through the code, I can't work out how. Can anyone short-cut my having to dig further into the code and tell me what properties I need to set in order to manage aggregation as I would like? [UPDATE 1: event grouping] This line appears in sentry.models.Group: class Group(MessageBase): """ Aggregated message which summarizes a set of Events. """ ... class Meta: unique_together = (('project', 'logger', 'culprit', 'checksum'),) ... Which makes sense - project, logger and culprit I am setting at the moment - the problem is checksum. I will investigate further, however 'checksum' suggests that binary equivalence, which is never going to work - it must be possible to group instances of the same exception, with differenct attributes? [UPDATE 2: event checksums] The event checksum comes from the sentry.manager.get_checksum_from_event method: def get_checksum_from_event(event): for interface in event.interfaces.itervalues(): result = interface.get_hash() if result: hash = hashlib.md5() for r in result: hash.update(to_string(r)) return hash.hexdigest() return hashlib.md5(to_string(event.message)).hexdigest() Next stop - where do the event interfaces come from? [UPDATE 3: event interfaces] I have worked out that interfaces refer to the standard mechanism for describing data passed into sentry events, and that I am using the standard sentry.interfaces.Message and sentry.interfaces.User interfaces. Both of these will contain different data depending on the exception instance - and so a checksum will never match. Is there any way that I can exclude these from the checksum calculation? (Or at least the User interface value, as that has to be different - the Message interface value I could standardise.) [UPDATE 4: solution] Here are the two get_hash functions for the Message and User interfaces respectively: # sentry.interfaces.Message def get_hash(self): return [self.message] # sentry.interfaces.User def get_hash(self): return [] Looking at these two, only the Message.get_hash interface will return a value that is picked up by the get_checksum_for_event method, and so this is the one that will be returned (hashed etc.) The net effect of this is that the the checksum is evaluated on the message alone - which in theory means that I can standardise the message and keep the user definition unique. I've answered my own question here, but hopefully my investigation is of use to others having the same problem. (As an aside, I've also submitted a pull request against the Sentry documentation as part of this ;-)) (Note to anyone using / extending Sentry with custom interfaces - if you want to avoid your interface being use to group exceptions, return an empty list.)

    Read the article

  • Using items in a list as arguments

    - by Travis Brown
    Suppose I have a function with the following type signature: g :: a -> a -> a -> b I also have a list of as—let's call it xs—that I know will contain at least three items. I'd like to apply g to the first three items of xs. I know I could define a combinator like the following: ($$$) :: (a -> a -> a -> b) -> [a] -> b f $$$ (x:y:z:_) = f x y z Then I could just use g $$$ xs. This makes $$$ a bit like uncurry, but for a function with three arguments of the same type and a list instead of a tuple. Is there a way to do this idiomatically using standard combinators? Or rather, what's the most idiomatic way to do this in Haskell? I thought trying pointfree on a non-infix version of $$$ might give me some idea of where to start, but the output was an abomination with 10 flips, a handful of heads and tails and aps, and 28 parentheses. (NB: I know this isn't a terribly Haskelly thing to do in the first place, but I've come across a couple of situations where it seems like a reasonable solution, especially when using Parsec. I'll certainly accept "don't ever do this in real code" if that's the best answer, but I'd prefer to see some clever trick involving the ((->) r) monad or whatever.)

    Read the article

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