Search Results

Search found 1411 results on 57 pages for 'openoffice writer'.

Page 50/57 | < Previous Page | 46 47 48 49 50 51 52 53 54 55 56 57  | Next Page >

  • iTextSharp last version doesnot support metadata?

    - by zp chen
    Console.WriteLine("Chapter 1 example 6: Meta Information"); // step 1: creation of a document-object Document document = new Document(); try { // step 2: // we create a writer that listens to the document // and directs a PDF-stream to a file PdfWriter.GetInstance(document, new FileStream("Chap0106.pdf", FileMode.Create)); // step 3: we add some metadata and open the document document.AddTitle("Hello World example"); document.AddSubject("This example explains step 6 in Chapter 1"); document.AddKeywords("Metadata, iText, step 6, tutorial"); document.AddCreator("My program using iText#"); document.AddAuthor("Bruno Lowagie"); document.AddHeader("Expires", "0"); document.Open(); // step 4: we add a paragraph to the document document.Add(new Paragraph("Hello World")); } catch (DocumentException de) { Console.Error.WriteLine(de.Message); } catch (IOException ioe) { Console.Error.WriteLine(ioe.Message); } // step 5: we close the document document.Close(); I am just copy the iTextSharp.tutorial. I get the pdf file Chap0106.pdf but metadata show nothing... I am use vs2008 xp system

    Read the article

  • How do I begin reading source code?

    - by anonnoir
    I understand the value of reading source code, and I am trying my best to read as much as I can. However, every time I try getting into a 'large' (i.e. complete) project of sorts, I am overwhelmed. For example, I use Anki a lot when revising languages. Also, I'm interested in getting to know how an audio player works (because I have some project ideas), hence quodlibet on Google Code. But whenever I open the source code folders for the above programs, there are just so many files that I don't know where or what to begin with. I think that I should start with files marked init.py but I can't see the logical structure of the programs, or what reasoning was applied when the original writer divided his modules the way he did. Hence, my questions: How/where should I begin reading source? Any general tips or ideas? How does a programmer keep in mind the overall structure and logic of the program, especially for large projects, and is it common not to document that structure? As an open source reader, must I look through all of the code and get a bird's eye view of the code and libraries, before even being able to proceed? Would an IDE like Eclipse SDK (with PyDev) help with code-reading? Thanks for the help; I really appreciate your helping me.

    Read the article

  • Using libcurl & SSL

    - by Haraldo
    Hi there. I've found there is really very little information around on this topic. I already have a dll making successful posts using libcurl. I've compiled libcurl with openssl for ssl functionality. Here is an exert of my original curl setup. curl_easy_setopt(handle, CURLOPT_ERRORBUFFER, errorBuffer); //curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER , 1); //curl_easy_setopt(curl, CURLOPT_SSL_VERIFYHOST , 1); //curl_easy_setopt(curl, CURLOPT_CAINFO , "./ca.cert"); curl_easy_setopt(handle, CURLOPT_POSTFIELDS, cParam); curl_easy_setopt(handle, CURLOPT_POSTFIELDSIZE, strlen(cParam)); curl_easy_setopt(handle, CURLOPT_FOLLOWLOCATION, 1); curl_easy_setopt(handle, CURLOPT_WRITEFUNCTION, Request::writer); curl_easy_setopt(handle, CURLOPT_WRITEDATA, &buffer); curl_easy_setopt(handle, CURLOPT_URL, cURL); My question to those who've done this before, is it as easy as just adding those lines above to get SSL to work (as long as the certificate exists)? Or is it more complicated? The funny thing is I'm not completely sure how SSL works. I've never worked with it before. Do I need to store a key in my application and send it with each request? Anyway my main question was the first. Thank you in advance.

    Read the article

  • Writing XML in different character encodings with Java

    - by Roman Myers
    I am attempting to write an XML library file that can be read again into my program. The file writer code is as follows: XMLBuilder builder = new XMLBuilder(); Document doc = builder.build(bookList); DOMImplementation impl = doc.getImplementation(); DOMImplementationLS implLS = (DOMImplementationLS) impl.getFeature("LS", "3.0"); LSSerializer ser = implLS.createLSSerializer(); String out = ser.writeToString(doc); //System.out.println(out); try{ FileWriter fstream = new FileWriter(location); BufferedWriter outwrite = new BufferedWriter(fstream); outwrite.write(out); outwrite.close(); }catch (Exception e){ } The above code does write an xml document. However, in the XML header, it is an attribute that the file is encoded in UTF-16. when i read in the file, i get the error: "content not allowed in prolog" this error does not occur when the encoding attribute is manually changed to UTF-8. I am trying to get the above code to write an XML document encoded in UTF-8, or successfully parse a UTF-16 file. the code for parsing in is DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); DocumentBuilder loader = factory.newDocumentBuilder(); Document document = loader.parse(filename); the last line returns the error.

    Read the article

  • i m trying to return list<object> from webmethod but gives error

    - by girish
    System.InvalidOperationException: There was an error generating the XML document. --- System.InvalidOperationException: The type WebService.Property.Property_Users was not expected. Use the XmlInclude or SoapInclude attribute to specify types that are not known statically. at System.Xml.Serialization.XmlSerializationWriter.WriteTypedPrimitive(String name, String ns, Object o, Boolean xsiType) at Microsoft.Xml.Serialization.GeneratedAssembly.XmlSerializationWriter1.Write1_Object(String n, String ns, Object o, Boolean isNullable, Boolean needType) at Microsoft.Xml.Serialization.GeneratedAssembly.XmlSerializationWriter1.Write8_ArrayOfAnyType(Object o) at Microsoft.Xml.Serialization.GeneratedAssembly.ListOfObjectSerializer.Serialize(Object objectToSerialize, XmlSerializationWriter writer) at System.Xml.Serialization.XmlSerializer.Serialize(XmlWriter xmlWriter, Object o, XmlSerializerNamespaces namespaces, String encodingStyle, String id) --- End of inner exception stack trace --- at System.Xml.Serialization.XmlSerializer.Serialize(XmlWriter xmlWriter, Object o, XmlSerializerNamespaces namespaces, String encodingStyle, String id) at System.Xml.Serialization.XmlSerializer.Serialize(TextWriter textWriter, Object o, XmlSerializerNamespaces namespaces) at System.Xml.Serialization.XmlSerializer.Serialize(TextWriter textWriter, Object o) at System.Web.Services.Protocols.XmlReturnWriter.Write(HttpResponse response, Stream outputStream, Object returnValue) at System.Web.Services.Protocols.HttpServerProtocol.WriteReturns(Object[] returnValues, Stream outputStream) at System.Web.Services.Protocols.WebServiceHandler.WriteReturns(Object[] returnValues) at System.Web.Services.Protocols.WebServiceHandler.Invoke() public List<object> GetDataByModuleName(string ModuleName) { List<Property_Users> obj_UserList = new List<Property_Users>(); // performing some operation that add data to obj_UserList List < Object > myList = new List<object>(); return ConvertToObjectList<Property_Users>(obj_UserList); } public List<Object> ConvertToObjectList<N>(List<N> sourceList) { List<Object> result = new List<Object>(); foreach (N item in sourceList) { result.Add(item as Object); } return result; } [WebMethod] public List<object> GetDataByModuleName(string ModuleName) { List<object> obj_list = new List<object>(); obj_list = BAL_GeneralService.GetDataByModuleName(ModuleName); return obj_list; }

    Read the article

  • Trying to use an Xslt for an xml in asp.net

    - by Josemalive
    Hello, i have the following xslt sheet: <?xml version="1.0" encoding="UTF-8" ?> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"> <xsl:variable name="nhits" select="Answer[@nhits]"></xsl:variable> <xsl:output method="html" indent="yes"/> <xsl:template match="/"> <div> <xsl:call-template name="resultsnumbertemplate"/> </div> </xsl:template> <xsl:template name="resultsnumbertemplate"> <xsl:value-of select="$nhits"/> matches found </xsl:template> </xsl:stylesheet> And this is the xml that im trying to mix with the previous xslt: <Answer xmlns="exa:com.exalead.search.v10" context="n%3Dsl-ocu%26q%3Dlavadoras" last="9" estimated="false" nmatches="219" nslices="0" nhits="219" start="0"> <time> <Time interrupted="false" overall="32348" parse="0" spell="0" exec="1241" synthesis="15302" cats="14061" kwds="14061"> <sliceTimes>15272 </sliceTimes> </Time> </time> </Answer> Im using a xslcompiledtransform and that's working fine: XslCompiledTransform transformer = new XslCompiledTransform(); transformer.Load(HttpContext.Current.Server.MapPath("xslt\\" + requestvariables["xslsheet"].ToString())); transformer.Transform(xmlreader, null, writer); My problems comes when im trying to put into a variable the "nhits" attribute value placed on the Answer element, but i'm not rendering anything using my xslt sheet. Do you know what could be the cause? Could be the xmlns attribute in my xml file? Thanks in advance. Best Regards. Jose

    Read the article

  • Controlling the order of PicoContainer startup

    - by Trejkaz
    I have been tasked with doing some refactoring work on how we start up applications. Basically we have a bunch of console apps which were depending on the GUI application startup code, causing bogus dependencies which have kick-on effects for which libraries we need to ship, and which dependencies other modules need to declare. So I have written a simple startup framework where I basically just throw a bunch of Runnable objects into a list and then run them in order - and it works. But I was thinking - we already have PicoContainer in our project, so all these things that need to be run on startup could potentially be thrown into a PicoContainer, and if they implement Startable they will start... But in some cases we want to specify the ordering between them. For example, I don't want any other component writing to the log before we write a header into the log indicating that the application is starting up. I know I can introduce ordering by introducing injection dependencies, but this feels like a hack in this case - I would need to add the log header writer as a dependency for every other component which might write to the log, which isn't great at all. Nonetheless it seems like it would be nice to control the order of PicoContainer startup, so is there perhaps some other way? Alternatively I could just keep it simple and stick to my list of Runnable. It does, after all, work.

    Read the article

  • Using libcurl to create a valid POST

    - by Haraldo
    static int get( const char * cURL, const char * cParam ) { CURL *handle; CURLcode result; std::string buffer; char errorBuffer[CURL_ERROR_SIZE]; //struct curl_slist *headers = NULL; //headers = curl_slist_append(headers, "Content-Type: Multipart/Related"); //headers = curl_slist_append(headers, "type: text/xml"); // Create our curl handle handle = curl_easy_init(); if( handle ) { curl_easy_setopt(handle, CURLOPT_ERRORBUFFER, errorBuffer); //curl_easy_setopt(handle, CURLOPT_HEADER, 0); //curl_easy_setopt(handle, CURLOPT_HTTPHEADER, headers); curl_easy_setopt(handle, CURLOPT_POST, 1); curl_easy_setopt(handle, CURLOPT_POSTFIELDS, cParam); curl_easy_setopt(handle, CURLOPT_POSTFIELDSIZE, strlen(cParam)); curl_easy_setopt(handle, CURLOPT_FOLLOWLOCATION, 1); curl_easy_setopt(handle, CURLOPT_WRITEFUNCTION, Request::writer); curl_easy_setopt(handle, CURLOPT_WRITEDATA, &buffer); curl_easy_setopt(handle, CURLOPT_USERAGENT, "libcurl-agent/1.0"); curl_easy_setopt(handle, CURLOPT_URL, cURL); result = curl_easy_perform(handle); curl_easy_cleanup(handle); } if( result == CURLE_OK ) { return atoi( buffer.c_str() ); } return 0; } Hi there, first of all I'm having trouble debugging this in visual studio express 2008 so I'm unsure what buffer.c_str() might actually be returning but I am outputting 1 or 0 to the web page being posted to. Therefore I'm expecting the buffer to be one or the other, however I seem to only be returning 0 or equivalent. Does the code above look like it will return what I expect or should my variable types be different? The conversion using "atoi" may be an issue. Any thought would be much appreciated.

    Read the article

  • Android - ListActivity, add Header and Footer view

    - by Victor
    I'm using ListActivity, listview. listView = getListView(); just working perfectly. I added footer view as LayoutInflater inflater = getLayoutInflater(); listView.addFooterView( inflater.inflate( R.layout.footer, null ), null, false); and everything was shiny but ugly, so i wanted to add this footer view (which contains only 1 edittext and only 1 button ) to header of listView as LayoutInflater inflater = getLayoutInflater(); listView.addHeaderView( inflater.inflate( R.layout.footer, null ), null, false); and suddenly everything goes wrong, and i get RuntimeException immediately. Suspended(exception RuntimeException) ActivityThread.performLaunchActivity(ActivityThread$ActivityRecord, Intent) ActivityThread.handleLaunchActivity(ActivityThread$ActivityRecord, Intent) ActivityThread.access$2200(ActivityThread, Activity$ActiviyRecord, Intent), so on.. Why is it throws exception ? What is different between addFooterView and addHeaderView, and how can i add Header to ListActivity ? UPDATE So as you can read in comments, my logcat still doesn't work, but i just tried next at this moment: } catch(Exception e){ Writer result = new StringWriter(); PrintWriter printWriter = new PrintWriter(result); e.printStackTrace(printWriter); String error = result.toString(); } and afterward i put breakpoint, and i can read error in expressions section. it said : java.lang.IllegalStateException: Cannot add header view to list -- setAdapter has already been called. it was instructive for all of us. After change sort of commands, it works perferctly.

    Read the article

  • UIWebView selection

    - by Infinity
    Hello guys! I subclassed the UIWindow to get the clicks from UIWebView. I used a tutorial for this. Here is the link: Tutorial It is working, but after I've got and other tutorial from the writer where he shows how to highlight the text in UIWebView. Here's the second link. But I can't use this second one. I tried to run this code in the - (void)userDidTapWebView:(id)tapPoint; delegate method. This delegate method is called when I tap in the UIWebView. Maybe somebody can help me to correct the script? I would like to get the tapped anchor's link. I tried many different java script, but until now I couldn't get the tapped anchor's link. One of the tries is when I tried to add a function to document.onClick. But I tap an anchor then it needs a second tap to get the anchor and I can't get the link neither with this method.

    Read the article

  • Display: Custom Control

    - by pipelinecache
    Hi folks, I've made a simple custom control: base.Style[HtmlTextWriterStyle.Position] = "absolute"; if (this.Expanded) // If the Calendar is expanded. this.Style[HtmlTextWriterStyle.Display] = "block"; else this.Style[HtmlTextWriterStyle.Display] = "none"; //create the containing table Panel pnl = new Panel(); pnl.ID = "pnl_" + this.ClientID; pnl.Enabled = true; SherlockIIITextBox txtCalendar = new SherlockIIITextBox(); txtCalendar.ID = "Cal_" + this.ClientID; pnl.Controls.Add(txtCalendar); ImageButton imgButton = new ImageButton(); imgButton.ImageUrl = ""; imgButton.ID = "img_" + this.ClientID; imgButton.BorderStyle = BorderStyle.NotSet; imgButton.OnClientClick = "o = document.getElementById('" + this.ClientID + "');if (o.style.display=='none'){o.style.display='block';}else{o.style.display='none';}"; pnl.Controls.Add(imgButton); pnl.RenderControl(writer); When I click the ImageButton it should render the calendar. But when I click the ImageButton nothing happens. Anyone got an idea?

    Read the article

  • Is there something wrong with this code? AMFReader vs AMFWriter

    - by Triynko
    Something doesn't seem right about the source code for Flash Remoting's Date(AS3) <- DateTime(.NET) stream reader/writer methods, when it comes to handling UTC <- Local times. It seems to write the DateTime data fine, including a 64-bit representation as milliseconds elapsed since Jan 1, 1970, as well as a UTC offset. public void WriteDateTime(DateTime d) { this.BaseStream.WriteByte(11); DateTime time = new DateTime(0x7b2, 1, 1); long totalMilliseconds = (long)d.Subtract(time).TotalMilliseconds; long l = BitConverter.DoubleToInt64Bits((double)totalMilliseconds); this.WriteLong(l); int hours = TimeZone.CurrentTimeZone.GetUtcOffset(DateTime.Today).Hours; this.WriteShort(hours); } But when the data is read... it seems to be ignoring the short UTC offset value that was written, and appears to just discard it! private DateTime ReadDateValue() { long num2 = (long)this.ReadDouble(); DateTime time2 = new DateTime(0x7b2, 1, 1).AddMilliseconds((double)num2); int num3 = this.ReadInt16() / 60; //num3 is not used for anything! return time2; } Can anyone make sense of this? I also found some similar source code for AMFReader here, which has a ReadDateTime method, that seems to do something very similar... but goes on to use the UTC offset for something.

    Read the article

  • Uncompress a TIFF file without going through BufferedImage

    - by Gert
    I am receiving large size CCITT Group 4 compressed TIFF files that need to be written elsewhere as uncompressed TIFF files. I am using the jai_imageio TIFF reader and writer to do that and it works well as long as the product _width * height_ of the image fits in an integer. Here is the code I am using: TIFFImageReaderSpi readerSpi= new TIFFImageReaderSpi(); ImageReader imageReader = readerSpi.createReaderInstance(); byte[] data = blobManager.getObjectForIdAndVersion(id, version); ImageInputStream imageInputStream = ImageIO.createImageInputStream(data); imageReader.setInput(imageInputStream); TIFFImageWriterSpi writerSpi = new TIFFImageWriterSpi(); ImageWriter imageWriter = writerSpi.createWriterInstance(); ImageWriteParam imageWriteParam = imageWriter.getDefaultWriteParam(); imageWriteParam.setCompressionMode(ImageWriteParam.MODE_DISABLED); //bufferFile is created in the constructor ImageOutputStream imageOutputStream = ImageIO.createImageOutputStream(bufferFile); imageWriter.setOutput(imageOutputStream); //Now read the bitmap BufferedImage bufferedImage = imageReader.read(0); IIOImage iIOImage = new IIOImage(bufferedImage, null, null); //and write it imageWriter.write(null, iIOImage, imageWriteParam); Unfortunately, the files that I receive are often very large and the BufferedImage cannot be created. I have been trying to find a way to stream from the ImageReader directly to the ImageWriter but I cannot find out how to do that. Anybody with a suggestion?

    Read the article

  • Object suddenly missing from HttpServletRequest

    - by Jeune
    I print a list directly in the servlet using the print writer and the list prints. When I try to put in the jsp however the list doesn't print whether I use JSTL or scriptlets. I tried to test in JSTL and scriptlet if the object is null and turns out that it is! Why does this happen and how can I fix this? Servlet code that works for (Artist artist:artists){ resp.getWriter().println(artist.getName()); } Servlet code that puts object in the request public void doGet(HttpServletRequest req, HttpServletResponse resp) throws IOException { ApplicationContext ctx = new ClassPathXmlApplicationContext("com/helloworld/beans/helloworld-context.xml"); ArtistDao artistDao = (ArtistDao) ctx.getBean("artistDao"); List<Artist> artists = null; try { artists = artistDao.getAll(); } catch (SQLException e) { e.printStackTrace(); } req.setAttribute("artists", artists); try { req.getRequestDispatcher("index.jsp").forward(req, resp); } catch (ServletException e) { e.printStackTrace(); } scriptlet code that suddenly finds the object null <% List<Artist> artists = (List<Artist>) request.getAttribute("artists"); if (artists == null) { out.println("artists null"); } else { for (Artist artist: artists){ out.println(artist.getName()); } } %> Even the jstl code seems to agree <c:if test="${artists eq null}"> Artists are null </c:if> <c:forEach var="artist" items="${artists}"> ${artist.name} </c:forEach> For my app I am using weblogic, spring 2.5.6 and ibatis.

    Read the article

  • Why compiler go to suspend mode when want to open database?

    - by rima
    Dear friend I try to connect to database with a less line for my connection string... I find out s.th in oracle website but i dont know Why when the compiler arrive to the line of open database do nothing????!it go back to GUI,but it like hanging...please help me to solve it. p.s.Its funny the program didnt get me any exception also! these service is active in my computer: > Oracle ORCL VSS Writer Service Start > OracleDBConsolrorcl > OracleJobSchedulerORCL Start > OracleOraDB11g+home1TNSListener Start > oracleServiceORCL Start try { /** * ORCL = (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = rima-PC)(PORT = 1521)) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = orcl) ) )*/ string oradb = "Data Source=(DESCRIPTION=" + "(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=rima-PC)(PORT=1521)))" + "(CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME=orcl)));" + "User Id=bird_artus;Password=123456;"; //string oradb = "Data Source=OraDb;User Id=scott;Password=tiger;"; string oradb1 = "Data Source=ORCL;User Id=scott;Password=tiger;"; // C# OracleConnection con = new OracleConnection(); con.ConnectionString = oradb1; String command = "select dname from dept where deptno = 10"; MessageBox.Show(command); OracleDataAdapter oda = new OracleDataAdapter(); oda.SelectCommand = new OracleCommand(); oda.SelectCommand.Connection = con; oda.SelectCommand.CommandText = command; con.Open(); oda.SelectCommand.ExecuteNonQuery(); DataSet ds = new DataSet(); oda.Fill(ds); Console.WriteLine(ds.GetXml()); dataGridView1.DataSource = ds; con.Close(); } catch (Exception ex) { MessageBox.Show(ex.Message.ToString()+Environment.NewLine+ ex.StackTrace.ToString()); }

    Read the article

  • How do set up jquery to exclude classes in a function?

    - by user1497158
    I essentially only understand how to read bits of javascript and make modifications. I am using grid-slider, a script I purchased, but the code writer is mia at the moment, so hopefully someone here can help me. Basically, it's a slider and there are options to have links open like normal or to have links open in a panel on the same page. I want some links to open in a panel and others to open in the parent window. It seems to me that all that would be required to do this would be to activate the panel display function (which I've done) and then set up an exclude function to exclude certain uls or lis with a specific class from the function. I've read about the .not selector, but I don't see how to make it applicable to this code: enter code hereelse { enter code here if (this._displayOverlay) { if ($item.find(">.content").size() > 0) { $item.data("type", "static"); } else { var contentType = this.getContentType($link); var url = $link.attr("href"); $item.data({type:contentType, url:(typeof url != "undefined") ? url : ""}); } $item.css("cursor", "pointer").bind("click", {elem:this, i:i}, this.openOverlay); } $link.data("text", $item.find(">div:first").html()); $img = $link.find(">img"); } Can anyone help based on looking at this? Here's a link to the demo of the code: http://codecanyon.net/item/jquery-grid-style-slider/full_screen_preview/1204040 Thank you.

    Read the article

  • Atomic int writes on file

    - by Waneck
    Hello! I'm writing an application that will have to be able to handle many concurrent accesses to it, either by threads as by processes. So no mutex'es or locks should be applied to this. To make the use of locks go down to a minimum, I'm designing for the file to be "append-only", so all data is first appended to disk, and then the address pointing to the info it has updated, is changed to refer to the new one. So I will need to implement a small lock system only to change this one int so it refers to the new address. How is the best way to do it? I was thinking about maybe putting a flag before the address, that when it's set, the readers will use a spin lock until it's released. But I'm afraid that it isn't at all atomic, is it? e.g. a reader reads the flag, and it is unset on the same time, a writer writes the flag and changes the value of the int the reader may read an inconsistent value! I'm looking for locking techniques but all I find is either for thread locking techniques, or to lock an entire file, not fields. Is it not possible to do this? How do append-only databases handle this? Thanks! Cauê

    Read the article

  • Updating a specific key/value inside of an array field with MongoDB

    - by Jesta
    As a preface, I've been working with MongoDB for about a week now, so this may turn out to be a pretty simple answer. I have data already stored in my collection, we will call this collection content, as it contains articles, news, etc. Each of these articles contains another array called author which has all of the author's information (Address, Phone, Title, etc). The Goal - I am trying to create a query that will update the author's address on every article that the specific author exists in, and only the specified author block (not others that exist within the array). Sort of a "Global Update" to a specific article that affects his/her information on every piece of content that exists. Here is an example of what the content with the author looks like. { "_id" : ObjectId("4c1a5a948ead0e4d09010000"), "authors" : [ { "user_id" : null, "slug" : "joe-somebody", "display_name" : "Joe Somebody", "display_title" : "Contributing Writer", "display_company_name" : null, "email" : null, "phone" : null, "fax" : null, "address" : null, "address2" : null, "city" : null, "state" : null, "zip" : null, "country" : null, "image" : null, "url" : null, "blurb" : null }, { "user_id" : null, "slug" : "jane-somebody", "display_name" : "Jane Somebody", "display_title" : "Editor", "display_company_name" : null, "email" : null, "phone" : null, "fax" : null, "address" : null, "address2" : null, "city" : null, "state" : null, "zip" : null, "country" : null, "image" : null, "url" : null, "blurb" : null }, ], "tags" : [ "tag1", "tag2", "tag3" ], "title" : "Title of the Article" } I can find every article that this author has created by running the following command: db.content.find({authors: {$elemMatch: {slug: 'joe-somebody'}}}); So theoretically I should be able to update the authors record for the slug joe-somebody but not jane-somebody (the 2nd author), I am just unsure exactly how you reach in and update every record for that author. I thought I was on the right track, and here's what I've tried. b.content.update( {authors: {$elemMatch: {slug: 'joe-somebody'} } }, {$set: {address: '1234 Avenue Rd.'} }, false, true ); I just believe there's something I am missing in the $set statement to specify the correct author and point inside of the correct array. Any ideas? **Update** I've also tried this now: b.content.update( {authors: {$elemMatch: {slug: 'joe-somebody'} } }, {$set: {'authors.$.address': '1234 Avenue Rd.'} }, false, true );

    Read the article

  • How much detail should be in a project plan or spec?

    - by DeanMc
    I have an issue that I feel many programmers can relate to... I have worked on many small scale projects. After my initial paper brain storm I tend to start coding. What I come up with is usually a rough working model of the actual application. I design in a disconnected fashion so I am talking about underlying code libraries, user interfaces are the last thing as the library usually dictates what is needed in the UI. As my projects get bigger I worry that so should my "spec" or design document. The above paragraph, from my investigations, is echoed all across the internet in one fashion or another. When a UI is concerned there is a bit more information but it is UI specific and does not relate to code libraries. What I am beginning to realise is that maybe code is code is code. It seems from my extensive research that there is no 1:1 mapping between a design document and the code. When I need to research a topic I dump information into OneNote and from there I prioritise features into versions and then into related chunks so that development runs in a fairly linear fashion, my tasks tend to look like so: Implement Binary File Reader Implement Binary File Writer Create Object to encapsulate Data for expression to the caller Now any programmer worth his salt is aware that between those three to do items could be a potential wall of code that could expand out to multiple files. I have tried to map the complete code process for each task but I simply don't think it can be done effectively. By the time one mangles pseudo code it is essentially code anyway so the time investment is negated. So my question is this: Am I right in assuming that the best documentation is the code itself. We are all in agreement that a high level overview is needed. How high should this be? Do you design to statement, class or concept level? What works for you?

    Read the article

  • Trap SIGPIPE when trying to write without reader

    - by Matt
    I am trying to implement a named-pipe communication solution in BASH between two processes. The first process runs a script which echo something in a named-pipe: send(){ echo 'something' > $NAMEDPIPE } And the second script is supposed to read the named-pipe via another script which contains: while true;do if read line < $NAMEDPIPE;do someCommands fi done Not that the named pipe has been previously created using the traditional command mkfifo $NAMEDPIPE My problem is that the reader script is not always running so that if the writer script try to write in the named-pipe it stay blocked until a reader connect the pipe. I want to avoid this behavior, and a solution would be to trap a SIGPIPE signal. Indeed, according to man 7 signal is supposed to be send when trying to write in a pipe with no reader. So I changed my red function by: read(){ trap 'echo "SIGPIPE received"' SIGPIPE echo 'something' > $NAMEDPIPE } But when I run the reader script, the script stay blocked, and not "SIGPIPE received" appears... Am I mistaking on the signal mechanism or is there any better solution to my problem ? Thank you for your help.

    Read the article

  • How do I do MongoDB console-style queries in PHP?

    - by Zoe Boles
    I'm trying to get a MongoDB query from the javascript console into my PHP app. What I'm trying to avoid is having to translate the query into the PHP "native driver"'s format... I don't want to hand build arrays and hand-chain functions any more than I want to manually build an array of MySQL's internal query structure just to get data. I already have a string producing the exact content I want in the Mongo console: db.intake.find({"processed": {"$exists": "false"}}).sort({"insert_date": "1"}).limit(10); The question is, is there a way for me to hand this string, as is, to MongoDB and have it return a cursor with the dataset I request? Right now I'm at the "write your own parser because it's not valid json to kinda turn a subset of valid Mongo queries into the format the PHP native driver wants" state, which isn't very fun. I don't want an ORM or a massive wrapper library; I just want to give a function my query string as it exists in the console and get an Iterator back that I can work with. I know there are a couple of PHP-based Mongo manager applications that apparently take console-style queries and handle them, but initial browsing through their code, I'm not sure how they handle the translation. I absolutely love working with mongo in the console, but I'm rapidly starting to loathe the thought of converting every query into the format the native writer wants...

    Read the article

  • How to overcome the programmer's block ?

    - by Nicolas Dorier
    How do you do when, during the development of your application, you can't decide yourself what to do next. You have no problem technically speaking, you have no problem to write clean code BUT you have a problem to decide yourself on what to code now. And you spend time thinking and thinking again on your design, in the car, in the shower, and you cannot write a single line of code... I think we call this "analysis paralysis". I hate being in this state ! How can you avoid this ? How do you do to not fall in this state ? I think this occurs when we are writting a big chunk of code with no visible improvement, but I'm not sure... UPDATE Like some of you said, this problem is also what we call the "programmer's block" (analogy with the writer's block). Doing some TDD doesn't help because I'm stuck, I can't decide myself what class to code, what methods to put inside (even a name of method). Though I admit that it helps to break a big chunk of code into smaller ones. Like Talesh said my head becomes full of "what-if".

    Read the article

  • Deal with undefined values in code or in the template?

    - by David
    I'm writing a web application (in Python, not that it matters). One of the features is that people can leave comments on things. I have a class for comments, basically like so: class Comment: user = ... # other stuff where user is an instance of another class, class User: name = ... # other stuff And of course in my template, I have <div>${comment.user.name}</div> Problem: Let's say I allow people to post comments anonymously. In that case comment.user is None (undefined), and of course accessing comment.user.name is going to raise an error. What's the best way to deal with that? I see three possibilities: Use a conditional in the template to test for that case and display something different. This is the most versatile solution, since I can change the way anonymous comments are displayed to, say, "Posted anonymously" (instead of "Posted by ..."), but I've often been told that templates should be mindless display machines and not include logic like that. Also, other people might wind up writing alternate templates for the same application, and I feel like I should be making things as easy as possible for the template writer. Implement an accessor method for the user property of a Comment that returns a dummy user object when the real user is undefined. This dummy object would have user.name = 'Anonymous' or something like that and so the template could access it and print its name with no error. Put an actual record in my database corresponding to a user with user.name = Anonymous (or something like that), and just assign that user to any comment posted when nobody's logged in. I know I've seen some real-world systems that operate this way. (phpBB?) Is there a prevailing wisdom among people who write these sorts of systems about which of these (or some other solution) is the best? Any pitfalls I should watch out for if I go one way vs. another? Whoever gives the best explanation gets the checkmark.

    Read the article

  • sqlite3 'database is locked' won't go away with retries

    - by Azarias
    I have a sqlite3 database that is accessed by a few threads (3-4). I am aware of the general limitations of sqlite3 with regards to concurrency as stated http://www.sqlite.org/faq.html#q6 , but I am convinced that is not the problem. All of the threads both read and write from this database. Whenever I do a write, I have the following construct: try: Cursor.execute(q, params) Connection.commit() except sqlite3.IntegrityError: Notify except sqlite3.OperationalError: print sys.exc_info() print("DATABASE LOCKED; sleeping for 3 seconds and trying again") time.sleep(3) Retry On some runs, I won't even hit this block, but when I do, it never comes out of it (keeps retrying, but I keep getting the 'database is locked' error from exc_info. If I understand the reader/writer lock usage correctly, some amount of waiting should help with the contention. What this sounds like is deadlock, but I do not use any transactions in my code, and every SELECT or INSERT is simply a one off. Some threads, however, keep the same connection when they do their operation (which includes a mix of SELECTS and INSERTS and other modifiers). I would appericiate it if you could shade a light on this, and also ways around fixing it (besides using a different database engine.)

    Read the article

  • Digitally sign MS Office (Word, Excel, etc..) and PDF files on the server

    - by Sébastien Nussbaumer
    I need to digitally sign MS Office and PDF files that are stored on a server. I really mean a digital signature that is integrated in the document, according to each specific file formats. This is the process I had in mind : Create a hash of the file's content Send the hash to a custom written java applet in the browser The user encrypts the hash with his/her private key (on an usb token via PKCS#11 for example), thus effectively signing the file. The applet then sends the signature to the server On the server I would then incorporate the signature in the file's (MS Office and PDF files can do that without changing the file's content, probably by just setting some metadata field) What is cool is that you never have to download and upload the complete file to the server again. What is even cooler, the customer doesn't need Office or PDF Writer to sign the files. Parts 2, 3 and 4 are OK for me, my company bought all the JAVA technology I need for that for a previous project I worked on. Problem : I can't seem to find any documentation/examples to do parts 1 and 5 for Office files . Are my google skills failing me this time ? Do you have any pointers to documentation or examples for doing that for MS Office files ? The underlying technology isn't that important to me : I can use Java, .Net, COM, any working technology is OK ! Note : I'm 95% sure I can nail points 1 and 5 for PDF files using iText Thanks ** Edit : If I can't do that with hashes and must download the complete file to the client, it's also possible. But then I still need the documentation to be able to sign Office file... in java this time (from an applet)

    Read the article

< Previous Page | 46 47 48 49 50 51 52 53 54 55 56 57  | Next Page >