Daily Archives

Articles indexed Tuesday May 4 2010

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

  • Format stdin in bash

    - by User1
    I have a multi-line string coming from another program that I want to convert to a SQL command. I was hoping that printf could help me, but it doesn't seem to work: echo -e '1\n2\n3'|printf 'SELECT %s INTO MyTable' I was hoping to see: SELECT '1 2 3' INTO MyTable But I got: SELECT INTO MyTable How can I get the %s to read stdin?

    Read the article

  • jQuery $.data(): Possible misuse?

    - by Rosarch
    Perhaps I'm using $.data incorrectly. Assigning the data: var course_li = sprintf('<li class="draggable course">%s</li>', course["fields"]["name"]); $(course_li).data('pk', course['pk']); alert(course['pk']); // shows a correct value Moving the li to a different ul: function moveToTerm(item, term) { item.fadeOut(function() { item.appendTo(term).fadeIn(); }); } Trying to access the data later: $.each($(term).children(".course"), function(index, course) { var pk = $(course).data('pk'); // pk is undefined courses.push(pk); }); What am I doing wrong? I have confirmed that the course li on which I am setting the data is the same as the one on which I am looking for it. (Unless I'm messing that up by calling appendTo() on it?)

    Read the article

  • emacs: x-popup-menu max size constraints?

    - by Cheeso
    I'm working on an intellisense or code-completion capability for C#. So far, so good. Right now I have basic completion working. There are 2 ways to request completion. The first cycles through all the potential matches. The second presents a popup menu of the matches. It works for types: And also for local variables: I'm confronting two problems with x-popup-menu: the popup menu can expand to consume all available screen space, when the number of choices is large. Literally it can obscure the entire screen. The silly thing is, it's scrollable. First it expands to consume all available space, then it also becomes scrollable. Is there a way I can limit the maximum size of x-popup-menu? To specify the position of the popup menu, I pass in a position, and x-popup-menu uses that as the *middle*, not the left, of the top line of the menu. Why middle? who knows. What this means is, if I specify (40 . 60) for the location of the menu, and the menu happens to be 100 pixels wide, the menu will extend beyond the left border of the emacs window. You can see this in the 2nd image above. If I knew how wide the popup would be before specifying the position, I could compensate. But I don't. Is there a workaround? Is there a way to get x-popup-menu to take its position as the LEFT rather than the middle.

    Read the article

  • Problem in databinding a dictionary in ListView combo-box column.

    - by Ashish Ashu
    I have a listview of which itemsource is set to my custom collection, let's say MyCollection. The code below is not full code , it's just a code snippets to explain the problem. class Item : INotifyPropertyChanged { Options _options; public Options OptionProp { get { return _options; } set { _options = value; OnPropertyChanged ("OptionProp");} } string _Name; public string NameProp { get { return _Name; } set { _Name = value; OnPropertyChanged ("NameProp");} } } class Options : Dictionary<string,string> { public Options() { this.Clear(); this.Add("One" , "1" ); this.Add("Two" , "2" ); this.Add("Three" , "3" ); } } MyCollection in my viewModel class viewModel { ObservableCollection<Item> **MyCollection**; KeyValuePair<sting,string> **SelectedOption**; } The listview Item Source is set to my MyCollection. <ListView ItemSource = MyCollectoin> I Listview contains two columns of which I have defined a datatemplats in the listview. First column is a combo-box of which Itemsource is set to Options ( defined above ) Second column is a simple textblock to display Name. Problem 1. I have defined a datatemplate for first column in which I have a combo box , I have set the Itemsource =**MyCollection** and SelectedItem = SelectedOption of the combo-box. User can perform following operations in the listview: Add ( Add the row in the listview ) Move Up ( Move row up in the listview ) Move Down ( Move down the item in the listview ) .Now when I add the row in the listview , the combo-box selected index is always comes to -1 (first column). However the combo box contains options One, Two and Three. Also, I have initialized the SelectedOption to contain the first item, i:e One. problem 2. . Let suppose, I have added a single row in a listview and I have selected Option "one" in the combo box manually. Now when I perform Move Up or Move Down operations the selected index of a combo box is again set to -1. In the Move Up or Move Down operation , I am calling MoveUp and MoveDown methods of the Observable collection. Probelm 3 How to serialize the entire collection in XML. Since I can't serialize the Dictionary and KeyValue Pair. I have to restore the state of the listview.

    Read the article

  • Im Stumped, Why is UIImage\Texture2d memory not being freed

    - by howsyourface
    I've been looking everywhere trying to find a solution to this problem. Nothing seems to help. I've set up this basic test to try to find the cause of why my memory wasn't being freed up: if (texture != nil) { [texture release]; texture = nil; } else { UIImage* ui = [UIImage imageWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"image" ofType:@"png"]]; texture = [[Texture2D alloc] initWithImage:ui]; } Now i would place this in the touches began and test by monitoring the memory usage using intstruments at the start (normally 11.5 - 12mb) after the first touch, with no object existing the texture is created and memory jumps to 13.5 - 14 However, after the second touch the memory does decrease, but only to around 12.5 - 13. There is a noticeable chunk of memory still occupied. I tested this on a much larger scale, loading 10 of these large textures at a time The memory jumps to over 30 mb and remains there, but on the second touch after releasing the textures it only falls to around 22mb. I tried the test another time loading the images in with [uiimage imagenamed:] but because of the caching this method performs it just means that the full 30mb remains in memory.

    Read the article

  • Figuring out page size with YSlow / Web Developer extension

    - by Goose Bumper
    I'm trying to figure out how much javascript is being loaded on my website. I'm using Reducisaurus to shrink my js files. The problem is, this is causing both YSlow and the Web Developer extension report the size of my files as ~.04K, which I know can't be right (one of the .js files is jquery, which is 50kb). Is there any way to accurately figure out how much time I've saving by using Reducisaurus?

    Read the article

  • Passing Variables Along in a Function

    - by John
    Hello, In the function show_commentbox() below, I would like to pass along the variables $_SESSION['loginid'], $submissionid, $submission, $url, $submittor, $submissiondate, $countcomments, $dispurl. With the setup below, it's not working. How could I change it to make show_commentbox() pass the variables along? Thanks in advance, John index.php: <?php $submission = $_GET['submission']; require_once "header.php"; include "login.php"; include "comments.php"; include "commentformonoff.php"; ?> In header.php: require_once ("function.inc.php"); In comments.php: $uid = $_SESSION['loginid']; $submissiondate = mysql_real_escape_string($_GET['submissiondate']); $submittor = mysql_real_escape_string($_GET['submittor']); $countcomments = mysql_real_escape_string($_GET['countcomments']); $dispurl = mysql_real_escape_string($_GET['dispurl']); $url = mysql_real_escape_string($_GET['url']); $submission = mysql_real_escape_string($_GET['submission']); $submissionid = mysql_real_escape_string($_GET['submissionid']); commentformonoff.php: <?php if (!isLoggedIn()) { if (isset($_POST['cmdlogin'])) { if (checkLogin($_POST['username'], $_POST['password'])) { show_commentbox(); } else { echo "Login to comment"; } } else { echo "Login to comment"; } } else { show_commentbox(); } ?> In display.functions.inc.php: function show_commentbox() { echo '<form action="http://www...com/sandbox/comments/comments2.php" method="post"> <input type="hidden" value="'.$_SESSION['loginid'].'" name="uid"> <input type="hidden" value="'.$submissionid.'" name="submissionid"> <input type="hidden" value="'.$submission.'" name="submission"> <input type="hidden" value="'.$url.'" name="url"> <input type="hidden" value="'.$submittor.'" name="submittor"> <input type="hidden" value="'.$submissiondate.'" name="submissiondate"> <input type="hidden" value="'.$countcomments.'" name="countcomments"> <input type="hidden" value="'.$dispurl.'" name="dispurl"> <label class="addacomment" for="title">Add a comment:</label> <textarea class="commentsubfield" name="comment" type="comment" id="comment" maxlength="1000"></textarea> <div class="commentsubbutton"><input name="submit" type="submit" value="Submit"></div> </form> '; }

    Read the article

  • How to create a simple server/client application using boost.asio?

    - by the_drow
    I was going over the examples of boost.asio and I am wondering why there isn't an example of a simple server/client example that prints a string on the server and then returns a response to the client. I tried to modify the echo server but I can't really figure out what I'm doing at all. Can anyone find me a template of a client and a template of a server? I would like to eventually create a server/client application that receives binary data and just returns an acknowledgment back to the client that the data is received.

    Read the article

  • Where does the tomcat axis file server-config.wsdd come from?

    - by David Sykes
    Part of our system provides a web service through apache tomcat, the service is referenced in the server-config.wsdd file. Unfortunately nobody can remember how it got in there. The apache set up has changed, and I need to update the system for the new configuration. What magic keywords can I google for to help me work out how and why it got into the existing server-config.wsdd, and how it might fit into the new server-config.wsdd

    Read the article

  • Observing model changes with Cocoa Bindings and NSArrayController

    - by jbrennan
    I've got an NSArrayController bound to a mutable array in my controller, which manages an array of my model objects. The array controller is bound to my UI. It works well. Now I'm trying to manually observe when a value changes in my model in my controller class (basically I'm marking the changed model as "needsToSave" for later on, but there are a few other tasks I have when it changes). I've read up on KVO but I'm not entirely sure what I need to be observing... The NSArrayController? The array of objects? each model object itself? Confusion. Any pointers would be very helpful. Thanks in advance!

    Read the article

  • GIS: Converting multi polygons to multiple features

    - by Kangkan
    Hi, I am involved in a GIS project. I have a base map file (shape file) that contains the road layer for a large portion of a town. The problem is that the shape file contains only two features each containing around 500000 points each. The features are multipolygons containing a large no of polygons inside. I wish to convert it to numerous features each containing not more than one polygon. Is it possible? If yes, how?

    Read the article

  • Parsing XML stream in ASP.NET 3.5

    - by Ranjit
    Hi All, I am trying to build an ASP.NET 3.5 application based on XML streams from a legacy systems. My issue is once I get the XML I have to built menus and sub menus from the XML as well filter data(XML stream) based on the menu selection without making roundtrip to the Data store(legacy system). Right now I have a DAL which will get the XML stream in the form of XDocument.I was able to built the first level Menu Items, but not the sub Menu Items based on the selection in the Main Menu and then the final content based on the sub menu selection, all this without making a round trip. Is there a way to do this in-memory. Please suggest. thank you. Ranjit

    Read the article

  • Best Practices - Data Annotations vs OnChanging in Entity Framework 4

    - by jptacek
    I was wondering what the general recommendation is for Entity Framework in terms of data validation. I am relatively new to EF, but it appears there are two main approaches to data validation. The first is to create a partial class for the model, and then perform data validations and update a rule violation collection of some sort. This is outlined at http://msdn.microsoft.com/en-us/library/cc716747.aspx The other is to use data annotations and then have the annotations perform data validation. Scott Guthrie explains this on his blog at http://weblogs.asp.net/scottgu/archive/2010/01/15/asp-net-mvc-2-model-validation.aspx. I was wondering what the benefits are of one over the other. It seems the data annotations would be the preferred mechanism, especially as you move to RIA Services, but I want to ensure I am not missing something. Of course, nothing precludes using both of them together. Thanks John

    Read the article

  • Quick Question: How can I make sure the current directory is not changed because of OpenFileDialog?

    - by pecker
    say my application is installed in C:\programfiles\xyz\ I've some setting & other data files (*.dat files) in this directory too. My application uses OpenFileDialog to open an image. Problem is that when ever user browses to some directory (say MyPictures) for an image. The current working directory of the application becomes that directory (MyPictures in this case). After user inputs the image. I do some processing over it and save some values to imagedata.dat which will be located in the path where original application is installed.(C:\programfiles\xyz here ) In my code I'm just using FileStream("imagedata.dat",...,...) without any path prefix before the filename. Problem here is that application is crashing because it is searching for imagedata.dat in 'MyPictures\imagedata.dat'. How can I avoid this?

    Read the article

  • Grails - attempting to include HTPPBuilder - Linkage error

    - by Stefan Kendall
    When I run grails install-dependency, I get this. java.lang.LinkageError: loader constraint violation: loader (instance of <bootloader>) previously initiated loading for a different type with name "org/xml/sax/SAXParseException" What's wrong? I've not used grails dependency management before, and this is rather cryptic. repositories { grailsPlugins() grailsHome() mavenLocal() mavenCentral() } dependencies { runtime 'org.codehaus.groovy.modules.http-builder:http-builder:0.5.0' }

    Read the article

  • Add a :filter param to the end of a url

    - by bob
    Hello, I am building an application that requires a search to go deeper than the initial level. I am using nested scopes to accomplish this and params in the URL For example, when a user searches for "handbag" it creates a query like the following. http://localhost:3000/junks?search=handbag&condition=&category=&main_submit=Go! I want to add a :filter param to the end of this url and reload the page with the new url. http://localhost:3000/junks?search=handbag&condition=&category=&main_submit=Go!&filter=lowest_price As shown above the &filter=lowest_price is added to the query. I have already written controller code to handle this and I know it works as long as the query is like the 2nd link above. my views code <div class = "filter_options"> <p> <strong>Filter by:</strong> <%= link_to_unless_current "Recent", :filter => 'recent' %> | <%= link_to_unless_current "Lowest Price", :filter => 'lowest_price' %> | <%= link_to_unless_current "Highest Price", :filter => 'highest_price' %> </p> </div> This is how I have it currently, which works if my URL does not have a search string attached to it. Unfortunately, this will go to a http://localhost:3000/junks?filter=lowest_price even if there is a search string. I would like to know how to create my links so that they add onto the search string shown in the 2nd code example. Additionally, if a search string with a filter is already present, it would only change that filter and resubmit the search string with the new filter. I hope I am being clear.

    Read the article

  • Selective emboldeing of text in a webpage

    - by Eknath Iyer
    while printing out utf-8 characters onto a webpage, if encapsulate them with they get emboldened, but anything else, the page turns blank. Why? def main(): print "Content-type: text/html\r\n\r\n"; print '<html>' print '<head>' print '<style type="text/css">' print '.highlight { background-color: yellow }' print '.color1 { color: green; }' print '.color2 { color: blue; }' print '.color3 { color: purple; }' print '.color4 { color: red; }' print '.color5 { color: teal; }' print '.color6 { color: yellow; }' print '.color7 { color: orange; }' print '.color8 { color: violet; }' print '</style></head>' print '<body>' form = cgi.FieldStorage() ch = form.getvalue('choice') if ch == 'English': in_sent = form.getvalue('f1') in_sent = in_sent.lower() cho=0 elif ch == 'Hindi': in_sent = trans_he(form.getvalue('transl1').decode("utf-8")).strip() cho=1 #cho = 0 for english #cho = 1 for hindi adict=[] print '<center><u> User Input Sentence ==> <b>', in_sent,'</b></u></center><br>' in_sent=in_sent.strip().split(' ') colordict={} counter=1 for word in in_sent: colordict[word]=counter counter = counter + 1 f = open('bidirectional.alignment.txt','rb').read() records=f.strip().split('\n\n\n') for record in records: el=[] el2 = [] #basic file processing is done here. record = record.strip().split('\n') source = record[cho] target = record[(cho+1)%2] source_sent = source.split(' # ')[1] target_sent = target.split(' # ')[1] source_words = source_sent.strip().split(' ') target_words = target_sent.strip().split(' ') trans_index = source.split(' # ')[2].strip().split(' ') for word in in_sent: if word in source_words: if int(trans_index[source_words.index(word)]) > 0: tword=target_words[(int(trans_index[source_words.index(word)])-1)] target_sent = target_sent.replace(tword+' ','<b>'+tword+' </b>') # When the <b> tag is used here(for the 'target_sent = ...' statement). it is fine. But when <b> is replaced by something like in the next line or even <i> or <u>, it doesn't show an output at all source_sent = source_sent.replace(word+' ','<span class="color1">'+word+' </span>') el2.append(source_sent) el2.append(target_sent) el.append(target_sent.count('<b>')) el.append(el2) if target_sent.count('<b>') > 0: adict.append(el) print '<table><tr><td><center><h1>SOURCE LANGUAGE</h1></center></td><td><center> <h1>TARGET LANGUAGE</h1></center></td></tr>' for entry in adict: print '<tr><td>',entry[1][0],'</td><td>',trans_eh(entry[1][1]).encode("utf-8"),'</td> </tr>' print '</table></body>' print '</html>' main()

    Read the article

  • How do I label a group of radio boxes for WCAG / 508 Compliance? Is ASP.NET doing it wrong?

    - by Mark Brittingham
    I am trying to bring an existing web site into greater conformance with WCAG 2.0 Guidelines and am a bit confused over the output emitted by Microsoft (ASP.NET 4.0 although it was the same in 3.5). Suppose you have a question like: "How would you rate your health?" and a set of 5 answers created using an ASP.NET RadioButtonList. I place the question in an asp:Label with an "AssociatedControlID" that matches the ID of the RadioButtonList (e.g. "SelfRatingBox"). Seems pretty easy... Only the output that is generated has an html "label" with a "For" that is equal to the ID of a table that wraps up the RadioButtons. I assumed that this would work with page readers but our 508 compliance guy is saying that the reader isn't associating the label with the radio controls. The WCAG guidelines indicate that you have to use a fieldset around the entire group and a legend to capture the associated text (the question). So what gives? It would be ideal if MS could take my label and the radiobuttonlist and generate the appropriate fieldset and legend tags but it seems pretty clear that to achieve WCAG compliance, I'll have to roll my own. Is this correct or am I missing something?

    Read the article

  • Best 3D Graphics Engine for .NET

    - by George Stocker
    I've been thinking about tinkering with 3D graphics programming in .NET. In the past, I've thought about Truevision3D, and XNA, but I've not used either of these. I scanned Stackoverflow for the exact question, but neither of the (almost) relevant question (such as this question about rendering graphics, and this question about Learning Game Programming) answer my specific question. Out of the graphics engine APIs you've used for .NET, which is the easiest to use, which has the most features, and which is the cheapest? Which would you recommend for a .NET programmer to learn first?

    Read the article

  • Problem with WHERE columnName = Data in MySQL query in C#

    - by Ryan Sullivan
    I have a C# webservice on a Windows Server that I am interfacing with on a linux server with PHP. The PHP grabs information from the database and then the page offers a "more information" button which then calls the webservice and passes in the name field of the record as a parameter. So i am using a WHERE statement in my query so I only pull the extra fields for that record. I am getting the error: System.Data.SqlClient.SqlException:Invalid column name '42' Where 42 is the value from the name field from the database. my query is string selectStr = "SELECT name, castNotes, triviaNotes FROM tableName WHERE name =\"" + show + "\""; I do not know if it is a problem with my query or something is wrong with the database, but here is the rest of my code for reference. NOTE: this all works perfectly when I grab all of the records, but I only want to grab the record that I ask my webservice for. public class ktvService : System.Web.Services.WebService { [WebMethod] public string moreInfo(string show) { string connectionStr = "MyConnectionString"; string selectStr = "SELECT name, castNotes, triviaNotes FROM tableName WHERE name =\"" + show + "\""; SqlConnection conn = new SqlConnection(connectionStr); SqlDataAdapter da = new SqlDataAdapter(selectStr, conn); DataSet ds = new DataSet(); da.Fill(ds, "tableName"); DataTable dt = ds.Tables["tableName"]; DataRow theShow = dt.Rows[0]; string response = "Name: " + theShow["name"].ToString() + "Cast: " + theShow["castNotes"].ToString() + " Trivia: " + theShow["triviaNotes"].ToString(); return response; } }

    Read the article

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