Search Results

Search found 2495 results on 100 pages for 'tom rom'.

Page 53/100 | < Previous Page | 49 50 51 52 53 54 55 56 57 58 59 60  | Next Page >

  • Obtaining FontMetrics before getting a Graphics instance

    - by Tom Castle
    Typically, I'd obtain a graphics instance something like this: BufferedImage img = new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB); Graphics2D g = img.createGraphics(); However, in the current project I'm working on, the width and height variables above are dependent upon the size of a number of text fragments that will later be drawn onto the graphics instance. But, to obtain the dimensions of the font being used I would usually use the FontMetrics that I get from the graphics object. FontMetrics metrics = g.getFontMetrics(); So, I have a nasty little dependency cycle. I cannot create the graphics object until I know the size of the text, and I cannot know the size of the text until I have a graphics object. One solution is just to create another BufferedImage/Graphics pair first in order to get the FontMetrics instance I need, but this seems unnecessary. So, is there a nicer way? Or is it the case that the width, height etc. properties for a Font are somehow dependent upon what (graphics, component...) the text is to be drawn on?

    Read the article

  • java multipart POST library

    - by tom
    Is there a multipart POST library out there that achieve the same effect of doing a POST from a html form? for example - upload a file programmingly in Java versus upload the file using a html form. And on the server side, it just blindly expect the request from client side to be a multipart POST request and parse out the data as appropriate. Has anyone tried this? specifically, I am trying to see if I can simulate the following with Java The user creates a blob by submitting an HTML form that includes one or more file input fields. Your app sets blobstoreService.createUploadUrl() as the destination (action) of this form, passing the function a URL path of a handler in your app. When the user submits the form, the user's browser uploads the specified files directly to the Blobstore. The Blobstore rewrites the user's request and stores the uploaded file data, replacing the uploaded file data with one or more corresponding blob keys, then passes the rewritten request to the handler at the URL path you provided to blobstoreService.createUploadUrl(). This handler can do additional processing based on the blob key. Finally, the handler must return a headers-only, redirect response (301, 302, or 303), typically a browser redirect to another page indicating the status of the blob upload. Set blobstoreService.createUploadUrl as the form action, passing the application path to load when the POST of the form is completed. <body> <form action="<%= blobstoreService.createUploadUrl("/upload") %>" method="post" enctype="multipart/form-data"> <input type="file" name="myFile"> <input type="submit" value="Submit"> </form> </body> Note that this is how the upload form would look if it were created as a JSP. The form must include a file upload field, and the form's enctype must be set to multipart/form-data. When the user submits the form, the POST is handled by the Blobstore API, which creates the blob. The API also creates an info record for the blob and stores the record in the datastore, and passes the rewritten request to your app on the given path as a blob key.

    Read the article

  • Using Gradle with an existing Android project

    - by Tom Reznik
    I have an existing Android project with the following structure: - ProjectName -- AndroidManifest.xml -- local.properties -- project.properties -- assets -- libs (containing all jars) -- modules (containing all library projects my project depends on) -- res -- src ---- com/namespace/projectname (all my classes including main activity are here) I haven't been using any specific build system to build my project other than the one provided by default with the Android Studio IDE (though the project was originally created with IntelliJ CE. I would like to use Gradle with the android plugin and do some work on my build process. I have tried several configurations in order to achieve this and have failed to complete a successful build every time. What's the recommended approach in this scenario? should I change my project structure? or is it possible to configure gradle using the existing structure? Any help would be greatly appreciated. Thanks!

    Read the article

  • Native XML WebService With Authentication Basic and SSL

    - by tom
    I'm using 2005 and the Native XML WebServices. The integrated authentication via HTTP:80 works fine. But i need the basic authentication which requires SSL. So if i change the web service to ssl i always get a connection reset (101). I tried several ports 80,443,9999 with the same outcome. What is the error?

    Read the article

  • What is the standard way to deploy memcached?

    - by Tom
    I have two IIS servers and two MySQL servers. On all servers I have some available memory (More than a GB). What is the standard way to deploy memcached? Should I add a new server especially for memcached, or should I use my existing servers? If so, which servers? Thanks in advance

    Read the article

  • Android: Showing photos runs out of memory

    - by Tom Beech
    I'm using a dialog box to display images in my android project. The first one opens fine, but when I close it and do the process again to show a different one the app falls over with a memory error (it's running on a samsung galaxy s3 - so shouldnt be an issue). Error: 10-24 11:25:45.575: E/dalvikvm-heap(29194): Out of memory on a 31961104-byte allocation. 10-24 11:25:45.580: E/AndroidRuntime(29194): FATAL EXCEPTION: main 10-24 11:25:45.580: E/AndroidRuntime(29194): java.lang.OutOfMemoryError 10-24 11:25:45.580: E/AndroidRuntime(29194): at android.graphics.BitmapFactory.nativeDecodeStream(Native Method) 10-24 11:25:45.580: E/AndroidRuntime(29194): at android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:587) 10-24 11:25:45.580: E/AndroidRuntime(29194): at android.graphics.BitmapFactory.decodeFile(BitmapFactory.java:389) 10-24 11:25:45.580: E/AndroidRuntime(29194): at android.graphics.BitmapFactory.decodeFile(BitmapFactory.java:418) 10-24 11:25:45.580: E/AndroidRuntime(29194): at android.graphics.drawable.Drawable.createFromPath(Drawable.java:882) 10-24 11:25:45.580: E/AndroidRuntime(29194): at android.widget.ImageView.resolveUri(ImageView.java:569) 10-24 11:25:45.580: E/AndroidRuntime(29194): at android.widget.ImageView.setImageURI(ImageView.java:340) 10-24 11:25:45.580: E/AndroidRuntime(29194): at com.directenquiries.assessment.tool.AddAsset.loadPhoto(AddAsset.java:771) 10-24 11:25:45.580: E/AndroidRuntime(29194): at com.directenquiries.assessment.tool.AddAsset$11.onClick(AddAsset.java:748) 10-24 11:25:45.580: E/AndroidRuntime(29194): at com.android.internal.app.AlertController$AlertParams$3.onItemClick(AlertController.java:936) 10-24 11:25:45.580: E/AndroidRuntime(29194): at android.widget.AdapterView.performItemClick(AdapterView.java:292) 10-24 11:25:45.580: E/AndroidRuntime(29194): at android.widget.AbsListView.performItemClick(AbsListView.java:1359) 10-24 11:25:45.580: E/AndroidRuntime(29194): at android.widget.AbsListView$PerformClick.run(AbsListView.java:2988) 10-24 11:25:45.580: E/AndroidRuntime(29194): at android.widget.AbsListView$1.run(AbsListView.java:3783) 10-24 11:25:45.580: E/AndroidRuntime(29194): at android.os.Handler.handleCallback(Handler.java:605) 10-24 11:25:45.580: E/AndroidRuntime(29194): at android.os.Handler.dispatchMessage(Handler.java:92) 10-24 11:25:45.580: E/AndroidRuntime(29194): at android.os.Looper.loop(Looper.java:137) 10-24 11:25:45.580: E/AndroidRuntime(29194): at android.app.ActivityThread.main(ActivityThread.java:4517) 10-24 11:25:45.580: E/AndroidRuntime(29194): at java.lang.reflect.Method.invokeNative(Native Method) 10-24 11:25:45.580: E/AndroidRuntime(29194): at java.lang.reflect.Method.invoke(Method.java:511) 10-24 11:25:45.580: E/AndroidRuntime(29194): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:993) 10-24 11:25:45.580: E/AndroidRuntime(29194): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:760) 10-24 11:25:45.580: E/AndroidRuntime(29194): at dalvik.system.NativeStart.main(Native Method) Loading code: public void loadPhotoList(){ Cursor f = db.rawQuery("select * from stationphotos where StationObjectID = '"+ checkStationObjectID + "'", null); final ArrayList<String> mHelperNames= new ArrayList<String>(); if(f.getCount() != 0) { f.moveToFirst(); f.moveToFirst(); while(!f.isAfterLast()) { mHelperNames.add(f.getString(f.getColumnIndex("FilePath"))); f.moveToNext(); } } f.close(); final String [] nameStrings = new String [mHelperNames.size()]; for(int i=0; i<mHelperNames.size(); i++) nameStrings[i] = mHelperNames.get(i).toString(); AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setTitle("Select Picture"); builder.setItems(nameStrings, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int item) { loadPhoto(mHelperNames.get(item).toString()); } }); AlertDialog alert = builder.create(); alert.show(); } public void loadPhoto(String imagepath){ Dialog dialog = new Dialog(this); dialog.setContentView(R.layout.activity_show_image); dialog.setTitle("Image"); dialog.setCancelable(true); ImageView img = (ImageView) dialog.findViewById(R.id.imageView1); img.setImageResource(R.drawable.ico_partial); Uri imgUri = Uri.parse(imagepath); img.setImageURI(imgUri); dialog.show(); }

    Read the article

  • Android SQLiteConstraintException: error code 19: constraint failed

    - by Tom D
    I've seen other questions about this exception, but all of them seem to be resolved with the solution that a row with the primary key specified already exists. This doesn't seem to be the case for me. I have tried replacing all single quotes in my strings with double quotes, but the same problem occurs. I'm trying to insert a row into the Settings table of the SQLite database I've created by doing the following: db.execSQL("DROP TABLE IF EXISTS "+Settings.SETTINGS_TABLE_NAME + ";"); db.execSQL(CREATE_MEDIA_TABLE); db.execSQL(CREATE_SETTINGS_TABLE); Cursor c = getAllSettings(); //If there isn't already a settings row, create a row full of defaults if(c.getCount()==0){ ContentValues cv = new ContentValues(); cv.put(Settings.SETTING_UNIQUE_ID, "'"+Settings.uniqueID+"'"); cv.put(Settings.SETTING_DEVICE_ID, Settings.SETTING_DEVICE_ID_DEFAULT); cv.put(Settings.SETTING_CONNECTION_PREFERENCE, Settings.SETTING_CONNECTION_PREFERENCE_DEFAULT); cv.put(Settings.SETTING_AD_HOC_ENABLED, Settings.SETTING_AD_HOC_ENABLED_DEFAULT); cv.put(Settings.SETTING_SERVER_ADDRESS, Settings.SETTING_SERVER_ADDRESS_DEFAULT); cv.put(Settings.SETTING_RECORDING_MODE, Settings.SETTING_RECORDING_MODE_DEFAULT); cv.put(Settings.SETTING_PREVIEW_ENABLED, Settings.SETTING_PREVIEW_ENABLED_DEFAULT); cv.put(Settings.SETTING_PICTURE_RESOLUTION_X, Settings.SETTING_PICTURE_RESOLUTION_X_DEFAULT); cv.put(Settings.SETTING_PICTURE_RESOLUTION_Y, Settings.SETTING_PICTURE_RESOLUTION_Y_DEFAULT); cv.put(Settings.SETTING_VIDEO_RESOLUTION_X, Settings.SETTING_VIDEO_RESOLUTION_X_DEFAULT); cv.put(Settings.SETTING_VIDEO_RESOLUTION_Y, Settings.SETTING_VIDEO_RESOLUTION_Y_DEFAULT); cv.put(Settings.SETTING_VIDEO_FPS, Settings.SETTING_VIDEO_FPS_DEFAULT); cv.put(Settings.SETTING_AUDIO_BITRATE_KBPS, Settings.SETTING_AUDIO_BITRATE_KBPS_DEFAULT); cv.put(Settings.SETTING_STORE_TO_SD, Settings.SETTING_STORE_TO_SD_DEFAULT); cv.put(Settings.SETTING_STORAGE_LIMIT_MB, Settings.SETTING_STORAGE_LIMIT_MB_DEFAULT); this.db.insert(Settings.SETTINGS_TABLE_NAME, null, cv); } The CREATE_SETTINGS_TABLE string is defined as the following: private static String CREATE_SETTINGS_TABLE = "CREATE TABLE IF NOT EXISTS " + Settings.SETTINGS_TABLE_NAME + "(" + Settings.SETTING_UNIQUE_ID + " TEXT NOT NULL PRIMARY KEY, " + Settings.SETTING_DEVICE_ID + " TEXT NOT NULL , " + Settings.SETTING_CONNECTION_PREFERENCE + " TEXT NOT NULL CHECK("+Settings.SETTING_CONNECTION_PREFERENCE+" IN("+Settings.SETTING_CONNECTION_PREFERENCE_ALLOWED+")), " + Settings.SETTING_AD_HOC_ENABLED + " TEXT NOT NULL CHECK("+Settings.SETTING_AD_HOC_ENABLED+" IN("+Settings.SETTING_AD_HOC_ENABLED_ALLOWED+")), " + Settings.SETTING_SERVER_ADDRESS + " TEXT NOT NULL, " + Settings.SETTING_RECORDING_MODE + " TEXT NOT NULL CHECK("+Settings.SETTING_RECORDING_MODE+" IN("+Settings.SETTING_RECORDING_MODE_ALLOWED+")), " + Settings.SETTING_PREVIEW_ENABLED + " TEXT NOT NULL CHECK("+Settings.SETTING_PREVIEW_ENABLED+" IN("+Settings.SETTING_PREVIEW_ENABLED_ALLOWED+")), " + Settings.SETTING_PICTURE_RESOLUTION_X + " TEXT NOT NULL, " + Settings.SETTING_PICTURE_RESOLUTION_Y + " TEXT NOT NULL, " + Settings.SETTING_VIDEO_RESOLUTION_X + " TEXT NOT NULL, " + Settings.SETTING_VIDEO_RESOLUTION_Y + " TEXT NOT NULL, " + Settings.SETTING_VIDEO_FPS + " TEXT NOT NULL, " + Settings.SETTING_AUDIO_BITRATE_KBPS + " TEXT NOT NULL, " + Settings.SETTING_STORE_TO_SD + " TEXT NOT NULL CHECK("+Settings.SETTING_STORE_TO_SD+" IN("+Settings.SETTING_STORE_TO_SD_ALLOWED+")), " + Settings.SETTING_STORAGE_LIMIT_MB + " TEXT NOT NULL )"; However, when I execute my insert, I always get: 03-19 19:37:36.974: ERROR/Database(386): Error inserting server_address='0.0.0.0' storage_limit='-1' connection='none' preview_enabled='0' sd_enabled='1' video_fps='15' audio_bitrate='96' device_id='-1' recording_mode='none' picture_resolution_x='-1' picture_resolution_y='-1' unique_id='000000000000000' adhoc_enable='0' video_resolution_x='320' video_resolution_y='240' 03-19 19:45:34.284: ERROR/Database(446): android.database.sqlite.SQLiteConstraintException: error code 19: constraint failed It seems as if all the columns in my insert are not null. The row's primary key HAS to be unique, because it's the only row in the table. Therefore, the only thing I can think of is my CHECK conditions aren't true. Here are the predefined strings I'm using: public static final String SETTING_UNIQUE_ID = "unique_id"; public static final String SETTING_DEVICE_ID = "device_id"; public static final String SETTING_DEVICE_ID_DEFAULT = "'-1'"; public static final String SETTING_CONNECTION_PREFERENCE = "connection"; public static final String SETTING_CONNECTION_PREFERENCE_3G = "'3g'"; public static final String SETTING_CONNECTION_PREFERENCE_WIFI = "'wifi'"; public static final String SETTING_CONNECTION_PREFERENCE_NONE = "'none'"; public static final String SETTING_CONNECTION_PREFERENCE_ALLOWED = SETTING_CONNECTION_PREFERENCE_3G+","+SETTING_CONNECTION_PREFERENCE_WIFI+","+SETTING_CONNECTION_PREFERENCE_NONE; public static final String SETTING_CONNECTION_PREFERENCE_DEFAULT = SETTING_CONNECTION_PREFERENCE_NONE; public static final String SETTING_AD_HOC_ENABLED = "adhoc_enable"; public static final String SETTING_AD_HOC_ENABLED_ALLOWED = TRUE+","+FALSE; public static final String SETTING_AD_HOC_ENABLED_DEFAULT = FALSE; public static final String SETTING_SERVER_ADDRESS = "server_address"; public static final String SETTING_SERVER_ADDRESS_DEFAULT = "'0.0.0.0'"; public static final String SETTING_RECORDING_MODE = "recording_mode"; public static final String SETTING_RECORDING_MODE_VIDEO = "'video'"; public static final String SETTING_RECORDING_MODE_AUDIO = "'audio'"; public static final String SETTING_RECORDING_MODE_PICTURE = "'picture'"; public static final String SETTING_RECORDING_MODE_NONE = "'none'"; public static final String SETTING_RECORDING_MODE_ALLOWED = SETTING_RECORDING_MODE_VIDEO+","+SETTING_RECORDING_MODE_AUDIO+","+SETTING_RECORDING_MODE_PICTURE+","+SETTING_RECORDING_MODE_NONE; public static final String SETTING_RECORDING_MODE_DEFAULT = SETTING_RECORDING_MODE_NONE; public static final String SETTING_PREVIEW_ENABLED = "preview_enabled"; public static final String SETTING_PREVIEW_ENABLED_ALLOWED = TRUE+","+FALSE; public static final String SETTING_PREVIEW_ENABLED_DEFAULT = FALSE; public static final String SETTING_PICTURE_RESOLUTION_X = "picture_resolution_x"; public static final String SETTING_PICTURE_RESOLUTION_X_DEFAULT = "'-1'"; public static final String SETTING_PICTURE_RESOLUTION_Y = "picture_resolution_y"; public static final String SETTING_PICTURE_RESOLUTION_Y_DEFAULT = "'-1'"; public static final String SETTING_VIDEO_RESOLUTION_X = "video_resolution_x"; public static final String SETTING_VIDEO_RESOLUTION_X_DEFAULT = "'320'"; public static final String SETTING_VIDEO_RESOLUTION_Y = "video_resolution_y"; public static final String SETTING_VIDEO_RESOLUTION_Y_DEFAULT = "'240'"; public static final String SETTING_VIDEO_FPS = "video_fps"; public static final String SETTING_VIDEO_FPS_DEFAULT = "'15'"; public static final String SETTING_AUDIO_BITRATE_KBPS = "audio_bitrate"; public static final String SETTING_AUDIO_BITRATE_KBPS_DEFAULT = "'96'"; public static final String SETTING_STORE_TO_SD = "sd_enabled"; public static final String SETTING_STORE_TO_SD_ALLOWED = TRUE+","+FALSE; public static final String SETTING_STORE_TO_SD_DEFAULT = TRUE; public static final String SETTING_STORAGE_LIMIT_MB = "storage_limit"; public static final String SETTING_STORAGE_LIMIT_MB_DEFAULT = "'-1'"; public static final String SETTING_CLIP_LENGTH_SECONDS = "clip_length"; public static final String SETTING_CLIP_LENGTH_SECONDS_DEFAULT = "'300'"; Does anyone see what could be going on? I'm stumped. Thanks in advance.

    Read the article

  • Is there a Scala version of .irbrc or another way to define some default libraries for REPL use?

    - by Tom Morris
    I've written a little library that uses implicits to add functionality that one only needs when using the REPL in Scala. Ruby has libraries like this - for things like pretty printing, firing up text editors (like the interactive_editor gem which invokes Vim from irb - see this post), debuggers and the like. The library I am trying to write adds some methods to java.lang.Class and java.lang.reflect classes using the 'pimp my library' implicit conversion process to help you go and find documentation (initially, with Google, then later possibly with a JavaDoc/ScalaDoc viewer, and maybe the StackOverflow API eventually!). It's an itch-scratching library: I spend so much time copying and pasting classnames into Google that I figured I may as well automate the process. It is the sort of functionality that developers will want to add to their system for use only in the REPL - they shouldn't really be adding it to projects (partly because it may not be something that their fellow developers want, but also because if you are doing some exploratory development, it may be with just a Scala REPL that's not being invoked by an IDE or build tool). In my case, I want to include a few classes and set up some implicits - include a .jar on the CLASSPATH and import it, basically. In Ruby, this is the sort of thing that you'd add to your .irbrc file. Other REPLs have similar ways of setting options and importing libraries. Is there a similar file or way of doing this for the Scala REPL?

    Read the article

  • How to write a good PHP database insert using an associative array

    - by Tom
    In PHP, I want to insert into a database using data contained in a associative array of field/value pairs. Example: $_fields = array('field1'=>'value1','field2'=>'value2','field3'=>'value3'); The resulting SQL insert should look as follows: INSERT INTO table (field1,field2,field3) VALUES ('value1','value2','value3'); I have come up with the following PHP one-liner: mysql_query("INSERT INTO table (".implode(',',array_keys($_fields)).") VALUES (".implode(',',array_values($_fields)).")"); It separates the keys and values of the the associative array and implodes to generate a comma-separated string . The problem is that it does not escape or quote the values that were inserted into the database. To illustrate the danger, Imagine if $_fields contained the following: $_fields = array('field1'=>"naustyvalue); drop table members; --"); The following SQL would be generated: INSERT INTO table (field1) VALUES (naustyvalue); drop table members; --; Luckily, multiple queries are not supported, nevertheless quoting and escaping are essential to prevent SQL injection vulnerabilities. How do you write your PHP Mysql Inserts? Note: PDO or mysqli prepared queries aren't currently an option for me because the codebase already uses mysql extensively - a change is planned but it'd take alot of resources to convert?

    Read the article

  • Document.oncontextmenu, component is not available (firefox)

    - by Tom J Nowell
    I have a script for a website, and one of the things ti does right at the end if attempt to disable an anti-right click protection in a website if($("span[class=MembersNameDisplay]").exists()){ var list_row = document.getElementsByTagName('script'); if(list_row != null){ list_row[0].parentNode.removeChild(list_row[0]); } } document.oncontextmenu=new Function("return true"); In google chrome this works, however in firefox with greasemonkey, the last line fails and the protection is not removed. Error: Component is not available Line: 171 How do I fix this, and why does it fail under firefox?

    Read the article

  • How to stop/override a Jquery TimeOut function?

    - by Tom
    Hi, I have a small jquery snippet that displays notification message at the top of the screen in response to user actions on a page. The notification is often displayed after Ajax actions with dynamic content inside it. For example: $("#mini-txt").html("Thank you!"); $("#mini").fadeIn("fast"); setTimeout(function() {$("#mini").animate({height: "hide", opacity: "hide"}, "medium");}, 3000); The notification works well, except when a user does two or more actions in rapid succession, in which case the TimeOut function will confuse itself and the second message appears to come inside the previous 3000 milliseconds. Is there a way to "kill" the previous notification if a new action is performed. I've got no problem with the actions/selectors, just the TimeOut function.... either stopping it or overriding it somehow. Or perhaps there's a better alternative for getting the message to linger on the screen for a few seconds before disappearing? Thank you.

    Read the article

  • How can I write an installer for 32 and 64 bit

    - by tom greene
    I have a .NET app which works in 32 and 64 bit. I would like to write one single installer that installs to c:\program files, not c:\program files(x86) regardless of the platform. From this link: http://msdn.microsoft.com/en-us/library/w1behyzx(v=VS.90).aspx it doesn't look possible. Is it the case?

    Read the article

  • Is adding a bit mask to all tables in a database useful?

    - by Tom
    A colleague is adding a bit mask to all our database tables. In theory this is so we can track certain properties of each row across the entire system. For example... Is the row shipped with the system or added by the client once they've started using the system Has the row been deleted from the table (soft deletes) Is the row a default value within a set of rows Is this a good idea? Are there other uses where this approach would be beneficial? My preference is these properties are obviously important, and having a dedicated column for each property is justified to make what is happening clearer to fellow developers.

    Read the article

  • Adding a custom option using an extension in Magento

    - by Tom
    I'm creating a custom extension and I would like to add a custom option when a certain item is purchased. For example, when the product "Name Tag" is purchased, the extension would detect that the specific product has been ordered and assign a custom option of "Year" to it. The user does not see this, but the attribute is added and displayed in the admin when viewing the order. Are there any specific listeners our there to accomplish this?

    Read the article

  • Silverlight 3 version compatibility

    - by Tom Allen
    We've noticed a compatibility issue with a Silverlight 3 app which runs fine with v3.0.40818, v3.0.50106 and v4.0.50401 but refuses to load in v3.0.40624. Instead it gives a message box saying a more recent version of Silverlight is required. Does anyone know what the changes were between 3.0.40624 and 3.0.40818 or why the app might not be compatible?

    Read the article

  • How do I redirect stdin/stdout when I have a sequence of commands in Bash?

    - by Tom
    I've currently got a Bash command being executed (via Python's subprocess::Popen) which is reading from stdin, doing something and outputing to stdout. Something along the lines of: pid = subprocess.Popen( ["-c", "cmd1 | cmd2"], stdin = subprocess.PIPE, stdout = subprocess.PIPE, shell =True ) output_data = pid.communicate( "input data\n" ) Now, what I want to do is to change that to execute another command in that same subshell that will alter the state before the next commands execute, so my shell command line will now (conceptually) be: cmd0; cmd1 | cmd2 Is there any way to have the input sent to cmd1 instead of cmd0 in this scenario? I'm assuming the output will include cmd0's output (which will be empty) followed by cmd2's output. cmd0 shouldn't actually read anything from stdin, does that make a difference in this situation? I know this is probably just a dumb way of doing this, I'm trying to patch in cmd0 without altering the other code too significantly. That said, I'm open to suggestions if there's a much cleaner way to approach this.

    Read the article

  • Symfony 1.4: Storing an array in session with SetAttribute

    - by Tom
    Hi, I'm wondering if someone knows how to store an array into a user session? This is the method to store a single attribute: $this->getUser()->setAttribute('something', $something); And the documentation says: "User attributes can store any type of data (strings, arrays, and associative arrays)" ... but doesn't say anything more. The API documentation doesn't have a "SetAttributes" or something similarly obvious. Thank you.

    Read the article

  • Why's a simple change to rt.jar causing the Java Runtime Environment to crash silently?

    - by Tom
    This is what I'm doing: extract contents of my JRE's rt.jar extract src.zip of my JDK (same version) Now, if I copy Runtime.java from the extracted src folder and compile it using javac.exe without any modifications and then put it in the extracted rt folder to finally put everything back in a jar file using jar.exe, everything works as expected. The JRE runs fine. However, if I make the slightest change to Runtime.java and compile it and put it in rt.jar, the JRE crashes whenever I attempt to start it. This is an example of a slight change that causes the silent crash: /** Don't let anyone else instantiate this class */ private Runtime() { System.out.println("This is a test."); } Instead of: /** Don't let anyone else instantiate this class */ private Runtime() {} Could anyone tell me why this is causing my JRE to crash? Thanks in advance.

    Read the article

  • How do I append Word templates to a new document in VB.NET?

    - by Tom
    I'm poking around to see if this app can be done. Basically the end user needs to create a bunch of export documents that are populated from a database. There will be numerous document templates (.dot) and the end result will be the user choosing templates x y and z to include for documentation, click a button and have the app create a new Word document, append the templates, and then populate the templates with the appropriate data. The reason it needs to be done in Word as opposed to something like Crystal Reports is that the user may customize some fields before printing the documents as it can vary from export to export. Is this possible to do through VB.NET (VS 2010)? I assume it is but I'm having difficulty tracking down a solution. Or alternatively is there a better solution? Here's what I have so far (not much I know) Import Microsoft.Office.Interop Public Class Form1 Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim oWord As Word.Application Dim oDoc As Word.Document oWord = CreateObject("Word.Application") oWord.Visible = False oDoc = oWord.Documents.Add 'Open templates x.dot, y.dot, z.dot 'Append above templates to new document created 'Populate new document oWord.Visible = True End Sub End Class Thanks.

    Read the article

  • What's the best way of accessing a DRb object (e.g. Ruby Queue) from Scala (and Java)?

    - by Tom Morris
    I have built a variety of little scripts using Ruby's very simple Queue class, and share the Queue between Ruby and JRuby processes using DRb. It would be nice to be able to access these from Scala (and maybe Java) using JRuby. I've put together something Scala and the JSR-223 interface to access jruby-complete.jar. import javax.script._ class DRbQueue(host: String, port: Int) { private var engine = DRbQueue.factory.getEngineByName("jruby") private var invoker = engine.asInstanceOf[Invocable] engine.eval("require \"drb\" ") private var queue = engine.eval("DRbObject.new(nil, \"druby://" + host + ":" + port.toString + "\")") def isEmpty(): Boolean = invoker.invokeMethod(this.queue, "empty?").asInstanceOf[Boolean] def size(): Long = invoker.invokeMethod(this.queue, "length").asInstanceOf[Long] def threadsWaiting: Long = invoker.invokeMethod(this.queue, "num_waiting").asInstanceOf[Long] def offer(obj: Any) = invoker.invokeMethod(this.queue, "push", obj.asInstanceOf[java.lang.Object]) def poll(): Any = invoker.invokeMethod(this.queue, "pop") def clear(): Unit = { invoker.invokeMethod(this.queue, "clear") } } object DRbQueue { var factory = new ScriptEngineManager() } (It conforms roughly to java.util.Queue interface, but I haven't declared the interface because it doesn't implement the element and peek methods because the Ruby class doesn't offer them.) The problem with this is the type conversion. JRuby is fine with Scala's Strings - because they are Java strings. But if I give it a Scala Int or Long, or one of the other Scala types (List, Set, RichString, Array, Symbol) or some other custom type. This seems unnecessarily hacky: surely there has got to be a better way of doing RMI/DRb interop without having to use JSR-223 API. I could either make it so that the offer method serializes the object to, say, a JSON string and takes a structural type of only objects that have a toJson method. I could then write a Ruby wrapper class (or just monkeypatch Queue) to would parse the JSON. Is there any point in carrying on with trying to access DRb from Java/Scala? Might it just be easier to install a real message queue? (If so, any suggestions for a lightweight JVM-based MQ?)

    Read the article

  • sqlplus remove \r \n \t from spool

    - by Tom
    Hi all, Is there any sql*plus command to remove \r \n and\t from the result set that's going out to the spool file? That is, "trim" every record? We've used set trim on in the past, but it doesn't seem to bue what we need right now. I'm trying to avoid calling oracle's translate, chr functions in the sql query. For example, If my query returns this |DATA| |\n \t\t\t\t\t thisistheactualdata \t\t\t\t\t\t\n| I'd like to keep this |DATA| |thisistheactualdata| Thanks in advance.

    Read the article

< Previous Page | 49 50 51 52 53 54 55 56 57 58 59 60  | Next Page >