Thursday 15 April 2010

xml serialization - Can we create a java object from an xml without knowing what object it is belong to -


I have an XML content, for which I do not know which class it belongs to Need to create a dynamic Java object? Is it possible to do this? It can be a simple Java object, so we can use the Java Reflection to get value from that object. For example,

  & lt; Employee & gt; & Lt; Name & gt; Jack & lt; / Name & gt; & Lt; Designation & gt; Manager & lt; / Designation & gt; & Lt; Department & gt; Finance & lt; / Department & gt; & Lt; / Staff & gt;   

So, with this XML, I need to convert to an employee object. But, I did not have an employee class in my class path, is it possible to create an object with XML?

  file fxmlFile = new file "Employee.xml"); Documentbilder factory dbfc = documentbilderfactor.Newinstance (); DocumentBuilder debugger = DBFTC NE DocumentBuilder (); Document doctor = debugger Parse (fxma file); // Optional, but recommended // read this - http://stackoverflow.com/questions/13786607/normalization-in-dom-parsing-with-java-how-does-it-work.doc.getDocumentElement (). Normal ( ); System.out.println ("Root Element:" + doc.getDocumentElement (.) GetNodeName ()); Node list nList = doc.getElementsByTagName ("employee"); Println ("----------------------------"); (At Temp = 0; Temp & LT; NLIIT: ATLANMENT (); Temporary ++) {Node NND = NLIT. ITM (temporary); System.out.println ("\ n Current element:" + nNode.getNodeName ()); If (nNode.getNodeType () == node. ELEMENT_NODE) ​​{Element EElment = (Element) nNode; System.out.println ("name: -" + eElement.getElementsByTagName ("name"). Item (0) .getTextContent ()); System.out.println ("Designation: -" + eElement.getElementsByTagName ("Designation"). Item (0) .getTextContent ()); System.out.println ("Department: -" + eElement.getElementsByTagName ("Department"). Item (0) .getTextContent ()); }}    

Proper explanation of JavaScript execution order -


I know there are so many questions on this topic, but they are all in accordance with a specific case. I am asking this question and hoping for an answer that everyone can use it while thinking about this matter.

Say that I have three functions that need to be executed in order, and they all do Async

For two tasks it is easy with callback: / P>

  var fOne = function (callback) {// do stuff callback (); }; Var fTwo = function () {// do stuff};   

Calling:

  fOne (fTwo);   

The FOO makes it to run after completion, how does the FTH in this case connect, so that it can be run after FTO, which is run after FOn?

Actually, if I think your question is correct, then you can add a logic to the FTO If you want to pass Lambda, then FTO has to take a callback and call it.

  var fOne = function (callback) {// do stuff callback (); }; Var fTwo = function (callback) {// do stuff callback (); }; Var fThree = function () {// do stuff}; Fun (function () {FTO (FT-2);}); // & lt; - Lambda    

visual studio 2012 - Why does select source for a SQL Schema Comparison cause VS2012 to crash? -


For instance, SQL & gt; Compare schema & gt; Visual Studio 2012 causes crash due to new schema comparison and then "attempting to select the source". Apart from trying to re-establish any possible solution there (hopefully for months it has been worked out)

Note: ? View an example of studio accident trying to debug shows an exception

  application: Devenvkexe Framework Version: v4.0.30319 Description: The process of a non-action Was ended due to the exception. Exception information: System.Security.Cryptography.CryptographicException ads: Microsoft.VisualStudio.Data.DataProtection.DecryptString (System.String) (System on Microsoft.VisualStudio.Data.Tools.Design.Core.Common.SqlClient.SqlUtils.DecryptConnectionString. Microsoft.VisualStudio.Data.Tools.Package.UI.DatabaseConnectionControl + Knekshnitm string) on ​​Microsoft.VisualStudio.Data.Tools.Design.Core.Common.SqlClient.ServerExplorerConnection.get_DisplayNameWithDatabase (). Start Microsoft.VisualStudio.Data.Tools.Package.UI.DatabaseConnectionControl.DatabaseConnectionControl_Load on (Microsoft.VisualStudio.Data.Tools Microsoft.VisualStudio.Data.Tools.Package.UI.DatabaseConnectionControl.PopulateDatabaseCombo () (System. Object, System. EventArgs)    

"itemprop =" text ">

After trying to follow the information, I see was checked which was accessible registry entries. HKCU \ Software \ Microsoft \ VisualStudio \ 11.0 \ SSDT \ ConnectionMruList is found under remove everything.

stringtemplate 4 - Is it possible to combine group files and group directories? -


I am using StringTemplate to create HTML and I use STGroupFile and STGroupDir This way I have a directory of group files. In this way I can include multiple templates in a file, but I can add templates from many files. It does not appear that there is support for it, but I thought that if I see something then I will see it.

If you are wondering why I would like to do this, see an example from the StringTemplate Docs:

  test (name) :: = "$ name: bracket () $ "// Apply bracket template in each name bracket (x): =" [$ x $] "// parameter parameter with square bracket   

All the above one file (Test.st) and we are using STGroupDir , it will be unable to resolve the "bracket (x)" template unless it is a separate file (bracket.st) Not in In this particular example, the bracket is like a local assistant that is useful for cleaning the main template. In this case, you probably do not want to show the bracket outside of the test.

However, if you want to create a library of simple supportive templates, you can find them all in one file and each of them is accessible to templates in other files.

"post-text" itemprop = "text">

Disclaimer: I am using StringTemplate in C # Em>

You have to use .stg files with a group of templates. StringTemplate groups can import groups of other templates or templates, and you can create those groups from a file or directory.

How to check if a folder exists in google drive? (ruby client) -


It seems that I can only return the contents of a folder, but there is no information about the folder.

  Result = client.execute ({: api_method => drive.files.list,: q = & gt; "mimeType = 'app / vnd.google-apps.folder' and Trashed = false and title = '# {App_folder_name}' ",: maxResults => 1})   

returned results. To_hash ["Item"] is populated with the contents of the array folder (sub folders and files). How do I get information about folders only? What I want to do, checks whether it exists or not. And it seems that more than one entry is being neglected in the array.

A folder Google Drive is like a regular file but a special MIME type ("app / vnd. Google-apps.folder "). After you have the ID of the folder, you can access the metadata with a request:

  ## # Print the file's metadata # # the ultimate [Google :: epicilient] Client #Official Client Instance # @ PRAM [String] File_ID # To print the #RetinNil DRP print_file (client, file_id) drive = client. Diskped_pi ('drive', 'V2') result = client.execute (: api_method = & gt; @ drive.files.get ,: parameter = & gt; {'fileId' = & gt; file_id}) if result.status == 200 file = result.data "title: # {file.title}" puts "Description: # {file.description}" puts "MIME type: # {file.mime_type}" and adds "An error occurred: # {Result.data ['error'] ['message']} "end and end    

sql - Read in only certain column names from TSV file into R -


I have a large TSV file that I can not read in R due to its size.

I only want to read the header name in the selected column, e.g. "Health".

How can I go about doing this?

See a read.table code colClasses : df & lt; - read.table (header = TRUE, colClasses = c (NA, "NULL", NA), text = 'ABC 1 2 3 4 5 6') DF # AC # 1 1 3 # 2 4 6 < / Pre>

Update:

To select names, first read in the header and then create a vector for the callclass:

  Read the # header header; & Lt; - read.table (header = FALSE, nrow = 1, text = 'ABC 1 2 3 4 5 6') # We want to take the call & lt; - c ('A', 'B') # Create a vector for callclose lecols & lt; - ifelse (t (header) %%, na, 'toll') # selected column df & lt; - read.table (header = TRUE, colClasses = lecoles, text = 'ABC 1 2 3 4 5 6')    

button - Fitting signals to slots in Qt -


I enable a QPushButton after another QPushButton Trying to click and I have participated in a problem first QPushButton one clicked () can remove the signal, while the second QPushButton has only the setEnabled (bool) slots and set to disable (boole) .

Actually, I am trying to do

  connect (ui-> pbViewVolume, signal (clicked)), UI-> pbSaveAsImage , Slot (setEnabled)));   

Since it is not possible to send a signal with less parameters compared to the slot, how can I do this? My only way is my main window like

  zero EnableSaveAsImageButton () {ui- & gt; PbSaveAsImage-> To create a public slot for setEnabled (true); }   

But I will not fill my main window with functions of this type of garbage.

  • You do not need to make this slot public, make it private. "Post-lesson" itemprop = "text">
    1. You have to create that slot.
    2. This function is not garbage.

  • c# - Decompiled assembly - unusual code -


    I weakened an assembly using ILSPT, public class customsstream : Network Stream {Private Event Handler & lt; Custom Event Egg & gt; SomeEvent; Public events event handler & lt; Custom Event Egg & gt; Add SomePublicEvent {add {EventHandler & lt; CustomEventArgs & gt; EventHandler = this.someEvent; Eventhandler & LT; CustomEventArgs & gt; EventHandler2; Do {eventHandler2 = eventHandler; Eventhandler & LT; CustomEventArgs & gt; Value2 = (Event Handler & lt; CustomEventErgies & gt;) Representative Cobain (eventhandsler 2, value); EventHindler = Interlock Comprex Exchange and lieutenant; EventHandler; & Lt; CustomAventAge & gt; & Gt; (Referee this Somewant, Value 2, EventHandler 2); } While (eventHandler! = EventHandler2); } Remove {// Similar stuff ...}}}

    In the next code, it seems that a real incident is set to fire a personal representative:

      if (some! = Null & amp; amp; something; ele =!) {This.someEvent (this, new CustomEventArgs (someArg)); }   

    Question: Can anyone guess what the idea behind this custom accessor could be, assuming that some "compile / divide magic" was not done? I am not very familiar with IL, BTW ...

    (Side note: application is multi-threaded and uses networking, obviously.)

    This is a new event handler code generated by the compiler. It was launched in C # 4 (C # version was different)

    Interlock Comparx Exchange compares the first argument with the third, and if they are equal, then the second argument changes with the other. This is a thread-safe operation Loop is used for any case when a variable eventHandler2 and check Prior to this, a thread changes to this representative. In this case, interlock Compressed Exchange does not execute the exchange, the position of the loop is correct and does not evaluate the next attempt.

    Generates simple code in C # 3 event handlers:

     Add  lock (this) {changed = change = value;  

    >



    MYSQL PHP Warning: mysql_query() expects parameter 1 to be string -


    I am having a very strange problem with PHP when trying to send a query to MYSQL. Here is my code

      $ newlogforuser = "create table" $ username "- logs (date CHAR (30), time CHAR (30), ipaddress char (30))"; // execute the query if (mysql_query ($ conl, $ newlogforuser)) {resonant "feedback from server: log successfully created"; } Else {Resonant "Response to the server: Error creating log:". Mysql_error (); }   

    Error: Warning: mysql_query () parameter 1 is expected to be a string

    I know that I am successfully connected to my MySQL database, so not so Is the issue I know there are many posts about the same problem on stack overflow, but one of them fixes my problem Please help!

    mysql_query is expected to be the first parameter string. Resource should be another parameter

    ssl certificate - How to use multiple SSL Keys when using two different git servers? -


    I have currently set up a personal installation on a private server for use on private repos.

    I also have to use the company's GTBLT to set up projects for the company.

    In a whole world, I will be able to use (like Geethabs) and can configure different SSP keys for each server. / P>

    Unfortunately GitBlit has chosen to use SSL and has not used SSH. Installing a single SSL certificate for GIT is really simple.

      git config --global http.sslKey path / to / username.key   

    but the global feature in settings appears like I have This is the only way to override the GIT_SSL_KEY in this project, or can there be only one key, or whether there are two different types within the global setting (IE: pointing http: sslKey - There is a way to use different SSL keys) in .keyig file instead of .config )

    You can configure a project differently except the - global argument and run it in the folder for the project you want to configure.

    For example:

    1. Configure the company's SSL key as the global default key

        git config - -global http.sslKey path / per / company.key    
    2. Configure each private repo with your private key

        CD / My / Private / Repo Git config http.sslKey path / to / private.key      

    php - alert only file names selected from file input -


    I have this Ajax call that checks if the name of multiple file input in a file already exists, and if When they do, a message warns them by telling them this. The problem is that I can only get it to alert all the file names from the result loop. How can I edit it so that it can only alert file names that were selected? Thank you.

      var file = $ ('# file') [0]; $ .get ('existing-filenames.php', function) {for (var i = 0; i & lt; file.files.length; i ++) {var fname = file.files [i] .name ;; (~ Data.indexOf (fname)) {// Only alert selected file name warnings ("These files already exist:" + data); return false;}}}, 'json');   

    and existing-filenames.php

      $ allfiles = $ db- & gt; Query ("Select file from files where email = '$ _SESSION [email]'); $ Result = []; While ($ files = $ allfiles -> fetch_assoc ()) {$ result [] = $ files ['filename']; } Echo json_encode ($ result);   

    and html

      & lt; Input name = "file []" type = "file" id = "file" multiple / & gt;    

    In doubt, add more jQuery:

      $ ('# File'). ('Change', function () {var self = this; $ .get ('existing-filenames.php', function (data) {$ .each (self.files, function () (if (data.indexOf (this .name)! = -1) {Warning ("These files already exist:" + + this.name);}});});});    

    plsql - Oracle PL/SQL Trigger Error -


    I am trying to get the trigger to update a reportnum and suffix and to be compatible with the Coldfusion ORM To do this work for tables with the same key, I have used the first part of the example below. In this table I need to update the suffix to the next value if the report number is given.

      create table tb1 (report number NUMBER, suffix number NUMBER); Start SEQ1 SEQ1 with 1; Before writing on TB1 for each line, create or replace Trigger "TRG1_TB1" IF: NEW.reportnum NULL SELECT SEQ1.NEXTVAL in: NEW.reportnum Dual; ELSIF: NEW.REPORTNUM = '' Then select seq1.NextTV: NEW.reportnum dual; ELSIF: NEW.suffix = '' Then select MAX (suffix) in +1: Where is tb1 from NEW suffix Reportnum =: NEW.reportnum ELSIF: NEW.suffix = NULL then select MAX (suffix) +1 in: NEW.suffix TB1 to WHERE reportnum =: NEW.reportnum END if; End;   

    The error I am getting is that this command is not finished properly.

    rabbitmq - How to ACK celery tasks with parallel code in reactor? -


    I have a celery that is called, just ignite the execution of some parallel code inside a twisted reactor. is. For example, there is no sample (runan) code:

      def run_task_in_reactor (): # to do this takes some time do_something () do_something_more () @ celery.task def run_task () : The print "reactor was started" reactor calfarththread (run_task_in_rector)   

    (For simplicity, please assume that the reactor is already running when the worker gets the work; As soon as the other thread in my reactor

    When I call run_task.delay () , the task is finished very quickly (because it run_task_in_reactor () does not wait to finish, only determines its execution time in reactor). And, when run_task_in_reactor () runs at the end, do_something () or do_something_more () can throw an exception, which will be untold.

    To use pika to consume my line, for example, to inform the worker about the correct completion of the job, I do_something_more () However, inside the celery, this does not seem possible (or, at least, I do not know how to make the same effect complete)

    Also, I can not remove the reactor because it One requirement is using some third-party code. I also appreciate other ways to achieve the same result.

    Use reactor. BlockingCallFromThread instead.

    Are there downsides to using var more than once on the same variable in JavaScript -


    Before asking my questions, I want to make a disclaimer I know what var does , I know about block scope, and I know about moving the variable I am not looking for answers to those topics

    I'm just thinking that more than one variable within the function But using a variable declaration is a functional, memory or performance cost.

    Here's an example:

      function foo () {var i = 0; Whereas (i ++ & lt; 10) {var j = i * i; }}   

    The last code can be easily written j variabled has been declared at the top:

      function Foo () {Var i = 0, j; While (i ++ & lt; 10) {j = i * i; }}   

    I am thinking that there is no real difference between these two methods. In other words, does var do anything other than the scope of the keyword?

    For this reason I have heard the second method to like:

    1. The first method gives the scope of the block when it actually works scoped.
    2. Variable dispersion is hoisted at the top of the scope, so it should be defined where.

      I consider these reasons as good, but are primarily stylish other reasons which work more with functionality, memory allocation, performance etc.?

      There will be no difference during the execution time . Interpreting / compiling time can be a susceptible small difference, but surely implementation will depend. Some bytes in the file size can also be different, which can affect download time. I do not think there is any concern about any of these.

      As you already know, any variable declaration will be hoisted at the top of the function. The important thing to note is that is done during the interpretation / compilation process, not during execution. Before the

      function is executed, the function should be parsed after every function is parsed, all the variables will take declaration declarations to the top of which It means that they will be identical and there will be no execution time cost.

      For this reason, there will be no memory cost differences after parsing, no difference will be.


      Since you are not asking about style, I am not telling you what I think is better. But I would say that the only reason you should prefer more than one is style.

    Starting debugging only from a certain point in time in C# with Visual Studio -


    I have a program that has a small Tetris like a game. I have a problem with my collision detector in some configurations, I want to debug it, but the game does not start in the "problematic" situation, I want to get the game in this situation and only want to start debugging. Since the collision detector runs very often, I can not put a breakpoint at a place that I will know that I will only run after the problematic situation, and the debugging process focuses on the game window, and allow me to give it Not input with keyboard.

    Using Visual Studio 2012, is there a way to start the debugger shortly after, where initially it will ignore the breakpoint, and only after telling it it starts breaking on the break point To do?

    Yes, you can start without debugging and then when you use the debug menu , You want to go to the state, select Attach the process when you are presented with the list, then double-click on your app.

    Another potential solution is to disable the breakpoint and then when you want the state (in which you start with debugging), simply enable breakpoints with a breakpoint window.

    regex - Find text string or part of text with dot in grepWin -


    I am using grepWin on Windows 7 64

    I have a folder with files and their duplicate copies.

    The original files are named "FILENAME DOT FILETYPE" (without spaces), for example "cartonbox.shelf".

    Copies of these files "FILENAME DOT 1 DOT FILETYPE" (without spaces), for example "cartonbox.1.shelf".

    I am trying to find all the files containing the exact string:

    "DOT 1 DOT FILETYPE" (without spaces), so in all those files For ".1.shelf".

    How can I do this in grepWin?

    If I did not get any result for ". 1 \ shelf " or ". 1 \ .shelf " example

    What is my fault? By reading but can not come with the correct pattern.

    How can I usually search for the exact portion of the filename in spite of symbols?

    Actually if I want to find the file "garden_1.1.4-JE50.tree" in the example how do I tell grepWin to find this exact string of text, including underscore, dots, or other characters?

    This file searches, files Do not search names

    In the directory you want to find, you can do something like this:

      dir *. * / B / s> My_file.txt   

    Then you can do my regular expression with grepWin on my_file.txt

    In Unix and Linux, you can normally go through the command line Command pipe:

      LS-A | | Grep \ .ree $   

    In Windows you will use

      dir * / b | Findstr \ .ree $    

    c# - XElement.CreateNavigator vs XDocument.CreateNavigator -


    class = "post-text" itemprop = "text">

    इस XML फ़ाइल को देखते हुए:

      & lt;? Xml संस्करण = "1.0" एन्कोडिंग = "utf-8" & gt; & LT; विन्यास & gt; & LT; स्टार्टअप & gt; & Lt; समर्थित क्रम संस्करण = "v4.0" sku = ".NETFramework, संस्करण = v4.5" / & gt; & Lt; / स्टार्टअप & gt; & LT; mySection & gt; & Lt; नेटवर्कशेयर फ़ोल्डर = "\\ myFolder \ v1" / & gt; & Lt; / mySection & gt; & Lt; / विन्यास & gt;   

    निम्न कोड काम नहीं करता (रिक्त आउटपुट देता है):

      var नेविगेटर = XElement.Load (कॉन्फ़िगरेशन प्रबंधक। OpenExeConfiguration (ConfigurationUserLevel.None) .FilePath) .CreateNavigator (); Var q = navigator.Select ("/ कॉन्फ़िगरेशन / mySection / NetworkShare"); यदि (q.Count == 1) // q.Count 0 है (q.MoveNext ()); कंसोल.दूषित लाइन (q.Current.GetAttribute ("फ़ोल्डर", नेविगेटर .फिरफिक्स)); }   

    लेकिन यह कोड काम करता है (सही तरीके से फ़ोल्डर को प्रिंट करता है):

      var नेविगेटर = XDocument.Load (कॉन्फ़िगरेशन प्रबंधक। OpenExeConfiguration (ConfigurationUserLevel.None) .FilePath ) .CreateNavigator (); Var q = navigator.Select ("/ कॉन्फ़िगरेशन / mySection / NetworkShare"); यदि (q.Count == 1) // q.Count 1 {q.MoveNext () है; कंसोल.दूषित लाइन (q.Current.GetAttribute ("फ़ोल्डर", नेविगेटर .फिरफिक्स)); }   

    क्या यह नेट में एक बग है?

    समस्या यह है कि XDocument पर एक प्रश्न किसी XElement से भिन्न संदर्भ में हैं एक XDocument के लिए, यह संपूर्ण दस्तावेज़ का प्रतिनिधित्व करता है यह बच्चा मूल तत्व है ( कॉन्फ़िगरेशन इस मामले में) XElement के लिए, यह तत्व का प्रतिनिधित्व करता है।

    इसलिए जब आप फ़ाइल को XElement.Load () के माध्यम से लोड करते हैं, तो प्रश्न उस के सापेक्ष होंगे तत्व। XDocument.Load () के माध्यम से फाइल को लोड करते हुए, क्वेरी दस्तावेज के सापेक्ष होंगे।

    इसलिए जब आपने / configuration /...//> क्योंकि XElement के लिए आप वर्तमान में कॉन्फ़िगरेशन तत्व में हैं, स्पष्ट रूप से कोई कॉन्फ़िगरेशन बच्चा नहीं है, इसलिए क्वेरी की पैदावार कुछ भी नहीं है दूसरी ओर, XDocument के लिए, यह अपेक्षा के अनुरूप काम करता है।

    ajax - Jquery AjaxSubmit + json datatype stripped HTML in IE9 -


    I jquery form.js. I am uploading the file using. The server side code returns a Jason formatted string, one of which is a "content" field. The content field contains an HTML form, that I spit out and spit out the page in one page.

    It works perfectly fine in Chrome and Firefox, but IE9 fails. IE9 All the opening HTML tags strips I was gogging all day and tried a lot of things, but I can not fix it.

    Here is my Jekery code:

      $ ('# file_form'). ("Change", ".file_upload_field", function {ev.preventDefault (); Var option = {url: '/ ajax / process', type: 'post', datatype: 'jason', success: function (Response) {$ ('# upload-confirm'). Show () .HTML (Response.data.content);}} $ $ ('# my-form') Ajax submit (option);});   

    The response is such a structure

      {"success": true, "message": "success", "data": {"content" : "& Lt; form & gt; & lt; input type = \" text \ "/> & lt; / form & gt;" }}   

    Your feedback is not valid json, a valid version will be "}}

    php - Show/hide dynamic textbox based on pulldown -


    How to locate / show how I show a dynamically generated text box based on a paneldown menu selection I am trying to make my JS skills are very limited based on the number of people I have made in the following loop:

        

    The ID of $ pid variable is required to be sorted and I

    The HTML output looks like this:

          

    c# - Alternative to using a ternary operator in Lambda -


    Currently .. My code looks like this. Phone Numbers = x.PhoneGune First and last ()! = Null? PhoneNumber.firstOrDefault (). PhoneNumber: string.Empty,

    PhoneNumbers a ICollection & lt; PhoneNumber & gt;

    This is a