Daily Archives

Articles indexed Thursday April 15 2010

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

  • [numpy] storing record arrays in object arrays

    - by Peter Prettenhofer
    I'd like to convert a list of record arrays -- dtype is (uint32, float32) -- into a numpy array of dtype np.object: X = np.array(instances, dtype = np.object) where instances is a list of arrays with data type np.dtype([('f0', '<u4'), ('f1', '<f4')]). However, the above statement results in an array whose elements are also of type np.object: X[0] array([(67111L, 1.0), (104242L, 1.0)], dtype=object) Does anybody know why? The following statement should be equivalent to the above but gives the desired result: X = np.empty((len(instances),), dtype = np.object) X[:] = instances X[0] array([(67111L, 1.0), (104242L, 1.0), dtype=[('f0', '<u4'), ('f1', '<f4')]) thanks & best regards, peter

    Read the article

  • Parse error when trying to install app on Asus eee PC 701 running Android 2.0

    - by Don
    A beta tester of mine has a Asus eee pc 701 running Android 2.0 and he is trying to install an app on it from my web site. He is able to download the app but is getting a "Parse Error: There is a problem parsing the package" error. I don't really know if this problem is with the eee pc or with the apk since he is the first person to try to install it. I built it for 2.0, the manifest has 5 as the minimum API level and I used Eclipse to export and sign it. But this is my first Android app and he is the first to try to install it, so I am not sure what the problem might be? Could just be the Android implementation too. Here is a site about putting Android on the Asus: http://www.liliputing.com/2009/01/how-to-built-google-android-for-the-asus-eee-pc-701.html Any thoughts on what I might try to get this app installed on his machine?

    Read the article

  • CakePHP save without form

    - by SDwebs
    I have a photo gallery I'm trying to set a picture as the cover for the album. I have a field cover_id in the albums table that has already been linked to the photos through the model. I'm passing the album_id and photo_id to the controller. I want to update the album.cover_id passed thru the params with the photo_id passed thru the params. Is there a way to do this or a way to make the link a form without having it look like or form or changing much of the CSS?

    Read the article

  • disable eclipse auto completion

    - by SpliFF
    I love Eclipse but I HATE auto-completion with a vengeance! I swear though, no matter how hard I look in prefs or Google I can't find where I turn this off! I'm having the problem with both CFEclipse and the PHP editor. How do I completely disable all "smart" quotes/tags/braces auto-inserting. Not some of it.. ALL of it. No matter how many options I untick both editors keep trying to finish my code for me.. usually with irritating results. Like this one (PHP editor): <img alt="banner" src="/images/banner.jpg"></img> This is HTML, not XHTML - I don't want, or need, my img tags closed. Anyway this is still happening after I've gone to Preferences | PHP | Editor | Typing and Preferences | PHP | Editor | Code Assist and unchecked every option. I can't be the only one having this issue but I can't find any howtos or help on this.

    Read the article

  • How would you go about tackling this problem? [SOLVED in C++]

    - by incrediman
    Intro: EDIT: See solution at the bottom of this question (c++) I have a programming contest coming up in about half a week, and I've been prepping :) I found a bunch of questions from this canadian competition, they're great practice: http://cemc.math.uwaterloo.ca/contests/computing/2009/stage2/day1.pdf I'm looking at problem B ("Dinner"). Any idea where to start? I can't really think of anything besides the naive approach (ie. trying all permutations) which would take too long to be a valid answer. Btw, the language there says c++ and pascal I think, but i don't care what language you use - I mean really all I want is a hint as to the direction I should proceed in, and perhpas a short explanation to go along with it. It feels like I'm missing something obvious... Of course extended speculation is more than welcome, but I just wanted to clarify that I'm not looking for a full solution here :) Short version of the question: You have a binary string N of length 1-100 (in the question they use H's and G's instead of one's and 0's). You must remove all of the digits from it, in the least number of steps possible. In each step you may remove any number of adjacent digits so long as they are the same. That is, in each step you can remove any number of adjacent G's, or any number of adjacent H's, but you can't remove H's and G's in one step. Example: HHHGHHGHH Solution to the example: 1. HHGGHH (remove middle Hs) 2. HHHH (remove middle Gs) 3. Done (remove Hs) -->Would return '3' as the answer. Note that there can also be a limit placed on how large adjacent groups have to be when you remove them. For example it might say '2', and then you can't remove single digits (you'd have to remove pairs or larger groups at a time). Solution I took Mark Harrison's main algorithm, and Paradigm's grouping idea and used them to create the solution below. You can try it out on the official test cases if you want. //B.cpp //include debug messages? #define DEBUG false #include <iostream> #include <stdio.h> #include <vector> using namespace std; #define FOR(i,n) for (int i=0;i<n;i++) #define FROM(i,s,n) for (int i=s;i<n;i++) #define H 'H' #define G 'G' class String{ public: int num; char type; String(){ type=H; num=0; } String(char type){ this->type=type; num=1; } }; //n is the number of bits originally in the line //k is the minimum number of people you can remove at a time //moves is the counter used to determine how many moves we've made so far int n, k, moves; int main(){ /*Input from File*/ scanf("%d %d",&n,&k); char * buffer = new char[200]; scanf("%s",buffer); /*Process input into a vector*/ //the 'line' is a vector of 'String's (essentially contigious groups of identical 'bits') vector<String> line; line.push_back(String()); FOR(i,n){ //if the last String is of the correct type, simply increment its count if (line.back().type==buffer[i]) line.back().num++; //if the last String is of the wrong type but has a 0 count, correct its type and set its count to 1 else if (line.back().num==0){ line.back().type=buffer[i]; line.back().num=1; } //otherwise this is the beginning of a new group, so create the new group at the back with the correct type, and a count of 1 else{ line.push_back(String(buffer[i])); } } /*Geedily remove groups until there are at most two groups left*/ moves=0; int I;//the position of the best group to remove int bestNum;//the size of the newly connected group the removal of group I will create while (line.size()>2){ /*START DEBUG*/ if (DEBUG){ cout<<"\n"<<moves<<"\n----\n"; FOR(i,line.size()) printf("%d %c \n",line[i].num,line[i].type); cout<<"----\n"; } /*END DEBUG*/ I=1; bestNum=-1; FROM(i,1,line.size()-1){ if (line[i-1].num+line[i+1].num>bestNum && line[i].num>=k){ bestNum=line[i-1].num+line[i+1].num; I=i; } } //remove the chosen group, thus merging the two adjacent groups line[I-1].num+=line[I+1].num; line.erase(line.begin()+I);line.erase(line.begin()+I); moves++; } /*START DEBUG*/ if (DEBUG){ cout<<"\n"<<moves<<"\n----\n"; FOR(i,line.size()) printf("%d %c \n",line[i].num,line[i].type); cout<<"----\n"; cout<<"\n\nFinal Answer: "; } /*END DEBUG*/ /*Attempt the removal of the last two groups, and output the final result*/ if (line.size()==2 && line[0].num>=k && line[1].num>=k) cout<<moves+2;//success else if (line.size()==1 && line[0].num>=k) cout<<moves+1;//success else cout<<-1;//not everyone could dine. /*START DEBUG*/ if (DEBUG){ cout<<" moves."; } /*END DEBUG*/ }

    Read the article

  • In Rails, how can a record belong_to a single user, but also have multiple "secondary" users?

    - by Kuro
    In my app, I have a User model and a Project model. A user has_many assignments and each project belongs_to a user. But along with each project having an owner, the user who created it, I would like the owner be able to share it with others (so that the project gets shown on the other users' account along with their own). I imagine having to use has_many :through, and setting up a projects_users table with a user_id and a project_id. And I guess this would be the end result? Project.first.user # The creator of the project => #<User id: 1, name: 'andrew', etc...> Project.first.users # The users that the creator chose to share it with => [#<User id: 2 ...>, #<User id: 3 ...>] How would I go about doing this? Thanks!

    Read the article

  • Oracle Apex:Why is this dynamic action not getting triggered/fired ?

    - by Sathya
    I'm using Application Express 4.0.0.00.25 ( Apex 4.0 EA2 ). I've created a tabular form, with few fields. Each of the field are not direct entry, but rather a LOV picker is attached to these, and on selecting the LOV value, the id gets stored in the field. I have a dynamic action associated to the field, ( event - change in item, condition - always, action - Set value via SQL query ). However, on selecting the value from the LOV, the dynamic action doesn't get triggered. If I select the dynamic action to be fired on page load, then it works but not upon selection of an item from the LOV. Why is this so, is it by design or a bug ?

    Read the article

  • Hudson CI project doesn't run NetBeans JUnit tests of dependent projects

    - by Liron Yahdav
    I have a set of NetBeans java projects with dependencies between them. I added the project at the top of the dependency tree to Hudson for continuous integration. Everything works fine, except that the unit tests of dependent projects don't get run by Hudson. This is because the ant scripts that NetBeans creates has dependent projects setup to run the "jar" target and not a target that also runs the unit tests. I could add ant build steps for each dependent project in Hudson to run the unit tests, but I was hoping there's a simpler solution.

    Read the article

  • PyQt: How to keep QTreeView nodes correctly expanded after a sort

    - by taynaron
    I'm writing a simple test program using QTreeModel and QTreeView for a more complex project later on. In this simple program, I have data in groups which may be contracted or expanded, as one would expect in a QTreeView. The data may also be sorted by the various data columns (QTreeView.setSortingEnabled is True). Each tree item is a list of data, so the sort function implemented in the TreeModel class uses the built-in python list sort: self.layoutAboutToBeChanged.emit() self.rootItem.childItems.sort(key=lambda x: x.itemData[col], reverse=order) for item in self.rootItem.childItems: item.childItems.sort(key=lambda x: x.itemData[col], reverse=order) self.layoutChanged.emit() The problem is that whenever I change the sorting of the root's child items (the tree is only 2 levels deep, so this is the only level with children) the nodes aren't necessarily expanded as they were before. If I change the sorting back without expanding or collapsing anything, the nodes are expanded as before the sorting change. Can anyone explain to me what I'm doing wrong? I suspect it's something with not properly reassigning QModelIndex with the sorted nodes, but I'm not sure.

    Read the article

  • Is displayMetrix xdpi and ydpi accurate?

    - by oddvark
    Can the xdpi and ydpi settings be relied upon to accurately represent the physical pixels in once inch of screen space? I need this to be accurate for some display code I'm writing. I realize the documention says that this is the case, but I need to know if individual handsets get this right MOST OF THE TIME. I know I can alternately use "densitiy" which will give me 120, 160, 240 steps of DPI, but an exact dpi would be much better. Thanks!

    Read the article

  • Are Hibernate named HQL queries (in annotations) optimised?

    - by Graham Lea
    A new colleague has just suggested using named HQL queries in Hibernate with annotations (i.e. @NamedQuery) instead of embedding HQL in our XxxxRepository classes. What I'd like to know is whether using the annotation provides any advantage except for centralising quueries? In particular, is there some performances gain, for instance because the query is only parsed once when the class is loaded rather than every time the Repository method is executed?

    Read the article

  • Linux Live USB Media

    <b>Jamie's Random Musings:</b> "It is pretty common these days for laptops, and even desktops, to be able to boot from a USB flash memory drive. So you can save a little time and a little money by converting various Linux distributions ISO images to bootable USB devices, rather than burning them to CD/DVD."

    Read the article

  • White House Cybersecurity Chief Slams Federal Security Efforts

    Although agencies are improving cybersecurity at the national level, the federal approach to securing U.S. interests online still leaves much to be desired, a high-ranking Obama administration official said....Did you know that DotNetSlackers also publishes .net articles written by top known .net Authors? We already have over 80 articles in several categories including Silverlight. Take a look: here.

    Read the article

  • My History of Visual Studio (Epilog)

    Visual Studio 2010 Launched on Monday.  Wow!  Its HUGE.  A major round of congratulations are in order for everyone involved, not just on the Visual Studio team but also on the Frameworks team and the supporting teams and of course the customers whose feedback was so vital to the success of the product. Ive already written a lot about VS2010 previously in the series and I dont want to go over all that stuff again.  In my last history posting, back when Beta 2 came out, I covered...Did you know that DotNetSlackers also publishes .net articles written by top known .net Authors? We already have over 80 articles in several categories including Silverlight. Take a look: here.

    Read the article

  • Xforwarding doesn't allow for switching users

    - by Dan
    I'm ssh'd into a remote computer and xforwarding is working fine... but as soon as I "sudo su -" or "sudo su user2" it no longer Xforwards anything giving me the error: X11 connection rejected because of wrong authentication. xterm Xt error: Can't open display: localhost:10.0 Any Ideas? Thanks

    Read the article

  • Font Setting in VS2010

    - by Nano HE
    Hi I installed VS2010 yesterday - (both VS2005 and VS2010 installed). But I can't find the "FixedSys" style font from the Fonts and Colors - Font (pull down list). Otherwise,I can use the style font in my VS2005. Any suggestion? Thank you.

    Read the article

  • Is there a way to avoid debugger?

    - by Gabriel Šcerbák
    I don't like debugging in a debugger, because I think it is often below the abstraction layer of the programming language and it is often not reproducible. I favor usign unit tests when possible and I think they are a good way, but it is not always that easy to implement them. Do you know about any other alternative approaches to avoid the use of debugger?

    Read the article

  • Embedded Linux for total beginner

    - by sasayins
    Hi, I want to learn how to develop in embedded linux. What materials should I need? I don't have the actual embedded device so I plan to use some device emulator for the PC. I want to know how to load the kernel and the filesystem in the device. Many thanks.

    Read the article

  • post to actionrequest from an anchor

    - by griegs
    I have the following; <% using(Html.BeginForm("GetRecommendedProducts", "Home", FormMethod.Post)) { %> <% Html.RenderPartial("QuickQuote", Model.quickQuote); %> <div class="But brown" style="float:left;"> <a href="." onclick="$.unblockUI(); return false;">Close</a> </div> <div class="But green" style=""> <a href="." onclick="this.form.submit(); return false;">Go</a> </div> <%} %> When I click the anchor I do not get a post to my action. I know this should be possible so what am I doing wrong? The partial view only contains fields and not another BeginForm or anything like that. If I use a submit button it works ok but I can't use a submit button I need to use an anchor.

    Read the article

  • How to write text files with DOS line endings on linux

    - by gaumann
    I want to write text files with DOS/Windows line endings '\r\n' using python running on Linux. It seems to me that there must be a better way than manually putting a '\r\n' at the end of every line or using a line ending conversion utility. Ideally I would like to be able to do something like assign to os.linesep the separator that I want to use when writing the file. Or specify the line separator when I open the file.

    Read the article

  • .NET StandardInput Sending Modifiers

    - by Paul Oakham
    We have some legacy software which depends on sending keystrokes to a DOS window and then scraping the screen. I am trying to re-create the software by redirecting the input and output streams of the process directly to my application. This part I have managed fine using: _Process = new Process(); { _Process.StartInfo.FileName = APPLICATION; _Process.StartInfo.RedirectStandardOutput = true; _Process.StartInfo.RedirectStandardInput = true; _Process.StartInfo.RedirectStandardError = true; _Process.StartInfo.UseShellExecute = false; _Process.StartInfo.CreateNoWindow = true; _Process.OutputDataReceived += new DataReceivedEventHandler(_Process_OutputDataReceived); _Process.ErrorDataReceived += new DataReceivedEventHandler(_Process_ErrorDataReceived); } My problem is I need to send some command modifiers such as Ctrl, ALT and Space as well as F1-12 to this process but am unsure how. I can send basic text and I receive response's fine. I just need to emulate these modifiers.

    Read the article

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