Search Results

Search found 2301 results on 93 pages for 'schrodingers cat'.

Page 23/93 | < Previous Page | 19 20 21 22 23 24 25 26 27 28 29 30  | Next Page >

  • How do I write to a file and print to a terminal cuncurrently in Unix?

    - by bias
    I have a little bash function to log my Macports outputs to a file (since installs often spew little tidbits that are easy to lose in terminal noise), then I just cat the file to the terminal: function porti { command sudo port install $@ >> $1.log 2>&1; cat $1.log } Is there a way to do this concurrently? I don't care about it being in Bash, that's just how I started it. BTW I pass $@ to install but only $1 for the file name so that I can do something like: porti git-gore +bash_completion and only get the file git-core.log however someone else might prefer to include variants in the file name ...

    Read the article

  • Why is the base() constructor not necessary?

    - by Earlz
    Hello, I have a class structure like abstract class Animal { public Animal(){ //init stuff.. } } class Cat : Animal { public Cat(bool is_keyboard) : base() //NOTE here { //other init stuff } } Now then, look at the noted line. If you remove : base() then it will compile without an error. Why is this? Is there a way to disable this behavior? I have had multiple bugs now from forgetting the base() which I would have thought to be required on such a special thing as a constructor.

    Read the article

  • SQL latest/top items in category

    - by drozzy
    What is a scalable way to select latest 10 items from each category. I have a schema list this: item category updated so I want to select 10 last update items from each category. The current solution I can come up with is to query for categories first and then issue some sort of union query: query = none for cat in categories: query += select top 10 from table where category=cat order by updated I am not sure how efficient this will be for bigger databases (1 million rows). If there is a way to do this in one go - that would be nice. Any help appreciated.

    Read the article

  • Regular expression for parsing CSV in PHP

    - by Discodancer
    I already managed to split the CSV file using this regex: "/,(?=(?:[^\"]\"[^\"]\")(?![^\"]\"))/" But I ended up with an array of strings that contain the opening and ending double quotes. Now I need a regex that would strip those strings of the delimiter double quotes. As far as I know the CSV format can encapsulate strings in double quotes, and all the double quotes that are already a part of the string are doubled. For example: My "other" cat becomes "My ""other"" cat" What I basically need is a regex that will replace all sequences of N doublequotes with a sequence of (N/2 - rounded down) double quotes. Or is there a better way ? Thanks in advance.

    Read the article

  • Persist collection of interface using Hibernate

    - by Olvagor
    I want to persist my litte zoo with Hibernate: @Entity @Table(name = "zoo") public class Zoo { @OneToMany private Set<Animal> animals = new HashSet<Animal>(); } // Just a marker interface public interface Animal { } @Entity @Table(name = "dog") public class Dog implements Animal { // ID and other properties } @Entity @Table(name = "cat") public class Cat implements Animal { // ID and other properties } When I try to persist the zoo, Hibernate complains: Use of @OneToMany or @ManyToMany targeting an unmapped class: blubb.Zoo.animals[blubb.Animal] I know about the targetEntity-property of @OneToMany but that would mean, only Dogs OR Cats can live in my zoo. Is there any way to persist a collection of an interface, which has several implementations, with Hibernate?

    Read the article

  • How to load program reading stdin and taking parameters in gdb?

    - by vinc456
    I have a program that takes input from stdin and also takes some parameters from command line. It looks like this: cat input.txt myprogram -path "/home/user/work" I try to debug the code with gdb inside emacs, by M-x gdb, I try to load the program with the command: gdb cat input.txt myprogram -path "/home/user/work" However, gdb does not like it. Question cribbed from here. Unfortunately I don't understand the solution and am not sure what to do beyond compiling with the -g option and running the command M-x gdb.

    Read the article

  • How to open a large text file in C#

    - by desmati
    I have a text file that contains about 100000 articles. The structure of file is: BEGIN OF FILE .Document ID 42944-YEAR:5 .Date 03\08\11 .Cat political Article Content 1 .Document ID 42945-YEAR:5 .Date 03\08\11 .Cat political Article Content 2 END OF FILE I want to open this file in c# for processing it line by line. I tried this code: String[] FileLines = File.ReadAllText(TB_SourceFile.Text).Split(Environment.NewLine.ToCharArray()); But it says: Exception of type 'System.OutOfMemoryException' was thrown. The question is How can I open this file and read it line by line. File Size: 564 MB (591,886,626 bytes) File Encoding: UTF-8 File contains Unicode characters.

    Read the article

  • Find all clauses related to an atom

    - by Luc Touraille
    This is probably a very silly question (I just started learning Prolog a few hours ago), but is it possible to find all the clauses related to an atom? For example, assuming the following knowledge base: cat(tom). animal(X) :- cat(X). , is there a way to obtain every possible information about tom (or at least all the facts that are explicitly stated in the base)? I understand that a query like this is not possible: ?- Pred(tom). so I thought I could write a rule that would deduce the correct information: meta(Object, Predicate) :- Goal =.. [Predicate, Object], call(Goal). so that I could write queries such as ?- meta(tom, Predicate). but this does not work because arguments to call are not sufficiently instantiated. So basically my question is: is this at all possible, or is Prolog not design to provide this kind of information? And if it is not possible, why?

    Read the article

  • Setting variables in shell script by running commands

    - by rajya vardhan
    >cat /tmp/list1 john jack >cat /tmp/list2 smith taylor It is guaranteed that list1 and list2 will have equal number of lines. f(){ i=1 while read line do var1 = `sed -n '$ip' /tmp/list1` var2 = `sed -n '$ip' /tmp/list2` echo $i,$var1,$var2 i=`expr $i+1` echo $i,$var1,$var2 done < $INFILE } So output of f() should be: 1,john,smith 2,jack,taylor But getting 1,p,p 1+1,p,p If i replace following: var1 = `sed -n '$ip' /tmp/list1` var2 = `sed -n '$ip' /tmp/list2` with this: var1=`head -$i /tmp/vip_list|tail -1` var2=`head -$i /tmp/lb_list|tail -1` Then output: 1,john,smith 1,john,smith Not an expert of shell, so please excuse if sounds childish :)

    Read the article

  • bash: hwo to know NUM option in grep -A -B "on the fly" ?

    - by Michael Mao
    Hello everyone: I am trying to analyze my agent results from a collection of 20 txt files here. If you wonder about the background info, please go see my page, what I am doing here is just one step. Basically I would like to take only my agent's result out of the messy context, so I've got this command for a single file: cat run15.txt | grep -A 50 -E '^Agent Name: agent10479475' | grep -B 50 '^==' This means : after the regex match, continue forward by 50 lines, stop, then match a line separator starts with "==", go back by 50 lines, if possible (This would certainly clash the very first line). This approach depends on the fact that the hard-coded line number counter 50, would be just fine to get exactly one line separator. And this would not work if I do the following code: cat run*.txt | grep -A 50 -E '^Agent Name: agent10479475' | grep -B 50 '^==' The output would be a mess... My question is: how to make sure grep knows exactly when to stop going forward, and when to stop getting backward? Any suggestion or hint is much appreciated.

    Read the article

  • Can I improve this regex check for valid domain names?

    - by Josh
    So, I have been working on this domain name regular expression. So far, it seems to pick up domain names with SLDs and TLDs (with the optional ccTLD), but there is duplication of the TLD listing. Can this be refactored any further? params[:domain_name].downcase.strip.match(/^[a-z0-9\-]{2,63} \.((a[cdefgilmnoqrstuwxz]|aero|arpa)|(b[abdefghijmnorstvwyz]|biz)| (c[acdfghiklmnorsuvxyz]|cat|com|coop)|d[ejkmoz]|(e[ceghrstu]|edu)|f[ijkmor]| (g[abdefghilmnpqrstuwy]|gov)|h[kmnrtu]|(i[delmnoqrst]|info|int)| (j[emop]|jobs)|k[eghimnprwyz]|l[abcikrstuvy]| (m[acdghklmnopqrstuvwxyz]|me|mil|mobi|museum)|(n[acefgilopruz]|name|net)|(om|org)| (p[aefghklmnrstwy]|pro)|qa|r[eouw]|s[abcdeghijklmnortvyz]| (t[cdfghjklmnoprtvwz]|travel)|u[agkmsyz]|v[aceginu]|w[fs]|y[etu]|z[amw]) (\.((a[cdefgilmnoqrstuwxz]|aero|arpa)|(b[abdefghijmnorstvwyz]|biz)| (c[acdfghiklmnorsuvxyz]|cat|com|coop)|d[ejkmoz]|(e[ceghrstu]|edu)|f[ijkmor]| (g[abdefghilmnpqrstuwy]|gov)|h[kmnrtu]|(i[delmnoqrst]|info|int)| (j[emop]|jobs)|k[eghimnprwyz]|l[abcikrstuvy]| m[acdghklmnopqrstuvwxyz]|mil|mobi|museum)| (n[acefgilopruz]|name|net)|(om|org)| (p[aefghklmnrstwy]|pro)|qa|r[eouw]|s[abcdeghijklmnortvyz]| (t[cdfghjklmnoprtvwz]|travel)|u[agkmsyz]|v[aceginu]|w[fs]|y[etu]|z[amw]))?$/)

    Read the article

  • remove duplicates from object array data java

    - by zahir hussain
    hi i want to know how to remove duplicates in object. for example cat c[] = new cat[10]; c[1].data = "ji"; c[2].data = "pi"; c[3].data = "ji"; c[4].data = "lp"; c[5].data = "ji"; c[6].data = "pi"; c[7].data = "jis"; c[8].data = "lp"; c[9].data = "js"; c[10].data = "psi"; i would like to remove the duplicates value from object array. thanks and advance

    Read the article

  • Symfony2 Entity to array

    - by Adriano Pedro
    I'm trying to migrate my flat php project to Symfony2, but its coming to be very hard. For instance, I have a table of Products specification that have several specifications and are distinguishables by its "cat" attribute in that Extraspecs DB table. Therefore I've created a Entity for that table and want to make an array of just the specifications with "cat" = 0... I supose the code is this one.. right? $typeavailable = $this->getDoctrine() ->getRepository('LabsCatalogBundle:ProductExtraspecsSpecs') ->findBy(array('cat' => '0')); Now how can i put this in an array to work with a form like this?: form = $this ->createFormBuilder($product) ->add('specs', 'choice', array('choices' => $typeavailableArray), 'multiple' => true) Thank you in advance :) # Thank you all.. But now I've came across with another problem.. In fact i'm building a form from an existing object: $form = $this ->createFormBuilder($product) ->add('name', 'text') ->add('genspec', 'choice', array('choices' => array('0' => 'None', '1' => 'General', '2' => 'Specific'))) ->add('isReg', 'choice', array('choices' => array('0' => 'Material', '1' => 'Reagent', '2' => 'Antibody', '3' => 'Growth Factors', '4' => 'Rodents', '5' => 'Lagomorphs'))) So.. in that case my current value is named "extraspecs", so i've added this like: ->add('extraspecs', 'entity', array( 'label' => 'desc', 'empty_value' => ' --- ', 'class' => 'LabsCatalogBundle:ProductExtraspecsSpecs', 'property' => 'specsid', 'query_builder' => function(EntityRepository $er) { return $er ->createQueryBuilder('e'); But "extraspecs" come from a relationship of oneToMany where every product has several extraspecs... Here is the ORM: Labs\CatalogBundle\Entity\Product: type: entity table: orders__regmat id: id: type: integer generator: { strategy: AUTO } fields: name: type: string length: 100 catnumber: type: string scale: 100 brand: type: integer scale: 10 company: type: integer scale: 10 size: type: decimal scale: 10 units: type: integer scale: 10 price: type: decimal scale: 10 reqcert: type: integer scale: 1 isReg: type: integer scale: 1 genspec: type: integer scale: 1 oneToMany: extraspecs: targetEntity: ProductExtraspecs mappedBy: product Labs\CatalogBundle\Entity\ProductExtraspecs: type: entity table: orders__regmat__extraspecs fields: extraspecid: id: true type: integer unsigned: false nullable: false generator: strategy: IDENTITY regmatid: type: integer scale: 11 spec: type: integer scale: 11 attrib: type: string length: 20 value: type: string length: 200 lifecycleCallbacks: { } manyToOne: product: targetEntity: Product inversedBy: extraspecs joinColumn: name: regmatid referencedColumnName: id HOw should I do this? Thank you!!!

    Read the article

  • return a php associative array to javascript array

    - by Eric Sim
    I am trying to return a php associative array to javascript array through ajaxRequest.responseText Here's what I do. First in php, I do this: $encoded = json_encode($thisarray); echo $encoded; If I echo $encoded, I get {"a":"apple,arrow","b":"boy,bank","c":"cat,camp"} Then in js script, thisarray = new Array(); thisarray = ajaxRequest.responseText; If I alert thisarray, I get {"a":"apple,arrow","b":"boy,bank","c":"cat,camp"} That's wrong since alerting an array should give error. But in this case, when I alert thisarray, I get the full array!! Needless to say, I can't call my value out of thisarray, since it is yet defined as an array. Anyone can tell me what am I missing here?

    Read the article

  • Ubuntu problem not connecting to wireless or wired network

    - by ToughPal
    I recently installed openvpn and things were working. But I got a weird screen after a few hours and on restart my wired and wireless connections are not working. Can someone help? cat /etc/network/interfaces auto lo iface lo inet loopback cat /etc/resolv.conf #Generated by NetworkManager Is there anything missing? I tried both wired and wireless and both are not working. Usually if I ever have a problem with wireless, the wired always work! My /etc/network/interfaces is looking wrong. Can you please send me yours? I am using ubuntu 9.10 and the internet was working correctly until today! Please help

    Read the article

  • discover if mod_rewrite is working (MAMP + codeigniter)

    - by Patrick
    Hi, I'm experimenting (and having problems!) with codeigniter. In particular, links do not work. even if they are correct (eg. http://localhost/ci-book/welcome/cat/3, where welcome is controller, cat the method), they can't be open and chrome says "Oops! This link appears to be broken...." Someone suggested to check that mod_rewrite is working. How can I do that? I'm using Mamp. thanks, P.

    Read the article

  • Serialize a generic collection specifying element names for items in the collection

    - by mdresser
    I have a simple class derived from a generic list of string as follows: [Serializable] [System.Xml.Serialization.XmlRoot("TestItems")] public class TemplateRoleCollection : List<string> { } when I serialize this, I get the following XML: <TestItems> <string>cat</string> <string>dog</string> <string>wolf</string> </TestItems> Is there any way to override the xml element name which is used for serializing items in the collection? I would like the following xml to be produced: <TestItems> <TestItem>cat</TestItem> <TestItem>dog</TestItem> <TestItem>wolf</TestItem> </TestItems>

    Read the article

  • How to use a dynamic smarty variable in foreach loop

    - by P Kumar
    Hi, Can anyone tell me how to use dynamic variables in smarty foreach loop. I am trying to create a module in prestashop and m very close to get it done. here's my code: //file name index.php foreach($subCategories as $s) { $foo = intval($s['id_category']); $k = new Category($foo); $var1 = "subSubCategories.$foo"; $var1 = $k-getSubCategories(1); $smarty-assign(array('foo'.$foo = $var1)); } //file name:index.tpl {assign var=foo value=$foo$cat} //where $cat is a variable that counts the number of categories {if isset($foo) AND $foo} {foreach from=$foo item=subCategories name=homesubCategories} <p>{$subCategories.name}</p> {/foreach} {else} <p>{l s='test failed'}</p> {/if} I've exhausted all of my resources and knowledge and feeling quite helpless at this moment. so plz help me out.

    Read the article

  • Finding the most frequent subtrees in a collection of (parse) trees

    - by peter.murray.rust
    I have a collection of trees whose nodes are labelled (but not uniquely). Specifically the trees are from a collection of parsed sentences (see http://en.wikipedia.org/wiki/Treebank). I wish to extract the most common subtrees from the collection - performance is not (yet) an issue. I'd be grateful for algorithms (ideally Java) or pointers to tools which do this for treebanks. Note that order of child nodes is important. EDIT @mjv. We are working in a limited domain (chemistry) which has a stylised language so the varirty of the trees is not huge - probably similar to children's readers. Simple tree for "the cat sat on the mat". <sentence> <nounPhrase> <article/> <noun/> </nounPhrase> <verbPhrase> <verb/> <prepositionPhrase> <preposition/> <nounPhrase> <article/> <noun/> </nounPhrase> </prepositionPhrase> </verbPhrase> </sentence> Here the sentence contains two identical part-of-speech subtrees (the actual tokens "cat". "mat" are not important in matching). So the algorithm would need to detect this. Note that not all nounPhrases are identical - "the big black cat" could be: <nounPhrase> <article/> <adjective/> <adjective/> <noun/> </nounPhrase> The length of sentences will be longer - between 15 to 30 nodes. I would expect to get useful results from 1000 trees. If this does not take more than a day or so that's acceptable. Obviously the shorter the tree the more frequent, so nounPhrase will be very common. EDIT If this is to be solved by flattening the tree then I think it would be related to Longest Common Substring, not Longest Common Sequence. But note that I don't necessarily just want the longest - I want a list of all those long enough to be "interesting" (criterion yet to be decided).

    Read the article

  • JQuery click event, not working

    - by Roland
    I have the following scenario. I have a index.php page with the following JQuery code included jQuery(document).ready(function(){ jQuery('#sIMG img').click(function(){ var currentSRC = jQuery(this).attr('src'); var altSRC = jQuery(this).attr('title'); var imgID = jQuery(this).attr('id'); var cat = jQuery(this).attr('name'); /*Fade, Callback, swap the alt and src, fade in */ jQuery('#main').fadeOut('fast',function(){ jQuery('#main').load("detail.php?id="+imgID+"&category="+cat); jQuery('#main').fadeIn('fast'); }); }); }); Now I have two div tags called #main and #right in the index.php page. When I click on a menu item right changes to a bunch of images, if I click on one of those images the above code should take effect and load into the main div, but it's just not working. the images are located within a div called sIMG. Any help will be appreciated

    Read the article

  • How can I make a group bar plot in ggplot2?

    - by maximusyoda
    I have four of these kind of dataframes each with a different name (Apple,Ball,Cat) with different values of frequency but same 4 season names Seasons Frequency DJF 9886 JJA 5408 MAM 12876 SON 6932 And I am trying to make a group bar plot. The graph I'm looking for is like this, where c,d,e,f will be the names - Apple, Ball, Cat. Y-axis will be Frequency Each group will have 4 bars: DJF,JJA,MAM,SON Filled by seasons The number of Frequency written above the bar plot. How can I format the data to make it suitable for ggplot (cbind, melt etc) and use it in ggplot?

    Read the article

  • How do I send a file as an email attachment using Linux command line?

    - by Kit Roed
    I've created a script that runs every night on my Linux server that uses mysqldump to back up each of my MySQL databases to .sql files and packages them together as a compressed .tar file. The next step I want to accomplish is to send that tar file through email to a remote email server for safekeeping. I've been able to send the raw script in the body an email by piping the backup text file to mailx like so: $ cat mysqldbbackup.sql | mailx [email protected] cat echoes the backup file's text which is piped into the mailx program with the recipient's email address passed as an argument. While this accomplishes what I need, I think it could be one step better, Is there any way, using shell scripts or otherwise, to send the compressed .tar file to an outgoing email message as an attachment? This would beat having to deal with very long email messages which contain header data and often have word-wrapping issues etc.

    Read the article

  • Problem with unix pipe command

    - by Keyo
    I have a list of directory names in a text file. I want to use these as part of a file_name a git-svn clone command. This prints out the contents of the file line by line. cat repos_to_migrate.txt | tee $1 This however does not work: cat repos_to_migrate.txt | git svn clone file:///home/svn/$1 ... Unable to open repository 'file:///home/svn' ... Any ideas here? I'f it matters I'm running centos5.

    Read the article

  • Using $this when not in object context

    - by Ken
    I'm creating a function to show blog's. So I made a show blog function but it keeps giving "Using $this when not in object context" error Class Blog{ public function getLatestBlogsBig($cat = null){ $sqlString = "SELECT blog_id FROM jab_blog"; if($cat != null) $sqlString .= " WHERE blog_cat = " . $cat; $sqlString .= " ORDER BY blog_id DESC LIMIT 5"; $blog = mysql_query($sqlString); while($id = mysql_result($blog,"blog_id")){ $this->showBlog($id); //Error is on this line } } function showBlog($id,$small = false){ $sqlString = "SELECT blog_id FROM jab_blog WHERE blog_id=" . $id . ";"; $blog = mysql_query($sqlString); if($small = true){ echo "<ul>"; while($blogItem = mysql_fetch_array($blog)){ echo '<a href="' . $_SESSION['JAB_LINK'] . "blog/" . $blogItem['blog_id'] . "/" . SimpleUrl::toAscii($blogItem['blog_title']) .'">' . $blogItem['blog_title'] . '</a></li>'; } echo "</ul>"; }else{ while($blogItem = mysql_fetch_array($blog)){ ?> <div class="post"> <h2 class="title"><a href="<?php echo $_SESSION['JAB_LINK'] . "blog/" . $blogItem['blog_id'] . "/" . SimpleUrl::toAscii($blogItem['blog_title']);?>"><?php echo $blogItem['blog_title'];?></a></h2> <p class="meta"><span class="date">The date implement</span><span class="posted">Posted by <a href="#">Someone</a></span></p> <div style="clear: both;">&nbsp;</div> <div class="entry"> <?php echo $blogItem['blog_content'];?> </div> </div> <?php } } } }

    Read the article

  • Java: calculate linenumber from charwise position according to the number of "\n"

    - by HH
    I know charwise positions of matches like 1 3 7 8. I need to know their corresponding line number. Example: file.txt Match: X Mathes: 1 3 7 8. Want: 1 2 4 4 $ cat file.txt X2 X 4 56XX [Added: does not notice many linewise matches, there is probably easier way to do it with stacks] $ java testt 1 2 4 $ cat testt.java import java.io.*; import java.util.*; public class testt { public static String data ="X2\nX\n4\n56XX"; public static String[] ar = data.split("\n"); public static void main(String[] args){ HashSet<Integer> hs = new HashSet<Integer>(); Integer numb = 1; for(String s : ar){ if(s.contains("X")){ hs.add(numb); numb++; }else{ numb++; } } for (Integer i : hs){ System.out.println(i); } } }

    Read the article

< Previous Page | 19 20 21 22 23 24 25 26 27 28 29 30  | Next Page >