Daily Archives

Articles indexed Monday March 8 2010

Page 11/124 | < Previous Page | 7 8 9 10 11 12 13 14 15 16 17 18  | Next Page >

  • Adding Volcanos and Options - Earthquake Locator, part 2

    - by Bobby Diaz
    Since volcanos are often associated with earthquakes, and vice versa, I decided to show recent volcanic activity on the Earthquake Locator map.  I am pulling the data from a website created for a joint project between the Smithsonian's Global Volcanism Program and the US Geological Survey's Volcano Hazards Program, found here.  They provide a Weekly Volcanic Activity Report as an RSS feed.   I started implementing this new functionality by creating a new Volcano entity in the domain model and adding the following to the EarthquakeService class (I also factored out the common reading/parsing helper methods to a separate FeedReader class that can be used by multiple domain service classes):           private static readonly string VolcanoFeedUrl =             ConfigurationManager.AppSettings["VolcanoFeedUrl"];           /// <summary>         /// Gets the volcano data for the previous week.         /// </summary>         /// <returns>A queryable collection of <see cref="Volcano"/> objects.</returns>         public IQueryable<Volcano> GetVolcanos()         {             var feed = FeedReader.Load(VolcanoFeedUrl);             var list = new List<Volcano>();               if ( feed != null )             {                 foreach ( var item in feed.Items )                 {                     var quake = CreateVolcano(item);                     if ( quake != null )                     {                         list.Add(quake);                     }                 }             }               return list.AsQueryable();         }           /// <summary>         /// Creates a <see cref="Volcano"/> object for each item in the RSS feed.         /// </summary>         /// <param name="item">The RSS item.</param>         /// <returns></returns>         private Volcano CreateVolcano(SyndicationItem item)         {             Volcano volcano = null;             string title = item.Title.Text;             string desc = item.Summary.Text;             double? latitude = null;             double? longitude = null;               FeedReader.GetGeoRssPoint(item, out latitude, out longitude);               if ( !String.IsNullOrEmpty(title) )             {                 title = title.Substring(0, title.IndexOf('-'));             }             if ( !String.IsNullOrEmpty(desc) )             {                 desc = String.Join("\n\n", desc                         .Replace("<p>", "")                         .Split(                             new string[] { "</p>" },                             StringSplitOptions.RemoveEmptyEntries)                         .Select(s => s.Trim())                         .ToArray())                         .Trim();             }               if ( latitude != null && longitude != null )             {                 volcano = new Volcano()                 {                     Id = item.Id,                     Title = title,                     Description = desc,                     Url = item.Links.Select(l => l.Uri.OriginalString).FirstOrDefault(),                     Latitude = latitude.GetValueOrDefault(),                     Longitude = longitude.GetValueOrDefault()                 };             }               return volcano;         } I then added the corresponding LoadVolcanos() method and Volcanos collection to the EarthquakeViewModel class in much the same way I did with the Earthquakes in my previous article in this series. Now that I am starting to add more information to the map, I wanted to give the user some options as to what is displayed and allowing them to choose what gets turned off.  I have updated the MainPage.xaml to look like this:   <UserControl x:Class="EarthquakeLocator.MainPage"     xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"     xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"     xmlns:d="http://schemas.microsoft.com/expression/blend/2008"     xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"     xmlns:basic="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls"     xmlns:bing="clr-namespace:Microsoft.Maps.MapControl;assembly=Microsoft.Maps.MapControl"     xmlns:vm="clr-namespace:EarthquakeLocator.ViewModel"     mc:Ignorable="d" d:DesignWidth="640" d:DesignHeight="480" >     <UserControl.Resources>         <DataTemplate x:Key="EarthquakeTemplate">             <Ellipse Fill="Red" Stroke="Black" StrokeThickness="1"                      Width="{Binding Size}" Height="{Binding Size}"                      bing:MapLayer.Position="{Binding Location}"                      bing:MapLayer.PositionOrigin="Center">                 <ToolTipService.ToolTip>                     <StackPanel>                         <TextBlock Text="{Binding Title}" FontSize="14" FontWeight="Bold" />                         <TextBlock Text="{Binding UtcTime}" />                         <TextBlock Text="{Binding LocalTime}" />                         <TextBlock Text="{Binding DepthDesc}" />                     </StackPanel>                 </ToolTipService.ToolTip>             </Ellipse>         </DataTemplate>           <DataTemplate x:Key="VolcanoTemplate">             <Polygon Fill="Gold" Stroke="Black" StrokeThickness="1" Points="0,10 5,0 10,10"                      bing:MapLayer.Position="{Binding Location}"                      bing:MapLayer.PositionOrigin="Center"                      MouseLeftButtonUp="Volcano_MouseLeftButtonUp">                 <ToolTipService.ToolTip>                     <StackPanel>                         <TextBlock Text="{Binding Title}" FontSize="14" FontWeight="Bold" />                         <TextBlock Text="Click icon for more information..." />                     </StackPanel>                 </ToolTipService.ToolTip>             </Polygon>         </DataTemplate>     </UserControl.Resources>       <UserControl.DataContext>         <vm:EarthquakeViewModel AutoLoadData="True" />     </UserControl.DataContext>       <Grid x:Name="LayoutRoot">           <bing:Map x:Name="map" CredentialsProvider="--Your-Bing-Maps-Key--"                   Center="{Binding MapCenter, Mode=TwoWay}"                   ZoomLevel="{Binding ZoomLevel, Mode=TwoWay}">               <bing:MapItemsControl ItemsSource="{Binding Earthquakes}"                                   ItemTemplate="{StaticResource EarthquakeTemplate}" />               <bing:MapItemsControl ItemsSource="{Binding Volcanos}"                                   ItemTemplate="{StaticResource VolcanoTemplate}" />         </bing:Map>           <basic:TabControl x:Name="tabs" VerticalAlignment="Bottom" MaxHeight="25" Opacity="0.7">             <basic:TabItem Margin="90,0,-90,0" MouseLeftButtonUp="TabItem_MouseLeftButtonUp">                 <basic:TabItem.Header>                     <TextBlock x:Name="txtHeader" Text="Options"                                FontSize="13" FontWeight="Bold" />                 </basic:TabItem.Header>                   <StackPanel Orientation="Horizontal">                     <TextBlock Text="Earthquakes:" FontWeight="Bold" Margin="3" />                     <StackPanel Margin="3">                         <CheckBox Content=" &lt; 4.0"                                   IsChecked="{Binding ShowLt4, Mode=TwoWay}" />                         <CheckBox Content="4.0 - 4.9"                                   IsChecked="{Binding Show4s, Mode=TwoWay}" />                         <CheckBox Content="5.0 - 5.9"                                   IsChecked="{Binding Show5s, Mode=TwoWay}" />                     </StackPanel>                       <StackPanel Margin="10,3,3,3">                         <CheckBox Content="6.0 - 6.9"                                   IsChecked="{Binding Show6s, Mode=TwoWay}" />                         <CheckBox Content="7.0 - 7.9"                                   IsChecked="{Binding Show7s, Mode=TwoWay}" />                         <CheckBox Content="8.0 +"                                   IsChecked="{Binding ShowGe8, Mode=TwoWay}" />                     </StackPanel>                       <TextBlock Text="Other:" FontWeight="Bold" Margin="50,3,3,3" />                     <StackPanel Margin="3">                         <CheckBox Content="Volcanos"                                   IsChecked="{Binding ShowVolcanos, Mode=TwoWay}" />                     </StackPanel>                 </StackPanel>               </basic:TabItem>         </basic:TabControl>       </Grid> </UserControl> Notice that I added a VolcanoTemplate that uses a triangle-shaped Polygon to represent the Volcano locations, and I also added a second <bing:MapItemsControl /> tag to the map to bind to the Volcanos collection.  The TabControl found below the map houses the options panel that will present the user with several checkboxes so they can filter the different points based on type and other properties (i.e. Magnitude).  Initially, the TabItem is collapsed to reduce it's footprint, but the screen shot below shows the options panel expanded to reveal the available settings:     I have updated the Source Code and Live Demo to include these new features.   Happy Mapping!

    Read the article

  • SQLAuthority News SQL SERVER 2008 R2 Pricing

    I was recently asked question about SQL Server 2008 pricing. I have bookmarked official site here which lists the pricing.Official site: What’s New in SQL Server 2008 R2 EditionsEditionsPer Processor PricingRetailPer Server Plus CAL PricingRetailParallel Data Warehouse$57,498Not offered via Server CALDatacenter $57,498Not offered via Server CALEnterprise$28,749$13,969 with 25 CALsStandard $7,499$1,849 with 5 CALsHowever, I have [...]...Did you know that DotNetSlackers also publishes .net articles written by top known .net Authors? We already have over 80 articles in several categories including Silverlight. Take a look: here.

    Read the article

  • OpenVPN Problems, connecting with Windows OpenVPC client to Linux OpenVPN

    - by Filip Ekberg
    After following this guide and connecting to the VPN Server, I get the following error: Sat Mar 06 19:43:08 2010 us=127000 NOTE: failed to obtain options consistency info from peer -- this could occur if the remote peer is running a version of OpenVPN before 1.5-beta8 or if there is a network connectivity problem, and will not necessarily prevent OpenVPN from running (0 bytes received from peer, 0 bytes authenticated data channel traffic) -- you can disable the options consistency check with --disable-occ. I am using Archlinux and installed openvpn with Pacman. I want to acheive the following: Connect to the VPN Server, being able to route certain made up hosts through it. Is this possible? openvpn --version gives me the following openvpn --version OpenVPN 2.1.1 i686-pc-linux-gnu [SSL] [LZO2] [EPOLL] built on Jan 31 2010 Originally developed by James Yonan Copyright (C) 2002-2009 OpenVPN Technologies, Inc. <[email protected]> Suggestions?

    Read the article

  • Headers and Chapters in Word 2007

    - by Jonas Gorauskas
    I have a single word document with 92 different chapters in it. I need to insert a header on every single page which has a chapter number on the far top right of the page. So for a few pages that number remains the same and then when the chapter changes the number on the header needs to increment. I have fiddled with headers in Word 2007 and can't make it work. Then I tried to break the document into sections and now I am stuck with trying to figure out how to link and unlink sections. Is there a quick and easy to achieve this? One of the requirements for this assignment is that I need to deliver a single document.

    Read the article

  • Turning XSLT into a simple HTML snippet.

    - by jaasum
    http://drp.ly/yeAex <?xml version="1.0" encoding="UTF-8"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:template match="/data/tour/entry"> <img src="{filename}"/> <h2>{heading}</h2> {description} </xsl:template> </xsl:stylesheet> Here is the code I am working with. I am a newbie to XSLT and I suppose I am not understanding how it transforms my XML into HTML entirely. This snippet of code I plan on loading via AJAX, so I really all I need it to output is a blank html document consisting only of these three items. I realize I am omitting the xsl:output tag and that is because I really don't understand how I can get this to just simply match that information to my tags in my xml without adding , tags etc. All it outputs is a string of text in an html document.

    Read the article

  • Strange exception of Httpcore nio in java

    - by bruce dou
    Exception in thread "Thread-0" java.lang.NullPointerException at org.apache.http.impl.nio.reactor.AbstractIOReactor.closeActiveChannels(AbstractIOReactor.java:532) at org.apache.http.impl.nio.reactor.AbstractIOReactor.hardShutdown(AbstractIOReactor.java:564) at org.apache.http.impl.nio.reactor.AbstractMultiworkerIOReactor.doShutdown(AbstractMultiworkerIOReactor.java:411) at org.apache.http.impl.nio.reactor.AbstractMultiworkerIOReactor.execute(AbstractMultiworkerIOReactor.java:340) at com.***.clawer.Clawer$1.run(Clawer.java:81) at java.lang.Thread.run(Unknown Source) Exception in thread "Thread-1" java.lang.IllegalStateException: I/O reactor has been shut down at org.apache.http.impl.nio.reactor.DefaultConnectingIOReactor.connect(DefaultConnectingIOReactor.java:190) at com.***.clawer.Run.run(Run.java:29)

    Read the article

  • Do WebSockets have exclusive access to their sockets?

    - by Aoriste
    I'm curious to know if, after a WebSocket has been established (after having received the proper handshake from a server that supports them), whether or not the TCP socket used by the "WebSocket connection" is used exclusively by the WebSocket, or if the browser may still make regular HTTP requests with it. It only makes sense to me that WebSockets would have exclusive use of their TCP sockets, but I don't remember having read in any of the documentation that such is the case.

    Read the article

  • Nginx and Passenger deploy issue

    - by merlin
    Currently I can only get the default nginx page to come up on my domain name. I am pretty sure the error is either in the /etc/hosts file or the enginx.config file. my /etc/hosts file is 127.0.0.1 localhost.localdomain localhost myip server.mydomain.com server and nginx.config is: server { listen 80; server_name server.mydomain.com; root /whatever/pulic; passenger_enabled on; rails_env production; I don't get any errors in the log. Incidentally I can run mongrel and on mydomain:3000 see the application there.

    Read the article

  • jquery form validation plugin need help?

    - by python
    </tr> for ($i = 0; $i < $dm_numrec; $i++) { ?> <tr> <td width="266" height="28" valign="top"> <input type="text" name="recommend_to_name<?php echo $i;?>" /> </td> <td height="28" valign="top"> <input type="text" name="recommend_to_email<?php echo $i;?> />" </td> </tr> I used jquery form validation plugin http://bassistance.de/jquery-plugins/jquery-plugin-validation/ <script src="jquery.min.js"></script> <script src="jquery.validate.min.js"></script> <script> $(document).ready(function(){ $('#recommend').validate({ 'rules':{ 'recommend_to_name':'required', 'recommend_to_email':{ 'required':true, 'email':true }, } }); }); </script> How can I validate for the recommend_to_name that its name is a dynamic string from loop: recommend_to_name0 recommend_to_name1 recommend_to_name2 recommend_to_name..

    Read the article

  • how to reduce 2d array

    - by owca
    I have a 2d array, let's say like this : 2 0 8 9 3 0 -1 20 13 12 17 18 1 2 3 4 2 0 7 9 How to create an array reduced by let's say 2nd row and third column? 2 0 9 13 12 18 1 2 4 2 0 9

    Read the article

  • Nitrogen: changing targetID breaks lightbox

    - by dewd
    I'm using Nitrogen & lightbox. I'm looking for some guidance after spending way too long trying to understand why a working example breaks as soon as I change the targetID of a lightbox. The fragment below works if I use "name_dialog" or "share_dialog", but not if I use "compose_dialog". I've looked through the source and style sheets, but have not found where those two are defined any differently than what I'm trying to do. In my .hrl: ... -record (compose_dialog, { ?ELEMENT_BASE(compose_dialog_element) }). .. In my element module: ... reflect() -> record_info(fields, compose_dialog). render_element(_HtmlID, _Record) -> #lightbox { id=compose_lightbox, style="display: none;", body = [ .. show() -> wf:wire(compose_lightbox, #show {}).

    Read the article

  • How to convert DateTime to a number with a precision greater than days in T-SQL?

    - by Jader Dias
    Both queries below translates to the same number SELECT CONVERT(bigint,CONVERT(datetime,'2009-06-15 15:00:00')) SELECT CAST(CONVERT(datetime,'2009-06-15 23:01:00') as bigint) Result 39978 39978 The generated number will be different only if the days are different. There is any way to convert the DateTime to a more precise number, as we do in .NET with the .Ticks property? I need at least a minute precision.

    Read the article

  • Simulating mouse clicks on Mac OSX does not work for some applications.

    - by Thomi
    Hi, I'm writing an App for Mac OSX 10.6 and later in C++. One part of theapp needs to simulate mouse movement and mouse clicks. I do this currently by posting CGEvent objects using CGEventPost(kCGHIDEventTap, event);. This works, for the msot part - I can simulate mouse movement and clicks just fine, but it seems to fail in some areas. For example: In Mozilla firefox & Safari, I can click on all the menus, but cannot click on a link within a website. When I try, the link is highlighted, but the browser never follows the link. However, I can right-click on a link, select "open link in new tab", and everything works as expected. I can click on the "Dashboard" icon to brink up the dashboard, but I cannot click on the "i" button on any of the dashboard widgets. This inconsistency is along application boundaries - Does anyone have any idea what the cause might be?

    Read the article

  • Swig typecast to derived class?

    - by Zack
    I notice that Swig provides a whole host of functions to allow for typecasting objects to their parent classes. However, in C++ one can produce a function like the following: A * getAnObject() { if(someBoolean) return (A *) new B; else return (A *) new C; } Where "A" is the parent of classes "B" and "C". One can then typecast the pointer returned into being a "B" type or "C" type at one's convenience like: B * some_var = (B *) getAnObject(); Is there some way I can typecast an object I've received from a generic-pointer-producing function at run-time in the scripting language using the wrappers? (In my case, Lua?) I have a function that could produce one of about a hundred possible classes, and I'd like to avoid writing an enormous switch structure that I'd have to maintain in C++. At the point where I receive the generic pointer, I also have a string representation of the data type I'd like to cast it to. Any thoughts? Thanks! -- EDIT -- I notice that SWIG offers to generate copy constructors for all of my classes. If I had it generate those, could I do something like the following?: var = myModule.getAnObject(); -- Function that returns an object type-cast down to a pointer of the parent class, as in the function getAnObject() above. var = myModule.ClassThatExtendsBaseClass(var); -- A copy constructor that SWIG theoretically creates for me and have var then be an instance of the inheriting class that knows it's an instance of the inheriting class?

    Read the article

  • Converting from One Class to another Class using Xml Serialization in C#

    - by nrk
    Hi, In our project we are consuming WCF webservices exposed at Central location as services with basicHttpBinding. In client desktop application we need consume those webservices. I am able to generate proxy class using WSDL.exe. But, I need to convert data/class given by the webservice into my local class, for that now I am xmlserialzing those class/objects given by webservice and deserializing into my local classes as both classes schema matches exactly same. Is there any better way that I can follow? or Do I need to assign each property from one class to another? thanks nRk.

    Read the article

  • Making HABTM relationships unique in CakePHP

    - by Andrea
    I have two models, called Book and Tag, which are in a HABTM relationship. I want a couple (book, tag) to be saved only once. In my models I have var $hasAndBelongsToMany = array( 'Tag' => array( 'className' => 'Tag', 'joinTable' => 'books_tags', 'foreignKey' => 'book_id', 'associationForeignKey' => 'tag_id', 'unique' => true ) ); and viceversa, but the Unique flag does not help me; I can still save two times the same couple. How do I do this in CakePHP? Should I declare the couple (book, tag) unique in the database directly, or will this make CakePHP go nuts? Is there a Cakey way to handle this situation? EDIT: I tried making the couple unique with the query (I'm using MySQL) ALTER TABLE books_tags ADD UNIQUE (book_id,tag_id); but this does not work well. When I save more than one tag at a time, everything goes well if all the couples are new. If at least one of the couples is repeated, CakePHP fails to do the whole operation, so it does not save ANY new couple (not even the good ones).

    Read the article

  • C# - setting a property by reflection with a string value

    - by David Hodgson
    Hi, I'd like to set a property of an object through reflection, with a value of type string. So, for instance, suppose I have a Ship class, with a property of Latitude, which is a double. Here's what I'd like to do: Ship ship = new Ship(); string value = "5.5"; PropertyInfo propertyInfo = ship.GetType().GetProperty("Latitude"); propertyInfo.SetValue(ship, value, null); As is, this throws an Argument exception (Object of type 'System.String' cannot be converted to type 'System.Double'). How can I convert value to the proper type, based on propertyInfo?

    Read the article

  • difference between Convert.ToInt32 and (int)

    - by balalakshmi
    the following syntax throws an compile time error like Cannot convert type 'string' to 'int' string name=(Session["name1"].ToString()); int i = (int)name; whereas the code below compiles and executes successfully string name=(Session["name1"].ToString()); int i = Convert.ToInt32(name); I would like to know 1) why the compile time error occurs in first code 2) what's the difference between the 2 code snippets

    Read the article

  • General type conversion without risking Exceptions

    - by Mongus Pong
    I am working on a control that can take a number of different datatypes (anything that implements IComparable). I need to be able to compare these with another variable passed in. If the main datatype is a DateTime, and I am passed a String, I need to attempt to convert the String to a DateTime to perform a Date comparison. if the String cannot be converted to a DateTime then do a String comparison. So I need a general way to attempt to convert from any type to any type. Easy enough, .Net provides us with the TypeConverter class. Now, the best I can work out to do to determine if the String can be converted to a DateTime is to use exceptions. If the ConvertFrom raises an exception, I know I cant do the conversion and have to do the string comparison. The following is the best I got : string theString = "99/12/2009"; DateTime theDate = new DateTime ( 2009, 11, 1 ); IComparable obj1 = theString as IComparable; IComparable obj2 = theDate as IComparable; try { TypeConverter converter = TypeDescriptor.GetConverter ( obj2.GetType () ); if ( converter.CanConvertFrom ( obj1.GetType () ) ) { Console.WriteLine ( obj2.CompareTo ( converter.ConvertFrom ( obj1 ) ) ); Console.WriteLine ( "Date comparison" ); } } catch ( FormatException ) { Console.WriteLine ( obj1.ToString ().CompareTo ( obj2.ToString () ) ); Console.WriteLine ( "String comparison" ); } Part of our standards at work state that : Exceptions should only be raised when an Exception situation - ie. an error is encountered. But this is not an exceptional situation. I need another way around it. Most variable types have a TryParse method which returns a boolean to allow you to determine if the conversion has succeeded or not. But there is no TryConvert method available to TypeConverter. CanConvertFrom only dermines if it is possible to convert between these types and doesnt consider the actual data to be converted. The IsValid method is also useless. Any ideas? EDIT I cannot use AS and IS. I do not know either data types at compile time. So I dont know what to As and Is to!!! EDIT Ok nailed the bastard. Its not as tidy as Marc Gravells, but it works (I hope). Thanks for the inpiration Marc. Will work on tidying it up when I get the time, but I've got a bit stack of bugfixes that I have to get on with. public static class CleanConverter { /// <summary> /// Stores the cache of all types that can be converted to all types. /// </summary> private static Dictionary<Type, Dictionary<Type, ConversionCache>> _Types = new Dictionary<Type, Dictionary<Type, ConversionCache>> (); /// <summary> /// Try parsing. /// </summary> /// <param name="s"></param> /// <param name="value"></param> /// <returns></returns> public static bool TryParse ( IComparable s, ref IComparable value ) { // First get the cached conversion method. Dictionary<Type, ConversionCache> type1Cache = null; ConversionCache type2Cache = null; if ( !_Types.ContainsKey ( s.GetType () ) ) { type1Cache = new Dictionary<Type, ConversionCache> (); _Types.Add ( s.GetType (), type1Cache ); } else { type1Cache = _Types[s.GetType ()]; } if ( !type1Cache.ContainsKey ( value.GetType () ) ) { // We havent converted this type before, so create a new conversion type2Cache = new ConversionCache ( s.GetType (), value.GetType () ); // Add to the cache type1Cache.Add ( value.GetType (), type2Cache ); } else { type2Cache = type1Cache[value.GetType ()]; } // Attempt the parse return type2Cache.TryParse ( s, ref value ); } /// <summary> /// Stores the method to convert from Type1 to Type2 /// </summary> internal class ConversionCache { internal bool TryParse ( IComparable s, ref IComparable value ) { if ( this._Method != null ) { // Invoke the cached TryParse method. object[] parameters = new object[] { s, value }; bool result = (bool)this._Method.Invoke ( null, parameters); if ( result ) value = parameters[1] as IComparable; return result; } else return false; } private MethodInfo _Method; internal ConversionCache ( Type type1, Type type2 ) { // Use reflection to get the TryParse method from it. this._Method = type2.GetMethod ( "TryParse", new Type[] { type1, type2.MakeByRefType () } ); } } }

    Read the article

  • Reserve RAM in C

    - by petersmith221
    Hi I need ideas on how to write a C program that reserve a specified amount of MB RAM until a key [ex. the any key] is pressed on a Linux 2.6 32 bit system. * /.eat_ram.out 200 # If free -m is execute at this time, it should report 200 MB more in the used section, than before running the program. [Any key is pressed] # Now all the reserved RAM should be released and the program exits. * It is the core functionality of the program [reserving the RAM] i do not know how to do, getting arguments from the commandline, printing [Any key is pressed] and so on is not a problem from me. Any ideas on how to do this?

    Read the article

< Previous Page | 7 8 9 10 11 12 13 14 15 16 17 18  | Next Page >