Search Results

Search found 1369 results on 55 pages for 'jc martin'.

Page 39/55 | < Previous Page | 35 36 37 38 39 40 41 42 43 44 45 46  | Next Page >

  • Should TcpClient be used for this scenario?

    - by Martín Marconcini
    I have to communicate with an iPhone. I have its IP Address and the port (obtained via Bonjour). I need to send a header that is “0x50544833” (or similar, It’s an HEX number), then the size of the data (below) and then the data itself. The data is just a string that looks like this: <?xml version="1.0" encoding="utf-8"?> <!DOCTYPE plist SYSTEM "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> <plist version="1.0"> <dict> <key>clientName</key> <string>XXX</string> <key>clientService</key> <string>0be397e7-21f4-4d3c-89d0-cdf179a7e14d</string> <key>registerCode</key> <string>0000</string> </dict> </plist> The requirement also says that I must send the data in little endian format (which I think is the default for Intel anyway). So it would be: hex_number + size of data + string_with_the_above_xml. I need to send that to the iPhone and read the response. What would be, according to your experience, the best way to send this data (and read the response)?

    Read the article

  • Set background of UITableview in interface builder?

    - by Martin
    In iPhone I need to set the background view of a UITableview. From 3.2 SDK I can in code use something like: [self.tableView setBackgroundView:[[UIImageView alloc] initWithImage:[UIImage imageNamed:@"mycustombackground.png"]]]; But how can I do the same in interface builder? It would be great if I could just set the background view directly in interface builder. But can't seem to find this property, where is it? Thanks!

    Read the article

  • PHP: Escape illegal chars in .ini-files

    - by Martin
    The documentation on parse_ini_file (http://php.net/manual/en/function.parse-ini-file.php) states that you can't use these chars {}|&~![()^" in the value. Is there some way to escape these chars? I need to use them. Normal escaping with \ doesn't seem to work.

    Read the article

  • Correct way to use Drupal 7 Entities and Field API

    - by Martin Petts
    I'm trying to use Drupal 7's entities and field API to correctly build a new module. What I have been unable to understand from the documentation is the correct way to use the new API to create a 'content type' (not a node type) with a number of set fields, such as Body. I'm trying to set up the entity using hook_entity_info, then I believe I need to add the body field using field_create_instance, but I can't seem to get it to work. In mycontenttype.module: /** * Implements hook_entity_info(). */ function mycontenttype_entity_info() { $return = array( 'mycontenttype' => array( 'label' => t('My Content Type'), 'controller class' => 'MyContentTypeEntityController', 'base table' => 'content_type', 'uri callback' => 'content_type_uri', 'entity keys' => array( 'id' => 'cid', 'label' => 'title' ), 'bundles' => array( 'mycontenttype' => array( 'label' => 'My Content Type', 'admin' => array( 'path' => 'admin/contenttype', 'access arguments' => array('administer contenttype') ) ) ), 'fieldable' => true ) ); return $return; } /** * Implements hook_field_extra_fields(). */ function mycontenttype_field_extra_fields() { $return['mycontenttype']['mycontenttype'] = array( 'form' = array( 'body' = array( 'label' = 'Body', 'description' = t('Body content'), 'weight' = 0, ), ), ); return $return; } Then does this go in the .install file? function mycontenttype_install() { $field = array( 'field_name' => 'body', 'type' => 'text_with_summary', 'entity_types' => array('survey'), 'translatable' => TRUE, ); field_create_field($field); $instance = array( 'entity_type' => 'mycontenttype', 'field_name' => 'body', 'bundle' => 'mycontenttype', 'label' => 'Body', 'widget_type' => 'text_textarea_with_summary', 'settings' => array('display_summary' => TRUE), 'display' => array( 'default' => array( 'label' => 'hidden', 'type' => 'text_default', ), 'teaser' => array( 'label' => 'hidden', 'type' => 'text_summary_or_trimmed', ) ) ); field_create_instance($instance); }

    Read the article

  • pre_replace multi-dimensional array problem

    - by Martin
    I want to replace word groups by links. I use a multi-dimensional array to define these (in the real world there will be thousands of them). Here's the code: $text = "<html><body><pre> Here is Foo in text. Now come Baz? and Bar-X. Replace nothing here: Foo (followed by brackets). </pre></body></html>"; $s = array( array("t" => "Foo", "u" => "http://www.foo.com", "c" => "foo"), array("t" => "Baz?", "u" => "http://www.baz.net", "c" => "test"), array("t" => "Bar-X", "u" => "http://www.baz.org", "c" => "test") ); foreach ($s as $i => $row) { $replaced = preg_replace('/(?=\Q'.$row["t"].'\E[^(]+$)\b\Q'.$row["t"].'\E\b/m', '<a href="'.$row["u"].'" class="'.$row["c"].'">'.$row["t"].'</a>', $text); } echo $replaced; ?> The problem is that only one array element is replaced and not all. It's something about $text in peg_replace(). Anyone got a hint for me? Thanks!

    Read the article

  • Can I add Controls that are not ListItems to a RadioButtonList?

    - by Simon Martin
    I need to provide a way to allow users to select 1 Subject, but the subjects are grouped into Qualifications and so I want to show a heading for each 'group'. My first thought is an asp:RadioButtonList as that provides a list of options from which only one can be selected but there's no means to add break the list up with headings. So I tried the following code - but I can't see that the LiteralControl is being added, which makes me think it's not a valid approach. For Each item As Subject In Qualifications If item.QualCode <> previousQualCode Then rblSelection.Controls.Add(New LiteralControl(item.QualName)) End If rblSelection.Items.Add(New ListItem(item.SubjectName, item.SelectionCode)) previousQualCode = item.QualCode Next

    Read the article

  • Error safe/correcting resource identifier

    - by Martin
    The receiver is my website, the sender is the same but the medium is noisy, a user. He will read an alphanumeric code of length 6 and later input the same code to identify a resource. A good use for a error correcting code, I thought, and rather than do the research I thought I'd just put the question out there. Or I might be going about it the wrong way, since the situation is rather like sending a perfect dictionary along with every transmission. The requirements on the code are simply: 6 alphanumeric digits, to start with until I run out, anyway. If the user gets it wrong I should still be able to identify the right resource. No resource is preferable to the wrong one. Easy to code or have free libraries for .net Any suggestions?

    Read the article

  • Nested functions not allowed in drawrect problem

    - by Martin
    I have a custom view onto which I draw some graphics from the drawrect function, which works fine. However I like to draw based on the contens of an array I pass on the the view just before I do a setNeedsDisplay. In the drawRect function I try to access the array but then I get a nested functions error which I do not understand. Here's my code: // // MyView.h // window // #import <UIKit/UIKit.h> @interface MyView : UIView { NSArray * nary; } @property (nonatomic, copy) NSArray *nary; @end // // MyView.m // window // #import "MyView.h" @implementation MyView @synthesize nary; CGContextRef c; CGFloat black[4] = {0.0f, 0.0f, 0.0f, 1.0f}; - (id)initWithFrame:(CGRect)frame { if (self = [super initWithFrame:frame]) { // Initialization code } return self; } - (void)drawRect:(CGRect)rect { c = UIGraphicsGetCurrentContext(); CGContextSetStrokeColor(c, black); NSLog(@"mview"); NSArray *ns = [nary objectAtIndex:0]; } - (void)dealloc { [super dealloc]; } @end

    Read the article

  • Need advice with a model - should I choose has_many through

    - by Martin Petrov
    I have something like a blog with posts and tags. I want to add email notification functionality - users can subscribe to one or more tags and receive email notifications when new posts are added. Currently I have a Tag model. There will be a Subscriber model (containing the user's email) Do you think I also need a Subscription table where Subscriber and Tag are joined? .. or I can skip it and directly link Subscriber with Tag?

    Read the article

  • jQuery $.ajax calls success handler when reuqest fails because of browser reloading

    - by Martin
    I have the following code: $.ajax({ type: "POST", url: url, data: sendable, dataType: "json", success: function(data) { if(customprocessfunc) customprocessfunc(data); }, error: function(XMLHttpRequest, textStatus, errorThrown){ // error handler here } }); I have a timer which makes AJAX requests often. If I do not receive anything in 'data', I show an error message to the user - it means, something wnet bad on the server. The problem is when user reloads the page while the AJAX call is in progress. I can see in the firebug that the AJAX call fails (URL is colored red and no HTTP status is displayed) so I expect that jQuery will stop the reuqest or at least go to the error handler. But it goes to the success handler and passes null in the 'data' variable. As a result, when user reloads the page, sometimes he can see my big red message about unknown error (because data is null). Is there any way to make jQuery abort the request on complete reloading all at least not to call my success function? I have no way to know in the success handler why the data is null - did it came empty from the server or the call was aborted because of reload.

    Read the article

  • EF4 + STE: Reattaching via a WCF Service? Using a new objectcontext each and every time?

    - by Martin
    Hi there, I am planning to use WCF (not ria) in conjunction with Entity Framework 4 and STE (Self tracking entitites). If i understnad this correctly my WCF should return an entity or collection of entities (using LIST for example and not IQueryable) to the client (in my case silverlight) The client then can change the entity or update it. At this point i believe it is self tracking???? This is where i sort of get a bit confused as there are a lot of reported problems with STEs not tracking.. Anyway... Then to update i just need to send back the entity to my WCF service on another method to do the update. I should be creating a new OBJECTCONTEXT everytime? In every method? If i am creaitng a new objectcontext everytime in everymethod on my WCF then don't i need to re-attach the STE to the objectcontext? So basically this alone wouldn't work?? using(var ctx = new MyContext()) { ctx.Orders.ApplyChanges(order); ctx.SaveChanges(); } Or should i be creating the object context once in the constructor of the WCF service so that 1 call and every additional call using the same wcf instance uses the same objectcontext? I could create and destroy the wcf service in each method call from the client - hence creating in effect a new objectcontext each time. I understand that it isn't a good idea to keep the objectcontext alive for very long. Any insight or information would be gratefully appreciated thanks

    Read the article

  • C++ socket protocol design issue (ring inclusion)

    - by Martin Lauridsen
    So I have these two classes, mpqs_client and client_protocol. The mpqs_client class handles a Boost socket connection to a server (sending and receiving messages with some specific format. Upon receiving a message, it calls a static method, parse_message(..), in the class client_protocol, and this method should analyse the message received and perform some corresponding action. Given some specific input, the parse_message method needs to send some data back to the server. As mentioned, this happens through the class mpqs_client. So I could, from mpqs_client, pass "this" to parse_message(..) in client_protocol. However, this leads to a two-way association relationship between the two classes. Something which I reckon is not desireable. Also, to implement this, I would need to include the other in each one, and this gives me a terrible pain. I am thinking this is more of a design issue. What is the best solution here? Code is posted below. Class mpqs_client: #include "mpqs_client.h" mpqs_client::mpqs_client(boost::asio::io_service& io_service, tcp::resolver::iterator endpoint_iterator) : io_service_(io_service), socket_(io_service) { ... } ... void mpqs_client::write(const network_message& msg) { io_service_.post(boost::bind(&mpqs_client::do_write, this, msg)); } Class client_protocol: #include "../network_message.hpp" #include "../protocol_consts.h" class client_protocol { public: static void parse_message(network_message& msg, mpqs_sieve **instance_, mpqs_client &client_) { ... switch (type) { case MPQS_DATA: ... break; case POLYNOMIAL_DATA: ... break; default: break; } }

    Read the article

  • Create lambda action from function expression

    - by Martin Robins
    It is relatively easy to create a lambda function that will return the value of a property from an object, even including deep properties... Func<Category, string> getCategoryName = new Func<Category, string>(c => c.Name); and this can be called as follows... string categoryName = getCategoryName(this.category); But, given only the resulting function above (or the expression originally used to create the function), can anybody provide an easy way to create the opposing action... Action<Category, string> setCategoryName = new Action<Category, string>((c, s) => c.Name = s); ...that will enable the same property value to be set as follows? setCategoryName(this.category, ""); Note that I am looking for a way to create the action programatically from the function or expression - I hope that I have shown that I already know how to create it manually. I am open to answers that work in both .net 3.5 and 4.0. Thanks.

    Read the article

  • Filling a LOV in Oracle Apex based on data in another text box

    - by Martin Pugh
    I am fairly new to Oracle Apex, and have a problem. Our application currently has a method of entering data, with several text boxes and Optional List of Values. I would like to have an LOV based on information in another text box like so: select APPOINTMENT_ID PATIENT_ID from APPOINTMENT where PATIENT_ID = :P9_PAT_NUM where P9_PAT_NUM is a patient number in a text box. However, this would apparently only work if the text box has already been submitted, else it assumes the text box is null. Is there any way to get this working with an LOV, or perhaps some other method?

    Read the article

  • Why do I get corrupt output on my file?

    - by Martin
    I have a simple program which I have compiled in both MinGW and Visual C++ 2008 Express, and both give an output file larger than 88200. When I set s = 0, both programs work as expected. What am I doing wrong? #include <fstream> using namespace std; int main(int argc, char *argv[]) { int i; short s; fstream f; f.open("test.raw", ios_base::out); for(i = 0; i < 44100; i++) { s = i & 0xFFFF; // PROBLEM? f.write(reinterpret_cast<const char *>(&s), sizeof(s)); } f.close(); return 0; }

    Read the article

  • Wordpress paths issue

    - by Martin
    I have set a crawler up in wordpress which grabs stocks data and writes to file which when a user enters a symbol/ticker the variable is read and if it matches the data of a previous crawl for that particular companies data will echo the text file on page, if no data is found the crawler then sets off grabs it and writes to file to save for the next time that symbol is used. The problem im having is that everything works groovey apart from one thing, when the content is written to file it saves it in the WP root and not inside a subfolder of the theme, basicaly this means that root becomes untidy very quickly and also should the theme be used on another site then its not practical as some important info is missing. I have tried bloginfo and absolute both return the same failure. This is the code i am using to write to file, like i say it works apart from writing the file into root. <?php $CompDetails = "http://www.devserverurl.com/mattv1/wp-content/themes/stocks/tools/modules/Stock_Quote/company_details/$Symbol.txt"; if (file_exists($CompDetails)) {} else { include ('crawler_file.php'); $html = file_get_html("http://targeturl.com/research/stocks/snapshot/snapshot.asp?ticker=$Symbol:US"); $es = $html->find('div[class="detailsDataContainerLt"]'); $tickerdetails = ("$es[0]"); $FileHandle2 = fopen($CompDetails, 'w') or die("can't open file"); fwrite($FileHandle2, $tickerdetails); fclose($FileHandle2); } ?> edit below, have also tried this and the same happens as above <?php if (file_exists($_SERVER['DOCUMENT_ROOT'] . "/wp-content/themes/stocks/tools/modules/Stock_Quote/company_details/$Symbol.txt")) {} else { include ('crawler_file.php'); $html = file_get_html("http://targeturl.com/research/stocks/snapshot/snapshot.asp?ticker=$Symbol:US"); $es = $html->find('div[class="detailsDataContainerLt"]'); $tickerdetails = ("$es[0]"); $FileHandle2 = fopen($_SERVER['DOCUMENT_ROOT'] . "/wp-content/themes/stocks/tools/modules/Stock_Quote/company_details/$Symbol.txt", 'w') or die("can't open file"); fwrite($FileHandle2, $tickerdetails); fclose($FileHandle2); } ?>

    Read the article

  • Merging list problem

    - by Martin Malmstrøm
    Sorry about the bad heading, but the question was not easy to compress into one sentence... I have two lists of contigs (list1 and list2). They contain mostly unique contigs, but with some overlap. I want to compare list1 and list2 and then create a list3 that contains all contigs in list1 minus those also present in list2. Is this possible with a simple cat/paste/grep/sort/uniq kind of batch command? Thanks!

    Read the article

  • Qt: default value of variable in class

    - by Martin
    When creating my own class in Qt I would like my variables in the class to have a standard/default value if I haven't set them to anything. It would be perfect if this was possible to set in the h-file so I don't have to do it in each instance method of my class. You can see what I want to do in the code below. In the example myBool would have the value of false and myInt the value of 0 when the object have been created. Is this possible at all? In myclass.h: class MyClass { Q_OBJECT public: MyClass(); ~MyClass(); bool myBool = false; //I want to set myBool and myInt to a default/standard value int myInt = 0; };

    Read the article

  • OnPaint event during a callback when the form is below?

    - by Martín Marconcini
    Imagine the following scenario: this.SetStyle(ControlStyles.UserPaint, true); //this doesn’t change anything … void OpenSomeForm() { SomeForm sf = new SomeForm(); sf.SomeEvent += new … (SomeEventOcurred); sf.ShowDialog(); } private void SomeEventOcurred(…) { OnePanelInThisForm.Invalidate(); } private void OnePanelInThisForm_Paint(object sender, PaintEventArgs e) { DoSomeDrawing(e.Graphics); } Now, OnePanelInThisForm draws correctly when the form loads. But if SomeEventOcurred is Fired from “SomeForm”, the paint event is not fired. If I close and reopen the form it correctly repaints. If I add a button to the form that executes: OnePanelInThisForm.Invalidate(); the panel is correctly repaint. What am I missing?

    Read the article

  • Fastest way to pad a number in Java to a certain number of digits

    - by Martin
    Am trying to create a well-optimised bit of code to create number of X-digits in length (where X is read from a runtime properties file), based on a DB-generated sequence number (Y), which is then used a folder-name when saving a file. I've come up with three ideas so far, the fastest of which is the last one, but I'd appreciate any advice people may have on this... 1) Instantiate a StringBuilder with initial capacity X. Append Y. While length < X, insert a zero at pos zero. 2) Instantiate a StringBuilder with initial capacity X. While length < X, append a zero. Create a DecimalFormat based on StringBuilder value, and then format the number when it's needed. 3) Create a new int of Math.pow( 10, X ) and add Y. Use String.valueOf() on the new number and then substring(1) it. The second one can obviously be split into outside-loop and inside-loop sections. So, any tips? Using a for-loop of 10,000 iterations, I'm getting similar timings from the first two, and the third method is approximately ten-times faster. Does this seem correct? Full test-method code below... // Setup test variables int numDigits = 9; int testNumber = 724; int numIterations = 10000; String folderHolder = null; DecimalFormat outputFormat = new DecimalFormat( "#,##0" ); // StringBuilder test long before = System.nanoTime(); for ( int i = 0; i < numIterations; i++ ) { StringBuilder sb = new StringBuilder( numDigits ); sb.append( testNumber ); while ( sb.length() < numDigits ) { sb.insert( 0, 0 ); } folderHolder = sb.toString(); } long after = System.nanoTime(); System.out.println( "01: " + outputFormat.format( after - before ) + " nanoseconds" ); System.out.println( "Sanity check: Folder = \"" + folderHolder + "\"" ); // DecimalFormat test before = System.nanoTime(); StringBuilder sb = new StringBuilder( numDigits ); while ( sb.length() < numDigits ) { sb.append( 0 ); } DecimalFormat formatter = new DecimalFormat( sb.toString() ); for ( int i = 0; i < numIterations; i++ ) { folderHolder = formatter.format( testNumber ); } after = System.nanoTime(); System.out.println( "02: " + outputFormat.format( after - before ) + " nanoseconds" ); System.out.println( "Sanity check: Folder = \"" + folderHolder + "\"" ); // Substring test before = System.nanoTime(); int baseNum = (int)Math.pow( 10, numDigits ); for ( int i = 0; i < numIterations; i++ ) { int newNum = baseNum + testNumber; folderHolder = String.valueOf( newNum ).substring( 1 ); } after = System.nanoTime(); System.out.println( "03: " + outputFormat.format( after - before ) + " nanoseconds" ); System.out.println( "Sanity check: Folder = \"" + folderHolder + "\"" );

    Read the article

  • How do I configure encodings (UTF-8) for code executed by Quartz scheduled Jobs in Spring framework

    - by Martin
    I wonder how to configure Quartz scheduled job threads to reflect proper encoding. Code which otherwise executes fine within Springframework injection loaded webapps (java) will get encoding issues when run in threads scheduled by quartz. Is there anyone who can help me out? All source is compiled using maven2 with source and file encodings configured as UTF-8. In the quartz threads any string will have encoding errors if outside ISO 8859-1 characters: Example config <bean name="jobDetail" class="org.springframework.scheduling.quartz.JobDetailBean"> <property name="jobClass" value="example.ExampleJob" /> </bean> <bean id="jobTrigger" class="org.springframework.scheduling.quartz.SimpleTriggerBean"> <property name="jobDetail" ref="jobDetail" /> <property name="startDelay" value="1000" /> <property name="repeatCount" value="0" /> <property name="repeatInterval" value="1" /> </bean> <bean class="org.springframework.scheduling.quartz.SchedulerFactoryBean"> <property name="triggers"> <list> <ref bean="jobTrigger"/> </list> </property> </bean> Example implementation public class ExampleJob extends QuartzJobBean { private Log log = LogFactory.getLog(ExampleJob.class); protected void executeInternal(JobExecutionContext ctx) throws JobExecutionException { log.info("ÅÄÖ"); log.info(Charset.defaultCharset()); } } Example output 2010-05-20 17:04:38,285 1342 INFO [QuartzScheduler_Worker-9] ExampleJob - vÖvÑvñ 2010-05-20 17:04:38,286 1343 INFO [QuartzScheduler_Worker-9] ExampleJob - UTF-8 The same lines of code executed within spring injected beans referenced by servlets in the web-container will output proper encoding. What is it that make Quartz threads encoding dependent?

    Read the article

  • Eclipse auto-complete of filenames

    - by Martin Tilsted
    Does anyone know if there exists a plugin to Eclipse which can auto complete filenames for files in the project. So if I type images/s [Alt+tab] it should present a list of all files located in images starting with s. Like the auto-complete for types but using filenames. It would be really cool if it worked with all kinds of editors.

    Read the article

  • Best way to track impressions/clicks in a bespoke advertisement system?

    - by Martin Bean
    I've been asked to create a bespoke advertisement system despite suggesting open source alternatives such as OpenX and DoubleClick for Publishers (the former Google Ad Manager). I've got the basics of the system set up, i.e. uploading creatives, creating positions and a mechanism to place creatives within positions; however, the area I'm stuck with is impression and click tracking. At the moment an impression and click is stored with the creative, but this then means impressions/clicks can't be queried. For example, we can't find how many impressions were in position x between date y and date z. How would I go about storing that kind of data? My theory was store the creative ID, position ID and timestamp in a database table, but given the amount of traffic the site has this would produce a very large database very quickly. If any one could give me a pointer or two, that would be great.

    Read the article

< Previous Page | 35 36 37 38 39 40 41 42 43 44 45 46  | Next Page >