Search Results

Search found 699 results on 28 pages for 'steven penny'.

Page 19/28 | < Previous Page | 15 16 17 18 19 20 21 22 23 24 25 26  | Next Page >

  • Extension method return using generics

    - by Steven de Salas
    Is it possible to return a generic type using extension methods? For example, I have the following method: // Convenience method to obtain a field within a row (as a double type) public static double GetDouble(this DataRow row, string field) { if (row != null && row.Table.Columns.Contains(field)) { object value = row[field]; if (value != null && value != DBNull.Value) return Convert.ToDouble(value); } return 0; } This is currently used as follows: double value = row.GetDouble("tangible-equity"); but I would like to use the following code: double value = row.Get<double>("tangible-equity"); Is this possible and if so, what would the method look like?

    Read the article

  • Creating collaborative whiteboard drawing application

    - by Steven Sproat
    I have my own drawing program in place, with a variety of "drawing tools" such as Pen, Eraser, Rectangle, Circle, Select, Text etc. It's made with Python and wxPython. Each tool mentioned above is a class, which all have polymorphic methods, such as left_down(), mouse_motion(), hit_test() etc. The program manages a list of all drawn shapes -- when a user has drawn a shape, it's added to the list. This is used to manage undo/redo operations too. So, I have a decent codebase that I can hook collaborative drawing into. Each shape could be changed to know its owner -- the user who drew it, and to only allow delete/move/rescale operations to be performed on shapes owned by one person. I'm just wondering the best way to develop this. One person in the "session" will have to act as the server, I have no money to offer free central servers. Somehow users will need a way to connect to servers, meaning some kind of "discover servers" browser...or something. How do I broadcast changes made to the application? Drawing in realtime and broadcasting a message on each mouse motion event would be costly in terms of performance and things get worse the more users there are at a given time. Any ideas are welcome, I'm not too sure where to begin with developing this (or even how to test it)

    Read the article

  • How I can I get my home network's IP address from a shell script?

    - by Steven Stewart-Gallus
    I have an account at a server at school, and a home computer that I need to work with sometimes. I have exchanged keys, and now only have one problem. While my school account has a name associated with it, "account_name@school", my home network does not. My plan is to have a script that every hour retrieves my home network's IP address, ssh'es into my school account and updates my ssh config file storing my home network's IP address. How can I retrieve my home computer's IP address from a shell script? P.S. Is this a sensible plan?

    Read the article

  • HTTP POST with URL query parameters -- good idea or not?

    - by Steven Huwig
    I'm designing an API to go over HTTP and I am wondering if using the HTTP POST command, but with URL query parameters only and no request body, is a good way to go. Considerations: "Good Web design" requires non-idempotent actions to be sent via POST. This is a non-idempotent action. It is easier to develop and debug this app when the request parameters are present in the URL. The API is not intended for widespread use. It seems like making a POST request with no body will take a bit more work, e.g. a Content-Length: 0 header must be explicitly added. It also seems to me that a POST with no body is a bit counter to most developer's and HTTP frameworks' expectations. Are there any more pitfalls or advantages to sending parameters on a POST request via the URL query rather than the request body? Edit: The reason this is under consideration is that the operations are not idempotent and have side effects other than retrieval. See the HTTP spec: In particular, the convention has been established that the GET and HEAD methods SHOULD NOT have the significance of taking an action other than retrieval. These methods ought to be considered "safe". This allows user agents to represent other methods, such as POST, PUT and DELETE, in a special way, so that the user is made aware of the fact that a possibly unsafe action is being requested. ... Methods can also have the property of "idempotence" in that (aside from error or expiration issues) the side-effects of N 0 identical requests is the same as for a single request. The methods GET, HEAD, PUT and DELETE share this property. Also, the methods OPTIONS and TRACE SHOULD NOT have side effects, and so are inherently idempotent.

    Read the article

  • submitHandler is an invalid label

    - by Steven
    Below is the code, I get an error which says that submitHandler is an invalid label $(document).ready(function() { $("#withdraw").validate({ rules: { amount: { required: true, number:true, min:0, max:<?php echo $balance; ?> } , bank:{ required:true, }, cardnumber1: { required: true, minlength:8 }, cardnumber2:{ required:true, equalTo: "#cardnumber1" }, holder:{ required:true, } } }), submitHandler: function(form){ var answer = confirm("Do you really want to withdraw this amount of money from your account?") if (answer){ form.submit(); } else{ return false; } } }); How to solve this problem?

    Read the article

  • MySQL - How do I insert an additional where clause into this full-text search query

    - by Steven
    I want to add a WHERE clause to a full text search query (to limit to past 24 hours), but wherever I insert it I get Low Level Error. Is it possible to add the clause and if so, how? $query = "SELECT * WHERE story_time > time()-86400 AND MATCH (story_title) AGAINST ('".validate_input($_GET['q'])."' IN BOOLEAN MODE) AS Relevance FROM ".$config['db']['pre']."stories WHERE MATCH (story_title) AGAINST ('+".validate_input($_GET['q'])."' IN BOOLEAN MODE) HAVING Relevance > 0.2 ORDER BY Relevance DESC, story_time DESC LIMIT ".validate_input(($_GET['page']-1)*10).",10";

    Read the article

  • What is the best way of retrieving a specific post in Wordpress?

    - by Steven
    I need to retrieve a specific post to display on my websites front page. To avoid hard coding the post ID, I've added a custom property where I add the post ID. The following code displays the wanted post: (The code is within the LOOP) // Get content from specific post (in this case, Åpningstider post)) $openingHoursID = get_post_meta($post->ID, "apningstider", true); if (!empty($openingHoursID)) { $openingHoursPost = get_post($openingHoursID); $openingHours = $openingHoursPost->post_content; } else $openingHours = "Åpningstid ikke angitt"; <div class="openinghours"><?php echo $openingHours; ?></div> Is there a better / easier way? The output is striped for HTML. How can I maintain HTML?

    Read the article

  • Failing to add different items in combobox on dynamic radiobutton click

    - by Steven Wilson
    I am working on radiobuttons and combobox in my wpf App. Although I am a C++ developer, I recently moved to C#. My app deals with dynamic generation of the above mentioned components. Basically I have created 4 dynamic radiobuttons in my app and on clicking each, i should should add different items to my combobox. Here is the code: XAML: <ItemsControl ItemsSource="{Binding Children}"> <ItemsControl.ItemTemplate> <DataTemplate> <StackPanel Orientation="Vertical" > <RadioButton Content="{Binding RadioBase}" Margin="0,10,0,0" IsChecked="{Binding BaseCheck}" GroupName="SlotGroup" Height="15" Width="80" HorizontalAlignment="Center" VerticalAlignment="Center"/> </StackPanel> </DataTemplate> </ItemsControl.ItemTemplate> </ItemsControl> <ComboBox Visibility="{Binding IsRegisterItemsVisible}" ItemsSource="{Binding RegComboList}" SelectedItem="{Binding SelectedRegComboList, Mode=TwoWay}" SelectedIndex="0" /> FPGARadioWidgetViewModel Class: public ObservableCollection<FPGAViewModel> Children { get; set; } public FPGARadioWidgetViewModel() { Children = new ObservableCollection<FPGAViewModel>(); Children.Add(new FPGAViewModel() { RadioBase = "Base 0x0", ID = 0 }); Children.Add(new FPGAViewModel() { RadioBase = "Base 0x40", ID = 1 }); Children.Add(new FPGAViewModel() { RadioBase = "Base 0x80", ID = 2 }); Children.Add(new FPGAViewModel() { RadioBase = "Base 0xc0", ID = 3 }); } FPGAViewModel Class: private bool sBaseCheck; public bool BaseCheck { get { return this.sBaseCheck; } set { this.sBaseCheck = value; AddComboItems(); this.OnPropertyChanged("BaseCheck"); } } private ObservableCollection<string> _RegComboList; public ObservableCollection<string> RegComboList { get { return _RegComboList; } set { _RegComboList = value; OnPropertyChanged("RegComboList"); } } private void AddComboItems() { int baseRegister = 0x40 * ID; ObservableCollection<string> combo = new ObservableCollection<string>(); for (int i = 0; i < 0x40; i++) { int reg = (i * 8) + baseRegister; combo[i] = "0x" + reg.ToString("X"); } RegComboList = new ObservableCollection<String>(combo); OnPropertyChanged("RegComboList"); } private bool isRegisterItemsVisible = false; public bool IsRegisterItemsVisible { get { return isRegisterItemsVisible; } set { isRegisterItemsVisible = value; OnPropertyChanged("IsRegisterItemsVisible"); OnPropertyChanged("RegComboList"); } } If you notice, on clicking a particular radiobutton, it should add items with different value in combobox based on ID. It has to be made sure that on clicking any radiobutton only the items of that should be added and previous content of combobox should be cleared. I am trying to do the same thing using my above code but nothing seems to appear in combobox when i debug. Please help :)

    Read the article

  • Me As Child Type In General Function

    - by Steven
    I have a MustInherit Parent class with two Child classes which Inherit from the Parent. How can I use (or Cast) Me in a Parent function as the the child type of that instance? EDIT: My actual goal is to be able to serialize (BinaryFormatter.Serialize(Stream, Object)) either of my child classes. However, "repeating the code" in each child "seems" wrong. EDIT2: This is my Serialize function. Where should I implement this function? Copying and pasting to each child doesn't seem right, but casting the parent to a child doesn't seem right either. Public Function Serialize() As Byte() Dim bFmt As New BinaryFormatter() Dim mStr As New MemoryStream() bFmt.Serialize(mStr, Me) Return mStr.ToArray() End Function

    Read the article

  • How to handle Win+Shift+LEft/Right on Win7 with custom WM_GETMINMAXINFO logic?

    - by Steven Robbins
    I have a custom windows implementation in a WPF app that hooks WM_GETMINMAXINFO as follows: private void MaximiseWithTaskbar(System.IntPtr hwnd, System.IntPtr lParam) { MINMAXINFO mmi = (MINMAXINFO)Marshal.PtrToStructure(lParam, typeof(MINMAXINFO)); System.IntPtr monitor = MonitorFromWindow(hwnd, MONITOR_DEFAULTTONEAREST); if (monitor != System.IntPtr.Zero) { MONITORINFO monitorInfo = new MONITORINFO(); GetMonitorInfo(monitor, monitorInfo); RECT rcWorkArea = monitorInfo.rcWork; RECT rcMonitorArea = monitorInfo.rcMonitor; mmi.ptMaxPosition.x = Math.Abs(rcWorkArea.left - rcMonitorArea.left); mmi.ptMaxPosition.y = Math.Abs(rcWorkArea.top - rcMonitorArea.top); mmi.ptMaxSize.x = Math.Abs(rcWorkArea.right - rcWorkArea.left); mmi.ptMaxSize.y = Math.Abs(rcWorkArea.bottom - rcWorkArea.top); mmi.ptMinTrackSize.x = Convert.ToInt16(this.MinWidth * (desktopDpiX / 96)); mmi.ptMinTrackSize.y = Convert.ToInt16(this.MinHeight * (desktopDpiY / 96)); } Marshal.StructureToPtr(mmi, lParam, true); } It all works a treat and it allows me to have a borderless window maximized without having it sit on to of the task bar, which is great, but it really doesn't like being moved between monitors with the new Win7 keyboard shortcuts. Whenever the app is moved with Win+Shift+Left/Right the WM_GETMINMAXINFO message is received, as I'd expect, but MonitorFromWindow(hwnd, MONITOR_DEFAULTTONEAREST) returns the monitor the application has just been moved FROM, rather than the monitor it is moving TO, so if the monitors are of differing resolutions the window end up the wrong size. I'm not sure if there's something else I can call, other then MonitorFromWindow, or whether there's a "moving monitors" message I can hook prior to WM_GETMINMAXINFO. I'm assuming there is a way to do it because "normal" windows work just fine.

    Read the article

  • What's a good way to parameterize "static" content (e.g. CSS) in a Tomcat webapp?

    - by Steven Huwig
    Some of our CSS files contain parameters that can vary based on the deployment location (dev, QA, prod). For example: background: url(#DOJO_PATH#/dijit/themes...) to avoid hardcoding a path to a particular CDN or locally-hosted Dojo installation. These values are textually substituted with the real values by a deployment script, when it copies the contents of the webapp into the Tomcat webapps directory. That way the same deployment archive file (WAR + TAR file containing other configuration) can be deployed to dev, QA, and prod, with the varying parameters provided by environment-specific configuration files. However, I'd like to make the contents of the WAR (including the templatized CSS files) independent of this in-house deployment script. Since we don't really have control over the deployment script, all I can think to do is configure Tomcat with #DOJO_PATH# etc. as environment variables in the application's context.xml, and use Tomcat to insert those parameters into the CSS at runtime. I could make the CSS files into generated JSPs, but it seems a little ugly to me. Moreover, the substitution only needs to be done once per application deployment, so repeatedly dynamically generating the stylesheets using JSP will be rather wasteful. Does anyone have any alternative ideas or tools to use for this? We're committed to Tomcat and to substituting these parameters at deployment or at runtime (that is, not at build time).

    Read the article

  • Is there a "fancy" Ruby way to check whether a local variable is both defined and evaluates to true without using ands and ors?

    - by Steven Xu
    This is quite a quick question. I currently use do_this if (testvar ||= false) Which works just fine. But this approach unnerves me because while fast, it does not short-circuit like defined?(testvar) && testvar does, and it instantiates and assigns a value to a local variable that is subsequently never used, which seems inefficient. I enjoy the very reasonable fact that instance variables are nil before assignment, but I'd like for the situation to be just as easy for local variables.

    Read the article

  • Are their any good way to genrate XML file through C# in .net

    - by steven spielberg
    i wanto make a xml file like <?xml version="1.0" encoding="Windows-1252" ?> <settings> <typeofsetting> <wordname="add" /> </typeofsettings> </settings> the wordname can be depend on what user need. how i can make a application that user can generate the XML file of thing they want. are their any good way to do this. the wordname not user defined it's come from database the application have inbuilt. are their any good practice to do this in c# win-forms.

    Read the article

  • What is the meaning of method class in the class definition in Ruby?

    - by Steven Xu
    I'm familiar with function definitions and variable declarations being in class definitions: public class MyClass { public int myvar; public void doSomething() { } } But what does it "mean" in Ruby when a method is actually called in the class definition? This happens amply in Rails, for instance: class User < ActiveRecord::Base has_many :posts end What exactly does this do (at a lower level than "it adds some methods to the class")? How would I implement such a function (e.g., one that mixes in some additional methods)?

    Read the article

  • Ms Access DB used by website

    - by Steven
    Hi Guys, I have been asked to update a legacy website. I was originally build in asp using a MS Access DB to store some user details. However I am aware that the DB can be downloaded if you use the correct url. What is the best way to stop this without stopping the website having access to the DB? Thanks Sp

    Read the article

  • How to create a level with curved lines with cocos2d + Box2d on the iphone?

    - by Steven
    I'd like to create a game that has levels such as this: http://img169.imageshack.us/img169/7294/picdq.png The Player moves "flies" through the level and mustn't collide with the walls. How can I create such levels? I found that piece of software: http://www.sapusmedia.com/levelsvg/ It's not that cheap, so I wonder whether there is another way to create such a level as shown in the picture above...?

    Read the article

  • Using WCF to expose underlying process

    - by Steven
    I have a server application that spins up and monitors about 8 separate processes that gather data from different systems. The server app then runs some calculations over the aggregated data and stores it in a db. Simple stuff. I now have a requirement to modify the process so that it no longer saves data to the db but rather exposes it directly to clients via WCF. That's cool, I've used WCF a fair bit but I'm struggling a little with it for some reason. Basically my plan is to HOST the WCF service in my application and have calls redirect into the internals of my existing application but I can figure out how to do that without getting the WCF class to encapsulate the existing app. I want the service to inside my current app, not become it. Any suggestions?

    Read the article

< Previous Page | 15 16 17 18 19 20 21 22 23 24 25 26  | Next Page >