Search Results

Search found 443 results on 18 pages for 'concat'.

Page 7/18 | < Previous Page | 3 4 5 6 7 8 9 10 11 12 13 14  | Next Page >

  • Recoverable error while running XSL

    - by Kate
    XSL: <?xml version="1.0" encoding="utf-8"?> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:ve="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships" xmlns:m="http://schemas.openxmlformats.org/officeDocument/2006/math" xmlns:v="urn:schemas-microsoft-com:vml" xmlns:wp="http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing" xmlns:w10="urn:schemas-microsoft-com:office:word" xmlns:w="http://schemas.openxmlformats.org/wordprocessingml/2006/main" xmlns:wne="http://schemas.microsoft.com/office/word/2006/wordml" exclude-result-prefixes="wp wne w10 w ve o r m v" version="2.0"> <xsl:output method="text"/> <xsl:param name="styleName"/> <xsl:template match="w:p"> <xsl:apply-templates/><xsl:text>&#10;</xsl:text> </xsl:template> <xsl:template match="w:r[not ((parent::w:hyperlink[@w:anchor[matches(.,concat('^(',$styleName,')')),'i']]))]"> <xsl:value-of select="replace(., '.', '&#xFF00;')"/> </xsl:template> </xsl:stylesheet> While processing the above XSL, I am getting the below error, Recoverable Error: Recoverable error on line 11 FORG0006: An error occurred matching pattern {w:r[not ((parent::w:hyperlink[@w:anchor[matches(.,concat('^(',$styleName,')')),'i']]))]}: Effective boolean value is not defined for a sequence of two or more items starting with a boolean Please Help. I am not able to figure out this.

    Read the article

  • Passing mix of T and T[] to a Java varargs method

    - by rfalke
    Suppose you have a Java method void foobar(int id, String ... args) and want to pass both String arrays and Strings into the method. Like this String arr1[]={"adas", "adasda"}; String arr2[]={"adas", "adasda"}; foobar(0, "adsa", "asdas"); foobar(1, arr1); foobar(2, arr1, arr2); foobar(3, arr1, "asdas", arr2); In Python there is "*" for this. Is there some way better than such rather ugly helper method: static String[] concat(Object... args) { List<String> result = new ArrayList<String>(); for (Object arg : args) { if (arg instanceof String) { String s = (String) arg; result.add(s); } else if (arg.getClass().isArray() && arg.getClass().getComponentType().equals(String.class)) { String arr[] = (String[]) arg; for (String s : arr) { result.add(s); } } else { throw new RuntimeException(); } } return result.toArray(new String[result.size()]); } which allows foobar(4, concat(arr1, "asdas", arr2));

    Read the article

  • breadth-first traversal of directory tree is not lazy

    - by user855443
    I try to traverse the diretory tree. A naive depth-first traversal seems not to produce the data in a lazy fashion and runs out of memory. I next tried a breadth first approach, which shows the same problem - it uses all the memory available and then crashes. the code i have is: getFilePathBreadtFirst :: FilePath -> IO [FilePath] getFilePathBreadtFirst fp = do fileinfo <- getInfo fp res :: [FilePath] <- if isReadableDirectory fileinfo then do children <- getChildren fp lower <- mapM getFilePathBreadtFirst children return (children ++ concat lower) return (children ++ concat () else return [fp] -- should only return the files? return res getChildren :: FilePath -> IO [FilePath] getChildren path = do names <- getUsefulContents path let namesfull = map (path </>) names return namesfull testBF fn = do -- crashes for /home/frank, does not go to swap fps <- getFilePathBreadtFirst fn putStrLn $ unlines fps I think all the code is either linear or tail recursive, and I would expect that the listing of filenames starts immediately, but in fact it does not. Where is the error in my code and my thinking? where have I lost lazy evaluation?

    Read the article

  • Anything wrong with this MySQL quert? takes 10 seconds+ to load

    - by user345426
    I have a search that is taking 10 seconds+ to execute! Keep in mind it is also searching over 200,000 products in the database. I posted the explain and MySQL query here. 1 SIMPLE p ref PRIMARY,products_status,prod_prodid_status,product... products_status 1 const 9048 Using where; Using temporary; Using filesort 1 SIMPLE v ref PRIMARY,vendors_id,vendors_vendorid vendors_vendorid 4 rhinomar_rhinomartnew.p.vendors_id 1 1 SIMPLE s ref products_id products_id 4 rhinomar_rhinomartnew.p.products_id 1 1 SIMPLE pd ref PRIMARY,products,prod_desc_prodid_prodname prod_desc_prodid_prodname 4 rhinomar_rhinomartnew.p.products_id 1 1 SIMPLE p2c ref PRIMARY,ptc_catidx PRIMARY 4 rhinomar_rhinomartnew.p.products_id 1 Using where; Using index 1 SIMPLE c eq_ref PRIMARY PRIMARY 4 rhinomar_rhinomartnew.p2c.categories_id 1 Using where MySQL Query: select p.products_id, p.products_image, p.products_price, p.products_weight, p.products_unit_quantity, s.specials_new_products_price, s.status, pd.products_name, pd.products_img_alt from products p left join vendors v ON v.vendors_id = p.vendors_id left join specials s on s.products_id = p.products_id left join products_description pd on pd.products_id = p.products_id left join products_to_categories p2c on p2c.products_id = p.products_id left join categories c on c.categories_id = p2c.categories_id where ( ( pd.products_name like '%apparel%' ) or p2c.categories_id IN (773, 132, 135, 136, 119, 122, 124, 125, 126, 1749, 1753, 1747, 123, 127, 130, 131, 178, 137, 140, 164, 165, 166, 167, 168, 169, 832, 2045 ) or p.products_id = 'apparel' or p.products_model = 'apparel' or CONCAT(v.vendors_prefix, '-') = 'apparel' or CONCAT( v.vendors_prefix, '-', p.products_id ) = 'apparel' ) and p.products_status = '1' and c.categories_status = '1' group by p.products_id order by pd.products_name

    Read the article

  • How can I merge two Linq IEnumerable<T> queries without running them?

    - by makerofthings7
    How do I merge a List<T> of TPL-based tasks for later execution? public async IEnumerable<Task<string>> CreateTasks(){ /* stuff*/ } My assumption is .Concat() but that doesn't seem to work: void MainTestApp() // Full sample available upon request. { List<string> nothingList = new List<string>(); nothingList.Add("whatever"); cts = new CancellationTokenSource(); delayedExecution = from str in nothingList select AccessTheWebAsync("", cts.Token); delayedExecution2 = from str in nothingList select AccessTheWebAsync("1", cts.Token); delayedExecution = delayedExecution.Concat(delayedExecution2); } /// SNIP async Task AccessTheWebAsync(string nothing, CancellationToken ct) { // return a Task } I want to make sure that this won't spawn any task or evaluate anything. In fact, I suppose I'm asking "what logically executes an IQueryable to something that returns data"? Background Since I'm doing recursion and I don't want to execute this until the correct time, what is the correct way to merge the results if called multiple times? If it matters I'm thinking of running this command to launch all the tasks var AllRunningDataTasks = results.ToList(); followed by this code: while (AllRunningDataTasks.Count > 0) { // Identify the first task that completes. Task<TableResult> firstFinishedTask = await Task.WhenAny(AllRunningDataTasks); // ***Remove the selected task from the list so that you don't // process it more than once. AllRunningDataTasks.Remove(firstFinishedTask); // TODO: Await the completed task. var taskOfTableResult = await firstFinishedTask; // Todo: (doen't work) TrustState thisState = (TrustState)firstFinishedTask.AsyncState; // TODO: Update the concurrent dictionary with data // thisState.QueryStartPoint + thisState.ThingToSearchFor Interlocked.Decrement(ref thisState.RunningDirectQueries); Interlocked.Increment(ref thisState.CompletedDirectQueries); if (thisState.RunningDirectQueries == 0) { thisState.TimeCompleted = DateTime.UtcNow; } }

    Read the article

  • customized form_for tag in rails

    - by poseid
    I want to make a table within a form by making a new form_tag. The following code in ApplicationHelper fails: module ApplicationHelper class TabularFormBuilder < ActionView::Helpers::FormBuilder # ... code to insert <tr> tags </tr> end def tabular_form_for(name, object = nil, options = nil, &proc) concat("<table>", proc.binding) form_for(name, object, (options||{}).merge(:builder => TabularFormBuilder), &proc) concat("</table>", proc.binding) end end The view I use is: <h1>New project</h1> <% tabular_form_for :project, :builder => ApplicationHelper::TabularFormBuilder do |f| %> <%= f.error_messages %> <%= f.text_field :name %> <%= f.text_area :description %> <%= f.text_field :location %> <%= f.submit 'Create' %> <% end %> The error I get is: NoMethodError in Projects#new Showing app/views/projects/new.html.erb where line #5 raised: undefined method `errors' for {:builder=ApplicationHelper::TabularFormBuilder}:Hash Any ideas how to make this custom tag work?

    Read the article

  • LINQ to SQL Converter

    - by user609511
    How can I convert My LINQ to SQL ? i have this LINQ statement: int LimCol = Convert.ToInt32(LimitColis); result = oListTUP .GroupBy(x => new { x.Item1, x.Item2, x.Item3, x.Item4, x.Item5 }) .Select(g => new { Key = g.Key, Sum = g.Sum(x => x.Item6), Poids = g.Sum(x => x.Item7), }) .Select(p => new { Key = p.Key, Items = Enumerable.Repeat(LimCol, p.Sum / LimCol).Concat(Enumerable.Repeat(p.Sum % LimCol, p.Sum % LimCol > 0 ? 1 : 0)), CalculPoids = p.Poids / Enumerable.Repeat(LimCol, p.Sum / LimCol).Concat(Enumerable.Repeat(p.Sum % LimCol, p.Sum % LimCol > 0 ? 1 : 0)).Count() }) .SelectMany(p => p.Items.Select(i => Tuple.Create(p.Key.Item1, p.Key.Item2, p.Key.Item3, p.Key.Item4, p.Key.Item5, i, p.CalculPoids))) .ToList(); } It works well, but somehow want to push it and it become too complicated, so I want to convert it into Pure SQL. I have tried SQL Profiler and LinqPad, but neither shows me the SQL. How can I see the SQL code from My LINQ ? Thank you in advance.

    Read the article

  • Why can't I use SSL certs imported via Server Admin in a custom Apache install?

    - by morgant
    I've got a couple of Mac OS X 10.6.8 Server web servers that run a custom AMP255 (Apache 2.x, MySQL 5.x, and PHP 5.x) stack installed using MacPorts. We've got a lot of Mac OS X Server servers and generally install SSL certs via Server Admin and they "just work" in the built-in services, however, these web servers have always had SSL certs installed in a non-standard location and used only for Apache. Long story short, we're trying to standardize this part of our administration and install certs via Server Admin, but have run into the following issue: when the certs are installed via Server Admin and referenced in our Apache conf files, Apache then prompts for a password upon trying to start. It does not seem to be any password we know, certainly not the admin or keychain passwords! We've added the _www user to the certusers (mainly just to ensure they have the proper access to the private key in /etc/certificates/). So, with the custom installed certs we have the following files (basically just pasted in from the company we purchase our certs from): -rw-r--r-- 1 root admin 1395 Apr 10 11:22 *.domain.tld.ca -rw-r--r-- 1 root admin 1656 Apr 10 11:21 *.domain.tld.cert -rw-r--r-- 1 root admin 1680 Apr 10 11:22 *.domain.tld.key And the following in the VirtualHost in /opt/local/apache2/conf/extra/httpd-ssl.conf: SSLCertificateFile /path/to/certs/*.domain.tld.cert SSLCertificateKeyFile /path/to/certs/*.domain.tld.key SSLCACertificateFile /path/to/certs/*.domain.tld.ca This setup functions normally. If we use the certs installed via Server Admin, which both Server Admin & Keychain Assistant show as valid, they're installed in /etc/certificates/ as follows: -rw-r--r-- 1 root wheel 1655 Apr 9 13:44 *.domain.tld.SOMELONGHASH.cert.pem -rw-r--r-- 1 root wheel 4266 Apr 9 13:44 *.domain.tld.SOMELONGHASH.chain.pem -rw-r----- 1 root certusers 3406 Apr 9 13:44 *.domain.tld.SOMELONGHASH.concat.pem -rw-r----- 1 root certusers 1751 Apr 9 13:44 *.domain.tld.SOMELONGHASH.key.pem And if we replace the aforementioned lines in our httpd-ssl.conf with the following: SSLCertificateFile /etc/certificates/*.domain.tld.SOMELONGHASH.cert.pem SSLCertificateKeyFile /etc/certificates/*.domain.tld.SOMELONGHASH.key.pem SSLCertificateChainFile /etc/certificates/*.domain.tld.SOMELONGHASH.chain.pem This prompts for the unknown password. I have also tried httpd-ssl.conf configured as follows: SSLCertificateFile /etc/certificates/*.domain.tld.SOMELONGHASH.cert.pem SSLCertificateKeyFile /etc/certificates/*.domain.tld.SOMELONGHASH.key.pem SSLCertificateChainFile /etc/certificates/*.domain.tld.SOMELONGHASH.concat.pem And as: SSLCertificateFile /etc/certificates/*.domain.tld.SOMELONGHASH.cert.pem SSLCertificateKeyFile /etc/certificates/*.domain.tld.SOMELONGHASH.key.pem SSLCACertificateFile /etc/certificates/*.domain.tld.SOMELONGHASH.chain.pem We've verified that the certificate is configured to allow all applications access it (in Keychain Assistant). A diff of the /etc/certificates/*.domain.tld.SOMELONGHASH.key.pem & *.domain.tld.key files shows the former is encrypted and the latter is not, so we're assuming that Server Admin/Keychain Assistant is encrypting them for some reason. I know I can create an unencrypted key file as follows: sudo openssl rsa -in /etc/certificates/*.domain.tld.SOMELONGHASH.key.pem -out /etc/certificates/*.domain.tld.SOMELONGHASH.key.no_password.pem But, I can't do that without entering the password. I thought maybe I could export an unencrypted copy of the key from Keychain Admin, but I'm not seeing such an option (not to mention that the .pem options are greyed out in all export options). Any assistance would be greatly appreciated.

    Read the article

  • Concatenation of a 2 second silence audio with a normal audio not working

    - by user1665130
    I have a code for concatenation of files using ffmpeg.Here silence.wav is a mute audio file with 2 seconds length. I need to prepend this mut audio file to REC00096_Jun-06-2014 16.47.28.wav. I tried the folowing code. ffmpeg -i D:\vishnu\silence.wav -i D:\vishnu\REC00096_Jun-06-2014 16.47.28.wav \-filter_complex '[0:0][1:0][2:0][3:0]concat=n=2:v=0:a=1[out]' \-map '[out]' output.wav Following is the error i am getting. D:\vishnu>ffmpeg -i silence.wav -i "D:\vishnu\REC00096_Jun-06-2014 16.47.28.wav" -filter_complex '[0:0][1:0][2:0][3:0]concat=n=2:v=0:a=1[out]' -map '[out]' outp ut.wav ffmpeg version N-59036-g5d8e4f6 Copyright (c) 2000-2013 the FFmpeg developers built on Dec 12 2013 22:01:01 with gcc 4.8.2 (GCC) configuration: --enable-gpl --enable-version3 --disable-w32threads --enable-av isynth --enable-bzlib --enable-fontconfig --enable-frei0r --enable-gnutls --enab le-iconv --enable-libass --enable-libbluray --enable-libcaca --enable-libfreetyp e --enable-libgsm --enable-libilbc --enable-libmodplug --enable-libmp3lame --ena ble-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-l ibopus --enable-librtmp --enable-libschroedinger --enable-libsoxr --enable-libsp eex --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvo-aa cenc --enable-libvo-amrwbenc --enable-libvorbis --enable-libvpx --enable-libwavp ack --enable-libx264 --enable-libxavs --enable-libxvid --enable-zlib libavutil 52. 58.100 / 52. 58.100 libavcodec 55. 45.101 / 55. 45.101 libavformat 55. 22.100 / 55. 22.100 libavdevice 55. 5.102 / 55. 5.102 libavfilter 3. 92.100 / 3. 92.100 libswscale 2. 5.101 / 2. 5.101 libswresample 0. 17.104 / 0. 17.104 libpostproc 52. 3.100 / 52. 3.100 Input #0, wav, from 'silence.wav': Metadata: encoder : Lavf55.22.100 Duration: 00:00:02.02, bitrate: 4234 kb/s Stream #0:0: Audio: pcm_s16le ([1][0][0][0] / 0x0001), 44100 Hz, 5.1, s16, 4 233 kb/s Guessed Channel Layout for Input Stream #1.0 : mono Input #1, wav, from 'D:\vishnu\REC00096_Jun-06-2014 16.47.28.wav': Duration: 00:00:08.04, bitrate: 384 kb/s Stream #1:0: Audio: pcm_s16le ([1][0][0][0] / 0x0001), 24000 Hz, mono, s16, 384 kb/s [wav @ 036f5e40] Invalid stream specifier: '[out]'. Last message repeated 1 times Stream map ''[out]'' matches no streams. D:\vishnu>

    Read the article

  • XSL unique values per node per position

    - by Nathan Colin
    this get ever more complicated :) now i face another issue in last question we managed to take unique values from only one parent node now with: <?xml version="1.0" encoding="ISO-8859-1"?> <roots> <root> <name>first</name> <item> <something>A</something> <something>A</something> </item> <item> <something>B</something> <something>A</something> </item> <item> <something>C</something> <something>P</something> </item> <item> <something>A</something> <something>L</something> </item> <item> <something>A</something> <something>A</something> </item> <item> <something>B</something> <something>A</something> </item> <item> <something>D</something> <something>A</something> </item> </root> <root> <name>second</name> <item> <something>E</something> <something>A</something> </item> <item> <something>B</something> <something>A</something> </item> <item> <something>F</something> <something>A</something> </item> <item> <something>A</something> <something>A</something> </item> <item> <something>A</something> <something>A</something> </item> <item> <something>B</something> <something>H</something> </item> <item> <something>D</something> <something>G</something> </item> </root> </roots> now i need to get the unique values depending only from one node before but just from the elements on the second position <?xml version="1.0" encoding="ISO-8859-1"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:output indent="yes" method="text"/> <xsl:key name="item-by-value" match="something" use="concat(normalize-space(.), ' ', generate-id(./ancestor::root))"/> <xsl:key name="rootkey" match="root" use="name"/> <xsl:template match="/"> <xsl:for-each select="key('rootkey','first')"> <xsl:for-each select="item/something[1]"> <xsl:sort /> <xsl:if test="generate-id() = generate-id(key('item-by-value', concat(normalize-space(.), ' ', generate-id(./ancestor::root))))"> <xsl:value-of select="."/> </xsl:if> </xsl:for-each> <xsl:text>_________</xsl:text> <xsl:for-each select="item/something[2]"> <xsl:sort /> <xsl:if test="generate-id() = generate-id(key('item-by-value', concat(normalize-space(.), ' ', generate-id(./ancestor::root))))"> <xsl:value-of select="."/> </xsl:if> </xsl:for-each> </xsl:for-each> </xsl:template> </xsl:stylesheet> with this XSL i get ABCD__LP where the result i need is ABCD__ALP any ideas?

    Read the article

  • What is the exception in java code? [closed]

    - by Karandeep Singh
    This java code is for reverse the string but it returning concat null with returned string. import java.util.*; import java.util.logging.Level; import java.util.logging.Logger; public class Practice { public static void main(String[] args) { String str = ""; try { str = reverse("Singh"); } catch (Exception ex) { Logger.getLogger(Practice.class.getName()).log(Level.SEVERE, null, ex); System.out.print(ex.getMessage()); }finally{ System.out.println(str); } } public static String reverse(String str) throws Exception{ String temp = null; if(str.length()<=0){ throw new Exception("empty"); }else{ for(int i=str.length()-1;i>=0;i--){ temp+=str.charAt(i); } } return temp.trim(); } } Output: nullhgniS

    Read the article

  • After the upgrading to 13.10, I can't input Japanese and Chinese in Emacs

    - by oda
    I have just upgraded Ubuntu from 13.04 to 13.10. It seems iBus have been made big changes.Then I just go to system setting - text entry settings - add "Chinese pinyin" and "Japanese anty" input method. It works well when I input Chinese or Japanese in terminal or .txt file. But when I want to input Chinese and Japanese in Emacs. Even though I have enable ibus-mode in the buffer and change to Chinese pinyin or Japanese anty input method. It just output the English word. Below is the ibus configure in .emacs.By the way, It works well before I upgrade Ubuntu to 13.10 and Emacs to 24.3.1. (add-to-list 'load-path (concat my-emacs-path "/ibus-el-0.3.2")) ;;(setq ibus-python-shell-command-name "python2.7") (require 'ibus) ;; Turn on ibus-mode automatically after loading .emacs (add-hook 'after-init-hook 'ibus-mode-on) (setq ibus-cursor-color '("red" "blue" "limegreen"))

    Read the article

  • Visual Tree Enumeration

    - by codingbloke
    I feel compelled to post this blog because I find I’m repeatedly posting this same code in silverlight and windows-phone-7 answers in Stackoverflow. One common task that we feel we need to do is burrow into the visual tree in a Silverlight or Windows Phone 7 application (actually more recently I found myself doing this in WPF as well).  This allows access to details that aren’t exposed directly by some controls.  A good example of this sort of requirement is found in the “Restoring exact scroll position of a listbox in Windows Phone 7”  question on stackoverflow.  This required that the scroll position of the scroll viewer internal to a listbox be accessed. A caveat One caveat here is that we should seriously challenge the need for this burrowing since it may indicate that there is a design problem.  Burrowing into the visual tree or indeed burrowing out to containing ancestors could represent significant coupling between module boundaries and that generally isn’t a good idea. Why isn’t this idea just not cast aside as a no-no?  Well the whole concept of a “Templated Control”, which are in extensive use in these applications, opens the coupling between the content of the visual tree and the internal code of a control.   For example, I can completely change the appearance and positioning of elements that make up a ComboBox.  The ComboBox control relies on specific template parts having set names of a specified type being present in my template.  Rightly or wrongly this does kind of give license to writing code that has similar coupling. Hasn’t this been done already? Yes it has.  There are number of blogs already out there with similar solutions.  In fact if you are using Silverlight toolkit the VisualTreeExtensions class already provides this feature.  However I prefer my specific code because of the simplicity principle I hold to.  Only write the minimum code necessary to give all the features needed.  In this case I add just two extension methods Ancestors and Descendents, note I don’t bother with “Get” or “Visual” prefixes.  Also I haven’t added Parent or Children methods nor additional “AndSelf” methods because all but Children is achievable with the addition of some other Linq methods.  I decided to give Descendents an additional overload for depth hence a depth of 1 is equivalent to Children but this overload is a little more flexible than simply Children. So here is the code:- VisualTreeEnumeration public static class VisualTreeEnumeration {     public static IEnumerable<DependencyObject> Descendents(this DependencyObject root, int depth)     {         int count = VisualTreeHelper.GetChildrenCount(root);         for (int i = 0; i < count; i++)         {             var child = VisualTreeHelper.GetChild(root, i);             yield return child;             if (depth > 0)             {                 foreach (var descendent in Descendents(child, --depth))                     yield return descendent;             }         }     }     public static IEnumerable<DependencyObject> Descendents(this DependencyObject root)     {         return Descendents(root, Int32.MaxValue);     }     public static IEnumerable<DependencyObject> Ancestors(this DependencyObject root)     {         DependencyObject current = VisualTreeHelper.GetParent(root);         while (current != null)         {             yield return current;             current = VisualTreeHelper.GetParent(current);         }     } }   Usage examples The following are some examples of how to combine the above extension methods with Linq to generate the other axis scenarios that tree traversal code might require. Missing Axis Scenarios var parent = control.Ancestors().Take(1).FirstOrDefault(); var children = control.Descendents(1); var previousSiblings = control.Ancestors().Take(1)     .SelectMany(p => p.Descendents(1).TakeWhile(c => c != control)); var followingSiblings = control.Ancestors().Take(1)     .SelectMany(p => p.Descendents(1).SkipWhile(c => c != control).Skip(1)); var ancestorsAndSelf = Enumerable.Repeat((DependencyObject)control, 1)     .Concat(control.Ancestors()); var descendentsAndSelf = Enumerable.Repeat((DependencyObject)control, 1)     .Concat(control.Descendents()); You might ask why I don’t just include these in the VisualTreeEnumerator.  I don’t on the principle of only including code that is actually needed.  If you find that one or more of the above  is needed in your code then go ahead and create additional methods.  One of the downsides to Extension methods is that they can make finding the method you actually want in intellisense harder. Here are some real world usage scenarios for these methods:- Real World Scenarios //Gets the internal scrollviewer of a ListBox ScrollViewer sv = someListBox.Descendents().OfType<ScrollViewer>().FirstOrDefault(); // Get all text boxes in current UserControl:- var textBoxes = this.Descendents().OfType<TextBox>(); // All UIElement direct children of the layout root grid:- var topLevelElements = LayoutRoot.Descendents(0).OfType<UIElement>(); // Find the containing `ListBoxItem` for a UIElement:- var container = elem.Ancestors().OfType<ListBoxItem>().FirstOrDefault(); // Seek a button with the name "PinkElephants" even if outside of the current Namescope:- var pinkElephantsButton = this.Descendents()     .OfType<Button>()     .FirstOrDefault(b => b.Name == "PinkElephants"); //Clear all checkboxes with the name "Selector" in a Treeview foreach (CheckBox checkBox in elem.Descendents()     .OfType<CheckBox>().Where(c => c.Name == "Selector")) {     checkBox.IsChecked = false; }   The last couple of examples above demonstrate a common requirement of finding controls that have a specific name.  FindName will often not find these controls because they exist in a different namescope. Hope you find this useful, if not I’m just glad to be able to link to this blog in future stackoverflow answers.

    Read the article

  • Insane load average after reboot

    - by Gazzer
    After doing a reboot of Ubuntu server 12.04 LTS (after an apt-get dist-upgrade) my server load (on a 16GB) machine goes insane (around 80) for about 10 or 15 minutes The only things I can think of are these two processes: /usr/bin/mysql --defaults-file=/etc/mysql/debian.cnf --skip-column-names --batch -e ? select concat('select count(*) into @discard from `',? TABLE_SCHEMA, '`.`', TABLE_NAME, '`') ? from information_schema.TABLES where ENGINE='MyISAM' /usr/bin/mysql --defaults-file=/etc/mysql/debian.cnf --skip-column-names --silent --batch --force -e select count(*) into @discard from `information_schema`.`PARTITIONS` Is this normal?

    Read the article

  • SQL Concatenate

    - by Bunch
    Concatenating output from a SELECT statement is a pretty basic thing to do in SQL. The main ways to perform this would be to use either the CONCAT() function, the || operator or the + operator. It really all depends on which version of SQL you are using. The following examples use T-SQL (MS SQL Server 2005) so it uses the + operator but other SQL versions have similar syntax. If you wanted to join two fields together for a full name: SELECT (lname + ', ' + fname) AS Name FROM tblCustomers To add some static text to a value: SELECT (lname + ' - SS') AS Name FROM tblPlayers WHERE PlayerPosition = 6 Or to select some text and an integer together: SELECT (lname + cast(playerNumber as varchar) AS Name FORM tblPlayers Technorati Tags: SQL

    Read the article

  • query in codeIgniter style

    - by troy
    I have below query: SET @sql = NULL ; SELECT GROUP_CONCAT( DISTINCT CONCAT( 'select latitude,longitude,max(serverTime) as serverTime,', deviceID, ' AS device from d', deviceID, '_gps' ) SEPARATOR ' UNION ALL ' ) INTO @sql FROM devices WHERE accountID =2; PREPARE stmt FROM @sql ; EXECUTE stmt; Can someone help me to write the above query in codeIgniter style.... ANd another thing is :What is the difference between writing the query in 1 and 2 formats 1. $query = $this->db->query('YOUR QUERY HERE'); 2. $this->db->select("..."); $this->db->from(); $this->db->where(); Will it have any effect on performance if we use 2nd style... Thank You

    Read the article

  • mysql replace accented characters

    - by pixeline
    Hi, i would like to generate strict alphanumeric character logins from users' first and lastname. Since many of them are foreigners, their names have special characters (é, è, ï, ...). I would like to remove the accents (e,e,i,...) in the logins. Here is my query. Is there a character set that does not contain accents? UPDATE contacts SET login=CONVERT(LOWER(CONCAT(firstname,'.',lastname)) USING utf8);

    Read the article

  • Toplink Exception, whats wrong?

    - by java_dude
    Hey, I've got an excpetion when I generate this EJB SQL Statement. Exception Description: Syntax error parsing the query [SELECT h FROM Busmodul h WHERE LOWER(h.modulNummer) LIKE :modulnummer AND h.einbauort.id = :einbauort_fk AND h.plattform.id = :plattform_fk ORDER BY TRIM(TRAILING '-' FROM CONCAT('0', h.modulNummer))], line 1, column 150: syntax error at [TRIM]. Internal Exception: line 1:150: expecting IDENT, found 'TRIM' Whats the meaning of IDENT. Any Ideas what I am doing wrong? Regards

    Read the article

  • Could not find function: resolve-uri

    - by Nisarg Mehta
    When i am trying to transform xml it gives me erro that Could not find function: resolve-uri where resolve-uri is a xpath function . below is my xslt line which will use resolve uri function . <xsl:variable name="filename" select="resolve-uri(concat($dir,'/',$xmlFileName,'_',position(),'.xml'))" /> Can anybody please help me.Is it because of xslt version difference ? Thanks in Advance.

    Read the article

  • SQLSTATE[HY093]: Invalid parameter number: mixed named and positional parameters

    - by Gremo
    Weird error and this is driving me crazy all the day. To me it seems a bug because there are no positional parameters in my query. Here is the method: public function getAll(User $user, DateTime $start = null, DateTime $end = null) { $params = array('user_id' => $user->getId()); $rsm = new \Doctrine\ORM\Query\ResultSetMapping(); // Result set mapping $rsm->addScalarResult('subtype', 'subtype'); $rsm->addScalarResult('count', 'count'); $sms_sql = "SELECT CONCAT('sms_', IF(is_auto = 0, 'user' , 'auto')) AS subtype, " . "SUM(messages_count * (customers_count + recipients_count)) AS count " . "FROM outgoing_message AS m INNER JOIN small_text_message AS s ON " . "m.id = s.id WHERE status <> 'pending' AND user_id = :user_id"; $news_sql = "SELECT CONCAT('news_', IF(is_auto = 0, 'user' , 'auto')) AS subtype, " . "SUM(customers_count + recipients_count) AS count " . "FROM outgoing_message AS m JOIN newsletter AS n ON m.id = n.id " . "WHERE status <> 'pending' AND user_id = :user_id"; if($start) : $sms_sql .= " AND sent_at >= :start"; $news_sql .= " AND sent_at >= :start"; $params['start'] = $start->format('Y-m-d'); endif; $sms_sql .= ' GROUP BY type, is_auto'; $news_sql .= ' GROUP BY type, is_auto'; return $this->_em->createNativeQuery("$sms_sql UNION ALL $news_sql", $rsm) >setParameters($params)->getResult(); } And this throws the exception: SQLSTATE[HY093]: Invalid parameter number: mixed named and positional parameters Array $arams is OK and so generated SQL: var_dump($params); array (size=2) 'user_id' => int 1 'start' => string '2012-01-01' (length=10) Strangest thing is that it works with "$sms_sql" only! Any help would make my day, thanks. Update Found another strange thing. If i change only the name (to start_date instead of start): if($start) : $sms_sql .= " AND sent_at >= :start_date"; $news_sql .= " AND sent_at >= :start_date"; $params['start_date'] = $start->format('Y-m-d'); endif; What happens is that Doctrine/PDO says: SQLSTATE[42S22]: Column not found: 1054 Unknown column 'sent1rt_date' in 'where clause' ... as string 1rt was added in the middle of the column name! Crazy...

    Read the article

  • Optimizing Haskell code

    - by Masse
    I'm trying to learn Haskell and after an article in reddit about Markov text chains, I decided to implement Markov text generation first in Python and now in Haskell. However I noticed that my python implementation is way faster than the Haskell version, even Haskell is compiled to native code. I am wondering what I should do to make the Haskell code run faster and for now I believe it's so much slower because of using Data.Map instead of hashmaps, but I'm not sure I'll post the Python code and Haskell as well. With the same data, Python takes around 3 seconds and Haskell is closer to 16 seconds. It comes without saying that I'll take any constructive criticism :). import random import re import cPickle class Markov: def __init__(self, filenames): self.filenames = filenames self.cache = self.train(self.readfiles()) picklefd = open("dump", "w") cPickle.dump(self.cache, picklefd) picklefd.close() def train(self, text): splitted = re.findall(r"(\w+|[.!?',])", text) print "Total of %d splitted words" % (len(splitted)) cache = {} for i in xrange(len(splitted)-2): pair = (splitted[i], splitted[i+1]) followup = splitted[i+2] if pair in cache: if followup not in cache[pair]: cache[pair][followup] = 1 else: cache[pair][followup] += 1 else: cache[pair] = {followup: 1} return cache def readfiles(self): data = "" for filename in self.filenames: fd = open(filename) data += fd.read() fd.close() return data def concat(self, words): sentence = "" for word in words: if word in "'\",?!:;.": sentence = sentence[0:-1] + word + " " else: sentence += word + " " return sentence def pickword(self, words): temp = [(k, words[k]) for k in words] results = [] for (word, n) in temp: results.append(word) if n > 1: for i in xrange(n-1): results.append(word) return random.choice(results) def gentext(self, words): allwords = [k for k in self.cache] (first, second) = random.choice(filter(lambda (a,b): a.istitle(), [k for k in self.cache])) sentence = [first, second] while len(sentence) < words or sentence[-1] is not ".": current = (sentence[-2], sentence[-1]) if current in self.cache: followup = self.pickword(self.cache[current]) sentence.append(followup) else: print "Wasn't able to. Breaking" break print self.concat(sentence) Markov(["76.txt"]) -- module Markov ( train , fox ) where import Debug.Trace import qualified Data.Map as M import qualified System.Random as R import qualified Data.ByteString.Char8 as B type Database = M.Map (B.ByteString, B.ByteString) (M.Map B.ByteString Int) train :: [B.ByteString] -> Database train (x:y:[]) = M.empty train (x:y:z:xs) = let l = train (y:z:xs) in M.insertWith' (\new old -> M.insertWith' (+) z 1 old) (x, y) (M.singleton z 1) `seq` l main = do contents <- B.readFile "76.txt" print $ train $ B.words contents fox="The quick brown fox jumps over the brown fox who is slow jumps over the brown fox who is dead."

    Read the article

  • mysql select update

    - by Tillebeck
    Got this: Table a ID RelatedBs 1 NULL 2 NULL Table b AID ID 1 1 1 2 1 3 2 4 2 5 2 6 Need Table a to have a comma separated list as given in table b. And then table b will become obsolete: Table a ID RelatedBs 1 1,2,3 2 4,5,6 This does not rund through all records, but just ad one 'b' to 'table a' UPDATE a, b SET relatedbs = CONCAT(relatedbs,',',b.id) WHERE a.id = b.aid

    Read the article

  • Why does this query only select a single row?

    - by Joe
    SELECT * FROM tbl_houses WHERE (SELECT HousesList FROM tbl_lists WHERE tbl_lists.ID = '123') LIKE CONCAT('% ', tbl_houses.ID, '#') It only selects the row from tbl_houses of the last occuring tbl_houses.ID inside tbl_lists.HousesList I need it to select all the rows where any ID from tbl_houses exists within tbl_lists.HousesList

    Read the article

  • Cleanest way to build an SQL string in Java

    - by Vidar
    I want to build an SQL string to do database manipulation (updates, deletes, inserts, selects, that sort of thing) - instead of the awful string concat method using millions of "+"'s and quotes which is unreadable at best - there must be a better way. I did think of using MessageFormat - but its supposed to be used for user messages, although I think it would do a reasonable job - but I guess there should be something more aligned to SQL type operations in the java sql libraries. Would Groovy be any good? Any help much appreciated.

    Read the article

< Previous Page | 3 4 5 6 7 8 9 10 11 12 13 14  | Next Page >