Daily Archives

Articles indexed Thursday June 3 2010

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

  • Convert rank-per-candidate format to OpenSTV BLT format

    - by kibibu
    I recently gathered, using a questionnaire, a set of opinions on the importance of various software components. Figuring that some form of Condorcet voting method would be the best way to obtain an overall rank, I opted to use OpenSTV to analyze it. My data is in tabular format, space delimited, and looks more or less like: A B C D E F G # Candidates 5 2 4 3 7 6 1 # First ballot. G is ranked first, and E is ranked 7th 4 2 6 5 1 7 3 # Second ballot etc In this format, the number indicates the rank and the sequence order indicates the candidate. Each "candidate" has a rank (required) from 1 to 7, where a 1 means most important and a 7 means least important. No duplicates are allowed. This format struck me as the most natural way to represent the output, being a direct representation of the ballot format. The OpenSTV/BLT format uses a different method of representing the same info, conceptually as follows: G B D C A F E # Again, G is ranked first and E is ranked 7th E B G A D C F # etc The actual numeric file format uses the (1-based) index of the candidate, rather than the label, and so is more like: 7 2 4 3 1 6 5 # Same ballots as before. 5 2 7 1 4 3 6 # A -> 1, G -> 7 In this format, the number indicates the candidate, and the sequence order indicates the rank. The actual, real, BLT format also includes a leading weight and a following zero to indicate the end of each ballot, which I don't care too much about for this. My question is, what is the most elegant way to convert from the first format to the (numeric) second?

    Read the article

  • Are the *A Win32 API calls still relevant?

    - by Thanatos
    I still see advice about using the LPTSTR/TCHAR types, etc., instead of LPWSTR/WCHAR. I believe the Unicode stuff was well introduced at Win2k, and I frankly don't write code for Windows 98 anymore. (Excepting special cases, of course.) Given that I don't care about Windows 98 (or, even less, ME) as they're decade old OS, is there any reason to use the compatibility TCHAR, etc. types? Why still advise people to use TCHAR - what benefit does it add over using WCHAR directly?

    Read the article

  • Tkinter Packing Strangeness: Buttons packed above others

    - by Parand
    I'm sure I'm doing something obvious wrong here, but I can't see it. I end up with the "Should be on top" label packed at the bottom instead of at the top. What am I doing wrong? from Tkinter import * class SelectAction(Frame): buttons = {} def callback(self): print "Callback" def createWidgets(self): logo_label = Label(text="Should be on top").pack(fill=X) for name, text, callback in ( ('setup_account', 'Account Settings', self.callback), ('do_action', 'Do Something', self.callback), ): self.buttons[name] = Button(self, text=text, command=callback).pack(fill=X) def __init__(self, master=None): Frame.__init__(self, master) self.pack() self.createWidgets() if __name__ == "__main__": root = Tk() app = SelectAction(master=root) app.mainloop() root.destroy()

    Read the article

  • Custom buttons in MS-Access 2k7

    - by terence6
    I'm adding some custom buttons to my forms in MS Access, but somehow I can't make them work. In buttons properties Event tab I've changed 'On Click' event to call 'Event procedure'. Then in VBasic I'm selecting my button and from what I know this code should give me prompt, and if Yos is selected the form should close. But when I click my buttons simply nothing happens. Am I doing something wrong ? Option Compare Database Option Explicit Private Sub cmdQuitApp_Click() If MsgBox("Are you sure you want to close the form?", vbYesNo + vbQuestion + vbInformation, "Clasing the form.") = vbYes Then DoCmd.Close End If End Sub

    Read the article

  • How to allow users to select their own grouping for a .NET TreeView control

    - by Chapso
    I am using a treeview to display projects, tasks, time entries, and the people who are working on a project. I would like to allow the user to define a custom grouping (ie. Project->Task->Time Entries or Project->Date (of time entry)->Task->TimeEntry). The relevant groups would be Project, Task, Time Entry, and Person, with some metadata from them. I want to have some modular way to allow a user to specify how they would like to display the information. Does anyone know of a good method by which this can be done? I currently have hard-coded a display which looks like this: Project Task Time Entry Next Project ... My thought is to do something like write methods to display each type and somehow let a user select what order the display would group. Please let me know if I am not being clear enough.

    Read the article

  • Remove certain filetypes in Python

    - by Gareth
    Hello. I am running a script that walks a directory structure and generates new files in each folder in the directory. I want to delete some of the files right after creation. This is my idea, but it is quite wrong I imagine: directory = os.path.dirname(obj) m = MeshExporterApplication(directory) os.remove(os.path.join(directory,"*.mesh.xml")) How to you put wildcards in a path? I guess not like /home/me/*.txt, but that is what I am trying. Thanks, Gareth

    Read the article

  • How to achieve "merge" of two data sets with Insert SQL statemen (Oracle DBMS)t?

    - by Roman Kagan
    Hi: What would be the insert SQL statement to merge data from two tables. For example I have events_source_1 table (columns: event_type_id, event_date) and events_source_2 table (same columns) and events_target table (columns: event_type_id, past_event_date nullalbe, future_event_date nullable). Events_source_1 has past events, Events_source_2 has future events and resultant events_target would contain past and future events in the same row for same event_type_id. If there is no past_events but future_events then past_event_date won't be set and only future_event_date will be and the opposite is true too. Thanks a lot in advance for helping me resolving this problem.

    Read the article

  • Going to Tech*Ed 2010

    - by Nikita Polyakov
    After years of one night community and volunteering tasks; and even running cool events like ]inbetween[ weekend, I finally get to go to the actual event! And this time it’s not in Orlando – it’s in New Orleans - which is also exciting! I will be attending many Windows Phone 7 sessions. And will hover over the Windows Phone booths. I am also extremely excited about this short exchange I had on twitter with the brand new Windows Phone Partner Community account: @wppartner #WindwosPhone 7 Enterprise story is what we are all waiting to hear :) #wp7dev 7:51 PM Jun 1st via TweetDeck in reply to wppartner @NikitaP We'll definitely be covering that at @WPCDC but we'll also be talking about it at @TechEd_NA next week! about 4 hours ago via CoTweet in reply to NikitaP As you might know I also love Microsoft Expression Blend and SketchFlow. I will be hanging out at the Microsoft Expression TLC [Technical Learning Center] booths in Expo Hall during these times: Day Start Finish 7-Jun 10:30 AM 12:30 PM 7-Jun 7:30 PM 9:00 PM 8-Jun 2:45 PM 5:00 PM 9-Jun 2:45 PM 5:00 PM 10-Jun 12:15 PM 3:00 PM   Feel free to find me and chat me up. I’ll be twittering under @NikitaP, if you are in Florida dev community use #teched_fl hash tag. If you are going and you have a Windows Phone 6.5, iPhone/ipad, Android or a Vista/Win7 laptop with you, grab this: Kevin Wolf’s TechEd 2010 Schedule and Twitter Tool – One App, 5 Different Platforms in one word: Aaaaaaamazing!

    Read the article

  • Is there a way i can see why Squid (Proxy Server) determines why a resources should be a MISS?

    - by Pure.Krome
    Hi folks, I'm using Fiddler/FireBug to debug some of our live server web content. We're getting a lot of :- X-Cache: MISS from X-Cache-Lookup: MISS from :8080 Via: 1.1 :8080 (squid/2.7.STABE3) I thought i knew a lot about cache-control / expires / last-modified / etags, etc.. but maybe not. So .. is there a way I can run squid in some verbose way to see why it thinks a resource which i request, is cached/is not getting cached, etc.. which is why we're getting MISSes back? cheers :)

    Read the article

  • Is `super` local variable?

    - by Michael
    // A : Parent @implementation A -(id) init { // change self here then return it } @end A A *a = [[A alloc] init]; a. Just wondering, if self is a local variable or global? If it's local then what is the point of self = [super init] in init? I can successfully define some local variable and use like this, why would I need to assign it to self. -(id) init { id tmp = [super init]; if(tmp != nil) { //do stuff } return tmp; } b. If [super init] returns some other object instance and I have to overwrite self then I will not be able to access A's methods any more, since it will be completely new object? Am I right? c. super and self pointing to the same memory and the major difference between them is method lookup order. Am I right? sorry, don't have Mac to try, learning theory as for now...

    Read the article

  • how to convert bitmap to intptr in C#

    - by carl
    code as fellow: Bitmap bmp = new Bitmap(e.width, e.height, System.Drawing.Imaging.PixelFormat.Format24bppRgb); System.Drawing.Imaging.BitmapData data = bmp.LockBits(new Rectangle(0, 0, e.width, e.height), System.Drawing.Imaging.ImageLockMode.ReadWrite, System.Drawing.Imaging.PixelFormat.Format24bppRgb); int dataLength = e.width * e.height * 3; Win32.memcpy(data.Scan0, (IntPtr)e.data, (uint)dataLength); convertBitmapToIntptr(bmp);????? how to code in this function like convertBitmapToIntptr(bmp). who give me some idea. thank you very much.

    Read the article

  • How can I ignore the block content reading in Perl.

    - by Nano HE
    Hello. I plan to ignore the block content which include the start line of "MaterializeU4()" with the subroutin() read_block below. But failed. # Read a constant definition block from a file handle. # void return when there is no data left in the file. # Otherwise return an array ref containing lines to in the block. sub read_block { my $fh = shift; my @lines; my $block_started = 0; while( my $line = <$fh> ) { # how to correct my code below? I don't need the 2nd block content. $block_started++ if ( ($line =~ /^(status)/) && (index($line, "MaterializeU4") != 0) ) ; if( $block_started ) { last if $line =~ /^\s*$/; push @lines, $line; } } return \@lines if @lines; return; } Data as below: __DATA__ status DynTest = <dynamic 100> vid = 10002 name = "DynTest" units = "" status VIDNAME9000 = <U4 MaterializeU4()> vid = 9000 name = "VIDNAME9000" units = "degC" status DynTest = <U1 100> vid = 100 name = "Hello" units = "" Output: <StatusVariables> <SVID logicalName="DynTest" type="L" value="100" vid="10002" name="DynTest" units=""></SVID> <SVID logicalName="VIDNAME9000" type="L" value="MaterializeU4()" vid="9000" name="VIDNAME9000" units="degC"></SVID> <SVID logicalName="DynTest" type="L" value="100" vid="100" name="Hello" units=""></SVID> </StatusVariables> [Updated] I print the value of index($line, "MaterializeU4"), it output 25. Then I updated the code as below $block_started++ if ( ($line =~ /^(status)/) && (index($line, "MaterializeU4") != 25) Now it works. Any comments are welcome about my practice. Thank you.

    Read the article

  • Android Performance Question : Many small apps or one big app?

    - by kunjaan
    I read this quote in one of the webpages: If you are writing a large application, consider dividing it into a suite of applications and services. Smaller applications load faster and use fewer resources. Making a suite of applications, content providers, and services makes your code more open to incorporation into other applications as described the "Use and be used" tip. Is this true? What is the thumb rule for the size of app?

    Read the article

  • How to center text in an inline-block span on lte firefox 2?

    - by Knu
    I have 3 spans inside a div. text-align:center isn't working (tried on the parent too) text-align: -moz-center neither (on ff2) i have to use spans no floats -moz-inline-box or -moz-inline-stack ? with -moz-inline-block it's working but the 2nd and 3rd spans clear left… Anyone got an idea? (fixing #6 is an alternative)

    Read the article

  • Advice on a simple Windows Form

    - by Austin Hyde
    I have a VERY simple windows form that the user uses to manage "Stores". Each store has a name and number, and is kept in a corresponding DB table. The form has a listbox of stores, an add button that creates a new store, a delete button, and an edit button. Beside those I have text boxes for the name and number, and save/cancel buttons. When the user chooses a store from the list box, and clicks 'edit', the textboxes become populated and save/cancel become active. When the user clicks 'add', I create a new Store, add it to the listbox, activate the textboxes and save/cancel buttons, then commit it to the database when the user clicks 'save', or discards it when the user clicks 'cancel'. Right now, my event system looks like this (in psuedo-code. It's just shorter that way.) add->click: store = new Store() listbox.add(store) populateAndEdit(store) delete->click: store = listbox.selectedItem db.deleteOnSubmit(store) listbox.remove(store) db.submit() edit->click: populateAndEdit(listbox.selectedItem) save->click: parseAndSave(listbox.selectedItem) db.submit() disableTexts() cancel->click: disableTexts() The problem is in how I determine if we are inserting a new Store, or updating an existing one. The obvious solution to me would be to make it a "modal" process - that is, when I click edit, I go into edit mode, and the save button does things differently than if I were in add mode. I know I could make this more MVC-like, but I don't really think this simple form merits the added complexity. I'm not very experienced with winforms, so I'm not sure if I even have the right idea for how to tackle this. Is there a better way to do this? I would like to keep it simple, but usable.

    Read the article

  • Simple code to expire Drupal cookie?

    - by user310594
    With a single click this simple script will do a multi-logout of: Moodle Elgg 2 MyBB's and (not) Drupal. <?php setcookie( 'Elgg', '', -3600, '/', '.domain.com', false, false); setcookie( 'http_auth_ext_complete', '1', -3600, '/d/', '.domain.com', false, false); // setcookie( 'http_auth_ext_complete', '1', -3600, '/d/', 'domain.com', false, false); setcookie( 'mybbuser', '', -3600, '/', '.domain.com', false, false); setcookie( 'mybbuser', '', -3600, '/bb/', '.domain.com', false, false); // unset all 3 Moodle cookies, the lazy way if (isset($_SERVER['HTTP_COOKIE'])) { $cookies = explode(';', $_SERVER['HTTP_COOKIE']); foreach($cookies as $cookie) { $parts = explode('=', $cookie); $name = trim($parts[0]); setcookie($name, '', time()-1000); setcookie($name, '', time()-1000, '/'); } } ?> This works on four sites but the Drupal cookie won't quit. How can I do the same with Drupal? Note: Drupal uses 'host' instead of 'domain', neither with or without the '.' works so far. Thank you.

    Read the article

  • resizing images with imagemagick via shell script

    - by jml
    Hi there, I don't really know that much about bash scripts OR imagemagick, but I am attempting to create a script in which you can give some sort of regexp matching pattern for a list of images and then process those into new files that have a given filename prefix. for example given the following dir listing: allfiles01.jpg allfiles02.jpg allfiles03.jpg i would like to call the script like so: ./resisemany.sh allfiles*.jpg 30 newnames*.jpg the end result of this would be that you get a bunch of new files with newnames, the numbers match up, so far what i have is: IMAGELIST=$1 RESIEZFACTOR=$2 NUMIMGS=length($IMAGELIST) for(i=0; i<NUMIMGS; i++) convert $IMAGELIST[i] -filter bessel -resize . RESIZEFACTOR . % myfile.JPG Thanks for any help... The parts that I obviously need help with are 1. how to give a bash script matching criteria that it understands 2. how to use the $2 without having it match the 2nd item in the image list 3. how to get the length of the image list 4. how to create a proper for loop in such a case 5. how to do proper text replacement for a shell command whereby you are appending items as i allude to. jml

    Read the article

  • How do I change a Git remote HEAD to point to something besides "master"

    - by jhs
    Short version: How do I set a Git remote's HEAD ref to point to something besides "master"? My project has a policy not to use a "master" branch (all branches are to have meaningful names). Furthermore, the canonical master repository is only accessible via ssh://, with no shell access (like GitHub or Unfuddle). My problem is that the remote repository still has a HEAD reference to refs/heads/master, but I need it to point to a different branch. This is causing two problems: When cloning the repo, there this, warning: remote HEAD refers to nonexistent ref, unable to checkout. That's confusing and inconvenient. The web-based code browser depends on HEAD as a basis for browsing the tree. I need HEAD to point to a valid branch, then.

    Read the article

  • Removing unused selectors in a CSS stylesheet?

    - by Legend
    I've been developing a web app for a few weeks now and ended up with about a 1000 lines. I am sure not all the selectors are being used and am trying to clean it up. At the same time, I don't want to do it manually for obvious reasons. Is there a safe and an efficient way to remove unused selectors? For this, am I supposed to navigate the entire website to let it know which selectors are not being used? (I use javascript to add some selectors so these might not show up until a particular usecase is seen)

    Read the article

  • Using Rx to synchronize asynchronous events

    - by Martin Liversage
    I want to put Reactive Extensions for .NET (Rx) to good use and would like to get some input on doing some basic tasks. To illustrate what I'm trying to do I have a contrived example where I have an external component with asyncronous events: class Component { public void BeginStart() { ... } public event EventHandler Started; } The component is started by calling BeginStart(). This method returns immediately, and later, when the component has completed startup, the Started event fires. I want to create a synchronous start method by wrapping the component and wait until the Started event is fired. This is what I've come up with so far: class ComponentWrapper { readonly Component component = new Component(); void StartComponent() { var componentStarted = Observable.FromEvent<EventArgs>(this.component, "Started"); using (var startedEvent = new ManualResetEvent(false)) using (componentStarted.Take(1).Subscribe(e => { startedEvent.Set(); })) { this.componenet.BeginStart(); startedEvent.WaitOne(); } } } I would like to get rid of the ManualResetEvent, and I expect that Rx has a solution. But how?

    Read the article

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