Search Results

Search found 950 results on 38 pages for 'st woland'.

Page 32/38 | < Previous Page | 28 29 30 31 32 33 34 35 36 37 38  | Next Page >

  • How do I use XML Builder to create xml in rails?

    - by Angela
    I am trying the following, but the output XML is badly formed: def submit xml = Builder::XmlMarkup.new xml.instruct! xml.mail xml.documents xml.document xml.template xml.source "gallery" xml.name "Postcard: Image fill front" @xml_display = xml end I need it to look more like this: <?xml version="1.0" encoding="UTF-8"?> <mail> <documents> <document> <template> <source>gallery</source> <name>Postcard: Image fill front</name> </template> <sections> <section> <name>Text</name> <text>Hello, World!</text> </section> <section> <name>Image</name> <attachment>...attachment id...</attachment> </section> </sections> </document> </documents> <addressees> <addressee> <name>John Doe</name> <address>123 Main St</address> <city>Anytown</city> <state>AZ</state> <postal-code>10000</postal-code> </addressee> </addressees> </mail>

    Read the article

  • Displaying emails in a JTable (Java Swing)

    - by Paul
    Hi I'm new to all this. I have been trying to display fetched emails in a JTable using the JavaMail add-on. However when I ask the program to set the value it never does. I have been working in NetBeans if that is any help? the fetchMail class finds all may on a server. The gui class is used to display all emails in a table as well as creating mail. You will probably think that I have tried it like a bull in a china shop, I am new to Java and trying to give myself a challenge. Any help/advice would be greatly appreciated fetchMail: package mail; import java.util.; import java.io.; import java.text.DateFormat; import java.text.SimpleDateFormat; import javax.mail.; import javax.mail.internet.; import javax.mail.search.; import javax.activation.; public class fetchMail { public void fetch(String username, String pass, String search){ MessagesTableModel tableModel = new MessagesTableModel(); String complete; DateFormat df = new SimpleDateFormat("dd/MM/yyyy"); gui gui = new gui(); // SUBSTITUTE YOUR ISP's POP3 SERVER HERE!!! String host = "imap.gmail.com"; // SUBSTITUTE YOUR USERNAME AND PASSWORD TO ACCESS E-MAIL HERE!!! String user = username; String password = pass; // SUBSTITUTE YOUR SUBJECT SUBSTRING TO SEARCH HERE!!! String subjectSubstringToSearch = search; // Get a session. Use a blank Properties object. Session session = Session.getInstance(new Properties()); Properties props = System.getProperties(); props.setProperty("mail.store.protocol", "imaps"); props.setProperty("mail.imap.socketFactory.class", "javax.net.ssl.SSLSocketFactory"); props.setProperty("mail.imap.socketFactory.fallback", "false"); try { // Get a Store object Store store = session.getStore("imaps"); store.connect(host, user, password); // Get "INBOX" Folder fldr = store.getFolder("INBOX"); fldr.open(Folder.READ_WRITE); int count = fldr.getMessageCount(); System.out.println(count + " total messages"); // Message numebers start at 1 for(int i = 1; i <= count; i++) { // Get a message by its sequence number Message m = fldr.getMessage(i); // Get some headers Date date = m.getSentDate(); int pos = i - 1; String d = df.format(date); Address [] from = m.getFrom(); String subj = m.getSubject(); String mimeType = m.getContentType(); complete = date + "\t" + from[0] + "\t" + subj + "\t" + mimeType; //tableModel.setMessages(m); gui.setDate(d, pos); // System.out.println(d + " " + i); } // Search for e-mails by some subject substring String pattern = subjectSubstringToSearch; SubjectTerm st = new SubjectTerm(pattern); // Get some message references Message [] found = fldr.search(st); System.out.println(found.length + " messages matched Subject pattern \"" + pattern + "\""); for (int i = 0; i < found.length; i++) { Message m = found[i]; // Get some headers Date date = m.getSentDate(); Address [] from = m.getFrom(); String subj = m.getSubject(); String mimeType = m.getContentType(); //System.out.println(date + "\t" + from[0] + "\t" + // subj + "\t" + mimeType); Object o = m.getContent(); if (o instanceof String) { // System.out.println("**This is a String Message**"); // System.out.println((String)o); } else if (o instanceof Multipart) { // System.out.print("**This is a Multipart Message. "); Multipart mp = (Multipart)o; int count3 = mp.getCount(); // System.out.println("It has " + count3 + // " BodyParts in it**"); for (int j = 0; j < count3; j++) { // Part are numbered starting at 0 BodyPart b = mp.getBodyPart(j); String mimeType2 = b.getContentType(); // System.out.println( "BodyPart " + (j + 1) + // " is of MimeType " + mimeType); Object o2 = b.getContent(); if (o2 instanceof String) { // System.out.println("**This is a String BodyPart**"); // System.out.println((String)o2); } else if (o2 instanceof Multipart) { // System.out.print( // "**This BodyPart is a nested Multipart. "); Multipart mp2 = (Multipart)o2; int count2 = mp2.getCount(); // System.out.println("It has " + count2 + // "further BodyParts in it**"); } else if (o2 instanceof InputStream) { // System.out.println( // "**This is an InputStream BodyPart**"); } } //End of for } else if (o instanceof InputStream) { // System.out.println("**This is an InputStream message**"); InputStream is = (InputStream)o; // Assumes character content (not binary images) int c; while ((c = is.read()) != -1) { // System.out.write(c); } } // Uncomment to set "delete" flag on the message //m.setFlag(Flags.Flag.DELETED,true); } //End of for // "true" actually deletes flagged messages from folder fldr.close(true); store.close(); } catch (MessagingException mex) { // Prints all nested (chained) exceptions as well mex.printStackTrace(); } catch (IOException ioex) { ioex.printStackTrace(); } } } gui: /* * gui.java * * Created on 13-May-2010, 18:29:30 */ package mail; import java.text.DateFormat; import java.text.FieldPosition; import java.text.ParsePosition; import java.text.SimpleDateFormat; import java.util.Date; import java.util.Vector; import javax.mail.Address; import javax.swing.JScrollPane; import javax.swing.JTable; import javax.swing.ListSelectionModel; import javax.swing.event.ListSelectionEvent; import javax.swing.event.ListSelectionListener; import javax.swing.event.TableModelListener; import javax.swing.table.DefaultTableModel; import javax.swing.table.TableModel; public class gui extends javax.swing.JFrame { private MessagesTableModel tableModel; // Table listing messages. private JTable table; String date; /** Creates new form gui */ public gui() { initComponents(); } @SuppressWarnings("unchecked") private void initComponents() { recieve = new javax.swing.JButton(); jButton1 = new javax.swing.JButton(); jScrollPane1 = new javax.swing.JScrollPane(); inboxTable = new javax.swing.JTable(); setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); recieve.setText("Receve"); recieve.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { recieveActionPerformed(evt); } }); jButton1.setText("new"); jButton1.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jButton1ActionPerformed(evt); } }); inboxTable.setModel(new javax.swing.table.DefaultTableModel( new Object [][] { {null, null, null}, {null, null, null}, {null, null, null}, {null, null, null} }, new String [] { "Date", "subject", "sender" } ) { Class[] types = new Class [] { java.lang.String.class, java.lang.String.class, java.lang.String.class }; public Class getColumnClass(int columnIndex) { return types [columnIndex]; } }); jScrollPane1.setViewportView(inboxTable); inboxTable.getColumnModel().getColumn(0).setResizable(false); inboxTable.getColumnModel().getColumn(1).setResizable(false); inboxTable.getColumnModel().getColumn(2).setResizable(false); javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); getContentPane().setLayout(layout); layout.setHorizontalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addGap(39, 39, 39) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 558, javax.swing.GroupLayout.PREFERRED_SIZE) .addGroup(layout.createSequentialGroup() .addComponent(recieve) .addGap(18, 18, 18) .addComponent(jButton1, javax.swing.GroupLayout.PREFERRED_SIZE, 75, javax.swing.GroupLayout.PREFERRED_SIZE))) .addGap(73, 73, 73)) ); layout.setVerticalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addGap(31, 31, 31) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(recieve) .addComponent(jButton1)) .addGap(18, 18, 18) .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 258, javax.swing.GroupLayout.PREFERRED_SIZE) .addContainerGap(179, Short.MAX_VALUE)) ); pack(); }// </editor-fold> private void recieveActionPerformed(java.awt.event.ActionEvent evt) { fetchMail fetch = new fetchMail(); fetch.fetch(email goes here, password goes here, search goes here); } private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) { createMail create = new createMail(); centerW center = new centerW(); //create.attVis(); center.center(create); create.setVisible(true); } public void setDate(String Date, int pos){ //pos = pos + 1; String [] s = new String [5]; s[pos] = Date; inboxTable.setValueAt(Date, pos, 0); } public String getDate(){ return date; } /** * @param args the command line arguments */ public static void main(String args[]) { java.awt.EventQueue.invokeLater(new Runnable() { public void run() { new gui().setVisible(true); } }); } // Variables declaration - do not modify private javax.swing.JTable inboxTable; private javax.swing.JButton jButton1; private javax.swing.JScrollPane jScrollPane1; private javax.swing.JButton recieve; // End of variables declaration }

    Read the article

  • Exclude specific value from a Min/Max agregate funcion using ICriteria.

    - by sparks
    I have a schedule (Voyages) table like this: ID Arrival Departure OrderIndex 1 01/01/1753 02/10/2009 0 1 02/11/2009 02/15/2009 1 1 02/16/2009 02/19/2009 2 1 02/21/2009 01/01/1753 3 2 01/01/1753 03/01/2009 0 2 03/04/2009 03/07/2009 1 2 03/09/2009 01/01/1753 2 By design i save '01/01/1753' as a default value if the user doesn't fill a the field on the capture screen and for the very first Arrival and the very last Departure which are never provided. Im using Nhibernate and Criteria, and im wondering whats the best way to query this data if i want to know the First departure and last arrival for each voyage in the table. My first thought was a groupby (ID) and then do some Min and Max with the arrival and departure but the `'01/01/1753' VALUE is messing aronud. ... .SetProjection(Projections.ProjectionList() .Add(Projections.GroupProperty("ID"), "ID") .Add(Projections.Min("DepartureDate"), "DepartureDate") .Add(Projections.Max("ArrivalDate"), "ArrivalDate") ) ... So is there a way to skip this value in the Min function comparison (without losing the whole row of data), or there is a better way to do this, maybe utilizing the OrderIndex that always indicate the correct order of the elements, maybe ordering ASC taking the 1st and then Order DESC and taking the 1 st again, but im not quite sure how to do that with criteria syntax.

    Read the article

  • Why does one of these statements compile in Scala but not the other?

    - by Jeff
    (Note: I'm using Scala 2.7.7 here, not 2.8). I'm doing something pretty simple -- creating a map based on the values in a simple, 2-column CSV file -- and I've completed it easily enough, but I'm perplexed at why my first attempt didn't compile. Here's the code: // Returns Iterator[String] private def getLines = Source.fromFile(csvFilePath).getLines // This doesn't compile: def mapping: Map[String,String] = { Map(getLines map { line: String => val pairArr = line.split(",") pairArr(0) -> pairArr(1).trim() }.toList:_*) } // This DOES compile def mapping: Map[String,String] = { def strPair(line: String): (String,String) = { val pairArr = line.split(",") pairArr(0) -> pairArr(1).trim() } Map(getLines.map( strPair(_) ).toList:_*) } The compiler error is CsvReader.scala:16: error: value toList is not a member of (St ring) = (java.lang.String, java.lang.String) [scalac] possible cause: maybe a semicolon is missing before `value toList'? [scalac] }.toList:_*) [scalac] ^ [scalac] one error found So what gives? They seem like they should be equivalent to me, apart from the explicit function definition (vs. anonymous in the nonworking example) and () vs. {}. If I replace the curly braces with parentheses in the nonworking example, the error is "';' expected, but 'val' found." But if I remove the local variable definition and split the string twice AND use parens instead of curly braces, it compiles. Can someone explain this difference to me, preferably with a link to Scala docs explaining the difference between parens and curly braces when used to surround method arguments?

    Read the article

  • Parsing Strings ( .crt files )

    - by user1661521
    Base Knowledge : I have a .crt file ( certification authoritie file ) and he is composed of many fields but in one line that resumes this question i have this : Certificate: ...(alot of stuff before)... Subject: C=US, ST=Maryland, L=Pasadena, O=Brent Baccala, OU=FreeSoft, CN=www.freesoft.org/[email protected] Subject Public Key Info: ...(alot of stuff after) and i need to parse the file to populate a .csv file and i have that done the problem that i need help is, i need to get the field: CN=www.fresoft.org but when i get this kind of CN=...(Value instead of the ...) with alot of slashes i get a error in the parsing like the raw string is: CN=foo/bar/the/hell/emailAddress=blablabla and i need only: foo/bar/the/hell and for a moment i got that in the correct column but when i dont have the emailAddress something just fail in my parsing and i then get in my CN .csv column the information wrong instead of |CN| foo/bar/the/hell i get: |CN| OU=FreeSoft, foo/bar/the/hell. I have this code doing the CN parsing: #!/bin/bash subject_line=$(echo $cert | grep -o "Subject:.*Subject Public Key Info") cn=$(echo $subject_line | grep -o "CN=.*" ) if [ $(echo $cn | grep -c ".*email.*") -gt 0 ]; then end_cn=$(echo $cn | grep -b -o emailAddress) end_cn_idx=$(echo $end_cn | grep -o .*:) final_end_cn=${end_cn_idx:0:-1} common_name=${cn:3:$final_end_cn-4} echo $common_name else end_cn=$(echo $cn | grep -b -o "Subject Public Key Info") end_cn_idx=$(echo $end_cn | grep -o .*:) final_end_cn=${end_cn_idx:0:-1} common_name=${cn:3:$final_end_cn-5} echo $common_name fi

    Read the article

  • PAYPAL IPN Response Problem

    - by Gorkem Tolan
    I am having a problem with Paypal IPN response. After payment is made by the customer, paypal ipn returns this url www.mywebsite.com?orderid=32&tx=2AC67201DL3533325&st=Pending&amt=2.50&cc=USD&cm=&item_number=32 There are a couple of issues 1- Postback field names are undefined or missing. Thus I can get the INVALID message. I am not sure if my website does not read POST variables. When I looked at IPN history, it shows that each IPN has been sent with the complete url. 2- Payment status keeps coming Pending. Does this issue cause the first issue? Thank you for your responses in advance. Here is the code: Dim strSandbox As String, strLive As String Dim req As HttpWebRequest strSandbox = "http://www.sandbox.paypal.com/cgi-bin/webscr/" strLive = "https://www.paypal.com/cgi-bin/webscr" req = CType(WebRequest.Create(strSandbox), HttpWebRequest) 'Set values for the request back req.Method = "POST" req.ContentType = "application/x-www-form-urlencoded" Dim param() As Byte param = Request.BinaryRead(HttpContext.Current.Request.ContentLength) Dim strRequest As String strRequest = Encoding.ASCII.GetString(param) strRequest = strRequest & "&cmd=_notify-validate" req.ContentLength = strRequest.Length 'Response.Write(strRequest) 'Send the request to PayPal and get the response Dim streamOut As StreamWriter streamOut = New StreamWriter(req.GetRequestStream(), System.Text.Encoding.ASCII) streamOut.Write(strRequest) streamOut.Close() Dim streamIn As StreamReader streamIn = New StreamReader(req.GetResponse().GetResponseStream()) Dim strResponse As String strResponse = streamIn.ReadToEnd() Response.Write(strResponse) streamIn.Close() If (strResponse = "VERIFIED") Then Response.Redirect("thankyou.aspx") ElseIf (strResponse = "INVALID") Then End If

    Read the article

  • NHibernate listener/event to replace object before insert/update

    - by vIceBerg
    Hi! I have a Company class which have a collection of Address. Here's my Address class:(written top of my head): public class Address { public string Civic; public string Street; public City City; } This is the City class: public class City { public int Id; public string Name; public string SearchableName{ get { //code } } } Address is persisted in his own table and have a reference to the city's ID. City are also persisted in is own table. The City's SearchableName is used to prevent some mistakes in the city the user type. For example, if the city name is "Montréal", the searchable name will be "montreal". If the city name is "St. John", the searchable name will be "stjohn", etc. It's used mainly to to search and to prevent having multiple cities with a typo in it. When I save an address, I want an listener/event to check if the city is already in the database. If so, cancel the insert and replace the user's city with the database one. I would like the same behavior with updates. I tried this: public bool OnPreInsert(PreInsertEvent @event) { City entity = (@event.Entity as City); if (entity != null) { if (entity.Id == 0) { var city = (from c in @event.Session.Linq<City>() where c.SearchableName == entity.SearchableName select c).SingleOrDefault(); if (city != null) { //don't know what to do here return true; } } } return false; } But if there's already a City in the database, I don't know what to do. @event.Entity is readonly, if I set @event.Entity.Id, I get an "null identifier" exception. I tried to trap insert/update on Address and on Company, but the City if the first one to get inserted (it's logic...) Any thoughts? Thanks

    Read the article

  • Ruby : UTF-8 IO

    - by subtenante
    I use ruby 1.8.7. I try to parse some text files containing greek sentences, encoded in UTF-8. (I can't much paste here sample files, because they are subject to copyright. Really just some greek text encoded in UTF-8.) I want, for each file, to parse the file, extract all the words, and make a list of each new word found in this file. All that saved to one big index file. Here is my code : #!/usr/bin/ruby -KU def prepare_line(l) l.gsub(/^\s*[ST]\d+\s*:\s*|\s+$|\(\d+\)\s*/u, "") end def tokenize(l) l.split /['·.;!:\s]+/u end $dict = {} $cpt = 0 $out = File.new 'out.txt', 'w' def lesson(file) $cpt = $cpt + 1 file.readlines.each do |l| $out.puts l l = prepare_line l tokenize(l).each do |t| unless $dict[t] $dict[t] = $cpt $out.puts " #{t}\n" end end end end Dir.new('etc/').each do |filename| f = File.new("etc/#{filename}") unless File.directory? f lesson f end end Here is part of my output : ?@???†?†?????????? ?...[snip very long hangul/hanzi mishmash]... ????????†? ???N2 : ?e?te?? (2) µ???µa (Note that the puts l part seems to work fine, at the end of the given output line.) Any idea what is wrong with my code ? (General comments about ruby idioms I could use are very welcome, I'm really a beginner.)

    Read the article

  • Deobfuscating Javascript

    - by David Murdoch
    What is this monstrosity? Anyone know of a way to make it readable? <script type="text/javascript"> //<![CDATA[ <!-- var x="function f(x){var i,o=\"\",l=x.length;for(i=0;i<l;i+=2) {if(i+1<l)o+=" + "x.charAt(i+1);try{o+=x.charAt(i);}catch(e){}}return o;}f(\"ufcnitnof x({)av" + " r,i=o\\\"\\\"o,=l.xelgnhtl,o=;lhwli(e.xhcraoCedtAl(1/)3=!76{)rt{y+xx=l;=+;" + "lc}tahce({)}}of(r=i-l;1>i0=i;--{)+ox=c.ahAr(t)i};erutnro s.buts(r,0lo;)f}\\" + "\"(0),9\\\"\\\\$.;(.34U03\\\\\\\\16\\\\0E\\\\NSCZhC24\\\\03\\\\01\\\\\\\\St" + "DEMPbM02\\\\0C\\\\x#opms58aJ}qb<jb7`17\\\\\\\\hc7s17\\\\\\\\rzEeljdp7m03\\\\"+ "\\\\36\\\\0F\\\\24\\\\06\\\\01\\\\\\\\25\\\\01\\\\02\\\\\\\\26\\\\03\\\\03\\"+ "\\\\\\(W4N02\\\\\\\\24\\\\02\\\\00\\\\\\\\07\\\\0N\\\\14\\\\0P\\\\BI07\\\\0" + "4\\\\00\\\\\\\\02\\\\02\\\\02\\\\\\\\14\\\\06\\\\02\\\\\\\\24\\\\0L\\\\25\\" + "\\06\\\\01\\\\\\\\3:?(>4\\\"\\\\f(;} ornture;}))++(y)^(iAtdeCoarchx.e(odrCh" + "amCro.fngriSt+=;o27=1y%i;+=)y90==(iif){++;i<l;i=0(ior;fthnglex.l=\\\\,\\\\\\"+ "\"=\\\",o iar{vy)x,f(n ioctun\\\"f)\")" ; while(x=eval(x)); //--> //]]> </script>

    Read the article

  • What makes people think that NNs have more computational power than existing models?

    - by Bubba88
    I've read in Wikipedia that neural-network functions defined on a field of arbitrary real/rational numbers (along with algorithmic schemas, and the speculative `transrecursive' models) have more computational power than the computers we use today. Of course it was a page of russian wikipedia (ru.wikipedia.org) and that may be not properly proven, but that's not the only source of such.. rumors Now, the thing that I really do not understand is: How can a string-rewriting machine (NNs are exactly string-rewriting machines just as Turing machines are; only programming language is different) be more powerful than a universally capable U-machine? Yes, the descriptive instrument is really different, but the fact is that any function of such class can be (easily or not) turned to be a legal Turing-machine. Am I wrong? Do I miss something important? What is the cause of people saying that? I do know that the fenomenum of undecidability is widely accepted today (though not consistently proven according to what I've read), but I do not really see a smallest chance of NNs being able to solve that particular problem. Add-in: Not consistently proven according to what I've read - I meant that you might want to take a look at A. Zenkin's (russian mathematician) papers after mid-90-s where he persuasively postulates the wrongness of G. Cantor's concepts, including transfinite sets, uncountable sets, diagonalization method (method used in the proof of undecidability by Turing) and maybe others. Even Goedel's incompletness theorems were proven in right way in only 21-st century.. That's all just to plug Zenkin's work to the post cause I don't know how widespread that knowledge is in CS community so forgive me if that did look stupid. Thank you!

    Read the article

  • How can I set the name of the class xml by constructor?

    - by spderosso
    Hi, I want to be able to do something like this: @Root(name="events") class XMLEvents { @ElementList(inline=true) ArrayList<XMLEvent> events = Lists.newArrayList(); XMLEvents(){ ... events.add(new XMLEvent(time, type, professorP)); events.add(new XMLEvent(time, type, student)); events.add(new XMLEvent(time, type, course)); ... } } The XMLEvent class to go something like: class XMLEvent { @Root(name="professor") XMLEvent(DateTime time, LogType type, Professor p){ ... } @Root(name="student") XMLEvent(DateTime time, LogType type, Student st){ ... } @Root(name="course") XMLEvent(DateTime time, LogType type, Course c){ ... } } For the output to be: <events> <professor> ... </professor> <student> ... </student> <course> ... </course> </events> So depending on the constructor I call to create a new XMLEvent the root name to which is mapped is different. Is this even possible? Of course the past example was just to transmit what I need. Putting the @Root annotation there didn't change anything Thanks!

    Read the article

  • capturing CMD batch file parameter list; write to file for later processing

    - by BobB
    I have written a batch file that is launched as a post processing utility by a program. The batch file reads ~24 parameters supplied by the calling program, stores them into variables, and then writes them to various text files. Since the max input variable in CMD is %9, it's necessary to use the 'shift' command to repeatedly read and store these individually to named variables. Because the program outputs several similar batch files, the result is opening several CMD windows sequentially, assigning variables and writing data files. This ties up the calling program for too long. It occurs to me that I could free up the calling program much faster if maybe there's a way to write a very simple batch file that can write all the command parameters to a text file, where I can process them later. Basically, just grab the parameter list, write it and done. Q: Is there some way to treat an entire series of parameter data as one big text string and write it to one big variable... and then echo the whole big thing to one text file? Then later read the string into %n variables when there's no program waiting to resume? Parameter list is something like 25 - 30 words, less than 200 characters. Sample parameter list: "First Name" "Lastname" "123 Steet Name Way" "Cityname" ST 12345 1004968 06/01/2010 "Firstname+Lastname" 101738 "On Account" 20.67 xy-1z 1 8.95 3.00 1.39 0 0 239 8.95 Items in quotes are processed as string variables. List is space delimited. Any suggestions?

    Read the article

  • What is the right pattern for a async data fetching method in .net async/await

    - by s093294
    Given a class with a method GetData. A few other clients call GetData, and instead of it fetching data each time, i would like to create a pattern where the first call starts the task to get the data, and the rest of the calls wait for the task to complete. private Task<string> _data; private async Task<string> _getdata() { return "my random data from the net"; //get_data_from_net() } public string GetData() { if(_data==null) _data=_getdata(); _data.wait(); //are there not a problem here. cant wait a task that is already completed ? if(_data.status != rantocompletion) _data.wait() is not any better, it might complete between the check and the _data.wait? return _data.Result; } How would i do the pattern correctly? (Solution) private static object _servertime_lock = new object(); private static Task<string> _servertime; private static async Task<string> servertime() { try { var thetvdb = new HttpClient(); thetvdb.Timeout = TimeSpan.FromSeconds(5); // var st = await thetvdb.GetStreamAsync("http://www.thetvdb.com/api/Updates.php?type=none"); var response = await thetvdb.GetAsync("http://www.thetvdb.com/api/Updates.php?type=none"); response.EnsureSuccessStatusCode(); Stream stream = await response.Content.ReadAsStreamAsync(); XDocument xdoc = XDocument.Load(stream); return xdoc.Descendants("Time").First().Value; } catch { return null; } } public static async Task<string> GetServerTime() { lock (_servertime_lock) { if (_servertime == null) _servertime = servertime(); } var time = await _servertime; if (time == null) _servertime = null; return time; }

    Read the article

  • What are the attributes that are need to Send with this FEDEX shipping script?

    - by Fero
    could any one please tell me what are the attributes that are send with $ship_data ? I am too confused about it. I know that ORIGIN ADDRESS, DESTINATION ADDRESS, NAME etc.. need to be send. But how the data should be aligned. Like name is FIRST, address is SECOND etc... Any help will be useful ** // create new fedex object $fed = new FedExDC('#########','#########'); $ship_data = array( 75= 'LBS', 16= 'Ma' , 13= '44 Main street' , 5= '312 stuart st', 1273= '01', 1274= '01', 18= '6173335555', 15= 'Boston', 23= '1', 9= '02134', 183= '6175556985', 8= 'MA', 117= 'US', 17= '02116', 50= 'US', 4= 'Vermonster LLC', 7= 'Boston', 1369= '1', 12= 'Jay Powers', 1333= '1', 1401= '1.0', 116= 1, 68= 'USD', 1368= 1, 1369= 1, 1370= 5 ); // Ship example $ship_Ret = $fed-ship_express($ship_data); if ($error = $fed-getError()) { echo "ERROR :". $error; } else { // Save the label to disk $fed-label('mylabel.png'); } /* tracking example $track_Ret = $fed-track( array( 29 = 790344664540, )); echo $fed-debug_str. "\n"; echo "Price ".$ship_Ret[1419];*/ echo ""; if ($error = $fed-getError()) { die("ERROR: ". $error); } else { // decode and save label $fed-label('myLabel.png'); echo $fed-debug_str. "\n"; echo "\n\n"; echo "Price $".$ship_Ret[1419]; echo "\n"; echo "Tracking# ".$ship_Ret[29]; } echo ""; ?** Thanks Fero

    Read the article

  • How can I bind a List as ItemSource to ListView in XAML?

    - by Jonas
    I'm learning WPF and would like to have a collection similar to a LinkedList, to where I can add and remove strings. And I want to have a ListView that listen to that collection with databinding. How can I do bind a simple list collection to a ListView in XAML? My idea (not working) is something like this: <Window x:Class="TestApp.MainWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Title="MainWindow" Height="350" Width="525"> <Window.Resources> <LinkedList x:Key="myList"></LinkedList> //Wrong <Window.Resources> <Grid> <ListView Height="100" HorizontalAlignment="Left" Margin="88,134,0,0" Name="listView1" VerticalAlignment="Top" Width="120" ItemsSource="{Binding Source={StaticResource myList}}"/> //Wrong </Grid> </Window> All my code (updated version, not working): <Window x:Class="TestApp.MainWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Title="MainWindow" Height="350" Width="525"> <Grid> <TextBox Height="23" HorizontalAlignment="Left" Margin="12,12,0,0" Name="textBox1" VerticalAlignment="Top" Width="120" /> <Button Content="Button" Height="23" HorizontalAlignment="Right" Margin="0,12,290,0" Name="button1" VerticalAlignment="Top" Width="75" Click="button1_Click" /> <ListView Height="100" HorizontalAlignment="Left" Margin="88,134,0,0" Name="listView1" VerticalAlignment="Top" Width="120" ItemsSource="{Binding myList}"/> </Grid> </Window> C#-code: namespace TestApp { public partial class MainWindow : Window { ObservableCollection<string> myList = new ObservableCollection<string>(); public MainWindow() { InitializeComponent(); myList.Add("first string"); } private void button1_Click(object sender, RoutedEventArgs e) { myList.Add(textBox1.Text); textBox1.Text = myList.Count+"st"; } } }

    Read the article

  • x509 certificate Information

    - by sid
    Certificate: Data: Version: 3 (0x2) Serial Number: 95 (0x5f) Signature Algorithm: sha1WithRSAEncryption Issuer: C=, O=, CN= Validity Not Before: Apr 22 16:42:11 2008 GMT Not After : Apr 22 16:42:11 2009 GMT Subject: C=, O=, CN=, L=, ST= Subject Public Key Info: Public Key Algorithm: rsaEncryption RSA Public Key: (1024 bit) Modulus (1024 bit): ... ... ... Exponent: 65537 (0x10001) X509v3 extensions: X509v3 Key Usage: critical Digital Signature, Key Encipherment X509v3 Extended Key Usage: critical Code Signing X509v3 Authority Key Identifier: keyid: ... Signature Algorithm: sha1WithRSAEncryption a9:55:56:9b:9e:60:7a:57:fd:7:6b:1e:c0:79:1c:50:62:8f: ... ... -----BEGIN CERTIFICATE----- ... ... ... -----END CERTIFICATE----- In This Certificate, Which is the public key? is Modulus? what does the Signature Algorithm, a9:55:56:... represent (is it message digest)? And what is between -----BEGIN CERTIFICATE----- & -----END CERTIFICATE-----, is That the whole certificate? As I am novice, little bit confusing between the message digest and public key? Thanks in Advance-opensid

    Read the article

  • How to change the behavior of string objects in web service calls via Windows Communication Foundati

    - by Geri Langlois
    I have third party api's which require string values to be submitted as empty strings. On an asp.net page I can use this code (abbreviated here) and it works fine: public class Customer { private string addr1 = ""; public string Addr1 { get {return addr1;} set {addr1 = value;} } private string addr2 = ""; public string Addr2 { get {return addr2;} set {addr2 = value;} } private string city = ""; public string City { get {return city;} set {city = value;} } } Customer cust = new Customer(); cust.Addr1 = "1 Main St."; cust.City = "Hartford"; int custno = CustomerController.InsertCustomer(cust); The Addr2 field, which was not initialized is still an empty string when inserted. However, using the same code but called it through a web service based on Windows Communication Foundation the Addr2 field is null. Is there a way (or setting) where all string fields, even if uninitialized, would return an empty string (unless, of course, a value was set).

    Read the article

  • Integer Extensions - 1st, 2nd, 3rd etc [closed]

    - by David Schiefer
    Possible Duplicate: NSNumberFormatter and ‘th’ ‘st’ ‘nd’ ‘rd’ (ordinal) number endings Hello, I'm building an application that downloads player ranks and displays them. So say for example, you're 3rd out of all the players, I inserted a condition that will display it as 3rd, not 3th and i did the same for 2nd and 1st. When getting to higher ranks though, such as 2883rd, it'll display 2883th (for obvious reasons) My question is, how can I get it to reformat the number to XXX1st, XXX2nd, XXX3rd etc? To show what I mean, here's how I format my number to add a "rd" if it's 3 if ([[container stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]] isEqualToString:@"3"]) { NSString*badge = [NSString stringWithFormat:@"%@rd",[container stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]]]; NSString*scoreText = [NSString stringWithFormat:@"ROC Server Rank: %@rd",[container stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]]]; profile.badgeValue = badge; rank.text = scoreText; } I can't do this for every number up to 2000 (there are 2000 ranks in total) - what can I do to solve this problem?

    Read the article

  • Excessive use of Inner Join for more than 3 tables

    - by Archangel08
    Good Day, I have 4 tables on my DB (not the actual name but almost similar) which are the ff: employee,education,employment_history,referrence employee_id is the name of the foreign key from employee table. Here's the example (not actual) data: **Employee** ID Name Birthday Gender Email 1 John Smith 08-15-2014 Male [email protected] 2 Jane Doe 00-00-0000 Female [email protected] 3 John Doe 00-00-0000 Male [email protected] **Education** Employee_ID Primary Secondary Vocation 1 Westside School Westshore H.S SouthernBay College 2 Eastside School Eastshore H.S NorthernBay College 3 Northern School SouthernShore H.S WesternBay College **Employment_History** Employee_ID WorkOne StartDate Enddate 1 StarBean Cafe 12-31-2012 01-01-2013 2 Coffebucks Cafe 11-01-2012 11-02-2012 3 Latte Cafe 01-02-2013 04-05-2013 Referrence Employee_ID ReferrenceOne Address Contact 1 Abraham Lincoln Lincoln Memorial 0000000000 2 Frankie N. Stein Thunder St. 0000000000 3 Peter D. Pan Neverland Ave. 0000000000 NOTE: I've only included few columns though the rest are part of the query. And below are the codes I've been working on for 3 consecutive days: $sql=mysql_query("SELECT emp.id,emp.name,emp.birthday,emp.pob,emp.gender,emp.civil,emp.email,emp.contact,emp.address,emp.paddress,emp.citizenship,educ.employee_id,educ.elementary,educ.egrad,educ.highschool,educ.hgrad,educ.vocational,educ.vgrad,ems.employee_id,ems.workOne,ems.estartDate,ems.eendDate,ems.workTwo,ems.wstartDate,ems.wendDate,ems.workThree,ems.hstartDate,ems.hendDate FROM employee AS emp INNER JOIN education AS educ ON educ.employee_id='emp.id' INNER JOIN employment_history AS ems ON ems.employee_id='emp.id' INNER JOIN referrence AS ref ON ref.employee_id='emp.id' WHERE emp.id='$id'"); Is it okay to use INNER JOIN this way? Or should I modify my query to get the results that I wanted? I've also tried to use LEFT JOIN but still it doesn't return anything .I didn't know where did I go wrong. You see, as I have thought, I've been using the INNER JOIN in correct manner, (since it was placed before the WHILE CLAUSE). So I couldn't think of what could've possible went wrong. Do you guys have a suggestion? Thanks in advance.

    Read the article

  • LINQ-to-XML Error "is not a member of 'String'"

    - by mmcglynn
    The following code returns the error from the For Each loop. I have similar code that does not return the error. 'DisplayTitle' is not a member of 'Sting' Dim evXML As XDocument = XDocument.Load(Server.MapPath("~/App_Data/event.xml")) Dim sbEventDetail As New StringBuilder() Dim summary = _ From sum In evXML.<root>.Elements() _ Select sum...<DisplayTitle>.Value For Each item In summary sbEventDetail.Append("<h4>" & item.DisplayTitle & "</h4>") Next The XML: <root xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> <StartTime>2010-03-05T16:00:00</StartTime> <EndTime>2010-03-06T02:00:00</EndTime> <Duration>10:00:00</Duration> <DisplayTitle>MARCH MADNESS</DisplayTitle> <Location>565 Main St</Location> <IsAllDay>False</IsAllDay> <Recurrence> <OriginatingTimeZone>Eastern Standard Time</OriginatingTimeZone> <RecurrenceType>0</RecurrenceType> <RecurrenceEndDate>9999-12-31T23:59:59</RecurrenceEndDate> </Recurrence> <IsVariance>False</IsVariance> <IsCancelled>False</IsCancelled> <OriginalStart>0001-01-01T00:00:00</OriginalStart> </root>

    Read the article

  • Get the equivalent time between "dynamic" time zones

    - by doctore
    I have a table providers that has three columns (containing more columns but not important in this case): starttime, start time in which you can contact him. endtime, final hour in which you can contact him. region_id, region where the provider resides. In USA: California, Texas, etc. In UK: England, Scotland, etc starttime and endtime are time without timezone columns, but, "indirectly", their value has time zone of the region in which the provider resides. For example: starttime | endtime | region_id (time zone of region) | "real" st | "real" et ----------|----------|---------------------------------|-----------|----------- 03:00:00 | 17:00:00 | 1 (EGT => -1) | 02:00:00 | 16:00:00 Often I need to get the list of suppliers whose time range is within the current server time (taking into account the time zone conversion). The problem is that the time zones aren't "constant", ie, they may change during the summer time. However, this change is very specific to the region and not always carried out at the same time: EGT <= EGST, ART <= ARST, etc. The question is: 1. Is it necessary to use a webservice to update every so often the time zones in the regions? Does anyone know of a web service that can serve? 2. Is there a better approach to solve this problem? Thanks in advance. UPDATE I will give an example to clarify what I'm trying to get. In the table providers I found this records: idproviders | starttime | endtime | region_id ------------|-----------|----------|----------- 1 | 03:00:00 | 17:00:00 | 23 (Texas) 2 | 04:00:00 | 18:00:00 | 23 (Texas) If I execute the query in January, with this information: Server time (UTC offset) = 0 hours Texas providers (UTC offset) = +1 hour Server time = 02:00:00 I should get the following results: idproviders = 1 If I execute the query in June, with this information: Server time (UTC offset) = 0 hours Texas providers (UTC offset) = +2 hours (their local time has not changed, but their time zone has changed) Server time = 02:00:00 I should get the following results: idproviders = 1 and 2

    Read the article

  • Could someone explain gtk2hs drag and drop to me, the listDND.hs demo just isn't doing it for me?

    - by Tom Carstens
    As the title says, I just don't get DND (or rather I understand the concept and I understand the order of callbacks, I just don't understand how to setup DND for actual usage.) I'd like to say that I've done DND stuff before in C, but considering I never really got that working... So I'm trying (and mostly succeeding, save DND) to write a text editor (using gtksourceview, because it has built in code highlighting.) Reasons are below if you want them. Anyways, there's not really a good DND demo or tutorial available for gtk2hs (listDND.hs just doesn't translate well in my head.) So what I'm asking is for code that demonstrates simple DND on a window widget (for example.) Ideally, it should accept drops from other windows (such as Thunar) and print out the information in string form. I think I can take it from there... Reasons: I'm running a fairly light weight setup, dwm and a few gtk+2 programs. I really don't want to have to pull in gtk+3 to get the current gedit from the repos (Arch Linux.) Currently, I'm using geany for all of my text editing needs, however, geany is a bit heavy for editing config files. Further, geany doesn't care for my terminal of choice (st;) so I don't even get the benefit of using it as an IDE. Meaning I'd like a lightweight text editor with syntax highlighting. I could configure emacs or vim or something, but that seems to me to be more of a hack then a proper solution. Thus my project was born. It's mostly working (aside from DND, all that's left is proper multi-tab support.) Admittedly, I could probably work this out if I wrote it in C, but there isn't that much state in a text editor so Haskell's been working fine with almost no need for mutable variables.

    Read the article

  • How do I insert null fields with Perl's DBD::Pg?

    - by User1
    I have a Perl script inserting data into Postgres according to a pipe delimited text file. Sometimes, a field is null (as expected). However, Perl makes this field into an empty string and the Postgres insert statement fails. Here's a snippet of code: use DBI; #Connect to the database. $dbh=DBI-connect('dbi:Pg:dbname=mydb','mydb','mydb',{AutoCommit=1,RaiseError=1,PrintError=1}); #Prepare an insert. $sth=$dbh-prepare("INSERT INTO mytable (field0,field1) SELECT ?,?"); while (<){ #Remove the whitespace chomp; #Parse the fields. @field=split(/\|/,$_); print "$_\n"; #Do the insert. $sth-execute($field[0],$field[1]); } And if the input is: a|1 b| c|3 EDIT: Use this input instead. a|1|x b||x c|3|x It will fail at b|. DBD::Pg::st execute failed: ERROR: invalid input syntax for integer: "" I just want it to insert a null on field1 instead. Any ideas? EDIT: I simplified the input at the last minute. The old input actually made it work for some reason. So now I changed the input to something that will make the program fail. Also note that field1 is a nullable integer datatype.

    Read the article

  • Retaining column state in grid panel depending on the user settings.

    - by xrx215
    Hi, I have a grid panel where I am retaining the state of the columns.It works fine for all the columns except one where i show or hide the column depending on user settings. If a checkbox is checked then i show the column in grid panel else hide it. In the column model I have defined the column as follows var colModel = new Ext.grid.ColumnModel([{ header: xppo.st('SDE_RESPONSIBILITY_ACTION1'), width: 80, sortable: true, hidden: !showColumn, hideable: !showInMenu, dataIndex: 'ResponsibilityForAction' }} In the grid panel I have given the following if (showColumn) { grid.getColumnModel().setHidden(23, false); } else { grid.getColumnModel().setHidden(23, true); } so i change the value of the checkbox column in the column header is shown (alowing the user to enable and disable in grid panel) or completely not shown in the column menu. So when the column in column menu does not exists it should no longer show that particular column in grid panel.But because I am retaining the state of the grid panel even though the column in column menu does not exists this particular column retains the state i.e it is still shown in grid panel. My question is how can we show or hide columns in grid panel like the way we do in column model.??

    Read the article

  • DBD::CSV: Problem with userdefined functions

    - by sid_com
    From the SQL::Statement::Functions documentation: Creating User-Defined Functions ... More complex functions can make use of a number of arguments always passed to functions automatically. Functions always receive these values in @_: sub FOO { my( $self, $sth, $rowhash, @params ); } #!/usr/bin/env perl use 5.012; use warnings; use strict; use DBI; my $dbh = DBI->connect( "DBI:CSV:", undef, undef, { RaiseError => 1, } ); my $table = 'wages'; my $array_ref = [ [ 'id', 'number' ], [ 0, 6900 ], [ 1, 3200 ], [ 2, 1800 ], ]; $dbh->do( "CREATE TEMP TABLE $table AS import( ? )", {}, $array_ref ); sub routine { my $self = shift; my $sth = shift; my $rowhash = shift; # return $_[0] / 30; }; $dbh->do( "CREATE FUNCTION routine" ); my $sth = $dbh->prepare( "SELECT id, routine( number ) AS result FROM $table" ); $sth->execute(); $sth->dump_results(); When I try this I get an error-message: DBD::CSV::st execute failed: Use of uninitialized value $_[0] in division (/) at ./so.pl line 27. [for Statement "SELECT id, routine( number ) AS result FROM "wages""] at ./so.pl line 34. When I comment out the third argument I works as expected ( because it looks as if the third argument is missing ): #!/usr/bin/env perl ... sub routine { my $self = shift; my $sth = shift; #my $rowhash = shift; return $_[0] / 30; }; ... 0, 230 1, 106.667 2, 60 3 rows Is this a bug?

    Read the article

< Previous Page | 28 29 30 31 32 33 34 35 36 37 38  | Next Page >