Search Results

Search found 1555 results on 63 pages for 'scott f'.

Page 39/63 | < Previous Page | 35 36 37 38 39 40 41 42 43 44 45 46  | Next Page >

  • jQuery equivalent of PHP's file_exists()?

    - by Scott B
    In the code snippet below, from my jQuery setup, I need to check if the image file actually exists and if not, I'd like to substitute a default image. Currently if the file does not exist, I just get a broken image placeholder... $('#myTheme').change ( function() { var myImage = $('#myTheme :selected').text(); $('.selectedImage img').attr('src','../wp-content/themes/myTheme/styles/'+myImage+'/screenshot.jpg'); //if screenshot.jpg does not exist, use "../../default.jpg" instead } );

    Read the article

  • Creating a custom categories widget

    - by Scott B
    The code below is an attempt to take the WP_Widget_Categories class and use it as the basis for a custom categories widget based on the default categories widget. I'm getting no output however and the widget is not showing up in the "Available Widgets" listing. What am I doing wrong? <?php /* Plugin Name: My Categories Widget Version: 1.0 */ class MY_Widget_Categories extends WP_Widget { function MY_Widget_Categories() { $widget_ops = array( 'classname' => 'widget_categories', 'description' => __( "A list or dropdown of categories" ) ); $this->WP_Widget('categories', __('Categories'), $widget_ops); } function widget( $args, $instance ) { extract( $args ); $title = apply_filters('widget_title', empty( $instance['title'] ) ? __( 'Categories' ) : $instance['title']); $c = $instance['count'] ? '1' : '0'; $h = $instance['hierarchical'] ? '1' : '0'; $d = $instance['dropdown'] ? '1' : '0'; echo $before_widget; if ( $title ) echo $before_title . $title . $after_title; $cat_args = array('orderby' => 'name', 'show_count' => $c, 'hierarchical' => $h); if ( $d ) { $cat_args['show_option_none'] = __('Select Category'); wp_dropdown_categories(apply_filters('widget_categories_dropdown_args', $cat_args)); ?> <script type='text/javascript'> /* <![CDATA[ */ var dropdown = document.getElementById("cat"); function onCatChange() { if ( dropdown.options[dropdown.selectedIndex].value > 0 ) { location.href = "<?php echo get_option('home'); ?>/?cat="+dropdown.options[dropdown.selectedIndex].value; } } dropdown.onchange = onCatChange; /* ]]> */ </script> <?php } else { ?> <ul> <?php $cat_args['title_li'] = ''; wp_list_categories(apply_filters('widget_categories_args', $cat_args)); ?> </ul> <?php } echo $after_widget; } function update( $new_instance, $old_instance ) { $instance = $old_instance; $instance['title'] = strip_tags($new_instance['title']); $instance['count'] = $new_instance['count'] ? 1 : 0; $instance['hierarchical'] = $new_instance['hierarchical'] ? 1 : 0; $instance['dropdown'] = $new_instance['dropdown'] ? 1 : 0; return $instance; } function form( $instance ) { //Defaults $instance = wp_parse_args( (array) $instance, array( 'title' => '') ); $title = esc_attr( $instance['title'] ); $count = isset($instance['count']) ? (bool) $instance['count'] :false; $hierarchical = isset( $instance['hierarchical'] ) ? (bool) $instance['hierarchical'] : false; $dropdown = isset( $instance['dropdown'] ) ? (bool) $instance['dropdown'] : false; ?> <p><label for="<?php echo $this->get_field_id('title'); ?>"><?php _e( 'Title:' ); ?></label> <input class="widefat" id="<?php echo $this->get_field_id('title'); ?>" name="<?php echo $this->get_field_name('title'); ?>" type="text" value="<?php echo $title; ?>" /></p> <p><input type="checkbox" class="checkbox" id="<?php echo $this->get_field_id('dropdown'); ?>" name="<?php echo $this->get_field_name('dropdown'); ?>"<?php checked( $dropdown ); ?> /> <label for="<?php echo $this->get_field_id('dropdown'); ?>"><?php _e( 'Show as dropdown' ); ?></label><br /> <input type="checkbox" class="checkbox" id="<?php echo $this->get_field_id('count'); ?>" name="<?php echo $this->get_field_name('count'); ?>"<?php checked( $count ); ?> /> <label for="<?php echo $this->get_field_id('count'); ?>"><?php _e( 'Show post counts' ); ?></label><br /> <input type="checkbox" class="checkbox" id="<?php echo $this->get_field_id('hierarchical'); ?>" name="<?php echo $this->get_field_name('hierarchical'); ?>"<?php checked( $hierarchical ); ?> /> <label for="<?php echo $this->get_field_id('hierarchical'); ?>"><?php _e( 'Show hierarchy' ); ?></label></p> <?php } } function my_categories_init() { register_sidebar_widget(__('My Categories Widget'), 'MY_Widget_Categories'); } add_action("plugins_loaded", "my_categories_init"); ?>

    Read the article

  • Foreach loop and tasks.

    - by Scott Chamberlain
    I know from the codeing guidlines that I have read you should not do for (int i = 0; i < 5; i++) { Task.Factory.StartNew(() => Console.WriteLine(i)); } Console.ReadLine(); as it will write 5 5's, I understand that and I think i understand why it is happening. I know the solution is just to do for (int i = 0; i < 5; i++) { int localI = i; Task.Factory.StartNew(() => Console.WriteLine(localI)); } Console.ReadLine(); However is something like this ok to do? foreach (MyClass myClass in myClassList) { Task.Factory.StartNew(() => myClass.DoAction()); } Console.ReadLine(); Or do I need to do the same thing I did in the for loop. foreach (MyClass myClass in myClassList) { MyClass localMyClass = myClass; Task.Factory.StartNew(() => localMyClass.DoAction()); } Console.ReadLine();

    Read the article

  • Context.Items.Add on an XML return type?

    - by Scott Schluer
    So I have the following code contained within an HttpModule in an application I've been asked to support: app.Context.Response.ContentType = "text/xml"; app.Context.Items.Add("IpixRoomId", ipixRoomId); app.Context.Items.Add("IpixId", ipixId); app.Context.Response.Cache.SetCacheability(HttpCacheability.NoCache); app.Context.RewritePath(rewriteUrl, true); What's the purpose of adding data to Context.Items when the content type is XML? EDIT: For clarification, I'm calling up this URL: http://website.com/virtualtour/1971/6284/panorama2flash.swf I assume the SWF file (I know very little about Flash) makes another call to http://website.com/virtualtour/config.xml. The code I pasted above only executes on calls to config.xml. So since it's only the SWF file and config.xml being requested from the server, I'm a little confused. Can the .SWF file have access to HttpContext.Current.Items? Other than the HttpModule, there is no .NET involved in the code, it's a straight request to the SWF file which triggers a call to config.xml but it seems that those Context.Items contain the data needed to make the SWF file display the right virtual tour. I'm just missing where that link happens. It can't happen in the XML, so maybe in Flash?

    Read the article

  • How do I dynamically import a module in App Engine?

    - by Scott Ferguson
    I'm trying to dynamically load a class from a specific module (called 'commands') and the code runs totally cool on my local setup running from a local Django server. This bombs out though when I deploy to Google App Engine. I've tried adding the commands module's parent module to the import as well with no avail (on either setup in that case). Here's the code: mod = __import__('commands.%s' % command, globals(), locals(), [command]) return getattr(mod, command) App Engine just throws an ImportError whenever it hits this. And the clarify, it doesn't bomb out on the commands module. If I have a command like 'commands.cat' it can't find 'cat'.

    Read the article

  • Why are my bound parameters all identical (using Linq)?

    - by Scott Stafford
    When I run this snippet of code: string[] words = new string[] { "foo", "bar" }; var results = from row in Assets select row; foreach (string word in words) { results = results.Where(row => row.Name.Contains(word)); } I get this SQL: -- Region Parameters DECLARE @p0 VarChar(5) = '%bar%' DECLARE @p1 VarChar(5) = '%bar%' -- EndRegion SELECT ... FROM [Assets] AS [t0] WHERE ([t0].[Name] LIKE @p0) AND ([t0].[Name] LIKE @p1) Note that @p0 and @p1 are both bar, when I wanted them to be foo and bar. I guess Linq is somehow binding a reference to the variable word rather than a reference to the string currently referenced by word? What is the best way to avoid this problem? (Also, if you have any suggestions for a better title for this question, please put it in the comments.) Note that I tried this with regular Linq also, with the same results (you can paste this right into Linqpad): string[] words = new string[] { "f", "a" }; string[] dictionary = new string[] { "foo", "bar", "jack", "splat" }; var results = from row in dictionary select row; foreach (string word in words) { results = results.Where(row => row.Contains(word)); } results.Dump(); Dumps: bar jack splat

    Read the article

  • jQuery carousel click updates selected item in a select list?

    - by Scott B
    I'm trying to hook up the click event on a jQuery image carousel's images so that it updates a select list in the same document and sets the "selected" option to match the item that was clicked in the carousel. The "title" attribute on each of the carousel images matches at least one option in the select list (title is always unique). For example: 1) carousel image titles are: image1, image2, image3 <div id="carousel"> <ul> <li><img src='folder1/screenshot.jpg' title=image1 /></li> <li><img src='folder2/screenshot.jpg' title=image2 /></li> <li><img src='folder3/screenshot.jpg' title=image3 /></li> </ul> </div> 2) select list options are... <select id="myThumbs"> <option>image1</option> <option selected="selected">image2</option> <option>image3</option> </select> My existing code is below, which already binds the hover event to a preview div outside the carousel. I want to keep this behavior, and also add the click behavior to update the selected item in the options list so that it matches the title of the carousel image that was clicked. $(function() { $("#carousel").jCarouselLite({ btnNext: ".next", btnPrev: ".prev", visible: 6, mouseWheel: true, speed: 700 }); $('#carousel').show(); $('#myThumbs').change(function() { var myImage = $('#myThumbs :selected').text(); $('.selectedImage img').attr('src','../wp-content/themes/mytheme/styles/'+myImage+'/screenshot.jpg'); }); $('#carousel ul li').click(function(e) { var myOption = $(this).children('img').attr('title'); $('#myThumbs').addOption('Text', myOption); }); $('#carousel ul li').hover(function(e) { var img_src = $(this).children('img').attr('src'); $('.selectedImage img').attr('src',img_src); } ,function() { $('.selectedImage img').attr('src', '<?php echo $selectedThumb; ?>');}); });

    Read the article

  • IIS7 URL Rewriting: How not to drop HTTPS protocol from rewritten URL?

    - by Scott Mitchell
    I'm working on a website that's using IIS 7's URL rewriting feature to do a permanent redirect from example.com to www.example.com, as well as rewrites from similar domain names to the "main" one, such as from www.examples.com to www.example.com. This rewrite rule - shown below - has worked well for sometime now. However, we recently added HTTPS support and noticed that if users visit one of the URLs to be rewritten to www.example.com then HTTPS is dropped. For instance, if a user visits https://example.com they get redirected to http://www.example.com, whereas we would like them to be sent to https://www.example.com. Here is the rewrite rule of interest (in Web.config): <rule name="Canonical Host Name" stopProcessing="true"> <match url="(.*)" /> <conditions logicalGrouping="MatchAny"> <add input="{HTTP_HOST}" pattern="^example\.com$" /> <add input="{HTTP_HOST}" pattern="^(www\.)?example\.net$" /> <add input="{HTTP_HOST}" pattern="^(www\.)?example\.info$" /> <add input="{HTTP_HOST}" pattern="^(www\.)?examples\.com$" /> </conditions> <action type="Redirect" url="http://www.example.com/{R:1}" redirectType="Permanent" /> </rule> As you can see, the action element's url attribute points directly to http://, so I get why https://example.com is redirected to http://www.example.com. My question is, how do I fix this? I tried (naively) to just drop the http:// part from the url attribute, but that didn't work. Thanks!

    Read the article

  • The Stackoverflow alert box, How is it done?

    - by Scott
    Question says it all. Can someone point me to an example of how they do the alerts at the top when a new message arrives or someone posts to my answers or I just have a notification.. Thanks. P.s. I would love a JQUERY solution, but can work with just a js solution.

    Read the article

  • Adding fields to Django form dynamically (and cleanly)

    - by scott
    Hey guys, I know this question has been brought up numerous times, but I'm not quite getting the full implementation. As you can see below, I've got a form that I can dynamically tell how many rows to create. How can I create an "Add Row" link that tells the view how many rows to create? I would really like to do it without augmenting the url... # views.py def myView(request): if request.method == "POST": form = MyForm(request.POST, num_rows=1) if form.is_valid(): return render_to_response('myform_result.html', context_instance=RequestContext(request)) else: form = MyForm(num_rows=1) return render_to_response('myform.html', {'form':form}, context_instance=RequestContext(request)) # forms.py class MyForm(forms.Form): def __init__(self, *args, **kwargs): num_rows = kwargs.pop('num_rows',1) super(MyForm, self).__init__(*args, **kwargs) for row in range(0, num_rows): field = forms.CharField(label="Row") self.fields[str(row)] = field # myform.html http://example.com/myform <form action="." method="POST" accept-charset="utf-8"> <ul> {% for field in form %} <li style="margin-top:.25em"> <span class="normal">{{ field.label }}</span> {{ field }} <span class="formError">{{ field.errors }}</span> </li> {% endfor %} </ul> <input type="submit" value="Save"> </form> <a href="ADD_ANOTHER_ROW?">+ Add Row</a>

    Read the article

  • Python/Numpy - Save Array with Column AND Row Titles

    - by Scott B
    I want to save a 2D array to a CSV file with row and column "header" information (like a table). I know that I could use the header argument to numpy.savetxt to save the column names, but is there any easy way to also include some other array (or list) as the first column of data (like row titles)? Below is an example of how I currently do it. Is there a better way to include those row titles, perhaps some trick with savetxt I'm unaware of? import csv import numpy as np data = np.arange(12).reshape(3,4) # Add a '' for the first column because the row titles go there... cols = ['', 'col1', 'col2', 'col3', 'col4'] rows = ['row1', 'row2', 'row3'] with open('test.csv', 'wb') as f: writer = csv.writer(f) writer.writerow(cols) for row_title, data_row in zip(rows, data): writer.writerow([row_title] + data_row.tolist())

    Read the article

  • just started getting the "validation of viewstate mac" error

    - by Scott J.
    I have had a site up and running for quite a while, but I've just started getting the MAC failed error. Quite often too. While coding tonight I've noticed it 4 times or so. The host (through someone else) changed servers and we've had a bunch of issues. This started happening since then. What are all the possibilities that it could be on the server end that I could ask? (I don't know all that much about IIS). Thanks!

    Read the article

  • Creating a image viewer window controll.

    - by Scott Chamberlain
    I am learning GDI+ and I am trying to make a display window with scroll bars (so I can only see part of the image at a time and I can scroll around it). I have read through the basics of GDI+ from several books but I have not found any good tutorials online or in books available to me about doing more advanced things like this. Any recommendations on guides or example code on how do do this? Here is what I have so far protected override void OnPaint(PaintEventArgs e) { base.OnPaint(e); if (Label != null) { using (Bitmap drawnLabel = new Bitmap(Label.LabelHeight, Label.LableLength, System.Drawing.Imaging.PixelFormat.Format1bppIndexed)) using (Graphics drawBuffer = Graphics.FromImage(drawnLabel)) { drawBuffer.ScaleTransform(_ImageScaleFactor, _ImageScaleFactor); foreach (Epl2.IDrawableCommand cmd in Label.Collection) { cmd.Paint(drawBuffer); } drawBuffer.ResetTransform(); } } } I would like to paint this in to a PictureBox I have on the control and control what is shown by a VScrollBar and HScrollBar but I don't know how to do that step. P.S. Label is a custom class that I have in my namespace, it is a object that represents a label you would print from a label printer.

    Read the article

  • Should I still use querystrings for page number, etc, when using ASP.NET 4 URL Routing?

    - by Scott
    I am switching from Intelligencia's UrlRewriter to the new web forms routing in ASP.NET 4.0. I have it working great for basic pages, however, in my e-commerce site, when browsing category pages, I previously used querystrings that were built into my pager control to control paging. An old url (with UrlRewriting) would be: http://www.mysite.com/Category/Arts-and-Crafts_17 I now have a MapPageRoute defined in global.asax as: routes.MapPageRoute("category-browse", "Category/{name}_{id}", ~/CategoryPage.aspx"); This works great. Now, somebody clicks to go to page 2. Previously I would have just tacked on ?page=2 as the querystring. Now, How do I handle this using web forms routing? I know I can do something like: http://www.mysite.com/Category/Arts-and-Crafts_17/page/2 But in addition to page, I can have filters, age ranges, gender, etc. Should I just keep defining routes that handle these variables, or should I continue using querystrings and can I define a route that allows me to use my querstrings like before?

    Read the article

  • How does Contract.Exists add value?

    - by Scott Bilas
    I am just starting to learn about the code contracts library that comes standard with VS2010. One thing I am running into right away is what some of the contract clauses really mean. For example, how are these two statements different? Contract.Requires(!mycollection.Any(a => a.ID == newID)); Contract.Requires(!Contract.Exists(mycollection, a => a.ID == newID)); In other words, what does Contract.Exists do in practical purposes, either for a developer using my function, or for the static code analysis system?

    Read the article

  • Can XSD elements have more than one <annotation>?

    - by Scott
    I have a common data schema in XSD that is used by two different applications, A and B, each uses the data differently. I want to document the different business rules per application. Can I do this? <xs:complexType name="Account"> <xs:annotation app="A"> <xs:documentation> The Account entity must be used this way for app A </xs:documentation> </xs:annotation> <xs:annotation app="B"> <xs:documentation> The Account entity must be used this way for app B </xs:documentation> </xs:annotation> <xs:complexContent> ...

    Read the article

  • ASP.NET MVC loading of CSS based off of controller

    - by Scott
    Within my site I have controller specific CSS files in addition to my master css file. For example CSS/ Prodcuts/ product.css ... Blog/ blog.css ... masterStyle.css Where masterStyle.css is the master css file. What I want to do is when the user hits http://www.example.com/Products/ only mySite.css and all css files under Products get included. What is the best way to go about doing this?

    Read the article

  • Remove specific string from multiple database rows in SQL

    - by Scott
    I have a column that contains page titles, which has the website name appended to the end of each. (e.g. Product Name | Company Name Inc.) I would like to remove the " | Company Name Inc." from multiple rows simultaneously. What SQl query commands (or query itself) would allow me to accomplish this? To re-illustrate, I want to convert multiple rows of 1 column from this: Product Name | Company Name Inc. To this: Product Name

    Read the article

  • Telling me my stored procedure isn't declared

    - by Scott
    Here is where the error is occuring in the stack: public static IKSList<DataParameter> Search(int categoryID, int departmentID, string title) { Database db = new Database(DatabaseConfig.CommonConnString, DatabaseConfig.CommonSchemaOwner, "pkg_data_params_new", "spdata_params_search"); db.AddParameter("category_id", categoryID); db.AddParameter("department_id", departmentID); db.AddParameter("title", title, title.Length); DataView temp = db.Execute_DataView(); IKSList<DataParameter> dps = new IKSList<DataParameter>(); foreach (DataRow dr in temp.Table.Rows) { DataParameter dp = new DataParameter(); dp.Load(dr); dps.Add(dp); } return dps; } And here is the error text: ORA-06550: line 1, column 38: PLS-00302: component 'SPDATA_PARAMS_SEARCH' must be declared ORA-06550: line 1, column 7: PL/SQL: Statement ignored Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. Exception Details: System.Data.OracleClient.OracleException: ORA-06550: line 1, column 38: PLS-00302: component 'SPDATA_PARAMS_SEARCH' must be declared ORA-06550: line 1, column 7: PL/SQL: Statement ignored Source Error: Line 161: db.AddParameter("title", title, title.Length); Line 162: Line 163: DataView temp = db.Execute_DataView(); Line 164: Line 165: IKSList dps = new IKSList(); My webconfig is pointing to the correct place and everything so idk where this is coming from.

    Read the article

  • PHP: parse URL for matching directory /somedirectory/ and execute conditional code

    - by Scott B
    This has to be pretty simple, but I'd like to parse the current URL and execute conditional code depending on whether the user is on the /sitemap/ directory. So for example, if the site is example.com, and if the request is example.com/sitemap/. Then I want to execute conditional code in that case. I'm using wordpress so I'm not sure if there is a built-in function that gets this... A pure PHP solution is fine.

    Read the article

  • change svn message editor

    - by Scott
    So my co-worker felt it necessary to go onto my development box and do some code changes, then submit his work to subversion. I never set the commit message editor, and all of a sudden, one day I forgot to add the -m handle and apparently he set the default editor to emacs. Being that I don't know the first thing about emacs and prefer vim myself, how do I go about changing the default editor for svn commands to vim after it's already been set. I deleted the .subversion directory under the home directory, and it still prompts me.

    Read the article

  • Creating a System.Windows.Controls.Image throws an exception - how do I use the dispatcher to instan

    - by Scott Whitlock
    I'm running my unit tests on a piece of code that does the following in the test: Assert.IsNotNull(target.Icon); Inside the getter for the Icon property, I'm doing this: System.Windows.Controls.Image img = new System.Windows.Controls.Image(); That's throwing this exception: System.InvalidOperationException : The calling thread must be STA, because many UI components require this. I understand what that means, and I understand that I need to use the Dispatcher, but I'm a bit confused about how or why... this is a property of my ViewModel and I don't get any of these exceptions when running the application. Other info: this only started failing when I upgraded to .NET 4.

    Read the article

< Previous Page | 35 36 37 38 39 40 41 42 43 44 45 46  | Next Page >