Daily Archives

Articles indexed Saturday May 8 2010

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

  • Additional spaces in String having read text file to String using FileInputStream

    - by David
    Hi, I'm trying to read in a text file to a String variable. The text file has multiple lines. Having printed the String to test the "read-in" code, there is an additional space between every character. As I am using the String to generate character bigrams, the spaces are making the sample text useless. The code is try{ FileInputStream fstream = new FileInputStream(textfile); DataInputStream in = new DataInputStream(fstream); BufferedReader br = new BufferedReader(new InputStreamReader(in)); //Read corpus file line-by-line, concatenating each line to the String "corpus" while ((strLine = br.readLine()) != null) { corpus = (corpus.concat(strLine)); } in.close(); //Close the input stream } catch (Exception e) {//Catch exception if any System.err.println("Error test check: " + e.getMessage()); } I'd be grateful for any advice. Thanks.

    Read the article

  • How to take a partial screen capture using Ruby?

    - by Jason
    Hi, I need to run a ruby client that wakes up every 10 minutes, takes a screen-shot (ss) of a users screen, crops part of the (ss) out and use's OCR to check for a matching word....its basically a program to make sure remote employees are actually working by checking that they have a specific application open & the case numbers shown change. Not sure where to even start when it comes to taking a screen-shot and cropping it, has anyone done any kind of screen capture work using Ruby? The app will run on OSX using Ruby 1.9 Thanks!

    Read the article

  • getting rid of filesort on WordPress MySQL query

    - by Hans
    An instance of WordPress that I manage goes down about once a day due to this monster MySQL query taking far too long: SELECT SQL_CALC_FOUND_ROWS distinct wp_posts.* FROM wp_posts LEFT JOIN wp_term_relationships ON (wp_posts.ID = wp_term_relationships.object_id) LEFT JOIN wp_term_taxonomy ON wp_term_taxonomy.term_taxonomy_id = wp_term_relationships.term_taxonomy_id LEFT JOIN wp_ec3_schedule ec3_sch ON ec3_sch.post_id=id WHERE 1=1 AND wp_posts.ID NOT IN ( SELECT tr.object_id FROM wp_term_relationships AS tr INNER JOIN wp_term_taxonomy AS tt ON tr.term_taxonomy_id = tt.term_taxonomy_id WHERE tt.taxonomy = 'category' AND tt.term_id IN ('1050') ) AND wp_posts.post_type = 'post' AND (wp_posts.post_status = 'publish') AND NOT EXISTS (SELECT * FROM wp_term_relationships JOIN wp_term_taxonomy ON wp_term_taxonomy.term_taxonomy_id = wp_term_relationships.term_taxonomy_id WHERE wp_term_relationships.object_id = wp_posts.ID AND wp_term_taxonomy.taxonomy = 'category' AND wp_term_taxonomy.term_id IN (533,3567) ) AND ec3_sch.post_id IS NULL GROUP BY wp_posts.ID ORDER BY wp_posts.post_date DESC LIMIT 0, 10; What do I have to do to get rid of the very slow filesort? I would think that the multicolumn type_status_date index would be fast enough. The EXPLAIN EXTENDED output is below. +----+--------------------+-----------------------+--------+-----------------------------------+------------------+---------+---------------------------------------------------------------------------------+------+----------------------------------------------+ | id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra | +----+--------------------+-----------------------+--------+-----------------------------------+------------------+---------+---------------------------------------------------------------------------------+------+----------------------------------------------+ | 1 | PRIMARY | wp_posts | ref | type_status_date | type_status_date | 124 | const,const | 7034 | Using where; Using temporary; Using filesort | | 1 | PRIMARY | wp_term_relationships | ref | PRIMARY | PRIMARY | 8 | bwog_wordpress_w.wp_posts.ID | 373 | Using index | | 1 | PRIMARY | wp_term_taxonomy | eq_ref | PRIMARY | PRIMARY | 8 | bwog_wordpress_w.wp_term_relationships.term_taxonomy_id | 1 | Using index | | 1 | PRIMARY | ec3_sch | ref | post_id_index | post_id_index | 9 | bwog_wordpress_w.wp_posts.ID | 1 | Using where; Using index | | 3 | DEPENDENT SUBQUERY | wp_term_taxonomy | range | PRIMARY,term_id_taxonomy,taxonomy | term_id_taxonomy | 106 | NULL | 2 | Using where | | 3 | DEPENDENT SUBQUERY | wp_term_relationships | eq_ref | PRIMARY,term_taxonomy_id | PRIMARY | 16 | bwog_wordpress_w.wp_posts.ID,bwog_wordpress_w.wp_term_taxonomy.term_taxonomy_id | 1 | Using index | | 2 | DEPENDENT SUBQUERY | tt | const | PRIMARY,term_id_taxonomy,taxonomy | term_id_taxonomy | 106 | const,const | 1 | | | 2 | DEPENDENT SUBQUERY | tr | eq_ref | PRIMARY,term_taxonomy_id | PRIMARY | 16 | func,const | 1 | Using index | +----+--------------------+-----------------------+--------+-----------------------------------+------------------+---------+---------------------------------------------------------------------------------+------+----------------------------------------------+ 8 rows in set, 2 warnings (0.05 sec) And CREATE TABLE: CREATE TABLE `wp_posts` ( `ID` bigint(20) unsigned NOT NULL auto_increment, `post_author` bigint(20) unsigned NOT NULL default '0', `post_date` datetime NOT NULL default '0000-00-00 00:00:00', `post_date_gmt` datetime NOT NULL default '0000-00-00 00:00:00', `post_content` longtext NOT NULL, `post_title` text NOT NULL, `post_excerpt` text NOT NULL, `post_status` varchar(20) NOT NULL default 'publish', `comment_status` varchar(20) NOT NULL default 'open', `ping_status` varchar(20) NOT NULL default 'open', `post_password` varchar(20) NOT NULL default '', `post_name` varchar(200) NOT NULL default '', `to_ping` text NOT NULL, `pinged` text NOT NULL, `post_modified` datetime NOT NULL default '0000-00-00 00:00:00', `post_modified_gmt` datetime NOT NULL default '0000-00-00 00:00:00', `post_content_filtered` text NOT NULL, `post_parent` bigint(20) unsigned NOT NULL default '0', `guid` varchar(255) NOT NULL default '', `menu_order` int(11) NOT NULL default '0', `post_type` varchar(20) NOT NULL default 'post', `post_mime_type` varchar(100) NOT NULL default '', `comment_count` bigint(20) NOT NULL default '0', `robotsmeta` varchar(64) default NULL, PRIMARY KEY (`ID`), KEY `post_name` (`post_name`), KEY `type_status_date` (`post_type`,`post_status`,`post_date`,`ID`), KEY `post_parent` (`post_parent`), KEY `post_date` (`post_date`), FULLTEXT KEY `post_related` (`post_title`,`post_content`) )

    Read the article

  • NLP with greatly contrained input and abilities

    - by Mike F
    Hat in hand here. I'm a seasoned developer and I would be grateful for a bit of help. I don't have time to read or digest long intricate discussions on theoretical concepts around NLP (or go get my PHD). That said, I have read a few and it's a damn interesting field. The problem is I need real world solutions, for real world products, in real world time frames. The problem I'm having is right now I'm not sure what the right questions are to ask to get started implementing. I believe this is mostly related to vocabulary. I'll read somewhere, a blog post, a forum post, a whitepaper, and it says, I'm doing flooping with the blargy blarg method, and I go google flooping and blargy blarg, and I get references to more obscurity. It seemingly never ends. So, my question is multiphased. First, more generally, how do I become passingly educated on this quickly? Just in time educated. I only need to know what I need to know to take the next step. I've spent 20 years writing code. Explain quick. I'll get it. (I mean provide a reference to something that explains quickly of course). I'm happy to read the right book, but I don't want to read a book where I read the chapter introduction that explains what floopy floop is and then skip over the rest of the chapter with examples of floopy flooping (because now I get what it is). I also don't want to read a book that goes into too much detail with theoretical underpinnings or history. For example, the Jurafsky book seems like way more than I need: http://www.amazon.com/gp/product/0131873210. But I will read it if this is the right book to read. (It's also dang expensive!) I need the root node of the expedited learning tree here, if you will. Point me in the right direction and I'll be quite grateful. I'm expecting quite a lot of firehose drinking - I just need the right firehose. Second, what I need to do is take a single sentence, with a very reduced vocabulary, and get a grammar tree (sorry if this is the wrong terminology) that I can do something with. I know I could easily write this command line input style in c in a more conventional manner, but I need it to be way better than that. But I don't need a chatterbot either. What I'm doing needs to live in a constrained environment. I can't use Python (unfortunately). I can't ship with gigabytes of corpuses. I need any libraries I use to be in c/c++. If I have to write this myself, I will. Hopefully, it will be achievable considering the reduced problem set. Maybe, probably, that's just naive. If so, let me know. :-) Thanks in advance - Mike

    Read the article

  • HTTPWebResponse returning no content

    - by Richard Yale
    Our company works with another company called iMatrix and they have an API for creating our own forms. They have confirmed that our request is hitting their servers but a response is supposed to come back in 1 of a few ways determined by a parameter. I'm getting a 200 OK response back but no content and a content-length of 0 in the response header. here is the url: https://secure4.office2office.com/designcenter/api/imx_api_call.asp I'm using this class: namespace WebSumit { public enum MethodType { POST = 0, GET = 1 } public class WebSumitter { public WebSumitter() { } public string Submit(string URL, Dictionary<string, string> Parameters, MethodType Method) { StringBuilder _Content = new StringBuilder(); string _ParametersString = ""; // Prepare Parameters String foreach (KeyValuePair<string, string> _Parameter in Parameters) { _ParametersString = _ParametersString + (_ParametersString != "" ? "&" : "") + string.Format("{0}={1}", _Parameter.Key, _Parameter.Value); } // Initialize Web Request HttpWebRequest _Request = (HttpWebRequest)WebRequest.Create(URL); // Request Method _Request.Method = Method == MethodType.POST ? "POST" : (Method == MethodType.GET ? "GET" : ""); _Request.UserAgent = "Mozilla/4.0 (compatible; MSIE 6.0; Win32)"; // Send Request using (StreamWriter _Writer = new StreamWriter(_Request.GetRequestStream(), Encoding.UTF8)) { _Writer.Write(_ParametersString); } // Initialize Web Response HttpWebResponse _Response = (HttpWebResponse)_Request.GetResponse(); // Get Response using (StreamReader _Reader = new StreamReader(_Response.GetResponseStream(), Encoding.UTF8)) { _Content.Append(_Reader.ReadToEnd()); } return _Content.ToString(); } } } I cannot post the actual parameters because they are to the live system, but can you look at this code and see if there is anything that is missing? Thanks!

    Read the article

  • Recommendations for 'C' Project architecture guidlines?

    - by SiegeX
    Now that I got my head wrapped around the 'C' language to a point where I feel proficient enough to write clean code, I'd like to focus my attention on project architecture guidelines. I'm looking for a good resource that coves the following topics: How to create an interface that promotes code maintainability and is extensible for future upgrades. Library creation guidelines. Example, when should I consider using static vs dynamic libraries. How to properly design an ABI to cope with either one. Header files: what to partition out and when. Examples on when to use 1:1 vs 1:many .h to .c Anything you feel I missed but is important when attempting to architect a new C project. Ideally, I'd like to see some example projects ranging from small to large and see how the architecture changes depending on project size, function or customer. What resource(s) would you recommend for such topics? Thanks

    Read the article

  • HTML form -> Flash submit button -> Set a PHP variable in flash button -> Submit form

    - by RobHardgood
    Okay, I'm sorry that this is pretty complicated, but it shouldn't be that hard to solve... Here's what I want to do. I have an HTML form that I want to upload to MySQL with PHP. That part's easy, but the thing is I want the submit button to be a Flash object. Somehow I need the Flash button to submit the form, but I think I can figure that out. The tricky part is that I need it to set another PHP variable before submitting the form. The variable will be determined by a bunch of stuff, but I can code that in actionscript later. I just need to figure out how to pass the variable back to the webpage. A $_POST variable would probably be fine. Thanks!! Let me know if I need to clarify more...

    Read the article

  • How to use mock and verify methods of OCMock in objective-C ? Is there any good tutorial on OCMock i

    - by san
    My problem is I am getting an error: OCMckObject[NSNumberFormatter]: expected method was not invoked:setAllowsFloats:YES I have written following Code: (void) testReturnStringFromNumber { id mockFormatter = [OCMockObject mockForClass:[NSNumberFormatter class]]; StringNumber *testObject = [[StringNumber alloc] init]; [[mockFormatter expect] setAllowsFloats:YES]; [testObject returnStringFromNumber:80.23456]; [mockFormatter verify]; } @implementation StringNumber - (NSString *) returnStringFromNumber:(float)num { NSNumberFormatter *formatter = [[NSNumberFormatter alloc] init]; [formatter setAllowsFloats:YES]; NSString *str= [formatter stringFromNumber:[NSNumber numberWithFloat:num]]; [formatter release]; return str; } @end

    Read the article

  • MSBuild fails, but building inside Visual Studio works fine

    - by Matt
    C#, .NET 2.0 I have an ASP.NET website in a solution, with 2 other projects (used as library references). When I build (debug or release) in Visual Studio, everything works fine. However, building with MSBuild fails. This build had been working (it's actually invoked via a nAnt task). The only thing that has changed is that I have a new user control whose Type I am referencing in my code behind. The offending code is in my ASPX code behind. MessageAlert is the UserControl: MessageAlert userControl = this.LoadControl("~/UserControls/MessageAlert.ascx") as MessageAlert; userControl.UserMessage = message; this.UserMessages.Controls.Add(userControl); In order to get Visual Studio to recognize the type 'MessageAlert' I had to: 1) Set the ClassName="MessageAlert" in the @Control markup at the top of the user control (because using the auto-generated UserControls_MessageAlert wasn't working either) 2) Register the user control in the markup of my ASPX, using an @Register 3) Add a "using ASP" to the top of my code behind After those steps, I could successfully reference the MessageAlert type in my codebehind from visual studio. But from MSBuild I get "The type or namespace name 'MessageAlert' could not be found (are you missing a using directive or an assembly reference?) " The MSBuild execution is very simple - it points the the very same solution file and sets the configuration property to release. It seems, based on the # of steps I had to go through to get Type references to MessageAlert in Visual Studio, that there is something missing in the MSBuild process. But what? Doesn't Visual Studio in fact invoke MSBuild behind the scenes? Is there a better way to reference a UserControl type in the code behind of an ASPX? EDIT: To clarify, the MessageAlert user control is not in the other referenced assemblies/projects. I mentioned them because, together with the website, the compose the Solution file, which is the same sln file being built by MS Build.

    Read the article

  • nginx + passenger not using rackup file

    - by Callum Jones
    I have an issue where Passenger is not detecting the config.ru file for the following nginx server server { listen 80; passenger_enabled on; server_name callumj.com cjlondon.com; access_log logs/callumj.access.log; root /webapps/callumj_com/public; } Nginx just seems to ignore it and treat it as a normal web page (as I get forbidden areas when it tries to look for index.html in public). I have verified that the rackup command and execute config.ru and it boots up sucessfully. I have another server directive much like this which is powered by Rails and it seems to be working perfectly. Am I missing something? Thanks in advance!

    Read the article

  • conditionals for C++ using MSBuild/vsbuild?

    - by redtuna
    I have a C++ project in Visual Studio 2008 and I'd like to be able to compile several versions from the command line, defining conditional variables (aka #define). If it were just a single file to compile I'd use something like cl /D, but this is complex enough that I would like to be able to use VS's other features like the build order etc. I've seen a similar question asked in stackoverflow and the answer was to use /p:DefineConstants="var1;var2". This doesn't seem to work with C++ though. The other problem with that answer is that it replaces the conditional variables, instead of adding to them. The vcproj files for C++ look quite different. If msbuild (or vsbuild) had a way to change Configurations/Tool[name="VCCLCompilerTool"] we'd be golden. But I haven't found such an option. The vcproj files are under source control so I'd rather not have a script mess with them. I've considered doubling the number of configurations (one with the #define, one without). That'd be annoying, and I'm especially unhappy with having to modify these configurations in tandem every time I need to modify anything there. A previous similar question found no solution. I'm hoping that has changed since? How would you go about building those variants (with and without define) from the command line? Thanks!

    Read the article

  • Passing object(s) to a Controller Action

    - by Nicholas H
    I'm attempting to use jQuery to do a $.post() to an MVC controller action. Here's the jQuery calls: var _authTicket = { username: 'testingu', password: 'testingp' }; function DoPost() { var inputObj = { authTicket: _authTicket, dateRange: 'ThisWeek' }; $.post('/MyController/MyAction', inputObj, PostResult); } function PostResult(data) { alert(JSON.stringify(data)); } Here's the controller action: <HttpPost()> _ Function MyAction(ByVal authTicket As AuthTicket, ByVal dateRange As String) As ActionResult Dim u = ValidateUser(authTicket) If u Is Nothing Then Throw New Exception("User not valid") ' etc.. End Function The problem is, MyAction's "authTicket" parameter is all empty. The second "dateRange" parameter gets populated just fine. I'm pretty sure that the issue stems from jQuery turning the data into key/value pairs to POST to the action. MVC must not understand the format, at least when it's an object with it's own properties. The name/value pair format that jQuery is converting to is like: authTicket[username] = "testingu" authTicket[password] = "testingp" Which in turn gets made into x-www-form-urlencoded'd data: authTicket%5Busername%5D=testingu &authTicket%5Bpassword%5D=testingp I guess I could always have "username" and "password" properties in my actions, but that seems wrong to me. Any help would be appreciated.

    Read the article

  • java Regular expression matching html

    - by user121196
    I want to match and capture the enclosing content of the <pre></pre> tag tried the following, not working, what's wrong? String p="<pre>.*</pre>"; Matcher m=Pattern.compile(p,Pattern.MULTILINE|Pattern.CASE_INSENSITIVE).matcher(input); if(m.find()){ String g=m.group(0); System.out.println("g is "+g); }

    Read the article

  • Comment nommer la plus grande unité de mesure mathématique, après le yotta ? "Hella", propose un étu

    Comment nommer la plus grande unité de mesure mathématique, après le yotta ? "Hella", propose un étudiant américain Austin Sendek est un étudiant californien inscrit dans une filière consacrée à la physique. Et, depuis quelques semaines, une question hante son esprit : quel nom donner à l'unité de mesure venant après mega, giga, etc ? Le système international d'unités dispose d'une série de préfixes pour désigner l'échelle mathématique de l'unité qui est mesuré. Il y a méga, puis giga, puis téra, et enfin peta. A ce jour, la plus grande unité de mesure est le yotta, qui équivaut à 10 puissance 24. Le prochain préfixe, si l'on suit la logique de ceux existants, devrait dénommer 10 puissance 27. Problème : au...

    Read the article

  • Why You Should Follow Google Webmaster Guidelines

    Creativity is one of the most important aspects of an appealing site. Unique and compelling content are vital components to any successful site, but they're rendered obsolete if the site doesn't follow basic guidelines established by the Google Webmaster Guidelines.

    Read the article

  • get property from XML using PHP

    - by Adnan
    Hello, I am using PHP's SimpleXML to get some values out of the following XML; - <entry> <id>http://www.google.com/m8/feeds/contacts/email_address%40gmail.com/base/0</id> <updated>2010-01-14T22:06:26.565Z</updated> <category scheme="http://schemas.google.com/g/2005#kind" term="http://schemas.google.com/contact/2008#contact" /> <title type="text">Customer Name</title> <link rel="http://schemas.google.com/contacts/2008/rel#edit-photo" type="image/*" href="http://www.google.com/m8/feeds/photos/media/email_address%40gmail.com/0/34h5jh34j5kj3444" /> <link rel="self" type="application/atom+xml" href="http://www.google.com/m8/feeds/contacts/email_address%40gmail.com/full/0" /> <link rel="edit" type="application/atom+xml" href="http://www.google.com/m8/feeds/contacts/email_address%40gmail.com/full/0/5555" /> <gd:email rel="http://schemas.google.com/g/2005#other" address="[email protected]" primary="true" /> </entry> I can get the title with: $xml = new SimpleXMLElement($response_h1); foreach ($xml->entry as $entry) { echo $entry->title, '<br />'; } But how to get the address="[email protected]" property?

    Read the article

  • Finding the centeroid of a polygon?

    - by user146780
    I have tried: for each vertex, add to total, divide by number of verities to get center. I'v also tried: Find the topmost, bottommost - get midpoint... find leftmost, rightmost, find midpoint. Both of these did not return the perfect center because I'm relying on the center to scale a polygon. I want to scale my polygons so I may put a border around them. What is the best way to find the centroid of a polygon given that the polygon may be concave, convex and have many many sides of various lengths. Thanks

    Read the article

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