Daily Archives

Articles indexed Thursday June 27 2013

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

  • Finding vectors with two points

    - by Christian Careaga
    We're are trying to get the direction of a projectile but we can't find out how For example: [1,1] will go SE [1,-1] will go NE [-1,-1] will go NW and [-1,1] will go SW we need an equation of some sort that will take the player pos and the mouse pos and find which direction the projectile needs to go. Here is where we are plugging in the vectors: def update(self): self.rect.x += self.vector[0] self.rect.y += self.vector[1] Then we are blitting the projectile at the rects coords.

    Read the article

  • Has "Killer Game Programming in Java" by Andrew Davison been rendered useless? What new tutorial should I follow? [duplicate]

    - by BDillan
    This question already has an answer here: Killer Game Programming [Java 3D] outdated? 5 answers Its pathetic how it was created in 2005 not so long ago when the Java 3D 1.31 API was released. Now after downloading the source code off the books website and implementing it onto my work-space it cant run. (The 3D Shooter Ch. 23) I downloaded Java 3D 1.5 API, installed it- went back to my source code and javax.media ect.., and EVERY imported class within the game simply couldn't be resolved... they are all outdated.. Please do not say how its meant for a positive curvature in your game development skills. No ~ I got the book to understand how to code 3D textures/particle systems/games. Without seeing results how can I learn? If there is still hope for this book please tell me. Otherwise what other books match this one in Game Programming? This one was very well organized, documented and long. I am not looking for a 3D game prog. book on Java. Rather one that has the same reputation as this one but is a bit newer..

    Read the article

  • What helped YOU learn C++? [on hold]

    - by Tips48
    So here's my attempt to not get this question closed for too subjective :P I'm a young programmer, specifically interested in Game Development. I've written my first couple games in Java, which I would consider my self intermediate-Advanced in. As I start to prepare myself for college and (hopefully) internships, I've noticed that learning C/C++ is essential to the industry. I've decided to start with C++, and so I read a couple of books that I saw were suggested. Anyway, now I have a decent understanding of the basics, but I really want to enhance my language knowledge. Instead of just asking for things to do, I was wondering what were some exercises that you did that really helped you understand the language? Preferably they would be near the beginner level. I understand that they obviously won't be directly related to Game Development, but it be nice if there were some things that I could transfer over eventually. (Specifically, I struggle with memory (pointers, etc) since there is no such concept in Java) Thanks! - Tips P.S.: Here's to hoping this isn't to subjective :P

    Read the article

  • Export a .FBX file in Unity3D at runtime

    - by Timothy Williams
    What I'm looking to do is be able to export an object as a .FBX at runtime in Unity3D. I've made a C# script which can export a mesh filter or skinned mesh renderer to a .OBJ file at runtime, but .OBJ doesn't support the same kind of animations and skins that .FBX does. I've been researching this for a while, as of right now it looks like somehow using the Autodesk FBX SDK or some other external .dll would be my best option. Does anyone know of external .dlls I could use for this? Or how to make calls to Autodesk's FBX SDK at runtime? Another option could possibly be to write the mesh information as a text file then convert to .FBX on exporting. Just looking for fellow programmer's thoughts, or tips, or to see if this has been accomplished already. As far as I can tell there isn't any pre-existing scripts to export FBX at runtime in Unity.

    Read the article

  • Set a 2d camera's position so that a building is under the players feet

    - by Potato
    My issue is this: i am making a scrolling game in XNA, and the camera updates based on the players velocity, but the player never actually moves, he is always in the center of the screen. When he hits the top of the building though i want him to always be on top and sink through the texture in a way like this: what i am doing to make this happen is i am just setting his velocity to 0, so its not moving, but the more velocity he hits a building with the more he sinks through it. I also tried setting the buildings position to the plays Bounding Box's bottom, and this achieved the look i wanted but this also resulted in the other buildings rising in the air, because the velocity was still moving (even if i set it to 0). if it was not a scrolling game, this would be not a problem, because you just set the players position to the top of the building, but because the player never actually moves, i actually need to move the camera to the point where the building is under the players feet without the other buildings rising. (Take note this is note a real camera, it is just a class that moves the objects in the world based on the players velocity). All questions are welcome.

    Read the article

  • Scrolling Box2D DebugDraw

    - by onedayitwillmake
    I'm developing a game using Box2D (javascript implementation - Box2DWeb), and I would like to know how I can pan the debug draw. I know the usual answer is - don't use debug draw, it's just for debugging. I'm not, however not all my objects are on the same screen, and i'd like to see where they are in the physics representation. How can I pan the debug drawing? As you can see the debug draw stuff, is show on the top left, but it only shows a small part of the world. Here is an example of what I mean: http://onedayitwillmake.com/ChuClone/ The game is open source, If you'd like to poke through and note something that perhaps i'm doing something that is obviously wrong: https://github.com/onedayitwillmake/ChuClone Here's my hacky way that I'm using now to scroll the b2DebugDraw view, in which I added a property offsetX and offsetY into b2DebugDraw

    Read the article

  • MultipartFormDataContent Access to patch xx is denied

    - by Florian Schaal
    So I'm trying to upload a pdf file to a restapi. For some reason I the application cant get access to the files on my pc. The code im using to upload: public void Upload(string token, string FileName, string FileLocation, string Name, int TypeId, int AddressId, string CompanyName, string StreetNr, string Zip, string City, string CountryCode, string CustomFieldName, string CustomFieldValue) { var client = new HttpClient(); client.BaseAddress = _API.baseAddress; //upload a new form client.DefaultRequestHeaders.Date = DateTime.Now; client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue(token); using (var multiPartContent = new MultipartFormDataContent()) { //get te bytes from a file byte[] pdfData; using (var pdf = new FileStream(@FileLocation, FileMode.Open))//Here i get the error. { pdfData = new byte[pdf.Length]; pdf.Read(pdfData, 0, (int)pdf.Length); } var fileContent = new ByteArrayContent(pdfData); fileContent.Headers.ContentDisposition = new ContentDispositionHeaderValue("attachment") { FileName = FileName + ".pdf" }; //add the bytes to the multipart message multiPartContent.Add(fileContent); //make a json message var json = new FormRest { Name = Name, TypeId = TypeId, AddressId = AddressId, CompanyName = CompanyName, StreetNr = StreetNr, Zip = Zip, City = City, CountryCode = CountryCode, CustomFields = new List<CustomFieldRest> { new CustomFieldRest {Name = CustomFieldName, Value = CustomFieldValue} } }; var Content = new JsonContent(json); //add the json message to the multipart message multiPartContent.Add(Content); var result = client.PostAsync("forms", multiPartContent).Result; } } }

    Read the article

  • skip after_filter in controller before_filter

    - by Rafael Carício
    I'm using Intercom rails in my application and I would like to not include intercom script in a certain situation. So, I would like to skip the intercom after_filter when a value is set in the user session. I tried that, but it didn't worked: class ApplicationController < ActionController::Base before_filter :verify_session def verify_session if skip_intercom? self.class.skip_after_filter :intercom_rails_auto_include end end end Any idea if it's possible?

    Read the article

  • php | Multidimensional array sorting

    - by user889349
    I have an array and need to be sorted (based on id): Array ( [0] => Array ( [qty] => 1 [id] => 3 [name] => Name1 [sku] => Model 1 [options] => [price] => 100.00 ) [1] => Array ( [qty] => 2 [id] => 1 [name] => Name2 [sku] => Model 1 [options] => Color: <em>Black (+10$)</em>. Memory: <em>32GB (+99$)</em>. [price] => 209.00 ) ) Is it possible to sort my array to get output (id based)? Array ( [0] => Array ( [qty] => 2 [id] => 1 [name] => Name2 [sku] => Model 1 [options] => Color: <em>Black (+10$)</em>. Memory: <em>32GB (+99$)</em>. [price] => 209.00 ) [1] => Array ( [qty] => 1 [id] => 3 [name] => Name1 [sku] => Model 1 [options] => [price] => 100.00 ) ) Thanks!

    Read the article

  • D3.js: "NS_ERROR_DOM_BAD_URI: Access to restricted URI denied"

    - by user2102328
    I have an html-file with several d3-graphs directly written in script tags into it. When I outsource one of the graphs into an external js file I get this message "NS_ERROR_DOM_BAD_URI: Access to restricted URI denied". If I delete the code with d3.json where it reads a local json file the error disappears. But it has to be possible to load a json file in an external js which is embedded into an html, right? d3.json("forcetree.json", function(json) { root = json; update(); });

    Read the article

  • php link to call another php page

    - by user2086894
    i have a php page which contain this field: Delete i want when i press on the Delete to call the delcat.php and send a categoryid which is in a field in the same table. any one can help me to reach this please? here my complete table code: <table border="0" align='center' class="styled-table"> <tr class="thh"> <th class="thh">Category Code</th> <th class="thh">Category Name </th> <th class="thh">Category IMage </th> <th class="thh">Edit</th> <th class="thh">Delete</th> </tr> <?php for ($counter = 0; $row = mysql_fetch_row ($resultSet); $counter++) { print ("<tr align='center' class='trh'>"); print ("<td align='center' class='tdh'>$row[0]</td>"); print ("<td align='center' class='tdh'>$row[1]</td>"); print ("<td align='center' class='tdh'><img src='$row[2]' width='50' height='50'></td>"); print ("<td align='center' class='tdh' width='50' align='center'><a href src='#'>Edit</a></td>"); print ("<td align='center' class='tdh' width='50' align='center'><a href src='delcat.php'>Delete</a></td>"); print("</tr>"); }

    Read the article

  • Capturing wildcards in java generics

    - by Rollerball
    From this orcale java tutorial: The WildcardError example produces a capture error when compiled: import java.util.List; public class WildcardError { void foo(List<?> i) { i.set(0, i.get(0)); } } After this error demonstration, they fix the problem by using a helper method: public class WildcardFixed { void foo(List<?> i) { fooHelper(i); } // Helper method created so that the wildcard can be captured // through type inference. private <T> void fooHelper(List<T> l) { l.set(0, l.get(0)); } } First, they say that the list input parameter (i) is seen as an Object: In this example, the compiler processes the i input parameter as being of type Object. Why then i.get(0) does not return an Object? if it was already passed in as such? Furthermore what is the point of using a <?> when then you have to use an helper method using <T>. Would not be better using directly which can be inferred?

    Read the article

  • MySQL: selecting totals as three fields from same table as one query?

    - by coderama
    I have a table with various orders in it: ID | Date | etc... 1 | 2013-01-01 | etc 2 | 2013-02-01 | etc 3 | 2013-03-01 | etc 4 | 2013-04-01 | etc 5 | 2013-05-01 | etc 6 | 2013-06-01 | etc 7 | 2013-06-01 | etc 8 | 2013-03-01 | etc 9 | 2013-04-01 | etc 10 | 2013-05-01 | etc I want a query that ends wit the result: overallTotal | totalThisMonth | totalLastMonth 10 | 2 | 1 But I want to do this in one query! I am trying to find a way to use subqueries to do this. SO far I have: SELECT * from ( SELECT count(*) as overallTotal from ORDERS ) How can I combine this with other subqueries so I can get the totals in one query?

    Read the article

  • How to validate my Alexa code <noscript> tag in Head section

    - by Naveen Valecha
    The doctype and HTML tag of my page is below: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML+RDFa 1.1//EN" "http://www.w3.org/MarkUp/DTD/xhtml-rdfa-2.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" version="XHTML+RDFa 1.1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.w3.org/1999/xhtml http://www.w3.org/MarkUp/SCHEMA/xhtml-rdfa-2.xsd" xmlns:og="http://ogp.me/ns#" xml:lang="en" lang="en" dir="ltr">

    Read the article

  • When not to do maximum compression in png?

    - by user1444680
    Intro When saving png images through GIMP, I've always used level 9 (maximum) compression, as I knew that it's lossless. Now I've to specify compression level when saving png format image through GD extension of PHP. Question Is there any case when I shouldn't compress PNG to maximum level? Like any compatibility issues? If there's no problem then why to ask user; why not automatically compress to max?

    Read the article

  • Replacing Text which does not match a pattern in Oracle

    - by kutekrish
    I have below text in a CLOB in a table Table Name: tbl1 Columns col1 - number (Primary Key) col2 - clob (as below) Row#1 ----- Col1 = 1 Col2 = 1331882981,ab123456,Some text here which can run multiple lines and have a lot of text... ~1331890329,pqr123223,Some more text... Row#2 ----- Col1 = 2 Col2 = 1331882981,abc333,Some text here which can run multiple lines and have a lot of text... ~1331890329,pqrs23,Some more text... Now I need to know how we can get below output Col1 Value ---- --------------------- 1 1331882981,ab123456 1 1331890329,pqr123223 2 1331882981,abc333 2 1331890329,pqrs23 ([0-9]{10},[a-z 0-9]+.), == This is the regular expression to match "1331890329,pqrs23" and I need to know how can replace which are not matching this regex and then split them into multiple rows

    Read the article

  • clang does not compile but g++ does

    - by user1095108
    Can someone help me with this code: #include <type_traits> #include <vector> struct nonsense { }; template <struct nonsense const* ptr, typename R> typename std::enable_if<!std::is_void<R>::value, int>::type fo(void* const) { return 0; } template <struct nonsense const* ptr, typename R> typename std::enable_if<std::is_void<R>::value, int>::type fo(void* const) { return 1; } typedef int (*func_type)(void*); template <std::size_t O> void run_me() { static struct nonsense data; typedef std::pair<char const* const, func_type> pair_type; std::vector<pair_type> v; v.push_back(pair_type{ "a", fo<&data, int> }); v.push_back(pair_type{ "b", fo<&data, void> }); } int main(int, char*[]) { run_me<2>(); return 0; } clang-3.3 does not compile this code, but g++-4.8.1 does, which of the two compiler is right? Is something wrong with the code, as I suspect? The error reads: a.cpp:32:15: error: no matching constructor for initialization of 'pair_type' (aka 'pair<const char *const, func_type>') v.push_back(pair_type{ "a", fo<&data, int> }); ^ ~~~~~~~~~~~~~~~~~~~~~~~ a.cpp:33:15: error: no matching constructor for initialization of 'pair_type' (aka 'pair<const char *const, func_type>') v.push_back(pair_type{ "b", fo<&data, void> }); ^ ~~~~~~~~~~~~~~~~~~~~~~~~

    Read the article

  • Maven Error - Expected START_TAG or END_TAG not TEXT

    - by onepotato
    I am setting up a spring mvc web application + hibernate jpa + maven from scratch using Eclipse Indigo. I am stuck in this error when doing a Maven build. [ERROR] BUILD ERROR [INFO] ------------------------------------------------------------------------ [INFO] Error installing artifact's metadata: Error installing metadata: Error updating group repository metadata expected START_TAG or END_TAG not TEXT (position: TEXT seen ...<extension>war</... @13:25) [INFO] ------------------------------------------------------------------------ I tried googling but can't find a solution that works for me. I even search the whole project for the text <extension>war</ and mysteriously, there is no text like this in my project. However, in the tomcat web.xml there are a lot of <extension> tag, but I doubt that it has something to do in this error because I never touched that web.xml Here is my pom.xml <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> <modelVersion>4.0.0</modelVersion> <groupId>com.mycompany.applicationname</groupId> <artifactId>Application MVC</artifactId> <packaging>war</packaging> <version>0.0.1-SNAPSHOT</version> <name>Maven Application Webapp</name> <url>http://maven.apache.org</url> <properties> <spring.version>3.0.3.RELEASE</spring.version> </properties> <dependencies> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-core</artifactId> <version>${spring.version}</version> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-web</artifactId> <version>${spring.version}</version> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-webmvc</artifactId> <version>${spring.version}</version> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-webmvc</artifactId> <version>${spring.version}</version> </dependency> <dependency> <groupId>org.hibernate.javax.persistence</groupId> <artifactId>hibernate-jpa-2.0-api</artifactId> <version>1.0.0.Final</version> </dependency> </dependencies> <build> <finalName>ApplicationName</finalName> </build> </project> As Funtik has suggested, I did a build with -X. Here is the stacktrace. [INFO] ------------------------------------------------------------------------ [ERROR] BUILD ERROR [INFO] ------------------------------------------------------------------------ [INFO] Error installing artifact's metadata: Error installing metadata: Error updating group repository metadata expected START_TAG or END_TAG not TEXT (position: TEXT seen ...<extension>war</... @13:25) [INFO] ------------------------------------------------------------------------ [DEBUG] Trace org.apache.maven.lifecycle.LifecycleExecutionException: Error installing artifact's metadata: Error installing metadata: Error updating group repository metadata at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoals(DefaultLifecycleExecutor.java:583) at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalWithLifecycle(DefaultLifecycleExecutor.java:499) at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoal(DefaultLifecycleExecutor.java:478) at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalAndHandleFailures(DefaultLifecycleExecutor.java:330) at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeTaskSegments(DefaultLifecycleExecutor.java:291) at org.apache.maven.lifecycle.DefaultLifecycleExecutor.execute(DefaultLifecycleExecutor.java:142) at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:336) at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:129) at org.apache.maven.cli.MavenCli.main(MavenCli.java:287) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:592) at org.codehaus.classworlds.Launcher.launchEnhanced(Launcher.java:315) at org.codehaus.classworlds.Launcher.launch(Launcher.java:255) at org.codehaus.classworlds.Launcher.mainWithExitCode(Launcher.java:430) at org.codehaus.classworlds.Launcher.main(Launcher.java:375) Caused by: org.apache.maven.plugin.MojoExecutionException: Error installing artifact's metadata: Error installing metadata: Error updating group repository metadata at org.apache.maven.plugin.install.InstallMojo.execute(InstallMojo.java:143) at org.apache.maven.plugin.DefaultPluginManager.executeMojo(DefaultPluginManager.java:451) at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoals(DefaultLifecycleExecutor.java:558) ... 16 more Caused by: org.apache.maven.artifact.installer.ArtifactInstallationException: Error installing artifact's metadata: Error installing metadata: Error updating group repository metadata at org.apache.maven.artifact.installer.DefaultArtifactInstaller.install(DefaultArtifactInstaller.java:91) at org.apache.maven.plugin.install.InstallMojo.execute(InstallMojo.java:105) ... 18 more Caused by: org.apache.maven.artifact.repository.metadata.RepositoryMetadataInstallationException: Error installing metadata: Error updating group repository metadata at org.apache.maven.artifact.repository.metadata.DefaultRepositoryMetadataManager.install(DefaultRepositoryMetadataManager.java:463) at org.apache.maven.artifact.installer.DefaultArtifactInstaller.install(DefaultArtifactInstaller.java:79) ... 19 more Caused by: org.apache.maven.artifact.repository.metadata.RepositoryMetadataStoreException: Error updating group repository metadata at org.apache.maven.artifact.repository.metadata.AbstractRepositoryMetadata.storeInLocalRepository(AbstractRepositoryMetadata.java:76) at org.apache.maven.artifact.repository.metadata.DefaultRepositoryMetadataManager.install(DefaultRepositoryMetadataManager.java:459) ... 20 more Caused by: org.codehaus.plexus.util.xml.pull.XmlPullParserException: expected START_TAG or END_TAG not TEXT (position: TEXT seen ...<extension>war</... @13:25) at org.codehaus.plexus.util.xml.pull.MXParser.nextTag(MXParser.java:1083) at org.apache.maven.artifact.repository.metadata.io.xpp3.MetadataXpp3Reader.parseVersioning(MetadataXpp3Reader.java:513) at org.apache.maven.artifact.repository.metadata.io.xpp3.MetadataXpp3Reader.parseMetadata(MetadataXpp3Reader.java:352) at org.apache.maven.artifact.repository.metadata.io.xpp3.MetadataXpp3Reader.read(MetadataXpp3Reader.java:866) at org.apache.maven.artifact.repository.metadata.AbstractRepositoryMetadata.updateRepositoryMetadata(AbstractRepositoryMetadata.java:98) at org.apache.maven.artifact.repository.metadata.AbstractRepositoryMetadata.storeInLocalRepository(AbstractRepositoryMetadata.java:68) ... 21 more [INFO] ------------------------------------------------------------------------ [INFO] Total time: 2 seconds [INFO] Finished at: Thu Jun 27 17:36:23 SGT 2013 [INFO] Final Memory: 9M/16M [INFO] ------------------------------------------------------------------------ web.xml <?xml version="1.0" encoding="UTF-8"?> <web-app id="WebApp_ID" version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"> <display-name>Adjustment Tool</display-name> <servlet> <servlet-name>mvc-dispatcher</servlet-name> <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class> <init-param> <param-name>contextConfigLocation</param-name> <param-value>/WEB-INF/spring-mvc.xml</param-value> </init-param> <load-on-startup>1</load-on-startup> </servlet> <servlet-mapping> <servlet-name>mvc-dispatcher</servlet-name> <url-pattern>/</url-pattern> </servlet-mapping> <listener> <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class> </listener> </web-app> Any ideas?

    Read the article

  • Multiple Notifications Not Firing

    - by motionpotion
    I'm scheduling two notifications as shown below. The app is a long-lived app. One local notification is scheduled to run every hour. The other is scheduled to run once per day. Only the second scheduled notification (the hourly notifcation) fires. - (void)scheduleNotification { LogInfo(@"IN scheduleNotification - DELETEYESTERDAY NOTIFICATION SCHEDULED."); UILocalNotification *notif = [[UILocalNotification alloc] init]; NSDictionary *deleteDict = [NSDictionary dictionaryWithObject:@"DeleteYesterday" forKey:@"DeleteYesterday"]; NSCalendar *calendar = [NSCalendar currentCalendar]; NSDateComponents *components = [[NSDateComponents alloc] init]; components = [[NSCalendar currentCalendar] components:NSDayCalendarUnit | NSMonthCalendarUnit | NSYearCalendarUnit fromDate:[NSDate date]]; NSInteger day = [components day]; NSInteger month = [components month]; NSInteger year = [components year]; [components setDay: day]; [components setMonth: month]; [components setYear: year]; [components setHour: 00]; [components setMinute: 45]; [components setSecond: 0]; [calendar setTimeZone: [NSTimeZone systemTimeZone]]; NSDate *dateToFire = [calendar dateFromComponents:components]; notif.fireDate = dateToFire; notif.timeZone = [NSTimeZone systemTimeZone]; notif.repeatInterval = NSDayCalendarUnit; notif.userInfo = deleteDict; [[UIApplication sharedApplication] scheduleLocalNotification:notif]; } and then I schedule this after above: - (void)scheduleHeartBeat { LogInfo(@"IN scheduleHeartBeat - HEARTBEAT NOTIFICATION SCHEDULED."); UILocalNotification *heartbeat = [[UILocalNotification alloc] init]; NSDictionary *heartbeatDict = [NSDictionary dictionaryWithObject:@"HeartBeat" forKey:@"HeartBeat"]; heartbeat.userInfo = heartbeatDict; NSCalendar *calendar = [NSCalendar currentCalendar]; NSDateComponents *components = [[NSDateComponents alloc] init]; components = [[NSCalendar currentCalendar] components:NSDayCalendarUnit | NSMonthCalendarUnit | NSYearCalendarUnit fromDate:[NSDate date]]; NSInteger day = [components day]; NSInteger month = [components month]; NSInteger year = [components year]; [components setDay: day]; [components setMonth: month]; [components setYear: year]; [components setHour: 00]; [components setMinute: 50]; [components setSecond: 0]; [calendar setTimeZone: [NSTimeZone systemTimeZone]]; NSDate *dateToFire = [calendar dateFromComponents:components]; heartbeat.fireDate = dateToFire; heartbeat.timeZone = [NSTimeZone systemTimeZone]; heartbeat.repeatInterval = NSHourCalendarUnit; [[UIApplication sharedApplication] scheduleLocalNotification:heartbeat]; } The above are scheduled when the app launches in the viewDidLoad of the main view controller. - (void)viewDidLoad { [self scheduleNotification]; [self scheduleHeartBeat]; [super viewDidLoad]; //OTHER CODE HERE } Then in the appdelegate I have the following: - (void)application:(UIApplication *)application didReceiveLocalNotification:(UILocalNotification *)notification { LogInfo(@"IN didReceiveLocalNotification NOTIFICATION RECEIVED."); NSString *notificationHeartBeat = nil; NSString *notificationDeleteYesterday = nil; application.applicationIconBadgeNumber = 0; if (notification) { notificationHeartBeat = [notification.userInfo objectForKey:@"HeartBeat"]; notificationDeleteYesterday = [notification.userInfo objectForKey:@"DeleteYesterday"]; LogInfo(@"IN didReceiveLocalNotification HEARTBEAT NOTIFICATION TYPE: %@", notificationHeartBeat); LogInfo(@"IN didReceiveLocalNotification DELETEYESTERDAY NOTIFICATION TYPE: %@", notificationDeleteYesterday); } if ([notificationHeartBeat isEqualToString:@"HeartBeat"]) { //CREATE THE HEARTBEAT LogInfo(@"CREATING THE HEARTBEAT."); //CALL THE FUNCTIONALITY HERE THAT CREATES HEARTBEAT. } if ([notificationDeleteYesterday isEqualToString:@"DeleteYesterday"]) { //DELETE YESTERDAYS RECORDS LogInfo(@"DELETING YESTERDAYS RECORDS."); } } The notification that is scheduled last (scheduleHeartBeat) is the only notification that is fired. Could somebody help me figure out why this is happening?

    Read the article

  • how could I pass closure problems in order to increment a global var

    - by hyptos
    I have a simple goal, I would like to increment a variable but I'm facing the closure problem. I've read why this s happening here How do JavaScript closures work? But I can't find the solution to my problem :/ let's assume this part of code I took from the link. function say667() { // Local variable that ends up within closure var num = 666; var sayAlert = function() { alert(num); //incrementation } num++; return sayAlert; } I would like to increment num within the function and to keep the changes to num. How could I do that ? Here is the JsFiddle where I have my problem, I can't figure out how to increment my totalSize and keep it. http://jsfiddle.net/knLbv/2/ I don't want a local variable that ends up with closure.

    Read the article

  • cakephp phone number validation

    - by hellosheikh
    i am new to cakephp 2.x so i dont know how to do this .. i want to login the user from his email address and phone number..what my intention is if the number in database is this "12345" and the user is trying to login through this number "+12345" he can be login into the system.. i have written a code but i dont know how can i use this or to adjust my code within the auth component as the auth component is autometically logging the user .. here is my controller public function beforeFilter() { parent::beforeFilter(); $this->Auth->authenticate = array( 'Authenticate.Cookie' => array( 'fields' => array( 'username' => 'email', 'password' => 'password' ), 'userModel' => 'User', 'scope' => array('User.active' => 1) ), 'Authenticate.MultiColumn' => array( 'fields' => array( 'username' => 'email', 'password' => 'password' ), 'columns' => array('email', 'mobileNo'), 'userModel' => 'User', ) ); } public function login() { if ($this->Auth->login() || $this->Auth->loggedIn()) { $this->redirect('/users/dashboard'); }else{ $this->layout='logindefault'; $this->set('title_for_layout', 'Account Login'); /*$this->Auth->logout(); $cookie = $this->Cookie->read('Auth.User'); */ if ($this->request->is('post')) { if ($this->Auth->login() || $this->Auth->loggedIn()) { if ($this->Session->check('Auth.User')){ $this->_setCookie($this->Auth->user('idUser')); $this->redirect('/users/dashboard'); } }else { $this->Session->setFlash('Incorrect Email/Password Combination'); } }} } here is the code which i am trying to add .. $mobileNo='+123456789'; if (strpos($mobileNo,'+') !== false) { $mobileNo=str_replace("+", "",$mobileNo); } ?

    Read the article

  • nodejs async.waterfall method

    - by user1513388
    Update 2 Complete code listing var request = require('request'); var cache = require('memory-cache'); var async = require('async'); var server = '172.16.221.190' var user = 'admin' var password ='Passw0rd' var dn ='\\VE\\Policy\\Objects' var jsonpayload = {"Username": user, "Password": password} async.waterfall([ //Get the API Key function(callback){ request.post({uri: 'http://' + server +'/sdk/authorize/', json: jsonpayload, headers: {'content_type': 'application/json'} }, function (e, r, body) { callback(null, body.APIKey); }) }, //List the credential objects function(apikey, callback){ var jsonpayload2 = {"ObjectDN": dn, "Recursive": true} request.post({uri: 'http://' + server +'/sdk/Config/enumerate?apikey=' + apikey, json: jsonpayload2, headers: {'content_type': 'application/json'} }, function (e, r, body) { var dns = []; for (var i = 0; i < body.Objects.length; i++) { dns.push({'name': body.Objects[i].Name, 'dn': body.Objects[i].DN}) } callback(null, dns, apikey); }) }, function(dns, apikey, callback){ // console.log(dns) var cb = []; for (var i = 0; i < dns.length; i++) { //Retrieve the credential var jsonpayload3 = {"CredentialPath": dns[i].dn, "Pattern": null, "Recursive": false} console.log(dns[i].dn) request.post({uri: 'http://' + server +'/sdk/credentials/retrieve?apikey=' + apikey, json: jsonpayload3, headers: {'content_type': 'application/json'} }, function (e, r, body) { // console.log(body) cb.push({'cl': body.Classname}) callback(null, cb, apikey); console.log(cb) }); } } ], function (err, result) { // console.log(result) // result now equals 'done' }); Update: I'm building a small application that needs to make multiple HTTP calls to a an external API and amalgamates the results into a single object or array. e.g. Connect to endpoint and get auth key - pass auth key to step 2 Connect to endpoint using auth key and get JSON results - create an object containing summary results and pass to step 3. Iterate over passed object summary results and call API for each item in the object to get detailed information for each summary line Create a single JSON data structure that contains the summary and detail information. The original question below outlines what I've tried so far! Original Question: Will the async.waterfall method support multiple callbacks? i.e. Iterate over an array thats passed from a previous item in the chain, then invoke multiple http requests each of which would have their own callbacks. e.g, sync.waterfall([ function(dns, key, callback){ var cb = []; for (var i = 0; i < dns.length; i++) { //Retrieve the credential var jsonpayload3 = {"Cred": dns[i].DN, "Pattern": null, "Recursive": false} console.log(dns[i].DN) request.post({uri: 'http://' + vedserver +'/api/cred/retrieve?apikey=' + key, json: jsonpayload3, headers: {'content_type': 'application/json'} }, function (e, r, body) { console.log(body) cb.push({'cl': body.Classname}) callback(null, cb, key); }); } }

    Read the article

  • Summation loop program in Pascal

    - by user2526598
    I am having a bit of an issue with this problem. I am taking a Pascal programming class and this problem was in my logic book. I am required to have the user enter a series of (+) numbers and once he/she enters a (-) number, the program should find the sum of all the (+) numbers. I accomplished this, but now I am attempting part two of this problem, which requires me to utilize a nested loop to run the program x amount of times based on the user's input. The following code is what I have so far and honestly I am stumped: program summation; //Define main program's variables var num, sum, numRun : integer; //Design procedure that will promt user for number of runs procedure numRunLoop ( var numRun : integer ); begin writeln('How many times shall I run this program?'); readln(numRun); end; //Design procedure that will sum a series of numbers //based on user input procedure numPromptLoop( numRun : integer; var num : integer ); var count : integer; begin //Utilize for to establish run limit for count := 1 to numRun do begin //Use repeat to prompt user for numbers repeat writeln('Enter a number: '); readln(num); //Tells program when to sum if num >= 0 then sum := sum + num; until num < 0; end; end; //Design procedure that will display procedure addItion( sum : integer ); begin writeln('The sum is; ', sum); end; begin numRunLoop(numRun); numPromptloop(numRun, num); addItion(sum); readln(); end.

    Read the article

  • jQuery ajax call doesn't seem to do anything at all

    - by icemanind
    I am having a problem with making an ajax call in jQuery. Having done this a million times, I know I am missing something really silly here. Here is my javascript code for making the ajax call: function editEmployee(id) { $('#<%= imgNewEmployeeWait.ClientID %>').hide(); $('#divAddNewEmployeeDialog input[type=text]').val(''); $('#divAddNewEmployeeDialog select option:first-child').attr("selected", "selected"); $('#divAddNewEmployeeDialog').dialog('open'); $('#createEditEmployeeId').text(id); var inputEmp = {}; inputEmp.id = id; var jsonInputEmp = JSON.stringify(inputEmp); debugger; alert('Before Ajax Call!'); $.ajax({ type: "POST", url: "Configuration.aspx/GetEmployee", data: jsonInputEmp, contentType: "application/json; charset=utf-8", dataType: "json", success: function (msg) { alert('success'); }, error: function (msg) { alert('failure'); } }); } Here is my CS code that is trying to be called: [WebMethod] public static string GetEmployee(int id) { var employee = new Employee(id); return Newtonsoft.Json.JsonConvert.SerializeObject(employee, Newtonsoft.Json.Formatting.Indented); } When I try to run this, I do get the alert that says Before Ajax Call!. However, I never get an alert back that says success or an alert that says failure. I did go into my CS code and put a breakpoint on the GetEmployee method. The breakpoint did hit, so I know jQuery is successfully calling the method. I stepped through the method and it executed just fine with no errors. I can only assume the error is happening when the jQuery ajax call is returning from the call. Also, I looked in my event logs just to make sure there wasn't an ASPX error occurring. There is no error in the logs. I also looked at the console. There are no script errors. Anyone have any ideas what I am missing here? `

    Read the article

  • How to display ppt file in Android views using Docx4j

    - by Ganesh
    I am working on Android and using docx4j to view the docx,pptx and xlsx files into my application. I am unable to view the ppt files . I am getting compile time error at SvgExporter class. which is not there in docx4j library. Can any one help me out to get the SvgExporter class library and build my application and get the Svghtml to load on webview for ppt files. my code is as follows. String inputfilepath = System.getProperty("user.dir") + "/sample-docs/pptx/pptx-basic.xml"; // Where to save images SvgExporter.setImageDirPath(System.getProperty("user.dir") + "/sample-docs/pptx/"); PresentationMLPackage presentationMLPackage = (PresentationMLPackage)PresentationMLPackage.load(new java.io.File(inputfilepath)); // TODO - render slides in document order! Iterator partIterator = presentationMLPackage.getParts().getParts().entrySet().iterator(); while (partIterator.hasNext()) { Map.Entry pairs = (Map.Entry)partIterator.next(); Part p = (Part)pairs.getValue(); if (p instanceof SlidePart) { System.out.println( SvgExporter.svg(presentationMLPackage, (SlidePart)p) ); } } // NB: file suffix must end with .xhtml in order to see the SVG in a browser }

    Read the article

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