Daily Archives

Articles indexed Friday June 6 2014

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

  • How to pause and unpause the Particular action of a sprite?

    - by user1609578
    My game has a sprite representing a character. When the character picks up an item, the sprite should stop moving for a period of time. I use CCbezier to make the sprite move, like this: sprite->runaction(x) Now I want the sprite to stop its current action (moving) and later resume it. I can make the sprite stop by using: sprite->stopaction(x) but if I do that, I can't resume the movement. How can I do that?

    Read the article

  • Bounding Box Collision Glitching Problem (Pygame)

    - by Ericson Willians
    So far the "Bounding Box" method is the only one that I know. It's efficient enough to deal with simple games. Nevertheless, the game I'm developing is not that simple anymore and for that reason, I've made a simplified example of the problem. (It's worth noticing that I don't have rotating sprites on my game or anything like that. After showing the code, I'll explain better). Here's the whole code: from pygame import * DONE = False screen = display.set_mode((1024,768)) class Thing(): def __init__(self,x,y,w,h,s,c): self.x = x self.y = y self.w = w self.h = h self.s = s self.sur = Surface((64,48)) draw.rect(self.sur,c,(self.x,self.y,w,h),1) self.sur.fill(c) def draw(self): screen.blit(self.sur,(self.x,self.y)) def move(self,x): if key.get_pressed()[K_w] or key.get_pressed()[K_UP]: if x == 1: self.y -= self.s else: self.y += self.s if key.get_pressed()[K_s] or key.get_pressed()[K_DOWN]: if x == 1: self.y += self.s else: self.y -= self.s if key.get_pressed()[K_a] or key.get_pressed()[K_LEFT]: if x == 1: self.x -= self.s else: self.x += self.s if key.get_pressed()[K_d] or key.get_pressed()[K_RIGHT]: if x == 1: self.x += self.s else: self.x -= self.s def warp(self): if self.y < -48: self.y = 768 if self.y > 768 + 48: self.y = 0 if self.x < -64: self.x = 1024 + 64 if self.x > 1024 + 64: self.x = -64 r1 = Thing(0,0,64,48,1,(0,255,0)) r2 = Thing(6*64,6*48,64,48,1,(255,0,0)) while not DONE: screen.fill((0,0,0)) r2.draw() r1.draw() # If not intersecting, then moves, else, it moves in the opposite direction. if not ((((r1.x + r1.w) > (r2.x - r1.s)) and (r1.x < ((r2.x + r2.w) + r1.s))) and (((r1.y + r1.h) > (r2.y - r1.s)) and (r1.y < ((r2.y + r2.h) + r1.s)))): r1.move(1) else: r1.move(0) r1.warp() if key.get_pressed()[K_ESCAPE]: DONE = True for ev in event.get(): if ev.type == QUIT: DONE = True display.update() quit() The problem: In my actual game, the grid is fixed and each tile has 64 by 48 pixels. I know how to deal with collision perfectly if I moved by that size. Nevertheless, obviously, the player moves really fast. In the example, the collision is detected pretty well (Just as I see in many examples throughout the internet). The problem is that if I put the player to move WHEN IS NOT intersecting, then, when it touches the obstacle, it does not move anymore. Giving that problem, I began switching the directions, but then, when it touches and I press the opposite key, it "glitches through". My actual game has many walls, and the player will touch them many times, and I can't afford letting the player go through them. The code-problem illustrated: When the player goes towards the wall (Fine). When the player goes towards the wall and press the opposite direction. (It glitches through). Here is the logic I've designed before implementing it: I don't know any other method, and I really just want to have walls fixed in a grid, but move by 1 or 2 or 3 pixels (Slowly) and have perfect collision without glitching-possibilities. What do you suggest?

    Read the article

  • Using Single Image for Map in 2D Platformer

    - by Jon
    I'm fairly new to game development, and have been messing around with Slick2D. Currently, my map consists of objects that are represented as rectangles. If I wanted to use am image simlar to: How would I be able to use this image to make a level? That question is a bit vague, but like I said, I'm new to game development and am not familiar with terminology or procedures. But going along with this question, how would I also use non-rectangular objects/platforms? Thanks

    Read the article

  • Pure functional programming and game state

    - by Fu86
    Is there a common technique to handle state (in general) in a functional programming language? There are solutions in every (functional) programming language to handle global state, but I want to avoid this as far as I could. All state in a pure functional manner are function parameters. So I need to put the whole game state (a gigantic hashmap with the world, players, positions, score, assets, enemies, ...)) as a parameter to all functions which wants to manipulate the world on a given input or trigger. The function itself picks the relevant information from the gamestate blob, do something with it, manipulate the gamestate and return the gamestate. But this looks like a poor mans solution for the problem. If I put the whole gamestate into all functions, there is no benefit for me in contrast to global variables or the imperative approach. I could put just the relevant information into the functions and return the actions which will be taken for the given input. And one single function apply all the actions to the gamestate. But most functions need a lot of "relevant" information. move() need the object position, the velocity, the map for collision, position of all enemys, current health, ... So this approach does not seem to work either. So my question is how do I handle the massive amount of state in a functional programming language -- especially for game development?

    Read the article

  • How to keep track of previous scenes and return to them in libgdx

    - by MxyL
    I have three scenes: SceneTitle, SceneMenu, SceneLoad. (The difference between the title scene and the menu scene is that the title scene is what you see when you first turn on the game, and the menu scene is what you can access during the game. During the game, meaning, after you've hit "play!" in the title scene.) I provide the ability to save progress and consequently load a particular game. An issue that I've run into is being able to easily keep track of the previous scene. For example, if you enter the load scene and then decide to change your mind, the game needs to go back to where you were before; this isn't something that can be hardcoded. Now, an easy solution off the top of my head is to simply maintain a scene stack, which basically keeps track of history for me. A simple transaction would be as follows I'm currently in the menu scene, so the top of the stack is SceneMenu I go to the load scene, so the game pushes SceneLoad onto the stack. When I return from the load scene, the game pops SceneLoad off the stack and initializes the scene that's currently at the top, which is SceneMenu I'm coding in Java, so I can't simply pass around Classes as if they were objects, so I've decided implemented as enum for eac scene and put that on the stack and then have my scene managing class go through a list of if conditions to return the appropriate instance of the class. How can I implement my scene stack without having to do too much work maintaining it?

    Read the article

  • What are the pros/cons of using a 3d engine for 2d games?

    - by mrohlf
    What pros or cons should a beginner be aware of when deciding between a 2d game engine (like Slick2D/Flixel/FlashPunk) and a 3d engine (like Unity) for 2d game development? I am just getting started in indie game development, though I have dabbled a bit with Game Maker, Flash, and XNA in the past. I've heard a lot of positive things about Unity, and its cross-platform nature makes it appealing, but as I understand, it's a 3d engine at its core. For a strictly 2d game, are there any compelling reasons to work with a 3d engine like Unity? Or would it just add unneeded complexity to my initial learning experience?

    Read the article

  • Google Maps Controls panel size is displayed wrong

    - by Andrea Giachetto
    I have a weird problem with Google Maps Control. I've tested in a blank page my custom maps with custom markers and everything seems to be ok, also with the control panel. When I tried to import all my code in the page I'm working with ( I use a full screen fluid grid system ) the control panel is displayed with strange size. I tried everything for disable/enable the ui of the Google Maps but the problem remain. The code of my maps are exactly the same, both in my blank page and in my site, but in the site the ui control panel is displayed very strange. Here's the code: <div id="map_canvas2" style="height: 580px; width: 100%;"></div> <script> var image = 'path/to/your/image.png'; var mapOptions = { zoom: 17, center: new google.maps.LatLng(45.499290, 12.621510), mapTypeId: google.maps.MapTypeId.ROADMAP, scrollwheel: false } var map = new google.maps.Map(document.getElementById('map_canvas2'), mapOptions); var myPos = new google.maps.LatLng(45.499290,12.621510); var myMarker = new google.maps.Marker({position: myPos, map: map, icon: 'http://www.factory42.it/jtaca/wordpress/wp-content/uploads/2014/06/pin-map.png' }); </script> </div> Here's an img: http://www.factory42.it/jtaca/wordpress/wp-content/uploads/2014/06/img-maps.png

    Read the article

  • Hibernate one to one with multiple columns

    - by Erdem Emekligil
    How can i bind two columns, using @OneToOne annotation? Lets say I've 2 tables A and B. Table A: id1 (primary key) id2 (pk) other columns Table B: id1 (pk) id2 (pk) other columns In class A i want to write something like this: @OneToOne(fetch = FetchType.EAGER, targetEntity = B.class) @JoinColumn(name = "id1 and id2", referencedColumnName = "id1 and id2") private B b; Is it possible to do this using annotations? Thanks.

    Read the article

  • Phantomjs creating black output from SVG using page.render

    - by Neil Young
    I have been running PhantomJS 1.9.6 happily on a turnkey Linux server for about 4 months now. Its purpose is to take an SVG file and create different sizes using the page.render function. This has been doing this but since a few days ago has started to generate a black mono output. Please see below: The code: var page = require('webpage').create(), system = require('system'), address, output, ext, width, height; if ( system.args.length !== 4 ) { console.log("{ \"result\": false, \"message\": \"phantomjs.rasterize: error need address, output, extension arguments\" }"); //console.log('phantomjs.rasterize: error need address, output, extension arguments'); phantom.exit(1); } else if( system.args[3] !== "jpg" && system.args[3] !== "png"){ console.log("{ \"result\": false, \"message\": \"phantomjs.rasterize: error \"jpg\" or \"png\" only please\" }"); //console.log('phantomjs.rasterize: error "jpg" or "png" only please'); phantom.exit(1); } else { address = system.args[1]; output = system.args[2]; ext = system.args[3]; width = 1044; height = 738; page.viewportSize = { width: width, height: height }; //postcard size page.open(address, function (status) { if (status !== 'success') { console.log("{ \"result\": false, \"message\": \"phantomjs.rasterize: error loading address ["+address+"]\" }"); //console.log('phantomjs.rasterize: error loading address ['+address+'] '); phantom.exit(); } else { window.setTimeout(function () { //--> redner full size postcard page.render( output + "." + ext ); //--> redner smaller postcard page.zoomFactor = 0.5; page.clipRect = {top:0, left:0, width:width*0.5, height:height*0.5}; page.render( output + ".50." + ext); //--> redner postcard thumb page.zoomFactor = 0.25; page.clipRect = {top:0, left:0, width:width*0.25, height:height*0.25}; page.render( output + ".25." + ext); //--> exit console.log("{ \"result\": true, \"message\": \"phantomjs.rasterize: success ["+address+"]>>["+output+"."+ext+"]\" }"); //console.log('phantomjs.rasterize: success ['+address+']>>['+output+'.'+ext+']'); phantom.exit(); }, 100); } }); } Does anyone know what can be causing this? There have been no server configuration changes that I know of. Many thanks for your help.

    Read the article

  • AngularJS directive not displaying the template

    - by iJay
    Here is my AngularJs directive. Its' expected to show the div in the template but it shown nothing while the code is run. Here is the html <div ng-app="SuperHero"> <SuperMan></SuperMan> </div> Here is the AngularJS directive var app = angular.module('SuperHero',[]); app.directive('SuperMan',function(){ return{ restrict:'E', template: '<div>Hello fromt Directive</div>' } }); And here is the demo

    Read the article

  • Jenkins and Visual Studio Online integration authentication

    - by user3120361
    right now I am trying to Setup Continuouse Integration - Delivery for a basic WCF Service, which will be hosted on a Microsoft Azure VM. The Project is Version Controlled through Visual Studio Online. So I installed Jenkins (also on the Azure VM), TFS plugin etc. and started the first Test Build: As Server URL I used "[VSO Adress]/DefaultCollection" and for Login purposes my Microsoft Account (I can Access VSO with that). The Problem is, when I run the Build I get the following error: Started by user Developer Building in workspace C:\Program Files (x86)\Jenkins\jobs\test\workspace [workspace] $ "C:\Program Files (x86)\TEE-CLC-11.0.0.1306\TEE-CLC-11.0.0\tf.cmd" workspaces -format:brief -server:[VSO Adress]/DefaultCollection ****" An error occurred: Access denied connecting to TFS server [VSO Adress] (authenticating as har****@*******o.com) FATAL: Executable returned an unexpected result code [100] ERROR: null Finished: FAILURE So my question is, whether it is generally possible to connect Jenkins and VSO that way and if so, which login credentials are needed

    Read the article

  • why i add more insignificant code but cost less time

    - by user3714382
    i write a method and when i add some insignificant code it works faster, like these : array[1]=array[1]; array[0]=array[0]; array[3]=array[3]; array[2]=array[2]; i use double t=System.currentTimeMillis(); at first to record the time. then call the method and use System.out.println(System.currentTimeMillis()-t); in the end. when i delete the code (array[1]=array[1];...) the cost time is 1035.0 ms,but if i add these code, the cost time become 898.0ms. here is my method and my code. PS:this method is use for the game 2048, exp: {2,2,2,2} trans to {0,0,4,4} static void toRight2(int[] array){ if (array[2]==array[3] ) { array[3]=array[2]*2; if (array[0]==array[1]) { array[2]=array[1]*2; array[0]=0; array[1]=0; }else { array[2]=array[1]; array[1]=array[0]; array[0]=0; } } else{ if (array[0]==array[1]) { array[1]=array[1]*2; array[0]=0; array[3]=array[3]; array[2]=array[2]; }else { array[1]=array[1];//delete this cost more time array[0]=array[0];//delete this cost more time array[3]=array[3];//delete this cost more time array[2]=array[2];//delete this cost more time } } } public static void main(String[] args) { double t=System.currentTimeMillis(); int[] array={1,2,3,3}; for (int j = 2; j <400*1000000; j++) { toRight2(array); } System.out.println(System.currentTimeMillis()-t); }

    Read the article

  • Changing the value of a variable

    - by neirpycc
    I'm trying to build a simple scoring app but I'm running into a problem trying to keep it so I don't have to repeat a bunch of code to deal with each 'base' individually. The basic idea is that when I click a button the script will; 1) grab the ID of said button 2) split the ID into two parts - (a) the bases name and (b) the button type (plus/minus) 3) if it's plus - add to the bases score, if it's minus - subtract from the bases score 4) update the assigned div with the new value The part I'm stuck at is adding and subtracting. I can't seem to get this to work. Here is the code: $('.base button').click(function() { var b1Score = 0; var b2Score = 0; var b3Score = 0; var b4Score = 0; var b5Score = 0; var clickedButton = $(this).attr('id'); var buttonInfo = clickedButton.split('-'); var baseClicked = buttonInfo[0]; var baseDirection = buttonInfo[1]; var baseDiv = ('#' + baseClicked); console.log('You clicked ' + clickedButton + '.'); if (baseDirection.indexOf('plus') >= 0) { console.log('Increasing ' + baseClicked + '!'); ++; $(baseDiv).val(); } else { console.log('Decreasing ' + baseClicked + '!'); --; $(baseDiv).val(); } }); ++; and --; are placeholders for where the adding and subtracting needs to happen. I just can't figure out how to get it to add or subtract from the correct value. Any help is appreciated. Thanks.

    Read the article

  • Configuring the expiry time for the messages destined to the "Expired message address" in Hornetq

    - by Rohit
    I have configured a message expiry destination in Hornetq as below <address-setting match="#"> <dead-letter-address>jms.queue.error</dead-letter-address> <expiry-address>jms.queue.error</expiry-address> <max-delivery-attempts>3</max-delivery-attempts> <redelivery-delay>2000</redelivery-delay> <max-size-bytes>10485760</max-size-bytes> <message-counter-history-day-limit>10</message-counter-history-day-limit> <address-full-policy>BLOCK</address-full-policy> <redistribution-delay>60000</redistribution-delay> </address-setting> And the messages do get redirected to the expiry address once the expiration time is exceeded. These messages live indefinitely on the expiry address, Is there a way to provide a expiry time for these messages so they live only limited time on the expiry address?

    Read the article

  • How to convert a string to variable name

    - by p1xelarchitect
    I'm loading several external JSON files and want to check if they have been successfully cached before the the next screen is displayed. My strategy is to check the name of the array to see if it an object. My code works perfectly when I check only a single array and hard code the array name into my function. My question is: how can i make this dynamic? not dynamic: (this works) $("document").ready(){ checkJSON("nav_items"); } function checkJSON(){ if(typeof nav_items == "object"){ // success... } } dynamic: (this doesn't work) $("document").ready(){ checkJSON("nav_items"); checkJSON("foo_items"); checkJSON("bar_items"); } function checkJSON(item){ if(typeof item == "object"){ // success... } } here is the a larger context of my code: var loadAttempts = 0; var reloadTimer = false; $("document").ready(){ checkJSON("nav_items"); } function checkJSON(item){ loadAttempts++; //if nav_items exists if(typeof nav_items == "object"){ //if a timer is running, kill it if(reloadTimer != false){ clearInterval(reloadTimer); reloadTimer = false; } console.log("found!!"); console.log(nav_items[1]); loadAttempts = 0; //reset // load next screen.... } //if nav_items does not yet exist, try 5 times, then give up! else { //set a timer if(reloadTimer == false){ reloadTimer = setInterval(function(){checkJSON(nav_items)},300); console.log(item + " not found. Attempts: " + loadAttempts ); } else { if(loadAttempts <= 5){ console.log(item + " not found. Attempts: " + loadAttempts ); } else { clearInterval(reloadTimer); reloadTimer = false; console.log("Giving up on " + item + "!!"); } } } }

    Read the article

  • value of type 'string' cannot be converted to 'Devart.data.postgresql.PgSqlParameter'

    - by hector
    The following is my PostgreSQL table structure and the vb.net code to insert into the tables.Using Devart's Component For PostgreSQL Connect table gtab83 CREATE TABLE gtab83 ( orderid integer NOT NULL DEFAULT nextval('seq_gtab83_id'::regclass), acid integer, slno integer, orderdte date ) table gtab84 CREATE TABLE gtab84 ( orderdetid integer DEFAULT nextval('seq_gtab84_id'::regclass), productid integer, qty integer, orderid integer ) Code to insert into the above tables is below '1.)INSERT INTO gtab83(orderid,acid, slno, orderdte) VALUES (?, ?, ?); '2.)INSERT INTO gtab84(orderdetid,productid, qty, orderid) VALUES (?, ?, ?); Try Dim cmd As PgSqlCommand = New PgSqlCommand("", Myconnstr) cmd.CommandText = _ "INSERT INTO GTAB83(ACID,SLNO,ORDERDTE)" & _ "VALUES " & _ "(@acid,@slno,@orderdte);" Dim paramAcid As PgSqlParameter = New PgSqlParameter("@acid", PgSqlType.Int, 0) Dim paramSlno As PgSqlParameter = New PgSqlParameter("@slno", PgSqlType.Int, 0) Dim paramOrderdte As PgSqlParameter = New PgSqlParameter("@orderdte", PgSqlType.Date, 0) paramAcid = cboCust.SelectedValue paramSlno = txtOrderNO.Text #ERROR# paramOrderdte = (txtDate.Text, "yyyy-MM-dd") #ERROR# Catch ex As Exception End Try ERROR : value of type 'string' cannot be converted to 'Devart.data.postgresql.PgSqlParameter'

    Read the article

  • Php mail pulling form data from previous page

    - by Mark
    So I have a form being filled out on one php like so: <p> <label for="first_name">First Name: </label> <input type="text" size="30" name="first_name" id="first_name"/> </p> <p> <label for="last_name"> Last Name:</label> <input type="text" size="30" name="last_name" id="last_name"/> </p> <p> <label for="address_street">Street:</label> <input type="text" size="30" name="address_street" id="address_street"/> </p> <p> <label for="address_city">City:</label> <input type="text" size="30" name="address_city" id="address_city"/> </p> <p> <label for="address_state">State/Province:</label> <input type="text" size="30" name="address_state" id="address_state"/> </p> <p> <label for="email">Your e-mail: </label> <input type="text" size="30" name="email" id="email"/> </p> <p> <label for="phone">Your phone number: </label> <input type="text" size="30" name="phone" id="phone"/> </p> This is on one php page. From here, it goes to another php which part of it contains script to send a html email to recipient. Problem is, I cannot seem to get it to pull the variables even though I thought I declared them correctly and mixed them into the html correctly. <?php $first_name = $_POST['first_name']; $last_name = $_POST['last_name']; $to = "[email protected], [email protected]"; $subject = "HTML email for ALPS"; $message .= ' <html> <body> <div style="display: inline-block; width: 28%; float: left;"> <img src="http://englishintheusa.com/images/alps-logo.jpg" alt="ALPS Language School" /> </div> <div style="display: inline-block; width: 68%; float: right;"> <p style="color: #4F81BD; font-size: 20px; text-decoration: underline;">Thanks You For Your Inquiry!</p> </div> <div style="padding-left: 20px; color: #666666; font-size: 16.8px; clear: both;"> <p>Dear $first_name $last_name ,</p> </br > <p>Thank you for the following inquiry:</p> </br > </br > </br > </br > <p>****Comment goes here****</p> </br > </br > <p>We will contact you within 2 business days. Our office is open Monday-Friday, 8:30 AM - 5:00 PM Pacific Standard Time.</p> </br > <p>Thank you for your interest!</p> </br > </br > <p>Best Regards,</p> </br > </br > <p>ALPS Language School</p> </br > </br > <p>430 Broadway East</p> <p>Seattle WA 98102</p> <p>Phone: 206.720.6363</p> <p>Fax: 206. 720.1806</p> <p>Email: [email protected]</p> </div> </body> </html>'; // Always set content-type when sending HTML email $headers .= "MIME-Version: 1.0" . "\r\n"; $headers .= "Content-type:text/html;charset=UTF-8" . "\r\n"; // More headers mail($to,$subject,$message,$headers); ?> So you see where I am trying to get first_name and last_name. Well it doesn't come out correctly. Can someone help here?

    Read the article

  • how to text-align columns in DataGrid? (style DataGridCell)

    - by Olga
    I use WPF (C #). I use DataGrid. I want the first column is aligned with the center, the other columns are right-aligned. I have style: <Style x:Key="TextInCellCenter" TargetType="{x:Type TextBlock}" > <Setter Property="HorizontalAlignment" Value="Center"/> </Style> <Style TargetType="{x:Type DataGridCell}"> <Setter Property="HorizontalAlignment" Value="Right"/> </Style> DataGrid: <DataGrid> <DataGrid.Columns> <DataGridTextColumn ElementStyle="{StaticResource TextInCellCenter}" Binding="{Binding Path=Name}" /> <DataGridTextColumn Binding="{Binding Path=Number}" /> <DataGridTextColumn Binding="{Binding Path=Number}" /> <DataGridTextColumn Binding="{Binding Path=Number}" /> I have all the columns are right-aligned. Please tell me, how do I change the first column had a center text-alignment?

    Read the article

  • Delete the first line that matches a pattern

    - by gioele
    How can I use sed to delete only the first line that contains a certain pattern? For example, I want to remove the first line matching FAA from this document: 1. foo bar quuz 2. foo FAA bar (this should go) 3. quuz quuz FAA (this should remain) 4. quuz FAA bar (this should also remain) The result should be 1. foo bar quuz 3. quuz quuz FAA (this should remain) 4. quuz FAA bar (this should also remain) A solution for POSIX sed would be greatly appreciated, GNU sed is OK.

    Read the article

  • iText PDFReader Extremely Slow To Open

    - by Wbmstrmjb
    I have some code that combines a few pages of acro forms (with acrofields in tact) and then at the end writes some JS to the entire document. It is the PdfReader in the function adding the JS that is taking extremely long to instantiate (about 12 seconds for a 1MB file). Here is the code (pretty simple): public static byte[] AddJavascript(byte[] document, string js) { PdfReader reader = new PdfReader(new RandomAccessFileOrArray(document), null); MemoryStream msOutput = new MemoryStream(); PdfStamper stamper = new PdfStamper(reader, msOutput); PdfWriter writer = stamper.Writer; writer.AddJavaScript(js); stamper.Close(); reader.Close(); byte[] withJS = msOutput.GetBuffer(); return withJS; } I have benchmarked the above and the line that is slow is the first one. I have tried reading it from a file instead of memory and tried using a MemoryStream instead of the RandomAccessFileOrArray. Nothing makes it any faster. If I add JS to a single page document, it is very fast. So my thought is that the code that combines the pages is somehow making the PDF slow to read for the PdfReader. Here is the combine code: public static byte[] CombineFiles(List<byte[]> sourceFiles) { MemoryStream output = new MemoryStream(); PdfCopyFields copier = new PdfCopyFields(output); try { output.Position = 0; foreach (var fileBytes in sourceFiles) { PdfReader fileReader = new PdfReader(fileBytes); copier.AddDocument(fileReader); } } catch (Exception exception) { //throw } finally { copier.Close(); } byte[] concat = output.GetBuffer(); return concat; } I am using PdfCopyFields because I need to preserve the form fields and so cannot use the PdfCopy or PdfSmartCopy. This combine code is very fast (few ms) and produces working documents. The AddJS code above is called after it and the PdfReader open is the slow piece. Any ideas?

    Read the article

  • Interesting OOPS puzzle

    - by user3714387
    Recently, faced the below question from one of the interviewer. Initially thought that the question was wrong, but the interviewer mentioned there is solution for this. Quite interesting. Can anyone shed light please ? Program as below. public class BaseHome { public static void main() { Console.WriteLine("A"); } } Required output : B A C Condition : Should not make any change in the Main function. Should not create any additional class. Please advice if this can be done with the condition met.

    Read the article

  • onPerformSync() is not triggered after ContentResolver.requestSync() call

    - by mark
    I am trying to implement sync adaptor, I have followed This guide. But onPerformSync() is not triggered after ContentResolver.requestSync() call . I have also tried some other tutorials and tried to run their code, but still same issue. Please tell me does I need to do some extra configuration for this. My code of triggering sync operation is as folows : Account newAccount = new Account(GlobalInfo.ACCOUNT, GlobalInfo.ACCOUNT_TYPE); AccountManager accountManager = (AccountManager) this.getSystemService(ACCOUNT_SERVICE); accountManager.addAccountExplicitly(newAccount, null, null); ContentResolver.requestSync(newAccount,GlobalInfo.AUTHORITY, Bundle.EMPTY); Please guide me to solve this issue. EDIT : Accounted created (in Settings - Accounts and Sync settings) by above code showing sync is off

    Read the article

  • How to deal with extra space characters while Reading a CSV file?

    - by Ravi Dutt
    I am reading a CSV file with CSV Open Source API. as shown below: Java Code:--> CSVReader reader = new CSVReader(new FileReader(filePath),'\n'); String[] values; if((read=(reader.readNext()))!=null) { values = (read[0].split(" (?=([^\"]*\"[^\"]*\")*[^\"]*$)",-1)).length; } // code ends here When I read this CSV file line by line and split that line with delimiter. Then after spliting values each value I get contains extra space character after each character in String. Suppose value in file is like "ABC" and I got this after reading from CSV file reader as " A B C " . I used removeAll("\s+","") on each value even after it is not working. Thank You in Advance.

    Read the article

  • Laravel check if id exists?

    - by devt204
    I've two columns in contents tables 1. id 2. content now this is what i'm trying to do Route::post('save', function() { $editor_content=Input::get('editor_content'); $rules = array('editor_content' => 'required'); $validator= Validator::make(Input::all(), $rules); if($validator->passes()) { //1. check if id is submitted? //2. if id exists update content table //3. else insert new content //create new instance $content= new Content; // insert the content to content column $content->content = $editor_content; //save the content $content->save(); // check if content has id $id=$content->id; return Response::json(array('success' => 'sucessfully saved', 'id' => $id)); } if($validator->fails()) { return $validator->messages() ; } }); i wanted to check if id has been already submit or checked i'm processing the request via ajax, and if id exists i wanted update the content column and if it doesn't i wanted to create new instance how do i do it ?

    Read the article

  • Creating a multiplatform webapp with HTML5 and Google maps

    - by Bart L.
    I'm struggling how to develop a webapp for Android and iOS. My first app was a simple todo app which was easy to test in my browser and it only used html, javascript and css. However, I have to create an app which uses Google Maps Api to get the location. I created a simple html5 page to test which places a marker on a map. It works fine when testing it on my local server. But when I create an .apk file for Android, the app doesn't work. So I'm wondering, isn't it possible to use it like this? Do I have the use the phonegap libraries to use their geolocation library? And if so, how do you handle the development of a webapp in phonegap for multiple OS? Do you have to install an Android environment and an iOS environment to each include the right phonegap library and to test them properly? Update: I use the following code on my webserver and it works perfectly. When I upload it in a zip-folder to the photogap cloud and install the APK file on my phone, it doesn't work. <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>Simple Geo test</title> <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.8/jquery.min.js"></script> </head> <body> <script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=true"></script> <script> function success(position) { var mapcanvas = document.createElement('div'); mapcanvas.id = 'mapcontainer'; mapcanvas.style.height = '200px'; mapcanvas.style.width = '200px'; document.querySelector('article').appendChild(mapcanvas); var coords = new google.maps.LatLng(position.coords.latitude, position.coords.longitude); var options = { zoom: 15, center: coords, mapTypeControl: false, navigationControlOptions: { style: google.maps.NavigationControlStyle.SMALL }, mapTypeId: google.maps.MapTypeId.ROADMAP }; var map = new google.maps.Map(document.getElementById("mapcontainer"), options); var marker = new google.maps.Marker({ position: coords, map: map, title:"You are here!" }); } if (navigator.geolocation) { navigator.geolocation.getCurrentPosition(success); } else { error('Geo Location is not supported'); } </script> <article></article> </body> </html>

    Read the article

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