Daily Archives

Articles indexed Saturday May 22 2010

Page 25/81 | < Previous Page | 21 22 23 24 25 26 27 28 29 30 31 32  | Next Page >

  • sqlite database help

    - by mamila
    Hi all i have some questions regarding database in android. 1. in my project, I would like to create a database with single table. i would also like to insert data on this table from word or excel document. is it possible? if so please how can i do it? some code snippets would be of great help. 2. i have four different activities which i would like them to interact with this single table. the first is the main activity and its purpose is just to launch the other three activities according to user choice. so it has no interaction with the db. but the other three activities will read from the table whenever called. can you please tell me how to call the dbhelper on these activities. am kind of unable to do this.and am currently creating one db per each activity which is not the optimal way. any help is really appreciated and would be better if very soon tahnks

    Read the article

  • learning and "singing" Ruby with Sinatra

    - by microspino
    Hello I'm trying to improve my ruby knowledge by reading The Ruby Programming Language book. Reading Coders at work I saw that lot of the interviewees suggest to dive into a project source code to learn best practices to be aware of bad habits and of course to take new inspirations for how to do things. I decided to pick a project as more self contained as I could find. My choice was Sinatra since It's 1000 LOC. Is It a good project to learn? Do you suggest another one more simple (i.e. less LOCs)? I've tried to see rails machinery before but I came out scared from It.

    Read the article

  • How to enforce foreign keys using Xerial SQLite JDBC?

    - by Space_C0wb0y
    According to their release notes, the Xerial SQLite JDBC driver supports foreign keys since version 3.6.20.1. I have tried some time now to get a foreign key constraint to be enforced, but to no avail. Here is what I came up with: public static void main(String[] args) throws ClassNotFoundException, SQLException { Class.forName("org.sqlite.JDBC"); SQLiteConfig config = new SQLiteConfig(); config.enforceForeignKeys(true); Connection connection = DriverManager.getConnection("jdbc:sqlite::memory:", config.toProperties()); connection.createStatement().executeUpdate( "CREATE TABLE artist(" + "artistid INTEGER PRIMARY KEY, " + "artistname TEXT);"); connection.createStatement().executeUpdate( "CREATE TABLE track("+ "trackid INTEGER," + "trackname TEXT," + "trackartist INTEGER," + "FOREIGN KEY(trackartist) REFERENCES artist(artistid)" + ");"); connection.createStatement().executeUpdate( "INSERT INTO track VALUES(14, 'Mr. Bojangles', 3)"); } The table definitions are taken directly from the sample in the SQLite documentation. This is supposed to fail, but it doesn't. I also checked, and it really inserts the tuple (no ignore or something like that). Does anyone have any experience with that, or knows how to make it work?

    Read the article

  • Architecting iPhone Views - seeking help on a specific issue + general advice

    - by Ev
    Hi there, I am a web developer (rails, python) that is new to iPhone development. I've done some desktop development in the past within the MS environment (C#). I'm trying to build a really simple iPhone application and I am confused by the way that views work in general. If someone can provide advice for my particular problem, along with some resources where I can learn how to architect iPhone views in the future, that would be awesome. I feel like a lot of the Apple documentation that I've come across is too specific - I am lacking a fundamental understanding of how views work on the iPhone. My particular problem looks like this: I need one view that displays some downloaded text content. This is the view that shows when the app loads, and it is pretty straightforward. Then I need a settings area (I've already decided I don't want to use the iPhone settings area). The settings area main page will have some text fields on it. It will also have a 2-row grouped table. Each cell in that table will take you to another view which also has a grouped table used for multi-select. I suspect that I can reuse the same view for these two final "detailed setting" views. In summary: home page settings main page detailed setting 1 detailed setting 2 Any help and advice appreciated.

    Read the article

  • How do software events work internally?

    - by Duddle
    Hello! I am a student of Computer Science and have learned many of the basic concepts of what is going on "under the hood" while a computer program is running. But recently I realized that I do not understand how software events work efficiently. In hardware, this is easy: instead of the processor "busy waiting" to see if something happened, the component sends an interrupt request. But how does this work in, for example, a mouse-over event? My guess is as follows: if the mouse sends a signal ("moved"), the operating system calculates its new position p, then checks what program is being drawn on the screen, tells that program position p, then the program itself checks what object is at p, checks if any event handlers are associated with said object and finally fires them. That sounds terribly inefficient to me, since a tiny mouse movement equates to a lot of cpu context switches (which I learned are relatively expensive). And then there are dozens of background applications that may want to do stuff of their own as well. Where is my intuition failing me? I realize that even "slow" 500MHz processors do 500 million operations per second, but still it seems too much work for such a simple event. Thanks in advance!

    Read the article

  • VC++2008 Debugger doesn't find library sources

    - by Stefan Monov
    An exception got thrown from a lib I use in my project. As I looked at the callstack, I clicked at the lib function that threw the exception. An "Open File" dialog popped up, prompting me to tell it where the lib source is located. Now clearly something is wrong. This should happen automatically somehow. How do I tell VS where to look for all files from that lib?

    Read the article

  • C# compare algorithms

    - by public static
    Hi, Are there any open source algorithms in c# that solve the problem of creating a difference between two text files? It would be super cool if it had some way of highlighting what exact areas where changed in the text document also.

    Read the article

  • Testing Django Inline ModelForms: How to arrange POST data?

    - by unclaimedbaggage
    Hi folks, I have a Django 'add business' view which adds a new business with an inline 'business_contact' form. The form works fine, but I'm wondering how to write up the unit test - specifically, the 'postdata' to send to self.client.post(settings.BUSINESS_ADD_URL, postdata) I've inspected the fields in my browser and tried adding post data with corresponding names, but I still get a 'ManagementForm data is missing or has been tampered with' error when run. Anyone know of any resources for figuring out how to post inline data? Relevant models, views & forms below if it helps. Lotsa thanks. MODEL: class Contact(models.Model): """ Contact details for the representatives of each business """ first_name = models.CharField(max_length=200) surname = models.CharField(max_length=200) business = models.ForeignKey('Business') slug = models.SlugField(max_length=150, unique=True, help_text=settings.SLUG_HELPER_TEXT) created = models.DateTimeField(auto_now_add=True) updated = models.DateTimeField(auto_now=True) phone = models.CharField(max_length=100, null=True, blank=True) mobile_phone = models.CharField(max_length=100, null=True, blank=True) email = models.EmailField(null=True) deleted = models.BooleanField(default=False) class Meta: db_table='business_contact' def __unicode__(self): return '%s %s' % (self.first_name, self.surname) @models.permalink def get_absolute_url(self): return('business_contact', (), {'contact_slug': self.slug }) class Business(models.Model): """ The business clients who you are selling products/services to """ business = models.CharField(max_length=255, unique=True) slug = models.SlugField(max_length=100, unique=True, help_text=settings.SLUG_HELPER_TEXT) description = models.TextField(null=True, blank=True) primary_contact = models.ForeignKey('Contact', null=True, blank=True, related_name='primary_contact') business_type = models.ForeignKey('BusinessType') deleted = models.BooleanField(default=False) created = models.DateTimeField(auto_now_add=True) updated = models.DateTimeField(auto_now=True) address_1 = models.CharField(max_length=255, null=True, blank=True) address_2 = models.CharField(max_length=255, null=True, blank=True) suburb = models.CharField(max_length=255, null=True, blank=True) city = models.CharField(max_length=255, null=True, blank=True) state = models.CharField(max_length=255, null=True, blank=True) country = models.CharField(max_length=255, null=True, blank=True) phone = models.CharField(max_length=40, null=True, blank=True) website = models.URLField(null=True, blank=True) class Meta: db_table = 'business' def __unicode__(self): return self.business def get_absolute_url(self): return '%s%s/' % (settings.BUSINESS_URL, self.slug) VIEWS: class Contact(models.Model): """ Contact details for the representatives of each business """ first_name = models.CharField(max_length=200) surname = models.CharField(max_length=200) business = models.ForeignKey('Business') slug = models.SlugField(max_length=150, unique=True, help_text=settings.SLUG_HELPER_TEXT) created = models.DateTimeField(auto_now_add=True) updated = models.DateTimeField(auto_now=True) phone = models.CharField(max_length=100, null=True, blank=True) mobile_phone = models.CharField(max_length=100, null=True, blank=True) email = models.EmailField(null=True) deleted = models.BooleanField(default=False) class Meta: db_table='business_contact' def __unicode__(self): return '%s %s' % (self.first_name, self.surname) @models.permalink def get_absolute_url(self): return('business_contact', (), {'contact_slug': self.slug }) class Business(models.Model): """ The business clients who you are selling products/services to """ business = models.CharField(max_length=255, unique=True) slug = models.SlugField(max_length=100, unique=True, help_text=settings.SLUG_HELPER_TEXT) description = models.TextField(null=True, blank=True) primary_contact = models.ForeignKey('Contact', null=True, blank=True, related_name='primary_contact') business_type = models.ForeignKey('BusinessType') deleted = models.BooleanField(default=False) created = models.DateTimeField(auto_now_add=True) updated = models.DateTimeField(auto_now=True) address_1 = models.CharField(max_length=255, null=True, blank=True) address_2 = models.CharField(max_length=255, null=True, blank=True) suburb = models.CharField(max_length=255, null=True, blank=True) city = models.CharField(max_length=255, null=True, blank=True) state = models.CharField(max_length=255, null=True, blank=True) country = models.CharField(max_length=255, null=True, blank=True) phone = models.CharField(max_length=40, null=True, blank=True) website = models.URLField(null=True, blank=True) class Meta: db_table = 'business' def __unicode__(self): return self.business def get_absolute_url(self): return '%s%s/' % (settings.BUSINESS_URL, self.slug) FORMS: class AddBusinessForm(ModelForm): class Meta: model = Business exclude = ['deleted','primary_contact',] class ContactForm(ModelForm): class Meta: model = Contact exclude = ['deleted',] AddBusinessFormSet = inlineformset_factory(Business, Contact, can_delete=False, extra=1, form=AddBusinessForm, )

    Read the article

  • database vs flat file, which is a faster structure for regex matching with many simultaneous request

    - by Jamex
    Hi, which structure returns faster result and/or less taxing on the host server, flat file or database (mysql)? Assume many users (100 users) are simultaneously query the file/db. Searches involve pattern matching using regex against a static file/db. File has 50,000 unique lines (same data type). There could be many matches. There is no writing to the file/db, just read. Is it possible to have a duplicate the file/db and write a logic switch to use the backup file/db if the main file is in use? Which language is best for the type of structure? Perl for flat and PHP for db? TIA

    Read the article

  • Deselect first row on gridview onload

    - by Suresh Behera
    I had situation to deselect the first gridview row on load and came to know IsSynchronizedWithCurrentItem on Gridview should able to that but some how i missed on gridview. Mean while below one should work void gvMain_RowLoaded( object sender, RowLoadedEventArgs e) { try { GridViewRow row = e.Row as GridViewRow; if (row != null && !firstItemExpanded) { row.DetailsVisibility = Visibility.Collapsed; firstItemExpanded = false ; } } catch (Exception ex) { throw ex; } } .csharpcode, .csharpcode...(read more)

    Read the article

  • Game network physics collision

    - by Jonas Byström
    How to simulating two client-controlled vehicles colliding (sensibly) in a typical client/server setup for a network game? I did read this eminent blog post on how to do distributed network physics in general (without traditional client prediction), but this question is specifically on how to handle collisions of owned objects. Example Say client A is 20 ms ahead of server, client B 300 ms ahead of server (counting both latency and maximum jitter). This means that when the two vehicles collide, both clients will see the other as 320 ms behind - in the opposite direction of the velocity of the other vehicle. Head-to-head on a Swedish highway means a difference of 16 meters/17.5 yards! What not to try It is virtually impossible to extrapolate the positions, since I also have very complex vehicles with joints and bodies all over, which in turn have linear and angular positions, velocities and accelerations, not to mention states from user input.

    Read the article

  • casting issue with realpath function (c programming)

    - by Ralph
    When I compile the following code: #define _POSIX_C_SOURCE 200112L #define _ISOC99_SOURCE #define __EXTENSIONS__ #include <stdio.h> #include <limits.h> #include <stdlib.h> int main(int argc, char *argv[]) { char *symlinkpath = argv[1]; char actualpath [PATH_MAX]; char *ptr; ptr = realpath(symlinkpath, actualpath); printf("%s\n", ptr); } I get a warning on the line that contains the call to the realpath function, saying: warning: assignment makes pointer from integer without a cast Anybody know what's up? I'm running Ubuntu Linux 9.04

    Read the article

  • how can i check ID of a clicked element js

    - by necker
    how can i check if an ID of a clicked element is lets say 'target'. what i am trying to do is actually show and hide comment form on clicking in the text field and hide it when the user clicks out of the form. the problem is that if the user clicks Submit button the form hides and nothing is sent over. so i'll have to check if the submit buttons id matches the clicked element and not hide it in this case. i am using ruby on rails remote_form_for and onblur and onfocus events now. this is my bigger form that i am showing. <div id="bigArea" style="display:none"> <% remote_form_for @horses do |f|%> <%= f.text_area :description, {:onBlur=>"{$(bigArea').hide();$('smallField').show();}"} %> <%= f.submit "Submit"%> <% end %> </div> and this is the smaller form field that hides everytime you click in it. <div id="smallField"> <%= text_field_tag 'sth',"Click to comment, {:onFocus=>"$('bigArea').show();$('smallField').hide();"} %> </div> My question is how can i disallow the form to hide when a user clicks submit button? i suppose i should check which element's id has been clicked. and if it's submit button's ID i should not hide the form. Or maybe there is some other way to do all this? i would greatly appreciate any answers!

    Read the article

  • taskbar-free window manager

    - by 7vies
    I'm looking for a window manager that is not based on the "standard" taskbar (which I find a poor idea and I'm completely tired of). I'm aware of tiling window managers and improvements in last versions of operating systems, but I can't find what I need. I suppose that any window takes the whole screen (or can be tiled), and I imagine switching between windows like that: on a hotkey or mouse hot zone the screen becomes a task switcher where tasks are organized in a somewhat convenient manner. Well, it's a bit like a taskbar with autohide, but I think there could be some more convenient ideas than simply stacking icons and descriptions... It is also supposed to be lightweight enough, for example to run on a netbook. Any suggestions?

    Read the article

  • How to convert Java program into jar?

    - by firestruq
    A little help from you all... I was trying to convert a simple java program into jar but nothing seems to have happened. I have 2 files: Tester.java , Tester.Class. Then I used this command line: jar -cvf Tester.jar Tester.class The .jar file was created but nothing seems to work. What did I miss?

    Read the article

  • inverse relation to multiple inheriting classes in django

    - by Ofri Raviv
    Here are my schematic models: class Law(models.Model): ... class Bill(models.Model): ... # data for a proposed law, or change of an existing law class PrivateBill(Bill): ... # data for a Bill that was initiated by a parliament member class GovernmentBill(Bill): ... # data for a Bill that was initiated by the government It is possible and likely that in the future I (or maybe someone else) would want to add more Bill types. Every Bill should point to a Law (indicating what law this bill is going to change) and my question is: What is the best way to implement this? If I add the ForeignKey(Law) to Bill, I'll have a relation from every Bill to Law, but a Law would only have an inverse relation to Bills (bill_set), and not a different inverse relation to each type of bill. Of course I'll be able to filter each type of bill to get only the ones pointing to a specific Law, but this is something I think I'll need to use often, so I think having privatebill_set, governmentbill_set etc would make the code more readable. Another possible solution is to add the foreign key to each of the inheriting classes (this would give me a privatebill_set, governmentbill_set, futurebill_set), but that seems hairy because I would be relying on future programmers to remember to add that relation. How would you solve this?

    Read the article

  • Confusing of TTimeSpan usage in Delphi 2010

    - by stanleyxu2005
    Hi All, I tried the new Record type TTimeSpan in Delphi 2010. But I encourage a very strange problem. assert(TTimeSpan.FromMilliseconds(5000).Milliseconds == 5000); This assertion does not pass. The value of 'TTimeSpan.FromMilliseconds(5000).Milliseconds' is always 0. I really cannot explain.

    Read the article

  • Blackberry UI tool bar : fields alignment

    - by Galaxy
    i am developing custom toolbar manager, but i want to adjust the fields alignment to be centered not aligned to the left , any advice below is the code of toolbar package galaxy.bb.ui.container; import net.rim.device.api.ui.Color; import net.rim.device.api.ui.Graphics; import net.rim.device.api.ui.XYEdges; import net.rim.device.api.ui.container.HorizontalFieldManager; import net.rim.device.api.ui.decor.Background; import net.rim.device.api.ui.decor.BackgroundFactory; import net.rim.device.api.ui.decor.Border; import net.rim.device.api.ui.decor.BorderFactory; public class ToolBarManager extends HorizontalFieldManager { private int bgColor = Color.BLACK; private int borderColor = Color.WHITE; private int borderStyle= Border.STYLE_FILLED; public ToolBarManager(){ super(USE_ALL_WIDTH); } public ToolBarManager(int bgColor) { super(USE_ALL_WIDTH); this.bgColor = bgColor; } public ToolBarManager(int bgColor, int borderStyle) { super(USE_ALL_WIDTH); this.bgColor = bgColor; this.borderStyle = borderStyle; } public int getBgColor() { return bgColor; } public void setBgColor(int bgColor) { this.bgColor = bgColor; } public int getBorderColor() { return borderColor; } public void setBorderColor(int borderColor) { this.borderColor = borderColor; } public int getBorderStyle() { return borderStyle; } public void setBorderStyle(int borderStyle) { this.borderStyle = borderStyle; } protected void paint(Graphics graphics) { super.paint(graphics); XYEdges padding = new XYEdges(5, 5, 5, 5); Border roundedBorder = BorderFactory.createRoundedBorder(padding, borderColor, borderStyle); this.setBorder(roundedBorder); Background bg = BackgroundFactory.createSolidBackground(bgColor); this.setBackground(bg); } }

    Read the article

  • Multi-Part Map Troubleshooting

    - by Michael Stephenson
    Scenario I came across a nice little one with multi-part maps the other day. I had an orchestration where I needed to combine 4 input messages into one output message like in the below table:   Input Messages Output Messages Company Details Member Details Event Message Member Search Member Import   I thought my orchestration was working fine but for some reason when I was trying to send my message it had no content under the root node like below <ns0:ImportMemberChange xmlns:ns0="http://---------------/"></ns0:ImportMemberChange>   My map is displayed in the below picture. I knew that the member search message may not have any elements under it but its root element would always exist. The rest of the messages were expected to be fully populated. I tried a number of different things and testing my map outside of the orchestration it always worked fine. The Eureka Moment The eureka moment came when I was looking at the xslt produced by the map. Even though I'd tried swapping the order of the messages in the input of the map you can see in the below picture that the first part of the processing of the message (with the red circle around it) is doing a for-each over the GetCompanyDetailsResult element within the GetCompanyDetailsResponse message. This is because the processing is driven by the output message format and the first element to output is the OrganisationID which comes from the GetCompanyDetailsResponse message. At this point I could focus my attention on this message as the xslt shows that if this xpath statement doesn’t return the an element from the GetCompanyDetailsResponse message then the whole body of the output message will not be produced and the output from the map would look like the message I was getting. <ns0:ImportMemberChange xmlns:ns0="http://---------------/"></ns0:ImportMemberChange> I was quickly able to prove this in my map test which proved this was a likely candidate for the problem. I revisited the orchestration focusing on the creation of the GetCompanyDetailsResponse message and there was actually a bug in the orchestration which resulted in the message being incorrectly created, once this was fixed everything worked as expected. Conclusion Originally I thought it was a problem with the map itself, and looking online there wasn’t really much in the way of content around troubleshooting for multi-part map problems so I thought I'd write this up. I guess technically it isn't a multi-part map problem, but I spend a good couple of hours the other day thinking it was.

    Read the article

  • Versioning and Continuous Integration with project settings files

    - by Michael Stephenson
    I came across something which was a bit of a pain in the bottom the other week. Our scenario was that we had implemented a helper style assembly which had some custom configuration implemented through the project settings. I'm sure most of you are familiar with this where you end up with a settings file which is viewable through the C# project file and you can configure some basic settings. The settings are embedded in the assembly during compilation to be part of a DefaultValue attribute. You have the ability to override the settings by adding information to your app.config and if the app.config doesn’t override the settings then the embedded default is used. All normal C# stuff so far… Where our pain started was when we implement Continuous Integration and we wanted to version all of this from our build. What I was finding was that the assembly was versioned fine but the embedded default value was maintaining the non CI build version number. I ended up getting this to work by using a build task to change the version numbers in the following files: App.config Settings.settings Settings.designer.cs I think I probably could have got away with just the settings.designer.cs, but wanted to keep them all consistent incase we had to look at the code on the build server for some reason. I think the reason this was painful was because the settings.designer.cs is only updated through Visual Studio and it writes out the code to this file including the DefaultValue attribute when the project is saved rather than as part of the compilation process. The compile just compiles the already existing C# file. As I said we got it working, and it was a bit of a pain. If anyone has a better solution for this I'd love to hear it

    Read the article

< Previous Page | 21 22 23 24 25 26 27 28 29 30 31 32  | Next Page >