Daily Archives

Articles indexed Sunday January 2 2011

Page 9/27 | < Previous Page | 5 6 7 8 9 10 11 12 13 14 15 16  | Next Page >

  • Hibernate : Opinions in Composite PK vs Surrogate PK

    - by Albert Kam
    As i understand it, whenever i use @Id and @GeneratedValue on a Long field inside JPA/Hibernate entity, i'm actually using a surrogate key, and i think this is a very nice way to define a primary key considering my not-so-good experiences in using composite primary keys, where : there are more than 1 business-value-columns combination that become a unique PK the composite pk values get duplicated across the table details cannot change the business value inside that composite PK I know hibernate can support both types of PK, but im left wondering by my previous chats with experienced colleagues where they said that composite PK is easier to deal with when doing complex SQL queries and stored procedure processes. They went on saying that when using surrogate keys will complicate things when doing joining and there are several condition when it's impossible to do some stuffs when using surrogate keys. Although im sorry i cant explain the detail here since i was not clear enough when they explain it. Maybe i'll put more details next time. Im currently trying to do a project, and want to try out surrogate keys, since it's not getting duplicated across tables, and we can change the business-column values. And when the need for some business value combination uniqueness, i can use something like : @Table(name="MY_TABLE", uniqueConstraints={ @UniqueConstraint(columnNames={"FIRST_NAME", "LAST_NAME"}) // name + lastName combination must be unique But im still in doubt because of the previous discussion about the composite key. Could you share your experiences in this matter ? Thank you !

    Read the article

  • Modifying resource contents of a running executable

    - by mrwoik
    All, I store my application settings in a resource. When my program first loads, I read the specified resource using WinAPI. I then parse the retrieved byte data. This works flawlessly for me. Now let's say that a user alters a setting in my application. He/she checks a checkbox control. I would like to save the updated setting to my resource. However, it seems that my call to UpdateResource will not work while my application is running. I can't modify my resource data even though it is the same size. First, is it possible to modify a running image's resource data? Second, if that is not possible, what alternatives do I have for storing settings internally within my application? NOTE: I must have the settings within my running executable. They cannot be on the harddrive or in the registry. Please don't even suggest that as an option.

    Read the article

  • CakePHP ACL Issue: Max_Join_Size

    - by Mayank
    Hi, The build_acl action works on localhost but on the shared sever it gives the following error: Warning (512): SQL Error: 1104: The SELECT would examine more than MAX_JOIN_SIZE rows; check your WHERE and use SET SQL_BIG_SELECTS=1 or SET SQL_MAX_JOIN_SIZE=# if the SELECT is okay [CORE/cake/libs/model/datasources/dbo_source.php, line 549] I cannot change the MAX_JOIN_SIZE value because of the lack of admin privileges. I read in some forum that deleting cache solves the problem, but even that's not working for me. Thanks, Mayank

    Read the article

  • Nullability (Regular Expressions)

    - by danportin
    In Brzozowski's "Derivatives of Regular Expressions" and elsewhere, the function d(R) returning ? if a R is nullable, and Ø otherwise, includes clauses such as the following: d(R1 + R2) = d(R1) + d(R2) d(R1 · R2) = d(R1) ? d(R2) Clearly, if both R1 and R2 are nullable then (R1 · R2) is nullable, and if either R1 or R2 is nullable then (R1 + R2) is nullable. It is unclear to me what the above clauses are supposed to mean, however. My first thought, mapping (+), (·), or the Boolean operations to regular sets is nonsensical, since in the base case, d(a) = Ø (for all a ? S) d(?) = ? d(Ø) = Ø and ? is not a set (nor is the return type of d, which is a regular expression). Furthermore, this mapping isn't indicated, and there is a separate notation for it. I understand nullability, but I'm lost on the definition of the sum, product, and Boolean operations in the definition of d: how are ? or Ø returned from d(R1) ? d(R2), for instance, in the definition off d(R1 · R2)?

    Read the article

  • Django Getting RequestContext in custom tag

    - by greggory.hz
    I'm trying to create a custom tag. Inside this custom tag, I want to be able to have some logic that checks if the user is logged in, and then have the tag rendered accordingly. This is what I have: class UserActionNode(template.Node): def __init__(self): pass def render(self, context): if context.user.is_authenticated(): return render_to_string('layout_elements/sign_in_register.html'); else: return render_to_string('layout_elements/logout_settings.html'); def user_actions(parser, test): return UserActionNode() register.tag('user_actions', user_actions) When I run this, I get this error: Caught AttributeError while rendering: 'Context' object has no attribute 'user' The view that renders this looks like this: return render_to_response('start/home.html', {}, context_instance=RequestContext(request)) Why doesn't the tag get a RequestContext object instead of the Context object? How can I get the tag to receive the RequestContext instead of the Context? EDIT: Whether or not it's possible to get a RequestContext inside a custom tag, I'd still be interested to know the "correct" or best way to determine a user's authentication state from within the custom tag. If that's not possible, then perhaps that kind of logic belongs elsewhere? Where?

    Read the article

  • Mixed static and dynamic link on Mac OS

    - by barbaz
    I want to use gcc to produce a shared library, but i want to link some other libraries it depends on statically. Now to produce the "standard" dynamically linked output file i use gcc -dynamiclib *.o -lfoo -lbar -o outfile which would be gcc -shared *.o -lfoo -lbar -o outfile on for a binutils ld on a linux system. Now if i want libfoo and libbar to be linked statically, I can name the static libraries directly gcc -dynamiclib *.o /usr/lib/libfoo.a /usr/lib/libbar.a -o outfile however, that way i have to look for the library files myself. GNU binutils ld supports this: gcc -shared *.o -l:libfoo.a -l:libbar.a -o outfile but apple's ld doesnt. Is there a way to make apple's ld look for the static libraries himself? If not, is there another way that would avoid naming the exact location of the archives, e.g. producing an intermediate output file out of the object files requiring libfoo and libbar with the -static switch and linking that file together with the remaining objectfiles to create the dynamic object?

    Read the article

  • Convert C# Lambda to vb.net

    - by Joven
    Need Help in converting this to VB.NET public void GetCustomers(Action<IEnumerable<Customer>> onSuccess, Action<Exception> onFail) { Manager.Customers.ExecuteAsync(op => { if (op.CompletedSuccessfully) { if (onSuccess != null) onSuccess(op.Results); } else { if (onFail != null) { op.MarkErrorAsHandled(); onFail(op.Error); } } } ); }

    Read the article

  • Computer won't start unless power is removed for ~5 minutes

    - by Paul Tarjan
    I have a fairly standard 2-year old desktop computer (quad-core intel, single hard drive, decent video card, 300W power supply) which recently started acting up. I'm not sure what the cause is, so hopefully you can help. Sometimes (once a week-ish) I press the power button and nothing happens. No blinking, no sounds, no nothing. If I remove the power cord (or flip the switch on the power supply) I hear a capacitor discharge. If I leave it in the "no power at all" state for about 5 minutes then I can put the plug back in and the computer works perfectly. What is the issue? What do you think I have to replace?

    Read the article

  • Trying to use a SmartHost with my Exchange 2010 server

    - by Pure.Krome
    Hi folks, I'm trying to use a SmartHost with my Exchange 2010 Server. SmartHost details: Secure SMTPS: securemail.internode.on.net 465 <-- Note: that's port 465 Configure your existing SMTP settings (in your email program) to: use authentication (enter your Internode username and password, enter your username as [email protected]). enable SSL for sending email (SMTPS). So I've added the smart host details to my Org Config -> Hub Transport. I then used PowerShell to add the port:- Set-SendConnector "securemail.internode.on.net" -port 465 I've then added my username/password (as suggested above) to the SmartHost as Basic Authentication (with no TLS). Then I try sending an email and I get the following error message :- 451 4.4.0 Primary target IP address responded with: "421 4.4.2 Connection dropped due to ConnectionReset." So i'm not sure how to continue. I also tried ticking the TLS box but stll I get the same error. If i don't use SMTPS (secure SMTP, on port 465) and use basic SMTP on port 25 with no Authentication, email gets sent. Any ideas? EDIT: Btw, I can telnet to that server on port 465 from my mail server .. just to make sure i'm not getting firewall'd, etc.

    Read the article

  • Sun Solaris Server Voltage issue

    - by dcd
    I have a sun solaris server which die off recently due to voltage issue Checking with sun solaris support personnel the cost is like 5k or 6k per maintence year support. I am wondering whether it is worth the price or should i instead purchase a new solaris server and redo the setup etc. Any advise anyone? And also is there anyaway i can remove the harddisk in the existing solaris server and put into the new server?

    Read the article

  • What type of malware can reside in windows restore?

    - by qwertymk
    I was reading aking1012's comment on How to create Windows Vista/Windows 7 Startup disk or Rescue disk or system restore points on a CD? . He says that: The first thing I usually do is disable system restore. Some REALLY nasty malware hides in there and is very difficult to delete. As far as rescue media, I make a full backup image. It doesn't directly address the question so it's a comment not an answer, but I thought it was worth noting What type of malware can hide there, and how is that possible as the restore info must be stored with a checksome to make sure it's not modified, right?

    Read the article

  • How do I get the Grub menu back after installing Windows on a separate disk?

    - by Shazzner
    Tried sudo grub-install on sda1 but it complained about being a BAD IDEA. I had to install windows for a work related issue so I used a separate disk (I had used it for ubuntu on this computer, but bought a bigger disk so installed ubuntu on that and left the old one in in case I needed an old file). Windows installed fine but overwrote Grub. So if I choose the Ubuntu disk to boot first in BIOS I get a blank screen. I googled and followed this advice: https://help.ubuntu.com/community/RecoveringUbuntuAfterInstallingWindows However, when I get down to this section: sudo grub-install --root-directory=/media/0d104aff-ec8c-44c8-b811-92b993823444 /dev/sda1 I get this: Attempting to install GRUB to a partition instead of the MBR. This is a BAD idea… --recheck does nothing. Any ideas?

    Read the article

  • No database selected error in CodeIgniter running on MAMP stack

    - by Apophenia Overload
    First off, does anyone know of a good place to get help with CodeIgniter? The official community forums are somewhat disappointing in terms of getting many responses. I have ci installed on a regular MAMP stack, and I’m working on this tutorial. However, I have only gone through the Created section, and currently I am getting a No database selected error. Model: <?php class submit_model extends Model { function submitForm($school, $district) { $data = array( 'school' => $school, 'district' => $district ); $this->db->insert('your_stats', $data); } } View: <?php $this->load->helper('form'); ?> <?php echo form_open('main'); ?> <p> <?php echo form_input('school'); ?> </p> <p> <?php echo form_input('district'); ?> </p> <p> <?php echo form_submit('submit', 'Submit'); ?> </p> <?php echo form_close(); ?> Controller: <?php class Main extends controller { function index() { // Check if form is submitted if ($this->input->post('submit')) { $school = $this->input->xss_clean($this->input->post('school')); $district = $this->input->xss_clean($this->input->post('district')); $this->load->model('submit_model'); // Add the post $this->submit_model->submitForm($school, $district); } $this->load->view('main_view'); } } database.php $db['default']['hostname'] = "localhost:8889"; $db['default']['username'] = "root"; $db['default']['password'] = "root"; $db['default']['database'] = "stats_test"; $db['default']['dbdriver'] = "mysql"; $db['default']['dbprefix'] = ""; $db['default']['pconnect'] = TRUE; $db['default']['db_debug'] = TRUE; $db['default']['cache_on'] = FALSE; $db['default']['cachedir'] = ""; $db['default']['char_set'] = "utf8"; $db['default']['dbcollat'] = "utf8_general_ci"; config.php $config['base_url'] = "http://localhost:8888/ci/"; ... $config['index_page'] = "index.php"; ... $config['uri_protocol'] = "AUTO"; So, how come it’s giving me this error message? A Database Error Occurred Error Number: 1046 No database selected INSERT INTO `your_stats` (`school`, `district`) VALUES ('TJHSST', 'FairFax') Is there any way for me to test if CodeIgniter can actually detect the mySQL databases I've created with phpMyAdmin in my MAMP stack?

    Read the article

  • PHP Modify Array

    - by Ozzy
    Hi all, I have the following array: array(a, a, a, b, b, c, c, c, c, d, d); When I loop through it and echo it, the result is: a a a b b c c c c d d How ever I want to echo it in such a way that it displays: a b c d a b c d a c c Here is the array in a grid to better explain what im trying to achieve Current a a a b b c c c c d d What im tryin to do a b c d a b c d a c c How would I do this?

    Read the article

  • savedInstanceState cannot be resolved to a variable

    - by Hector
    I'm currently working through "The Android Developers Cookbook" and one of the tutorials involves multiple activities in an app. To give a bit of background right now I have to .java files, a "menu screen" and a "game screen". The menu screen simply has a button that leads to the game screen which is currently empty except for a button that takes you back to the menu screen. Currently the game.java file is giving me a "savedInstanceState error" this is the code I am working on. public void onCreate(Bundle savedInsanceState) { // below is where the error comes up super.onCreate(savedInstanceState); setContentView(R.layout.game); Button startButton = (Button) findViewById(R.id.end_game); startButton.setOnClickListener(new OnClickListener() { public void onClick(View view) { finish(); } }); } I'm not sure why the error is coming up because on the first java file that same "public void...setContentView..." bit of code compiled perfectly fine... Please help!

    Read the article

  • Getting started with nexus s NFC/RFID

    - by Chuck Fletcher
    Getting started with Nexus S NFC/RFID. Can anyone provide any guidance? I'm interested in creating some home brew demos using the nexus s NFC/RFID hardware. I think I need to find the appropriate tags and how to encode urls into tags that the nexus s can read by it's tags app. Not sure about iso 14443 tags or mifare etc Does nexus s support all of libnfc? If I root the device can I get access to write functionality? Thanks

    Read the article

  • Unexpected output from Bubblesort program with MSVC vs TCC

    - by Sujith S Pillai
    One of my friends sent this code to me, saying it doesn't work as expected: #include<stdio.h> void main() { int a [10] ={23, 100, 20, 30, 25, 45, 40, 55, 43, 42}; int sizeOfInput = sizeof(a)/sizeof(int); int b, outer, inner, c; printf("Size is : %d \n", sizeOfInput); printf("Values before bubble sort are : \n"); for ( b = 0; b &lt; sizeOfInput; b++) printf("%d\n", a[b]); printf("End of values before bubble sort... \n"); for ( outer = sizeOfInput; outer &gt; 0; outer-- ) { for ( inner = 0 ; inner &lt; outer ; inner++) { printf ( "Comparing positions: %d and %d\n",inner,inner+1); if ( a[inner] &gt; a[inner + 1] ) { int tmp = a[inner]; a[inner] = a [inner+1]; a[inner+1] = tmp; } } printf ( "Bubble sort total array size after inner loop is %d :\n",sizeOfInput); printf ( "Bubble sort sizeOfInput after inner loop is %d :\n",sizeOfInput); } printf ( "Bubble sort total array size at the end is %d :\n",sizeOfInput); for ( c = 0 ; c &lt; sizeOfInput; c++) printf("Element: %d\n", a[c]); } I am using Micosoft Visual Studio Command Line Tool for compiling this on a Windows XP machine. cl /EHsc bubblesort01.c My friend gets the correct output on a dinosaur machine (code is compiled using TCC there). My output is unexpected. The array mysteriously grows in size, in between. If you change the code so that the variable sizeOfInput is changed to sizeOfInputt, it gives the expected results! A search done at Microsoft Visual C++ Developer Center doesn't give any results for "sizeOfInput". I am not a C/C++ expert, and am curious to find out why this happens - any C/C++ experts who can "shed some light" on this? Unrelated note: I seriously thought of rewriting the whole code to use quicksort or merge sort before posting it here. But, after all, it is not Stooge sort... Edit: I know the code is not correct (it reads beyond the last element), but I am curious why the variable name makes a difference.

    Read the article

  • Resizing a UIButton programmatically by maintaining a margin

    - by Oscar Del Ben
    Hello, I'm adding a UIButton to a tableView footer programmatically. This button has a left and right margin that is equal to the tableView margin: UIButton *deleteButton = [UIButton buttonWithType:UIButtonTypeRoundedRect]; deleteButton.frame = CGRectMake(10, 60, 300, 34); deleteButton.autoresizingMask = UIViewAutoresizingFlexibleWidth I'm adding autoresizingMask because I want to support rotation. However, it does not work as I want, as the button stretches all the way down to the right, as shown by the image below. Any idea how to fix it? If I remove the autosizing property then the margin is correct.

    Read the article

  • django admin gives warning "Field 'X' doesn't have a default value"

    - by noam
    I have created two models out of an existing legacy DB , one for articles and one for tags that one can associate with articles: class Article(models.Model): article_id = models.AutoField(primary_key=True) text = models.CharField(max_length=400) class Meta: db_table = u'articles' class Tag(models.Model): tag_id = models.AutoField(primary_key=True) tag = models.CharField(max_length=20) article=models.ForeignKey(Article) class Meta: db_table = u'article_tags' I want to enable adding tags for an article from the admin interface, so my admin.py file looks like this: from models import Article,Tag from django.contrib import admin class TagInline(admin.StackedInline): model = Tag class ArticleAdmin(admin.ModelAdmin): inlines = [TagInline] admin.site.register(Article,ArticleAdmin) The interface looks fine, but when I try to save, I get: Warning at /admin/webserver/article/382/ Field 'tag_id' doesn't have a default value

    Read the article

  • Get a font filename based on Font Name and Style (Bold/Italic)

    - by Brad
    This has been driving me crazy all day. I need to get a font filename (eg. Arial.ttf) based off of it's name (Arial in this case). The problem is, I am only supplied with the font name (Arial) and weather it's bold, italic or both. Using those pieces of information, I need to find the font file so I can use it for rendering. Some more examples: Calibri, Bold would resolve to calibrib.ttf Calibri, Italic would resolve to calibrii.ttf Any ideas on how I could achieve this in C++ (Win32)

    Read the article

  • save html-formatted text to database

    - by yozhik
    Hi all! I want to save html-formatted text to database, but when I do that it is don't save html-symbols like < / ' and others This is how I read article from database for editing: <p class="Title">??????????? ???????:</p> <textarea name="EN" cols="90" rows="20" value="<?php echo $articleArr['EN']; ?>" ></textarea> And this is how I save it to database: function UpdateArticle($ArticleID, $ParentName, $Title, $RU, $EN, $UKR) { //fetch data from database for dropdown lists //connect to db or die) $db = mysql_connect($GLOBALS["gl_dbName"], $GLOBALS["gl_UserName"], $GLOBALS["gl_Password"] ) or die ("Unable to connect"); //to prevenr ????? symbols in unicode - utf-8 coding mysql_query("SET NAMES 'UTF8'"); mysql_set_charset('utf8'); mysql_query("SET NAMES 'utf8' COLLATE 'utf8_general_ci'"); //select database mysql_select_db($GLOBALS["gl_adminDatabase"], $db); $sql = "UPDATE Articles SET AParentName='".$ParentName."', ATitle='".$Title."', RU='".$RU."', EN='".$EN."', UKR='".$UKR."' WHERE ArticleID='".$ArticleID."';"; //execute SQL-query $result = mysql_query($sql, $db); if (!$result) { die('Invalid query: ' . mysql_error()); } //close database = very inportant mysql_close($db); } Help me please, how can I save such texts properly, Thanx!

    Read the article

  • Nightmare: Upgrading Tomcat 5.5 to 6.0

    - by pavanlimo
    I'm trying to upgrade a perfectly running embedded Tomcat 5.5 to Tomcat 6.0. I understand that all I need to do is replace Tomcat 5.5 jars with 6.0. That's what I did. So I replaced the following jars: catalina-5.0.28.jar catalina-5.5.9.jar catalina-optional-5.5.9.jar commons-el.jar commons-modeler-1.1.0.jar jasper-compiler-jdt.jar jasper-compiler.jar jasper-runtime.jar jmx-5.0.28.jar jsp-api-2.0.jar naming-factory.jar naming-resources.jar servlet-api-2.4.jar servlets-default.jar tomcat-coyote.jar tomcat-http.jar tomcat-util.jar with: annotations-api.jar catalina.jar jasper.jar tomcat-dbcp.jar catalina-ant.jar el-api.jar jsp-api.jar tomcat-i18n-es.jar catalina-ha.jar jasper-el.jar servlet-api.jar tomcat-i18n-fr.jar catalina-tribes.jar jasper-jdt.jar tomcat-coyote.jar tomcat-i18n-ja.jar tomcat-juli.jar As soon as I start the server, I get the following message in the logs at INFO level: INFO: Starting Servlet Engine: Apache Tomcat/6.0.29 Dec 31, 2010 6:04:18 AM org.apache.catalina.loader.WebappClassLoader validateJarFile INFO: validateJarFile(/usr/local/blah/blue/./WEB-INF/lib/servlet-api.jar) - jar not loaded. See Servlet Spec 2.3, section 9.7.2. Offending class: javax/servlet/Servlet.class Based on the this explanation, I need to remove a jar file which has a conflicting Servlet.class. I swear to God, there is no other conflicting jar file, I grepped system wide for Servlet.class, it matched only servlet-api.jar. I also downloaded javaee.jar and replaced it by servlet-api.jar, to same avail. Having tried lot of these stuff, I did not have much to look upto, so set the tomcat logging level to ALL. In the log I could see that it is trying to check for Servlet.class in each and every jar it is loading until it finds servlet-api.jar and throws "jar not loaded" message as soon as it finds servlet-api.jar. See below: FINE: Checking for javax/servlet/Servlet.class Jan 2, 2011 7:39:33 AM org.apache.catalina.loader.WebappLoader setRepositories FINE: Deploy JAR /WEB-INF/lib/servlet-api.jar to /usr/local/blah/blue/./WEB-INF/lib/servlet-api.jar Jan 2, 2011 7:39:33 AM org.apache.catalina.loader.WebappClassLoader addJar FINE: addJar(/WEB-INF/lib/servlet-api.jar) Jan 2, 2011 7:39:33 AM org.apache.catalina.loader.WebappClassLoader validateJarFile FINE: Checking for javax/servlet/Servlet.class Jan 2, 2011 7:39:33 AM org.apache.catalina.loader.WebappClassLoader validateJarFile INFO: validateJarFile(/usr/local/blah/blue/./WEB-INF/lib/servlet-api.jar) - jar not loaded. See Servlet Spec 2.3, section 9.7.2. Offending class: javax/servlet/Servlet.class Jan 2, 2011 7:39:33 AM org.apache.catalina.loader.WebappLoader setRepositories Please note however, that Tomcat starts successfully! And as soon as I hit the URL on the browser, I get blank page(this may be in my case only, I guess 'cuz of my web.xml, sorta different from most. Other people on the internet have got Error 404 instead.) with following log statements(at finest level) Jan 2, 2011 9:40:01 AM org.apache.catalina.connector.CoyoteAdapter parseSessionCookiesId FINE: Requested cookie session id is 0FBA716E3F9B0147C3AF7ABAE3B1C27B Jan 2, 2011 9:40:01 AM org.apache.catalina.authenticator.AuthenticatorBase invoke FINE: Security checking request GET /login.jsp Jan 2, 2011 9:40:01 AM org.apache.catalina.realm.RealmBase findSecurityConstraints FINE: Checking constraint 'SecurityConstraint[protected]' against GET /login.jsp --> false Jan 2, 2011 9:40:01 AM org.apache.catalina.realm.RealmBase findSecurityConstraints FINE: Checking constraint 'SecurityConstraint[protected]' against GET /login.jsp --> false Jan 2, 2011 9:40:01 AM org.apache.catalina.realm.RealmBase findSecurityConstraints FINE: Checking constraint 'SecurityConstraint[protected]' against GET /login.jsp --> false Jan 2, 2011 9:40:01 AM org.apache.catalina.realm.RealmBase findSecurityConstraints FINE: Checking constraint 'SecurityConstraint[protected]' against GET /login.jsp --> false Jan 2, 2011 9:40:01 AM org.apache.catalina.realm.RealmBase findSecurityConstraints FINE: No applicable constraint located Jan 2, 2011 9:40:01 AM org.apache.catalina.authenticator.AuthenticatorBase invoke FINE: Not subject to any constraint Jan 2, 2011 9:40:01 AM org.apache.catalina.core.StandardWrapper allocate FINEST: Returning non-STM instance I'm not sure if the above log message is important, but I'm for all-out disclosure here. One interesting thing though, I manually created a dummy jsp file containing only "helloooo" just outside WEB-INF folder(no security constraints for this file). This file was accessible and could be displayed. But, all my jsp's and classes are inside WEB-INF(ofcourse). Sick and tired of this issue, please help me solve it. I've already spent 20-24 hours on this unsuccessfully. Any pointers directions hints leads?

    Read the article

  • Pong: How does the paddle know where the ball will hit?

    - by Roflcoptr
    After implementing Pacman and Snake I'm implementing the next very very classic game: Pong. The implementation is really simple, but I just have one little problem remaining. When one of the paddle (I'm not sure if it is called paddle) is controlled by the computer, I have trouble to position it at the correct position. The ball has a current position, a speed (which for now is constant) and a direction angle. So I could calculate the position where it will hit the side of the computer controlled paddle. And so Icould position the paddle right there. But however in the real game, there is a probability that the computer's paddle will miss the ball. How can I implement this probability? If I only use a probability of lets say 0.5 that the computer's paddle will hit the ball, the problem is solved, but I think it isn't that simple. From the original game I think the probability depends on the distance between the current paddle position and the position the ball will hit the border. Does anybody have any hints how exactly this is calculated?

    Read the article

  • Android app unexpectedly quitted when I closed the bluetooth serversocket or bluetooth socket

    - by Lewisou
    The android app quitted without any warning and error when bluetoothServersocket.close() called in the main thread while bluetoothServersocket.accept(); was blocked for incoming connections in another thread. Here is pieces of my code. public void run() { try { bluetoothServerSocket = BluetoothAdapter. getDefaultAdapter().listenUsingRfcommWithServiceRecord(LISTEN_NAME, LISTEN_UUID); /* the thread blocked here for incoming connections */ bluetoothSocket = bluetoothServerSocket.accept(); ... } catch(Exception e) {} finally { try {bluetoothServerSocket.close();} catch(Exception ex) {} try {bluetoothSocket.close();} catch(Exception ex) {} } } And in the activity. public void onStop () { try{thread.bluetoothSocket.close();} catch(Exception ex) {} try{thread.bluetoothServerSocket.close();} catch(Exception ex) {} super.onStop(); } When I clicked the back button. The activity closed but after about one second the app quitted without any warning. My android os version is 2.2. a HTC Desire device.

    Read the article

  • Load SWF data without loading sound, then load sound later

    - by Jon Sandness
    So, hypothetical situation here: I have an SWF that's 30MB. Sound files (music) make up 25MB, art and other things make up the remaining 5MB. Would it be possible for me to load the 5MB of necessary art and other things first to allow the user to operate the app, then after that's all loaded and they are operating the app, load the remaining 25MB of sound files in the background? UPDATE: Loading SWF externally is not an option.

    Read the article

< Previous Page | 5 6 7 8 9 10 11 12 13 14 15 16  | Next Page >