Search Results

Search found 1875 results on 75 pages for 'tom irons'.

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

  • Trigger function on deserialization

    - by Tom Savage
    I have a class with a number of fields which are normally calculated in the constructor from other data in the class. They are not serialized to XML because any changes to the rest of the data will likely require their recalculation. Is there a way I can set up a function call to be triggered on deserialization?

    Read the article

  • Python Textwrap - forcing 'hard' breaks

    - by Tom Werner
    I am trying to use textwrap to format an import file that is quite particular in how it is formatted. Basically, it is as follows (line length shortened for simplicity): abcdef <- Ok line abcdef ghijk <- Note leading space to indicate wrapped line lm Now, I have got code to work as follows: wrapper = TextWrapper(width=80, subsequent_indent=' ', break_long_words=True, break_on_hyphens=False) for l in lines: wrapline=wrapper.wrap(l) This works nearly perfectly, however, the text wrapping code doesn't do a hard break at the 80 character mark, it tries to be smart and break on a space (at approx 20 chars in). I have got round this by replacing all spaces in the string list with a unique character (#), wrapping them and then removing the character, but surely there must be a cleaner way? N.B Any possible answers need to work on Python 2.4 - sorry!

    Read the article

  • AJAX XMLHttpRequest POST X-Domain

    - by Tom
    Hi Guys, I am sending an AJAX request using POST over X-Domain for a widget we are producing for our website. The problem we are facing is that this is getting blocked. My question is - for "modern browsers" [Chrome, Safari, FF, IE8] - it is my understanding that setting "Access-Control" headers Access-Control-Allow-Origin: http://www.test.com Access-Control-Allow-Methods: POST, GET, OPTIONS Access-Control-Allow-Headers: * Access-Control-Max-Age: 1728000 Will allow these "POST" requests to work ? But for IE7 we need to implement some "custom" JSONP solution? Am I correct in this ?

    Read the article

  • How to find memory leak from ASPX app having a DLL

    - by Tom
    Any tips How to figure out where is memory leak in my Facebook app, its ASPX using Facebook toolkit DLL and I am afraid the bug may be in that CS library. The problem is that after one week uptime, server is running out of memory and needs to be rebooted, there are quite many users and I cannot run debugger on this "production server", so I would need to simulate somehow use on my local PC.

    Read the article

  • Does my basic PHP Socket Server need optimization?

    - by Tom
    Like many people, I can do a lot of things with PHP. One problem I do face constantly is that other people can do it much cleaner, much more organized and much more structured. This also results in much faster execution times and much less bugs. I just finished writing a basic PHP Socket Server (the real core), and am asking you if you can tell me what I should do different before I start expanding the core. I'm not asking about improvements such as encrypted data, authentication or multi-threading. I'm more wondering about questions like "should I maybe do it in a more object oriented way (using PHP5)?", or "is the general structure of the way the script works good, or should some things be done different?". Basically, "is this how the core of a socket server should work?" In fact, I think that if I just show you the code here many of you will immediately see room for improvements. Please be so kind to tell me. Thanks! #!/usr/bin/php -q <? // config $timelimit = 180; // amount of seconds the server should run for, 0 = run indefintely $address = $_SERVER['SERVER_ADDR']; // the server's external IP $port = 9000; // the port to listen on $backlog = SOMAXCONN; // the maximum of backlog incoming connections that will be queued for processing // configure custom PHP settings error_reporting(1); // report all errors ini_set('display_errors', 1); // display all errors set_time_limit($timelimit); // timeout after x seconds ob_implicit_flush(); // results in a flush operation after every output call //create master IPv4 based TCP socket if (!($master = socket_create(AF_INET, SOCK_STREAM, SOL_TCP))) die("Could not create master socket, error: ".socket_strerror(socket_last_error())); // set socket options (local addresses can be reused) if (!socket_set_option($master, SOL_SOCKET, SO_REUSEADDR, 1)) die("Could not set socket options, error: ".socket_strerror(socket_last_error())); // bind to socket server if (!socket_bind($master, $address, $port)) die("Could not bind to socket server, error: ".socket_strerror(socket_last_error())); // start listening if (!socket_listen($master, $backlog)) die("Could not start listening to socket, error: ".socket_strerror(socket_last_error())); //display startup information echo "[".date('Y-m-d H:i:s')."] SERVER CREATED (MAXCONN: ".SOMAXCONN.").\n"; //max connections is a kernel variable and can be adjusted with sysctl echo "[".date('Y-m-d H:i:s')."] Listening on ".$address.":".$port.".\n"; $time = time(); //set startup timestamp // init read sockets array $read_sockets = array($master); // continuously handle incoming socket messages, or close if time limit has been reached while ((!$timelimit) or (time() - $time < $timelimit)) { $changed_sockets = $read_sockets; socket_select($changed_sockets, $write = null, $except = null, null); foreach($changed_sockets as $socket) { if ($socket == $master) { if (($client = socket_accept($master)) < 0) { echo "[".date('Y-m-d H:i:s')."] Socket_accept() failed, error: ".socket_strerror(socket_last_error())."\n"; continue; } else { array_push($read_sockets, $client); echo "[".date('Y-m-d H:i:s')."] Client #".count($read_sockets)." connected (connections: ".count($read_sockets)."/".SOMAXCONN.")\n"; } } else { $data = @socket_read($socket, 1024, PHP_NORMAL_READ); //read a maximum of 1024 bytes until a new line has been sent if ($data === false) { //the client disconnected $index = array_search($socket, $read_sockets); unset($read_sockets[$index]); socket_close($socket); echo "[".date('Y-m-d H:i:s')."] Client #".($index-1)." disconnected (connections: ".count($read_sockets)."/".SOMAXCONN.")\n"; } else { if ($data = trim($data)) { //remove whitespace and continue only if the message is not empty switch ($data) { case "exit": //close connection when exit command is given $index = array_search($socket, $read_sockets); unset($read_sockets[$index]); socket_close($socket); echo "[".date('Y-m-d H:i:s')."] Client #".($index-1)." disconnected (connections: ".count($read_sockets)."/".SOMAXCONN.")\n"; break; default: //for experimental purposes, write the given data back socket_write($socket, "\n you wrote: ".$data); } } } } } } socket_close($master); //close the socket echo "[".date('Y-m-d H:i:s')."] SERVER CLOSED.\n"; ?>

    Read the article

  • XSD problem: The value of attribute on element is not valid with respect to its type

    - by Tom Brito
    (First of all, I'm trying to learn how to handle xsd files, I know very little) I got this xsd, and just copy to Eclipse IDE, and it says there an error on line 26: <xs:element name="Issuer" type="dkx:IssuerType" /> saying: cvc-attribute.3: The value 'dkx:IssuerType' of attribute 'type' on element 'xs:element' is not valid with respect to its type, 'QName'. Any idea what is this? (as this is an example file, I'm assuming it is an independent file, hope it is)

    Read the article

  • SVG Scaling Text to fit container

    - by Tom
    This is likely a very simple question, but how do I get text in SVG to stretch to fit its container? I don't care if it looks ugly from being stretched too long or high, but it needs to fits its container and be as big as possible. Thanks

    Read the article

  • How can I write to a single xml file from two programs at the same time?

    - by Tom Bushell
    We recently started working with XML files, after many years of experience with the old INI files. My coworker found some CodeProject sample code that uses System.Xml.XmlDocument.Save. We are getting exceptions when two programs try to write to the same file at the same time. System.IO.IOException: The process cannot access the file 'C:\Test.xml' because it is being used by another process. This seems obvious in hindsight, but we had not anticipated it because accessing INI files via the Win32 API does not have this limitation. I assume there's some arbitration done by the Win32 calls that work at a higher level than the the XmlDocument.Save method. I'm hoping there are higher level XML routines somewhere in the .Net library that work similarily to the Win32 functions, but don't know where to start looking. Or maybe we can set up our file access permissions to allow multiple programs to write to the same file? Time is short (like almost all SW projects), and if we can't find a solution quickly, we'll have to hold our noses and go back to INI files.

    Read the article

  • XMLEncoder in java for serialization

    - by tom
    Im just wondering how i use xmlencoder to serialize ArrayList where foo is my own made class. Do i have to do anything in particular, ie define my own xml structure first and then call toString on each value in my list and write it out? Can anyone point me to a good tutorial? http://java.sun.com/products/jfc/tsc/articles/persistence4/ Thats what i have been looking at but it doesnt seem to mention what to do with non library classes. Thanks

    Read the article

  • Using write to print floating point numbers.

    - by Tom
    Hi, As an exercise to achieve something larger, i'm trying to use write to print a floating point number. I haven't done this in a while. I must be doing something wrong because I cant get it to work. Here is my code #include <unistd.h> int main(){ float f = 4.5; write(1,&f,sizeof float); return 0; } However, when running it im getting ?@ Any thoughts? Thanks in advance.

    Read the article

  • How to get the field name of a java (weak) reference pointing to an object in an other class?

    - by Tom
    Imagine I have the following situation: Test1.java import java.lang.ref.WeakReference; public class Test1 { public WeakReference fieldName; public init() { fieldName = new WeakReference(this); Test2.setWeakRef(fieldName); } } Test2.java import java.lang.ref.WeakReference; public class Test2 { public static setWeakRef(WeakReference weakRef) { //at this point I got weakRef in an other class.. now, how do I get the field name this reference was created with? So that it returns exactly "fieldName", because that's the name I gave it in Test1.java? } } At the location of the comment I received the weak reference created in an other class. How would I retreive the field name that this weak reference was created with, in this case "fieldName"? Thanks in advance.

    Read the article

  • Adding a view with a view controller as a subview of another view controller. Doesn't work.

    - by Tom
    I'm trying to essentially re-implement the UISplitViewController (because it has its limits), but when I create a UIViewController viewController, and then do an "[viewController.view addSubview contentViewController.view]" on it, to add a view that already has a view controller, that content view doesn't seem to get initialised by its view controller. I guess its view controller is getting detached or deallocated, is this the case?

    Read the article

  • Django app for different clients

    - by Tom Hagen
    I want both mobile phones and regular PCs to be able to use my app by navigating to the same URL, but I want them to get different versions of the code. How do I tell Django to give different versions of the code to different clients?

    Read the article

  • C Remove the first line from a text file without rewriting file

    - by Tom Van den Bon
    Hi, I've got a service which runs all the time and also keeps a log file. It basically adds new lines to the log file every few seconds. I'm written a small file which reads these lines and then parses them to various actions. The question I have is how can I delete the lines which I have already parsed from the log file without disrupting the writing of the log file by the service? Usually when I need to delete a line in a file then I open the original one and a temporary one and then I just write all the lines to the temp file except the original which I want to delete. Obviously this method will not word here. So how do I go about deleting them ?

    Read the article

  • Implicit linking vs. explicit linking of DLL in Delphi

    - by Tom
    I'm having trouble getting my dll to work when using explicit linking. Using implicit linking it works fine. Would someone google me a solution? :) No, just kidding, here's my code: This code works fine: function CountChars(_s: Pchar): integer; StdCall; external 'sample_dll.dll'; procedure TForm1.Button1Click(Sender: TObject); begin ShowMessage(IntToStr(CountChars('Hello world'))); end; This code doesn't work (I get an access violation): procedure TForm1.Button1Click(Sender: TObject); var LibHandle: HMODULE; CountChars: function(_s: PChar): integer; begin LibHandle := LoadLibrary('sample_dll.dll'); ShowMessage(IntToStr(CountChars('Hello world'))); // Access violation FreeLibrary(LibHandle); end; This is the DLL code: library sample_dll; uses FastMM4, FastMM4Messages, SysUtils, Classes; {$R *.res} function CountChars(_s: PChar): integer; stdcall; begin Result := Length(_s); end; exports CountChars; begin end.

    Read the article

  • Weird code appearing when I loop over model instances in Rails

    - by Tom Maxwell
    In my Rails app I'm trying to loop over the Submission instances inside my Folder instances with Rails templating code. It works. However, it's also returning each instance in code which doesn't seem to be JSON. It's what's returned when you look up an instance in the Rails console. Here's an example: #<Submission id: 112, title: nil, content: nil, created_at: "2013-10-10 23:29:39", updated_at: "2013-10-10 23:29:39", user_id: 1, folder_id: 1, parent_id: nil> Here's what the code looks like for the loop: <%= @folder.submissions.each do |x| %> <% if x.title != nil %> <div id="<%= x.id %>" class="submission-textual"> <h1><%= x.title %></h1> </div> <% else %> <% end %> <% end %> I checked my Folder and Submissions controllers but am not sure what this is. Why are these strings being rendered whenever I try and render an instance in my view? I'm still new to Ruby so that explains why I haven't seen this.

    Read the article

  • Why jquery.animate on a textarea make the blinking cursor disapears?

    - by Tom S.
    Hello everyone. I have the following code $(document).ready(function() { $("#myTextArea").focus(function() { $("#myTextArea").animate({ "height": "75px"}, "normal"); return false; }); to expand a textbox when it gets focus. The expand occurs, however the blinking cursor disapears, at least in Firefox! Edited: The textarea is still focused, and i can type on it. Why does this happen? Is there a way to show it again? Thanks in advance

    Read the article

  • Multiple dropdown combination check and filter

    - by Tom
    Using Javascript / jQuery, I'm trying to build a "combination checker" that will take the values of three (but can be more) dropdown lists and filter the options based on a supplied list of allowed combinations. For example: DROPDOWNS Field 1: - value_1 - value_2 Field 2: - value_3 Field 3: - value_4 - value_5 COMBINATIONS - value_1, value_3, value_5 - value_1, value_3, value_4 - value_2, value_3, value_5 When a user selects Field 3 - value_4, the unavailable options will be disabled - ie, Field 1 - value_2 (there is no combination that allows value_2 and value_4 to be selected together). It would be really great if someone could provide some pointers on how this can be achieved or just provide a fresh perspective - I'm going round in circles on this one!

    Read the article

  • Php/Shell remote SVN tarballs

    - by Tom J Nowell
    I'd like to set up daily tarballs/zip archives on my host for an SVN of a related project. I do not have access to their server, however they do have a publicly accessible SVN. How would I grab this SVN and build archives with minimal load ( dreamhost shared ), via Cron task + php/shell script?

    Read the article

  • JList with JScrollPane and prototype cell value wraps element names (replaces with dots instead of s

    - by Tom
    I've got a Jlist inside a JScrollPane and I've set a prototype value so that it doesn't have to calculate the width for big lists, but just uses this default width. Now, the problem is that the Jlist is for some reason replacing the end of an element with dots (...) so that a horizontal scrollbar will never be shown. How do I disable with "wrapping"? So that long elements are not being replaced with dots if they are wider than the Jlist's width? I've reproduced the issue in a small example application. Please run it if you don't understand what I mean: import javax.swing.*; import java.awt.*; public class Test { //window private static final int windowWidth = 450; private static final int windowHeight = 500; //components private JFrame frame; private JList classesList; private DefaultListModel classesListModel; public Test() { load(); } private void load() { //create window frame = new JFrame("Test"); frame.setSize(windowWidth, windowHeight); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setUndecorated(true); frame.getRootPane().setWindowDecorationStyle(JRootPane.PLAIN_DIALOG); //classes list classesListModel = new DefaultListModel(); classesList = new JList(classesListModel); classesList.setPrototypeCellValue("prototype value"); classesList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); classesList.setVisibleRowCount(20); JScrollPane scrollClasses = new JScrollPane(classesList, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED); for (int i = 0; i < 200; i++) { classesListModel.addElement("this is a long string, does not fit in width"); } //panel JPanel drawingArea = new JPanel(); drawingArea.setBackground(Color.white); drawingArea.add(scrollClasses); frame.add(drawingArea); //set visible frame.setVisible(true); } } Even if you force horizontal scrollbar, you still won't be able to scroll because the element is actually not wider than the width because of the dot (...) wrapping. Thanks in advance.

    Read the article

  • Cannot open a .tif with color using .Net Image or Bitmap classes

    - by Tom Regan
    I am attempting to open .tif files that have color in them (300 dpi, PixelFormat.Format24bppRgb) using the .Net Image and Bitmap classes. I always get an "invalid parameter" error when the tiffs have color (works fine for black and white tiffs). If anyone has source code on how to open a .tif with color in it I'd deeply appreciate it. Below is what I'm attempting to do; this also fails when calling Bitmap.FromStream: using (FileStream fs = File.OpenRead(fileName)) { using (Image img = Image.FromStream(fs)) {} }

    Read the article

  • How to make a DIV auto height resizable even if the content is absolute?

    - by Tom
    Hi, i have a container div which is position:relative and the squares are position:absolute because i want to play with their positions. Like what you see, the container does not fit the content except if the squares are positioned in Relative, is there a solution for this? I don't want to just set the height for container because the squares are not static so i want something that resizes automatically. Thanks

    Read the article

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