Daily Archives

Articles indexed Sunday September 2 2012

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

  • how to debug upstart scripts?

    - by poolie
    For some reason I'm getting an error during apport upgrades, the cause of which is % sudo service apport start start: Job failed to start Under sysvinit, I could debug this kind of problem by running eg sudo sh -x /etc/init.d/whatever start but that doesn't seem to map over to upstart. What should I try next? update: it turns out there is a workaround that will let the install proceed. But I'm still interested in the general question of how you would trace the script.

    Read the article

  • What is a "Public DNS registered IP address"?

    - by Emma
    I've been reading this ICANN agreement on new TLDs and it has this section on DNS service availability, which i don't completely understand: Refers to the ability of the group of listed-as-authoritative name servers of a particular domain name (e.g., a TLD), to answer DNS queries from DNS probes. For the service to be considered available at a particular moment, at least, two of the delegated name servers registered in the DNS must have successful results from “DNS tests” to each of their public-DNS registered “IP addresses” to which the name server resolves. If 51% or more of the DNS testing probes see the service as unavailable during a given time, the DNS service will be considered unavailable. I'm not 100% sure of the part in bold: does "public" refer to the DNS or to the IP addesses? It looks like there's a mistake and that the hyphen should have been after "DNS". So basically does it mean "the public IP addresses registered in the DNS"?

    Read the article

  • Is it possible to use Google Analytics to track file downloads?

    - by Eric Falsken
    It's always bothered me that Google Analytics (and similar embedded web traffic monitoring services) can only see a reflection of the traffic going to my server and can only see page visits since it depends on the browser executing a Javascript snippet. If I want to track real downloads of a software package (ZIP file), there's no way Google Analytics can possibly tell me that because its javascript can't be attached to a ZIP file. Is there a way I can upload my log files to Google so that the pointy-haired boss can see downloads of our ZIP/PDF/BIN files and not just visits to the download page?

    Read the article

  • How to handle loading and keeping many bitmaps in an Android 2D game

    - by Lumis
    In an Android 2D game which is using SurfaceView where its onDraw is driven by a loop from a Thread, I use many bitmap sprites (sprite sheets) and two background size bitmaps, which are all loaded into memory at the start. It all works fine, however, when the activity is onPause or after reloading it few times, Android shows a tendency to wipe out the big bitmaps only, probably to free memory. Sometimes this happens even in the middle of loading this very activity. In order to counter this, I made a check in the onDraw method to test if the big bitmaps are still there and reload them if they are forcefully recycled by Android, before drawing them on Canvas. This solution may not be the most stable, and since I know that there are much more accomplished android game programmers here than myself, I hope you can reveal some tricks or secrets or at least provide some good hints, how to overcome this.

    Read the article

  • How is the terrain generated in Commandos and Commandos game clones/look-alikes?

    - by teodron
    The Commandos series of games and its similar western counterpart, Desperados, use a mix of 2D and 3D elements to achieve a very pleasing and immersive atmosphere. Apart from the concept that alone made the series a best-seller, the graphics eye-candy was also a much appreciated asset of that game. I was very curious on what was the technique used to model and adorn the realistic terrains in those titles? Below are some screenshots that could be relevant as a reference for whomever has a candidate answer: The tiny details and patternless distribution of ornamental textures make me think that these terrains were not generated using a standard heightmap-blendmap method.

    Read the article

  • Expiring timed actions a good idea?

    - by Bart van Heukelom
    We have an online game where players sometimes have to wait a while (say 30 minutes) before a process they intiated completes. This encourages them to come back later. An example of this is growing crops in Farmville or basically any action in the Sims Play4Free. Now, however, there is the idea to let these processes expire, so if the player doesn't 'reap' them in time (e.g. within 4 hours) they are aborted. I'm a bit sceptical about this. How will this make players come back more often? Is not the reward of reaping the process enough for that? Can we expect players to fit their daily schedule around our game, maybe even set the alarm clock at night? Won't this just cause players to give up on starting these processes in the first place? I realise this may be too subjective for this site, so I'll end with a concrete question: Do (m)any other online free-to-play games employ this technique?

    Read the article

  • How to fix “The requested service, ‘net.pipe://localhost/SecurityTokenServiceApplication/appsts.svc’ could not be activated.”

    - by ybbest
    Problem: When I try to publish a SharePoint2013 workflow, I received the error: The requested service, ‘net.pipe://localhost/SecurityTokenServiceApplication/appsts.svc’ could not be activated. After that, my workflow stopped working and every time I start a work I receive the following error message: System.ApplicationException: PreconditionFailed ---> System.ApplicationException: Error in the application. --- End of inner exception stack trace --- at System.Activities.Statements.Throw.Execute(CodeActivityContext context) at System.Activities.CodeActivity.InternalExecute(ActivityInstance instance, ActivityExecutor executor, BookmarkManager bookmarkManager) at System.Activities.Runtime.ActivityExecutor.ExecuteActivityWorkItem.ExecuteBody(ActivityExecutor executor, BookmarkManager bookmarkManager, Location resultLocation) Analysis: After analysis, I found the error by visiting the http://localhost:32843/SecurityTokenServiceApplication/securitytoken.svc and the error I got on the message is                                                                                                                                              Solution: The solution is basically getting more memory to the server. For development environment, you can restart your noderunner.exe or some other services to release some memories. To verify you have enough memory    you can browse to http://localhost:32843/SecurityTokenServiceApplication/securitytoken.svc , it should return the information below. Then you can republish your workflow and it will work like a charm.

    Read the article

  • uWSGI loggin format unification

    - by Mediocre Gopher
    I'm attempting to unify the log format of my uwsgi instance. Currently there's three different types of log items: Sun Sep 2 17:31:00 2012 - spawned uWSGI worker 10 (pid: 2958, cores: 8) (DEBUG) 2012-09-02 17:31:01,526 - getFileKeys_rpc called Traceback (most recent call last): File "src/dispatch.py", line 13, in application obj = discovery(env) File "src/dispatch.py", line 23, in discovery ret_obj = {"return":dispatch(method,env)} File "src/dispatch.py", line 32, in dispatch raise Exception("test") Exception: test The first is an error spawned by uWSGI internally (I have the --log-date option set). The second is from the logging module, which has logging.basicConfig(format='(%(levelname)s) %(asctime)s - %(message)s') set. The final one is an uncaught exception. I understand that the uncaught exception probably can't be formatted, but is there some way of having uwsgi use the logging module for its internal logs? Or the other way around?

    Read the article

  • Where does one enter the JavaScript code in CRM Dynamics?

    - by Konrad Viltersten
    I've started to play with CRM Dynamics yesterday so this question should be seen as a very basic one. I've been coding for many years but CRM D is news to me. Apparently, one is supposed to be able to enter JavaScript code to customize the behavior of the application. I've understood that there's an API for that and that touching DOM directly or playing with jQuery is a no-no. Question: Where is the JS-code supposed to be entered? I've gone through all the menus but as far I can see, there's no spot where I could plug-in my custom code. E.g.: Where do I get to define a validation for the last name of a contact currently being defined?

    Read the article

  • Android opengl releasing textures

    - by user1642418
    I have a bit of a problem. I am developing a game for android + engine and I got stuck. I am getting OpenGL out of memory error and either app crashes or phone hangs after loading a scene multiple times. For example: app launches, shows main menu, 1st level/scene is loaded. Then I go back to main menu, and repeat. It doesnt matter which scene I load, after 4-6 times the error occurs. Some background: Each time when scene is loaded all the resources are released and upon first frame render - needed stuff gets loaded. The performance is more or less ok. Note that I am calling glDeleteTexture method, but I think its not doing its job and releasing memory. Thing is that -when I minimize and open it again - problem doesn't occur, but almost the same things are executed. Problem doesn't occur. This way android releases memory. How do I release/get rid of unused textures properly? This happens on HTC Desire HD ( ice cream sandwich 4.0.4) . Other games works fine, so I bet this is not the problem in ROM.

    Read the article

  • Retrieving values from WSDL before making a request

    - by Egor
    I'm very new to working with web services and I'm trying to understand the basics of it in Android using the ksoap2 library. Here's the question: this is the WSDL file of a service I'm using. It's a service that converts values between different units. The units are stated in the WSDL. Now, is there any way to read those units and, say, populate a Spinner to let users choose the units they want to work with? A code solution will be highly appreciated. Thanks in advance.

    Read the article

  • two threads acting on the same runnable

    - by Eslam
    Given: public class Thread1 { int x = 0; public class Runner implements Runnable { public void run() { int current = 0; for (int i = 0; i < 4; i++) { current = x; System.out.print(current + " "); x = current + 2; } } } public void go() { Runnable r1 = new Runner(); new Thread(r1).start(); new Thread(r1).start(); } public static void main(String[] args) { new Thread1().go(); } } Which two are possible results? (Choose two) A. 0, 2, 4, 4, 6, 8, 10, 6, B. 0, 2, 4, 6, 8, 10, 2, 4, C. 0, 2, 4, 6, 8, 10, 12, 14, D. 0, 0, 2, 2, 4, 4, 6, 6, 8, 8, 10, 10, 12, 12, 14, 14, E. 0, 2, 4, 6, 8, 10, 12, 14, 0, 2, 4, 6, 8, 10, 12, 14, i chosed A,B but i'm not certain is those is the true or not.

    Read the article

  • Mail Rule to Run Applescript Not Working?

    - by William Andy Hainline
    Question for my fellow AppleScripters. I have the following script which runs just fine if you run it in AppleScript Editor or Script Debugger, but that won't run at all if you try to run it from a Mail rule. The script is correctly placed in ~/Library/Application Scripts/com.apple.mail, and shows up in the "Run AppleScript" menu in the Mail rule, but simply refuses to work when new mail arrives. on perform_mail_action(info) tell application "Mail" set theMessages to |SelectedMessages| of info repeat with thisMessage in theMessages set AppleScript's text item delimiters to {""} set thisSender to sender of thisMessage as string set quotepos to offset of "\"" in thisSender if (quotepos is not 0) then set thisSender to (text items (quotepos + 1) through -1) ¬ of thisSender as string set quotepos to offset of "\"" in thisSender if (quotepos is not 0) then set thisSender to (text items 1 through (quotepos - 1)) ¬ of thisSender as string end if else set atpos to offset of "@" in thisSender if (atpos is not 0) then set thisSender to (text items 1 through (atpos - 1)) ¬ of thisSender as string end if set brkpos to offset of "<" in thisSender if (brkpos is not 0) then set thisSender to (text items (brkpos + 1) through -1) ¬ of thisSender as string end if end if tell application "Finder" to say "Mail from " & thisSender end repeat end tell end perform_mail_action Any ideas?

    Read the article

  • Create generic class instance throws TypeLoadException

    - by Elisa
    My TestLayer class has the namespace: "BLL.Infrastructure.TestLayer" and is inside the assembly: "BLL" public class LayerFactory<T, U> { public static IBaseLayer<T, U> Get() { var obj = Activator.CreateInstance("BLL", "BLL.Infrastructure.TestLayer", new object[] { (IBaseLayer<T, U>)null }); } } When I run the code the Activator throws an TypeLoadException with no more details Thats the concrete class it should create: GenericBaseLayer implements the IBaseLayer. public class TestLayer<T, U> : GenericBaseLayer<MyRequest, MyInfo.ActionType> { public TestLayer(IBaseLayer<MyRequest, MyInfo.ActionType> layer) : base(layer) { } } What do I wrong?

    Read the article

  • Image panning in sencha touch 2

    - by MattD
    I'm trying to have show a large image that the user can pan around (so scroll vertically & horizontally). But I can't get the image to scroll. This is what I have: Ext.define('myapp.view.image.Floorplan', { extend: 'Ext.Container', requires: 'Ext.Img', xtype: 'floorplan', config: { title: 'Floorplan', iconCls: 'locate', items: [ { xtype: 'image', scrollable: true, src: './resources/images/floorplan.png', height: 1570, width: 1047 } ] } }); How can I make the image scrollable? Thanks Matt

    Read the article

  • mysql get table based on common column between two tables

    - by Zentdayn
    while trying to learn sql i came across "Learn SQL The Hard Way" and i started reading it. Everything was going fine then i thought ,as a way to practice, to make something like given example in the book (example consists in 3 tables pet,person,person_pet and the person_pet table 'links' pets to their owners). I made this: report table +----+-------------+ | id | content | +----+-------------+ | 1 | bank robbery| | 2 | invalid | | 3 | cat on tree | +----+-------------+ notes table +-----------+--------------------+ | report_id | content | +-----------+--------------------+ | 1 | they had guns | | 3 | cat was saved | +-----------+--------------------+ wanted result +-----------+--------------------+---------------+ | report_id | report_content | report_notes | +-----------+--------------------+---------------+ | 1 | bank robbery | they had guns | | 2 | invalid | null or '' | | 3 | cat on tree | cat was saved | +-----------+--------------------+---------------+ I tried a few combinations but no success. My first thought was SELECT report.id,report.content AS report_content,note.content AS note_content FROM report,note WHERE report.id = note.report_id but this only returns the ones that have a match (would not return the invalid report). after this i tried adding IF conditions but i just made it worse. My question is, is this something i will figure out after getting past basic sql or can this be done in simple way? Anyway i would appreciate any help, i pretty much lost with this. Thank you. EDIT: i have looked into related questions but havent yet found one that solves my problem. I probably need to look into other statements such as join or something to sort this out.

    Read the article

  • Script that replaces strings doesn't work on some sites

    - by groovy354
    I've created a simple Chrome extension that seeks for certain strings using regex and replaces matches with predefined text. It works well on most websites, but somehow the script doesn't take effect on, for example, Lifehacker (like this page http://lifehacker.com/5939740/five-best-audio-editing-applications?popular=true ). The code is: $('p, h1, h2, h3, span, .content, .post-body').each(function(){ //do something with $(this) }); Any ideas why is Lifehacker's site resistant to my script?

    Read the article

  • Fastest way of converting a quad to a triangle strip?

    - by Tina Brooks
    What is the fastest way of converting a quadrilateral (made up of foyr x,y points) to a triangle strip? I'm well aware of the general triangulation algorithms that exist, but I need a short, well optimized algorithm that deals with quadrilaterals only. My current algorithm does this, which works for most quads but still gets the points mixed up for some: #define fp(f) bounds.p##f /* Sort four points in ascending order by their Y values */ point_sort4_y(&fp(1), &fp(2), &fp(3), &fp(4)); /* Bottom two */ if (fminf(-fp(1).x, -fp(2).x) == -fp(2).x) { out_quad.p1 = fp(2); out_quad.p2 = fp(1); } else { out_quad.p1 = fp(1); out_quad.p2 = fp(2); } /* Top two */ if (fminf(-fp(3).x, -fp(4).x) == -fp(3).x) { out_quad.p3 = fp(3); out_quad.p4 = fp(4); } else { out_quad.p3 = fp(4); out_quad.p4 = fp(3); }

    Read the article

  • How do I expand my <div> to properly fit more vertical content?

    - by CSS_maniac
    Whenever I try to add margin-top: 30px to my box_1 and box_2 <div>, my bottom <div> gets pushed down and disappears. It seems like my wrapper wont expand to fit the content. How do I get a 30px gap between top and box_1/2 and bottom? <html> <head> <title>Circle Motion</title> <link rel="stylesheet" type="text/css" href="styles.css" /> </head> <body> <div id="outer-wrapper"> <div id="wrapper"> <div id="top"> </div> <div id="box_1"> <img src="chrome_400x400.png" /> </div> <div id="box_2"> <img src="firefox_400x400.png" /> </div> <div id="bottom"> <p>All Rights Reserved - CSS_maniac 2012 ©</p> </div> </div> </div> </body> </html> CSS /* My CSS */ html { height: 100% } body { background-color: grey; } #outer-wrapper { height: 100%; width: 1000px; margin: 0px auto; background-color: #EAFFDB; -moz-border-radius: 15px; border-radius: 15px; } #wrapper { height: 100%; width: 960px; margin: 0px auto; background-color: #EAFFDB; overflow: hidden; } #top { width: 900px; height: 110px; margin-top: 35px; margin-left: 30px; margin-right: 30px; background-color: white; -moz-border-radius: 15px; border-radius: 15px; } #box_1 { width: 430px; height: 430px; background-color: white; -moz-border-radius: 15px; border-radius: 15px; float:left; margin-left: 30px; text-align: center; } #box_2 { width: 430px; height: 430px; background-color: white; -moz-border-radius: 15px; border-radius: 15px; float:right; margin-right: 30px; text-align: center; } #box_1 img { margin: 15px 0px; } #box_2 img { margin: 15px 0px; } #bottom { width: 900px; margin: 0px auto 0px auto; text-align: center; background-color: white; -moz-border-radius: 15px; border-radius: 15px; clear:both; } /* Classes */ .clear { clear: both; }

    Read the article

  • Fatal error: Call to a member function escape() on a non-object in .....on line 10

    - by danyo
    i am making a simple javascript login form for wordpress. i have the form submitting to the following bit of php to handle the login: <?php get_header(); global $user_ID; if (!$user_ID) { if($_POST){ //We shall SQL escape all inputs $username = $wpdb->escape($_REQUEST['username']); $password = $wpdb->escape($_REQUEST['password']); $remember = $wpdb->escape($_REQUEST['rememberme']); if($remember) $remember = "true"; else $remember = "false"; $login_data = array(); $login_data['user_login'] = $username; $login_data['user_password'] = $password; $login_data['remember'] = $remember; $user_verify = wp_signon( $login_data, false ); //wp_signon is a wordpress function which authenticates a user. It accepts user info parameters as an array. if ( is_wp_error($user_verify) ) { echo "<span class='error'>Invalid username or password. Please try again!</span>"; exit(); } else { echo "<script type='text/javascript'>window.location='". get_bloginfo('url') ."'</script>"; exit(); } } else { //get_header(); ?> any ideas on why i am getting the error? Cheers, Dan

    Read the article

  • android upload progressbarr not working

    - by pieter
    I'm a beginner in Android programming and I was tryinh to upload an image to a server. I found some code here on stackoverflow, I adjusted it and it still doesn't work. The problem is my image still won't upload. edit I solved the problem, I had no rights on the folder on the server. Now I have a new problem. the progresbarr doesn't work. it keeps saying 0 % transmitted does anyone sees an error in my code? import android.app.Activity; import android.app.AlertDialog; import android.app.Dialog; import android.app.ProgressDialog; import android.content.Context; import android.content.DialogInterface; import android.graphics.Bitmap; import android.graphics.BitmapFactory; import android.location.Location; import android.location.LocationListener; import android.location.LocationManager; import android.os.AsyncTask; import android.os.Bundle; import android.util.Log; import android.view.View; import android.view.Window; import android.widget.Button; import android.widget.ImageView; import java.io.DataInputStream; import java.io.DataOutputStream; import java.io.File; import java.io.FileInputStream; import java.io.IOException; import java.net.HttpURLConnection; import java.net.URL; public class PreviewActivity extends Activity { /** The captured image file. Get it's path from the starting intent */ private File mImage; public static final String EXTRA_IMAGE_PATH = "extraImagePath" /** Log tag */ private static final String TAG = "DFH"; /** Progress dialog id */ private static final int UPLOAD_PROGRESS_DIALOG = 0; private static final int UPLOAD_ERROR_DIALOG = 1; private static final int UPLOAD_SUCCESS_DIALOG = 2; /** Handler to confirm button */ private Button mConfirm; /** Handler to cancel button */ private Button mCancel; /** Uploading progress dialog */ private ProgressDialog mDialog; /** * Called when the activity is created * * We load the captured image, and register button callbacks */ @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS); setContentView(R.layout.preview); setResult(RESULT_CANCELED); // Import image Bundle extras = getIntent().getExtras(); String imagePath = extras.getString(FotoActivity.EXTRA_IMAGE_PATH); Log.d("DFHprev", imagePath); mImage = new File(imagePath); if (mImage.exists()) { setResult(RESULT_OK); loadImage(mImage); } registerButtonCallbacks(); } @Override protected void onPause() { super.onPause(); } /** * Register callbacks for ui buttons */ protected void registerButtonCallbacks() { // Cancel button callback mCancel = (Button) findViewById(R.id.preview_send_cancel); mCancel.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { PreviewActivity.this.finish(); } }); // Confirm button callback mConfirm = (Button) findViewById(R.id.preview_send_confirm); mConfirm.setEnabled(true); mConfirm.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { new UploadImageTask().execute(mImage); } }); } /** * Initialize the dialogs */ @Override protected Dialog onCreateDialog(int id) { switch(id) { case UPLOAD_PROGRESS_DIALOG: mDialog = new ProgressDialog(this); mDialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL); mDialog.setCancelable(false); mDialog.setTitle(getString(R.string.progress_dialog_title_connecting)); return mDialog; case UPLOAD_ERROR_DIALOG: AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setTitle(R.string.upload_error_title) .setIcon(android.R.drawable.ic_dialog_alert) .setMessage(R.string.upload_error_message) .setCancelable(false) .setPositiveButton(getString(R.string.retry), new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { PreviewActivity.this.finish(); } }); return builder.create(); case UPLOAD_SUCCESS_DIALOG: AlertDialog.Builder success = new AlertDialog.Builder(this); success.setTitle(R.string.upload_success_title) .setIcon(android.R.drawable.ic_dialog_info) .setMessage(R.string.upload_success_message) .setCancelable(false) .setPositiveButton(getString(R.string.success), new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { PreviewActivity.this.finish(); } }); return success.create(); default: return null; } } /** * Prepare the progress dialog */ @Override protected void onPrepareDialog(int id, Dialog dialog) { switch(id) { case UPLOAD_PROGRESS_DIALOG: mDialog.setProgress(0); mDialog.setTitle(getString(R.string.progress_dialog_title_connecting)); } } /** * Load the image file into the imageView * * @param image */ protected void loadImage(File image) { Bitmap bm = BitmapFactory.decodeFile(image.getPath()); ImageView view = (ImageView) findViewById(R.id.preview_image); view.setImageBitmap(bm); } /** * Asynchronous task to upload file to server */ class UploadImageTask extends AsyncTask<File, Integer, Boolean> { /** Upload file to this url */ private static final String UPLOAD_URL = "http://www.xxxx.x/xxxx/fotos"; /** Send the file with this form name */ private static final String FIELD_FILE = "file"; /** * Prepare activity before upload */ @Override protected void onPreExecute() { super.onPreExecute(); setProgressBarIndeterminateVisibility(true); mConfirm.setEnabled(false); mCancel.setEnabled(false); showDialog(UPLOAD_PROGRESS_DIALOG); } /** * Clean app state after upload is completed */ @Override protected void onPostExecute(Boolean result) { super.onPostExecute(result); setProgressBarIndeterminateVisibility(false); mConfirm.setEnabled(true); mDialog.dismiss(); if (result) { showDialog(UPLOAD_SUCCESS_DIALOG); } else { showDialog(UPLOAD_ERROR_DIALOG); } } @Override protected Boolean doInBackground(File... image) { return doFileUpload(image[0], "UPLOAD_URL"); } @Override protected void onProgressUpdate(Integer... values) { super.onProgressUpdate(values); if (values[0] == 0) { mDialog.setTitle(getString(R.string.progress_dialog_title_uploading)); } mDialog.setProgress(values[0]); } private boolean doFileUpload(File file, String uploadUrl) { HttpURLConnection connection = null; DataOutputStream outputStream = null; DataInputStream inputStream = null; String pathToOurFile = file.getPath(); String urlServer = "http://www.xxxx.x/xxxx/upload.php"; String lineEnd = "\r\n"; String twoHyphens = "--"; String boundary = "*****"; // log pathtoourfile Log.d("DFHinUpl", pathToOurFile); int bytesRead, bytesAvailable, bufferSize; byte[] buffer; int maxBufferSize = 1*1024*1024; int sentBytes = 0; long fileSize = file.length(); // log filesize String files= String.valueOf(fileSize); String buffers= String.valueOf(maxBufferSize); Log.d("fotosize",files); Log.d("buffers",buffers); try { FileInputStream fileInputStream = new FileInputStream(new File(pathToOurFile) ); URL url = new URL(urlServer); connection = (HttpURLConnection) url.openConnection(); // Allow Inputs & Outputs connection.setDoInput(true); connection.setDoOutput(true); connection.setUseCaches(false); // Enable POST method connection.setRequestMethod("POST"); connection.setRequestProperty("Connection", "Keep-Alive"); connection.setRequestProperty("Content-Type", "multipart/form-data;boundary="+boundary); outputStream = new DataOutputStream( connection.getOutputStream() ); outputStream.writeBytes(twoHyphens + boundary + lineEnd); outputStream.writeBytes("Content-Disposition: form-data; name=\"uploadedfile\";filename=\"" + pathToOurFile +"\"" + lineEnd); outputStream.writeBytes(lineEnd); bytesAvailable = fileInputStream.available(); bufferSize = Math.min(bytesAvailable, maxBufferSize); buffer = new byte[bufferSize]; // Read file bytesRead = fileInputStream.read(buffer, 0, bufferSize); while (bytesRead > 0) { outputStream.write(buffer, 0, bufferSize); bytesAvailable = fileInputStream.available(); bufferSize = Math.min(bytesAvailable, maxBufferSize); bytesRead = fileInputStream.read(buffer, 0, bufferSize); sentBytes += bufferSize; publishProgress((int)(sentBytes * 100 / fileSize)); bytesAvailable = fileInputStream.available(); bufferSize = Math.min(bytesAvailable, maxBufferSize); bytesRead = fileInputStream.read(buffer, 0, bufferSize); } outputStream.writeBytes(lineEnd); outputStream.writeBytes(twoHyphens + boundary + twoHyphens + lineEnd); // Responses from the server (code and message) int serverResponseCode = connection.getResponseCode(); String serverResponseMessage = connection.getResponseMessage(); fileInputStream.close(); outputStream.flush(); outputStream.close(); try { int responseCode = connection.getResponseCode(); return responseCode == 200; } catch (IOException ioex) { Log.e("DFHUPLOAD", "Upload file failed: " + ioex.getMessage(), ioex); return false; } catch (Exception e) { Log.e("DFHUPLOAD", "Upload file failed: " + e.getMessage(), e); return false; } } catch (Exception ex) { String msg= ex.getMessage(); Log.d("DFHUPLOAD", msg); } return true; } } } the PHP code that handles this upload is following: <?php $date=getdate(); $urldate=$date['year'].$date['month'].$date['month'].$date['hours'].$date['minutes'].$date[ 'seconds']; $target_path = "./"; $target_path = $target_path . basename( $_FILES['uploadedfile']['name']) . $urldate; if(move_uploaded_file($_FILES['uploadedfile']['tmp_name'], $target_path)) { echo "The file ". basename( $_FILES['uploadedfile']['name']). " has been uploaded"; } else{ echo "There was an error uploading the file, please try again!"; } ?> would really appreciate it if someone could help me.

    Read the article

  • Padding/Margin/Border On Element Does Not Change DIV Height

    - by ryandlf
    Here is a very simply jsFiddle to demonstrate my problem: http://jsfiddle.net/ryandlf/mSmUv/4/ When an element has a top padding or margin and it sits on the first line within a div, the div does not respect that padding or margin and push the element down. In most cases this isn't an issue, but for example, if I have a button that has a top border and padding the top of the border will be cut off because the div is not taking into consideration the padding value. Is there a workaround for this other than just blindly setting margins or padding on every container div element and hoping I have added enough to account for any internal element that might be affected?

    Read the article

  • how do I add a texture to a triangle in three.js?

    - by Kae Verens
    I've created a scene which has many cubes, spheres, etc, in it, and have been able to apply textures to those primitives, but when I want to add a texture to a simple triangle, I'm totally lost. Here's the closest I've come to getting it right: var texture=THREE.ImageUtils.loadTexture('/f/3d-images/texture-steel.jpg'); var materialDecalRoof=new THREE.MeshBasicMaterial( { 'map': texture, 'wireframe': false, 'overdraw': true } ); var geometry = new THREE.Geometry(); geometry.vertices.push(new THREE.Vector3(tentX/2+1, tentY, tentZ/2+1)); geometry.vertices.push(new THREE.Vector3(0, tentT, 0)); geometry.vertices.push(new THREE.Vector3(0, tentT, 0)); geometry.vertices.push(new THREE.Vector3(-tentX/2-1, tentY, tentZ/2+1)); geometry.faces.push(new THREE.Face4(0, 1, 2, 3)); geometry.faceVertexUvs[0].push([ new THREE.UV(0, 0), new THREE.UV(0, 0), new THREE.UV(0, 0), new THREE.UV(0, 0) ]); geometry.computeFaceNormals(); geometry.computeCentroids(); geometry.computeVertexNormals(); var mesh= new THREE.Mesh( geometry, materialDecalRoof); scene.add(mesh); This does not work. All i get is a flickering triangle (when the scene is moved) where an image should be. To test this, go to https://www.poptents.eu/3dFrame.php, upload an image in the Roof section, and drag the view to see the roof flicker. Does anyone know what I'm doing wrong here?

    Read the article

  • How do C or .NET programmers store and load strings in their programs?

    - by Ivan Ivkovic
    I've been doing PHP and stuff for the last year; I just got into a bit of C and C++. In the book I'm just reading, all the strings are actually in the code (I realize this is just for example, but just curious). My interest is — is there a common way for programmers to store strings and display them? Does .NET have some predefined way of doing this — like Android does in strings file? (In PHP, I keep them in all CSV files completely separate from code.)

    Read the article

  • Session does not giving right records?

    - by Jugal
    I want to keep one session, but when I rollback transaction then transaction gets isActive=false, so I can not commit and rollback in next statements by using same transaction. then I need to create new transaction but what is going wrong here ? var session = NHibernateHelper.OpenSession();/* It returns new session. */ var transaction1 = session.BeginTransaction(); var list1 = session.Query<Make>().ToList(); /* It returs 4 records. */ session.Delete(list1[2]); /* After Rollback, transaction is isActive=false so I can not commit * and rollback from this transaction in future. so I need to create new transaction. */ transaction1.Rollback(); var transaction2 = session.BeginTransaction(); /* It returns 3 records. * I am not getting object(which was deleted but after that rollback) here why ? */ var list2 = session.Query<Make>().ToList(); Anyone have idea what is going wrong here ? I am not getting deleted object which was rollback.

    Read the article

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