Search Results

Search found 15210 results on 609 pages for 'technical writing'.

Page 29/609 | < Previous Page | 25 26 27 28 29 30 31 32 33 34 35 36  | Next Page >

  • Writing jQuery functions that allow chaining.

    - by Rich Bradshaw
    I want to write some code that allows me to replace jQuery's animate function with one that does different things, but still allows me to call a secondary function on completion. At the moment, I'm writing lots of code like this; if (cssTransitions) { $("#content_box").css("height",0); window.setTimeout(function() { secondFunction(); }, 600); } else { $("#content_box").animate({ height:0 }, 600, function() { secondFunction(); }); } I'd much rather write a function that looks like this: function slideUpContent(object) { if (cssTransitions) { object.css("height",0); // Not sure how I get a callback here } else { $("#content_box").animate({ height:0 }, 600, function() { }); } } That I could use like this: slideUpContent("#content_box", function(){ secondFunction(); }); But I'm not sure how to get the functionality I need - namely a way to run another function once my one has completed. Can anyone help my rather addled brain?

    Read the article

  • Writing an installer using codigniter

    - by RobertWHurst
    I'm just about finished my first release of automailer, a program I've been working on for a while now. I've just got to finish writing the installer. Its job is to rewrite the codigniter configs from templates. I've got the read/write stuff working, but I'd like to be able to test the server credentials given by the user without codingiter throwing a system error if they're wrong. Is there a function other than mysql_connect that I can use to test a connection that will return true or false and won't make codeigniter have a fit?

    Read the article

  • Writing array to text file

    - by user3661876
    I have an array, but it won't write each index to the text file. Instead it is only writing the last index and the other indexes are not appearing. Can anyone help me to get the entire array printed to the text file? static void solve(int k) { if (k == N) // We placed N-1 queens (0 included), problem solved! { // Solution found! using (StreamWriter sw = new StreamWriter("names.txt")) { Console.Write("Solution: "); for (int i = 0; i < N; i++) { Console.Write(position[i] + " "); foreach (int s in position[i].ToString()) { string list = position[i].ToString(); sw.Write(list + " "); } } Console.WriteLine(); sum += 1; } }

    Read the article

  • Should a programmer take writing lessons to enhance code expressiveness?

    - by Jose Faeti
    Given that programmers are authors and write code to express abstract thoughts and concepts, and good code should be read by other programmers without difficulties and misunderstandings, should a programmer take writing lessons to write better code? Abstracting concepts and real world problems/entities is an important part of writing good code, and a good mastery of the language used for coding should allow the programmer to express his thoughts more easily, or in a better way. Besides, when trying to write or rewrite some code to make it better, much time can be spent in deciding the names for functions, variables or data structures. I think this could also help to avoid writing code with more than one meaning, often cause of misunderstanding between different programmers. Code should always express clearly its function unambiguously.

    Read the article

  • What are the pre-requisites for writing .NET web services?

    - by wackytacky99
    I am very new to web development. I have been a C,C++ programmer for 5 years and I'm starting to get into the web development, writing web services, etc. I understand that basic concepts of web services. I know .Net web services can be written in VB or C#. Working with C,C++ will help getting used to writing code in C#. I do not have experience in .Net framework. I'd like to quickly get into writing .Net web services and learning on the go, without extensively spending a lot of time learning .Net framework (if possible) Any suggestions? Update - I know my way around databases and sql express in Visual Studio

    Read the article

  • Writing a docx file to a BLOB using Java 1.4 inside Oracle 10g

    - by Jon Renaut
    I'm trying to generate a blank docx file using Java, add some text, then write it to a BLOB that I can return to our document processing engine (a custom mess of PL/SQL and Java). I have to use the 1.4 JVM inside Oracle 10g, so no Java 1.5 stuff. I don't have a problem writing the docx to a file on my local machine, but when I try to write to BLOB, I'm getting garbage. Am I doing something dumb? Any help is appreciated. Note in the code below, all the get[name]Xml() methods return an org.w3c.dom.Document. public void save(String fileName) throws Exception { ZipOutputStream zos = new ZipOutputStream(new FileOutputStream(fileName)); addEntry(zos, getDocumentXml(), "word/document.xml"); addEntry(zos, getContentTypesXml(), "[Content_Types].xml"); addEntry(zos, getRelsXml(), "_rels/.rels"); zos.flush(); zos.close(); } public java.sql.BLOB save() throws Exception { java.sql.Connection conn = DbUtilities.openConnection(); BLOB outBlob = BLOB.createTemporary(conn, true, BLOB.DURATION_SESSION); outBlob.open(BLOB.MODE_READWRITE); ZipOutputStream zos = new ZipOutputStream(outBlob.setBinaryStream(0L)); addEntry(zos, getDocumentXml(), "word/document.xml"); addEntry(zos, getContentTypesXml(), "[Content_Types].xml"); addEntry(zos, getRelsXml(), "_rels/.rels"); zos.flush(); zos.close(); return outBlob; } private void addEntry(ZipOutputStream zos, Document doc, String fileName) throws Exception { Transformer t = TransformerFactory.newInstance().newTransformer(); ByteArrayOutputStream baos = new ByteArrayOutputStream(); t.transform(new DOMSource(doc), new StreamResult(baos)); ZipEntry ze = new ZipEntry(fileName); byte[] data = baos.toByteArray(); ze.setSize(data.length); zos.putNextEntry(ze); zos.write(data); zos.flush(); zos.closeEntry(); }

    Read the article

  • Writing an efficient cron job script utilizing Zend_Mail_Storage_Imap.

    - by fireeyedboy
    I'm new to the IMAP protocol and Zend_Mail_Storage and I'm writing a small php script for a cron job that should regularly poll an IMAP account and check for new messages, and send an e-mail if new messages have arrived. As you can imagine, I want to only poll the IMAP account for relevant messages, and I only want to send a new e-mail if new messages have arrived since the last polled new message. So I thought of keeping track of the last message I polled with some unique identifier for a message. But I'm a bit uncertain about whether the methods I want to utilize for this do what I expect them to do though. So my questions are: Does the iterator position of Zend_Mail_Storage_Imap actually resemble some IMAP unique identifier for messages, or is it simply only and internal position of Zend_Mail_Storage_Abstract? For instance, if I tell it to seek() to message 5 (which I stored from an earlier session) will it indeed seek to the appropriate message on the IMAP server, even if for instance messages have been deleted since last session? Would keeping track of this latest polled message id in a file suffice for a cron job that, say, polls the account every 5 or 10 minutes? Or is this too naive, and should I be using a database for instance. Or is there maybe a much easier way to keep track of such state with Zend_Mail_Storage_Abstract? Also, do I need to poll every IMAP folder? Or is everything accumulated when I poll INBOX? If you could shed some light on any of these matters, I'ld appreciate it. Thanks in advance.

    Read the article

  • Writing files in App_Data causes tempdata to be null

    - by RAMX
    I have a small asp.net MVC 1 web app that can store files and create directories in the App_Data directory. When the write operation succeeds, I add a message to the tempdata and do a redirectToRoute. The problem is that the tempdata is null when the action is executed. If i write the files in a directory outside of the web applications root directory, the tempdata is not null and everything works correctly. Any ideas why writing in the app_data seems to clear the tempdata ? edit: if DRS.Logic.Repository.Manager.CreateFile(path, hpf, comment) writes in the App_Data, TempData will be null in the action being redirected to. if it is a directory out of the web app root it is fine. No exceptions are being thrown. [AcceptVerbs(HttpVerbs.Post)] public ActionResult Create(int id, string path, FormCollection form) { ViewData["path"] = path; ViewData["id"] = id; HttpPostedFileBase hpf; string comment = form["FileComment"]; hpf = Request.Files["File"] as HttpPostedFileBase; if (hpf.ContentLength != 0) { DRS.Logic.Repository.Manager.CreateFile(path, hpf, comment); TempData["notification"] = "file was created"; return RedirectToRoute(new { controller = "File", action ="ViewDetails", id = id, path = path + Path.GetFileName(hpf.FileName) }); } else { TempData["notification"] = "No file were selected."; return View(); } }

    Read the article

  • Access Violation When Writing Dynamic 2D Array... Sometimes

    - by Shraptnel
    This program is meant to generate a dynamic array, however it gives an access violation error when writing when given certain dimensions. Eg: R = 6, C = 5 crashes, but then R = 5, C = 6 doesn't. In case your wondering, it isn't my homework to "fix" this broken program, this is the method we were taught in class. Also part of my assessment is to use this method, so vectors are out. Thanks in advance! #include <iostream> using namespace std; int main(){ const int R = 6; const int C = 5; char **d; d = new char *[R]; for(int i=0; i<C; ++i){ d[i] = new char[C]; } //initialise for(int i=0; i<R; ++i){ for(int j=0; j<C; ++j){ d[i][j] = 'd'; cout<<d[i][j]; } cout<<endl; } cout<<endl; system("pause"); return 0; }

    Read the article

  • Writing PHP extension - Unable to load dynamic library

    - by Luke
    I'm writing a PHP extension similar to V8JS. The goal, like V8JS, is to embed the V8 engine into PHP so I can execute sandboxed JavaScript code in PHP. (The implementation is different.) The extension compiles fine, but when I attempt to run it I get: PHP Warning: PHP Startup: Unable to load dynamic library '/phpdev/lib/php/extensions/debug-zts-20090626/v8php.so' - dlopen(/phpdev/lib/php/extensions/debug-zts-20090626/v8php.so, 9): Symbol not found: __ZN2v88internal8Snapshot13context_size_E Referenced from: /phpdev/lib/php/extensions/debug-zts-20090626/v8php.so Expected in: flat namespace PHP is compiled with the prefix /phpdev (with debug and maintainer flags). v8 is compiled in /v8/ with gyp with the commands make dependencies and make x64 which produced /v8/out/x64.release and /v8/out/x64.debug. I soft-linked the header files from /v8/include to /phpdev/include and libv8_base.a from /v8/out/x64.release/libv8_base.a to /phpdev/lib/libv8.a. This is my config.m4 file: PHP_ARG_ENABLE(v8php, [V8PHP], [--enable-v8php Include V8 JavaScript Engine]) if test $PHP_V8PHP != "no"; then SEARCH_PATH="$prefix /usr/local /usr" SEARCH_FOR="/include/v8.h" if test -r $PHP_V8PHP/$SEARCH_FOR; then V8_DIR=$PHP_V8PHP else AC_MSG_CHECKING([for V8 files in default path]) for i in $SEARCH_PATH ; do if test -r $i/$SEARCH_FOR; then V8_DIR=$i AC_MSG_RESULT(found in $i) fi done fi if test -z "$V8_DIR"; then AC_MSG_RESULT([not found]) AC_MSG_ERROR([Unable to locate V8]) fi PHP_ADD_INCLUDE($V8_DIR/include) PHP_SUBST(V8PHP_SHARED_LIBADD) PHP_ADD_LIBRARY_WITH_PATH(v8, $V8_DIR/$PHP_LIBDIR, V8PHP_SHARED_LIBADD) PHP_REQUIRE_CXX() PHP_NEW_EXTENSION(v8php, v8php.cc v8_class.cc, $ext_shared) fi What am I doing wrong?

    Read the article

  • Reading,Writing, Editing BLOBS through DataTables and DataRows

    - by Soham
    Consider this piece of code: DataSet ds = new DataSet(); SQLiteDataAdapter Da = new SQLiteDataAdapter(Command); Da.Fill(ds); DataTable dt = ds.Tables[0]; bool PositionExists; if (dt.Rows.Count > 0) { PositionExists = true; } else { PositionExists = false; } if (PositionExists) { //dt.Rows[0].Field<>("Date") } Here the "Date" field is a BLOB. My question is, a. Will reading through the DataAdapter create any problems later on, when I am working with BLOBS? More, specifically, will it read the BLOB properly? b. This was the read part.Now when I am writing the BLOB to the DB,its a queue actually. I.e I am trying to store a queue in MySQLite using a BLOB. Will Conn.ExecuteNonQuery() serve my purpose? c. When I am reading the BLOB back from the DB, can I edit it as the original datatype, it used to be in C# environment i.e { Queue - BLOB - ? } {C# -MySQL - C# } So in this context, Date field was a queue, I wrote it back as a BLOB, when reading it back, can I access it(and edit) as a queue? Thank You. Soham

    Read the article

  • Is using a StringBuilder for writing XML ok?

    - by Jack Lawson
    It feels dirty. But maybe it isn't... is it ok to use a StringBuilder for writing XML? My gut instinct says "although this feels wrong, it's probably pretty darn performant because it's not loading extra libraries and overhead." Here's what it looks like. I'm building an OpenSearch XML doc based on the domain you come in from. public void ProcessRequest(HttpContext context) { context.Response.ContentType = "text/xml"; string domain = WebUtils.ReturnParsedSourceUrl(null); //returns something like www.sample.com string cachedChan = context.Cache[domain + "_opensearchdescription"] as String; if (cachedChan == null) { StringBuilder sb = new StringBuilder(); sb.Append("<?xml version=\"1.0\" encoding=\"UTF-8\"?>"); sb.Append("<OpenSearchDescription xmlns=\"http://a9.com/-/spec/opensearch/1.1/\" xmlns:moz=\"http://www.mozilla.org/2006/browser/search/\">"); sb.Append(" <ShortName>Search</ShortName>"); sb.Append(" <Description>Use " + domain + " to search.</Description>"); sb.Append(" <Contact>[email protected]</Contact>"); sb.Append(" <Url type=\"text/html\" method=\"get\" template=\"http://" + domain + "/Search.aspx?q={searchTerms}\" />"); sb.Append(" <moz:SearchForm>http://" + domain + "/Search.aspx</moz:SearchForm>"); sb.Append(" <Image height=\"16\" width=\"16\" type=\"image/x-icon\">http://" + domain + "/favicon.ico</Image>"); sb.Append("</OpenSearchDescription>"); cachedChan = sb.ToString(); context.Cache.Insert(domain + "_opensearchdescription", cachedChan, null, DateTime.Now.AddDays(14), TimeSpan.Zero); } context.Response.Write(cachedChan); }

    Read the article

  • Writing Russian in XML

    - by zavié
    Hi, I am writing a Xml Tag Renamer class with Java which reads in a XML, renames the tags and write them back into another XML file using DocumentBuilderFactory and TransformerFactory (text nodes are preserved). It worked fine before with German and English texts, until today, when I tried to rename a XML file with russian text. Instead of the source texts I got ????? in the newly created XML file. I've tried setting Encoding Any idea how to correct this? Thanks! PS. Strings were correct before entering TransformerFactory, as I checked in the debugger. I've tried setting OutputKeys.ENCODING to UTF-8 and ISO-8859-5. None of them helped. The Transformer part: // Output the XML // Set up a transformer TransformerFactory transFactory = TransformerFactory.newInstance(); Transformer transformer = transFactory.newTransformer(); transformer.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, "no"); // Fix to a bug about indent in transformer transformer.setOutputProperty ("{http://xml.apache.org/xslt}indent-amount", "4"); transformer.setOutputProperty(OutputKeys.INDENT, "yes"); // TODO encoding parameter transformer.setOutputProperty(OutputKeys.ENCODING, "UTF-8"); // Create string from xml tree StringWriter sw = new StringWriter(); StreamResult result = new StreamResult(sw); DOMSource source = new DOMSource(doc); transformer.transform(source, result); String xmlString = sw.toString(); xmlString.replaceAll("\n", System.getProperty("line.separator")); // Write to file BufferedWriter output = new BufferedWriter(new FileWriter(outputPath)); output.write(xmlString); output.close();

    Read the article

  • MSBuild - Writing Escape Characters to Files

    - by Richm7
    I've got a very similar scenario to the one described in this post. It describes how to load the contents of a file that contains properties & items, making sure they're resolved as part of the process. I'm doing the same thing except writing the contents away to another text file (generally .ini file). In short I'd start by importing a project / propertygroup which contains this text: ; ----------- [heading] setting1=$(FirstValue) setting2=$(SecondValue) setting3=list;of;values;delimited;by;semicolons setting4=bla bla bla ; ----------- & hopefully write it away to a new .ini file containing the following: ; ----------- [heading] setting1=value resolved by msbuild setting2=another value resolved by msbuild setting3=list;of;values;delimited;by;semicolons setting4=bla bla bla ; ----------- Only problem is that some files will contain semicolons. I can live without comments, but they're also used as part of values e.g. in lists. This is the result of using the WriteLinesToFile task. The semicolons are treated as escape characters & result in new lines, so the value of 'setting3' in the above example would be split over 6 lines. Is there a way around this without implementing my own task? Thanks in advance for the help!

    Read the article

  • Writing a JMS Publisher without "public static void main"

    - by The Elite Gentleman
    Hi guys, Every example I've seen on the web, e.g. http://www.codeproject.com/KB/docview/jms_to_jms_bridge_activem.aspx, creates a publisher and subscriber with a public static void main method. I don't think that'll work for my web application. I'm learning JMS and I've setup Apache ActiveMQ to run on JBoss 5 and Tomcat 6 (with no glitches). I'm writing a messaging JMS service that needs to send email asynchronously. I've already written a JMS subscriber that receives the message (the class inherits MessageListener). My question is simple: How do I write a publisher that will so that my web applications can call it? Does it have to be published somewhere? My thought is to create a publisher with a no-attribute constructor (in there) and get the MessageQueue Factory, etc. from the JNDI pool (in the constructor). Is my idea correct? How do I subscribe my subscriber to the Queue Receiver? (So far, the subscriber has no constructor, and if I write a constructor, do I always subscribe myself to the Queue receiver?) Thanks for your help, sorry if my terminology is not up to scratch, there are too many java terminologies that I get lost sometimes (maybe a java GPS will do! :-) ) PS Is there a tutorial out there that explains how to write a "better" (better can mean anything, but in my case it's all about performance in high demand requests) JMS Publisher and Subscriber that I can run on Application Server such as JBoss or Glassfish? Don't forget that the JMS application will needs a "guarantee" uptime as many applications will use this.

    Read the article

  • Writing to a file in Python inserts null bytes

    - by Javier Badia
    I'm writing a todo list program. It keeps a file with a thing to do per line, and lets the user add or delete items. The problem is that for some reason, I end up with a lot of zero bytes at the start of the file, even though the item is correctly deleted. I'll show you a couple of screenshots to make sure I'm making myself clear. This is the file in Notepad++ before running the program: This is the file after deleting item 3 (counting from 1): This is the relevant code. The actual program is bigger, but running just this part triggers the error. import os TODO_FILE = r"E:\javi\code\Python\todo-list\src\todo.txt" def del_elems(f, delete): """Takes an open file and either a number or a list of numbers, and deletes the lines corresponding to those numbers (counting from 1).""" if isinstance(delete, int): delete = [delete] lines = f.readlines() f.truncate(0) counter = 1 for line in lines: if counter not in delete: f.write(line) counter += 1 f = open(TODO_FILE, "r+") del_elems(f, 3) f.close() Could you please point out where's the mistake?

    Read the article

  • Manually Writing the HTML in TWebBrowser Pt. 2

    - by nomad311
    As the name suggests this is a continuation (sort of) of http://stackoverflow.com/questions/2784679/manually-writing-the-html-in-twebbrowser This time around I'm trying to add some auto-refresh logic to the HTML I get. I have pieced together an approach from several sources (see below). In short, I am trying to locate the title node and add a meta node after it (in the HTML head node). But, I get an access violation. Here is the source: iHtmlDoc := IHTMLDocument3(WebBrowser1.Document); iHtmlEleTitle := IHTMLElement2(iHtmlDoc.getElementsByName('title').item(0, 0)); iHtmlEle := IHTMLElement2(IHTMLDocument2(iHtmlDoc).createElement(Format('<meta http-equiv="refresh" content="%d">', [1]))); iHtmlEleTitle.insertAdjacentElement('afterEnd', IHTMLElement(iHtmlEle)); And A (technically not functionally) different way of doing it ...casting is slightly different here: IHTMLElement2(IHtmlDocument3(WebBrowser1.Document).getElementsByName('title').item(0, 0)).insertAdjacentElement('afterEnd', IHTMLDocument2(WebBrowser1.Document).createElement(Format('<meta http-equiv="refresh" content="%d">', [VPI_ISSUANCE_AUTO_RELOAD]))); Again all I get from Delphi is a access exception, and I fished through MSDN documentation on it, but now I'm hoping someone out there has gone through the same and has some insight. Any help? Sources (I think this is all of them): http://webdesign.about.com/od/metataglibraries/a/aa080300a.htm (auto-reload) http://delphi.about.com/od/adptips2005/qt/webbrowserhtml.htm (web browser document as an HTML document) http://msdn.microsoft.com/en-us/library/system.windows.forms.htmlelement.insertadjacentelement(VS.80).aspx (GetElementsByName) http://www.experts-exchange.com/Web_Development/Components/ActiveX/Q_26131034.html (insertAdjacentElement) http://www.experts-exchange.com/Programming/Languages/Pascal/Delphi/Q_23407977.html (GetElementsByName)

    Read the article

  • Require help in Writing Query

    - by harigm
    The following image have been uploaded to show what I am trying to do and what I wanted out of it Can any one help me write the Query to get the results what I want Please check the following SELECT * FROM KPT WHERE PROPERTY_ID IN (SELECT PROPERTY_ID FROM khata_header WHERE DIV_ID = 3 and RECORD_STATUS = 0) and CHALLAN_NO > 42646 The above is the query I have written and I have got the following result set ID CHALLAN_NO PROPERTY_ID SITE_NO TOTAL_AMOUNT ----- ------------- -------------- ------------------- --------------- 1242 42757 3103010141 296 595 1243 63743 3204190257 483 594 1244 63743 3204190257 483 594 1334 43395 3217010223 1088 576 1421 524210 3320050416 (null) (null) 1422 524210 3320050416 (null) (null) 1560 564355 3320021408 (null) (null) 1870 516292 3320040420 (null) (null) 1940 68357 3217100104 139 1153 1941 68357 3217100104 139 1153 2002 56256 3320100733 511 4430 2003 56256 3320100733 511 4430 2004 66488 3217040869 293 3094 2005 66488 3217040869 293 3094 2016 64571 3217040374 (null) (null) 2036 523122 3320020352 (null) (null) 2039 65682 3217040021 273 919 In my resultset, I am getting the PropertyId repeated, since there are multilple entries, How Can I know How many have been repeated What are those Property Id which have repeated more than 2 times. Little Back ground about the tables are PROPERTY_ID is the FK in the KPT PROPERTY_ID is the PK in KH I am writing a subquery to get the Result, so I am stuck I dont know how to get my results Please help

    Read the article

  • how to use "tab space" while writing in text file

    - by Manu
    SimpleDateFormat formatter = new SimpleDateFormat("ddMMyyyy_HHmmSS"); String strCurrDate = formatter.format(new java.util.Date()); String strfileNm = "Cust_Advice_" + strCurrDate + ".txt"; String strFileGenLoc = strFileLocation + "/" + strfileNm; String strQuery="select name, age, data from basetable; try { stmt = conn.createStatement(); System.out.println("Query is -> " + strQuery); rs = stmt.executeQuery(strQuery); File f = new File(strFileGenLoc); OutputStream os = (OutputStream)new FileOutputStream(f); String encoding = "UTF8"; OutputStreamWriter osw = new OutputStreamWriter(os, encoding); BufferedWriter bw = new BufferedWriter(osw); while (rs.next() ) { bw.write(rs.getString(1)==null? "":rs.getString(1)); bw.write(" "); bw.write(rs.getString(2)==null? "":rs.getString(2)); bw.write(" "); } bw.flush(); bw.close(); } catch (Exception e) { System.out.println( "Exception occured while getting resultset by the query"); e.printStackTrace(); } finally { try { if (conn != null) { System.out.println("Closing the connection" + conn); conn.close(); } } catch (SQLException e) { System.out.println( "Exception occured while closing the connection"); e.printStackTrace(); } } return objArrayListValue; } i need "one tab space" in between each column(while writing to text file). like manu 25 data1 manc 35 data3 in my code i use bw.write(" ") for creating space between each column. how to use "one tab space" in that place instead of giving "space".

    Read the article

  • Writing language converter in ANTLR

    - by Stefan
    I'm writing a converter between some dialects of the same programming language. I've found a grammar on the net - it's complex and handles all the cases. Now I'm trying to write the appropriate actions. Most of the input is just going to be rewritten to output. What I need to do is parse function calls, do my magic (rename function, reorder arguments, etc) and write it. I'm using AST as output. When I come across a function call, I build a custom object structure (from classes defined in my target language), call the appropriate function and I have a string that represents the transformed function that I want to get. The problem is, what I'm supposed to do with that string? I'd like to replace the .text attribute of the enclosing rule, but setText() is only available on lexer rules and the rule's .text attribute is read-only. How to solve this problem? program : statement_list { output = $statement_list.text; } ; //... statement : expression_statement // ... ; expression_statement : function_call // ... ; function_call : ID '(' { /* build the object, assign name */ Function function = new Function(); //... } ( arg1 = expression { /* add first parameter */ } ( ',' arg2 = expression { /* add the rest of parameters */ } )* )? ')' { /* convert the function call */ string converted = Tools.Convert(function); // $setText(converted); // doesn't work // $functionCall.text = converted; // doesn't work } ;

    Read the article

  • Hadoop/MapReduce: Reading and writing classes generated from DDL

    - by Dave
    Hi, Can someone walk me though the basic work-flow of reading and writing data with classes generated from DDL? I have defined some struct-like records using DDL. For example: class Customer { ustring FirstName; ustring LastName; ustring CardNo; long LastPurchase; } I've compiled this to get a Customer class and included it into my project. I can easily see how to use this as input and output for mappers and reducers (the generated class implements Writable), but not how to read and write it to file. The JavaDoc for the org.apache.hadoop.record package talks about serializing these records in Binary, CSV or XML format. How do I actually do that? Say my reducer produces IntWritable keys and Customer values. What OutputFormat do I use to write the result in CSV format? What InputFormat would I use to read the resulting files in later, if I wanted to perform analysis over them?

    Read the article

  • Writing good tests for Django applications

    - by Ludwik Trammer
    I've never written any tests in my life, but I'd like to start writing tests for my Django projects. I've read some articles about tests and decided to try to write some tests for an extremely simple Django app or a start. The app has two views (a list view, and a detail view) and a model with four fields: class News(models.Model): title = models.CharField(max_length=250) content = models.TextField() pub_date = models.DateTimeField(default=datetime.datetime.now) slug = models.SlugField(unique=True) I would like to show you my tests.py file and ask: Does it make sense? Am I even testing for the right things? Are there best practices I'm not following, and you could point me to? my tests.py (it contains 11 tests): # -*- coding: utf-8 -*- from django.test import TestCase from django.test.client import Client from django.core.urlresolvers import reverse import datetime from someproject.myapp.models import News class viewTest(TestCase): def setUp(self): self.test_title = u'Test title: bareksc' self.test_content = u'This is a content 156' self.test_slug = u'test-title-bareksc' self.test_pub_date = datetime.datetime.today() self.test_item = News.objects.create( title=self.test_title, content=self.test_content, slug=self.test_slug, pub_date=self.test_pub_date, ) client = Client() self.response_detail = client.get(self.test_item.get_absolute_url()) self.response_index = client.get(reverse('the-list-view')) def test_detail_status_code(self): """ HTTP status code for the detail view """ self.failUnlessEqual(self.response_detail.status_code, 200) def test_list_status_code(self): """ HTTP status code for the list view """ self.failUnlessEqual(self.response_index.status_code, 200) def test_list_numer_of_items(self): self.failUnlessEqual(len(self.response_index.context['object_list']), 1) def test_detail_title(self): self.failUnlessEqual(self.response_detail.context['object'].title, self.test_title) def test_list_title(self): self.failUnlessEqual(self.response_index.context['object_list'][0].title, self.test_title) def test_detail_content(self): self.failUnlessEqual(self.response_detail.context['object'].content, self.test_content) def test_list_content(self): self.failUnlessEqual(self.response_index.context['object_list'][0].content, self.test_content) def test_detail_slug(self): self.failUnlessEqual(self.response_detail.context['object'].slug, self.test_slug) def test_list_slug(self): self.failUnlessEqual(self.response_index.context['object_list'][0].slug, self.test_slug) def test_detail_template(self): self.assertContains(self.response_detail, self.test_title) self.assertContains(self.response_detail, self.test_content) def test_list_template(self): self.assertContains(self.response_index, self.test_title)

    Read the article

  • Writing a VM - well formed bytecode?

    - by David Titarenco
    Hi, I'm writing a virtual machine in C just for fun. Lame, I know, but luckily I'm on SO so hopefully no one will make fun :) I wrote a really quick'n'dirty VM that reads lines of (my own) ASM and does stuff. Right now, I only have 3 instructions: add, jmp, end. All is well and it's actually pretty cool being able to feed lines (doing it something like write_line(&prog[1], "jmp", regA, regB, 0); and then running the program: while (machine.code_pointer <= BOUNDS && DONE != true) { run_line(&prog[machine.cp]); } I'm using an opcode lookup table (which may not be efficient but it's elegant) in C and everything seems to be working OK. My question is more of a "best practices" question but I do think there's a correct answer to it. I'm making the VM able to read binary files (storing bytes in unsigned char[]) and execute bytecode. My question is: is it the VM's job to make sure the bytecode is well formed or is it just the compiler's job to make sure the binary file it spits out is well formed? I only ask this because what would happen if someone would edit a binary file and screw stuff up (delete arbitrary parts of it, etc). Clearly, the program would be buggy and probably not functional. Is this even the VM's problem? I'm sure that people much smarter than me have figured out solutions to these problems, I'm just curious what they are!

    Read the article

  • Reading/Writing DataTables to and from an OleDb Database LINQ

    - by jsmith
    My current project is to take information from an OleDbDatabase and .CSV files and place it all into a larger OleDbDatabase. I have currently read in all the information I need from both .CSV files, and the OleDbDatabase into DataTables.... Where it is getting hairy is writing all of the information back to another OleDbDatabase. Right now my current method is to do something like this: OleDbTransaction myTransaction = null; try { OleDbConnection conn = new OleDbConnection("PROVIDER=Microsoft.Jet.OLEDB.4.0;" + "Data Source=" + Database); conn.Open(); OleDbCommand command = conn.CreateCommand(); string strSQL; command.Transaction = myTransaction; strSQL = "Insert into TABLE " + "(FirstName, LastName) values ('" + FirstName + "', '" + LastName + "')"; command.CommandType = CommandType.Text; command.CommandText = strSQL; command.ExecuteNonQuery(); conn.close(); catch (Exception) { // IF invalid data is entered, rolls back the database myTransaction.Rollback(); } Of course, this is very basic and I'm using an SQL command to commit my transactions to a connection. My problem is I could do this, but I have about 200 fields that need inserted over several tables. I'm willing to do the leg work if that's the only way to go. But I feel like there is an easier method. Is there anything in LINQ that could help me out with this?

    Read the article

  • Intermittent Issue Writing to Google Appengine Datastore

    - by user242153
    Hi, I have a functioning app and recently have had intermittent problems writing to the datastore. I did not make any relevant code changes, however in the last few days my attempts to write to the datastore sometimes work and sometimes don't. I am trying to save an object that is in a many to one relationship with an existing persisted parent. So, the logic works like this: 1) Parent pulled from the datastore 2) Child created / instantiated using constructor 3) Parent.addSingleChild(child); // the "addSingleChild" method just adds the object argument to the collection of children 4) child.setParent(Parent); // sets the Parent object to the parent field I am using transactions as explained in the documentation ending with "finally {if (tx.isActive()) {tx.rollback(); } }" When the servlet is called, the parent is called from the datastore and the child object is created and added to the many to one mapping to the pre-existing parent. The child should automatically be persisted, since the parent is already persistent, and the child is added to the collection of children that map to the parent. And it worked this way in the past. However, to be sure, i did add a pm.makePersistent(child). Doesn't seem to help, still have the intermittent problem. Any suggestions would be appreciated, and if you need to see the actual code I can post. Thanks

    Read the article

< Previous Page | 25 26 27 28 29 30 31 32 33 34 35 36  | Next Page >