Search Results

Search found 148 results on 6 pages for 'gavin brock'.

Page 3/6 | < Previous Page | 1 2 3 4 5 6  | Next Page >

  • Fuzzy Date algorithm in Objective-C

    - by Brock Woolf
    I would like to write a fuzzy date method for calculating dates in Objective-C for iPhone. There is a popular explanation here: http://stackoverflow.com/questions/11/how-do-i-calculate-relative-time However it contains missing arguments. How could this be used in Objective-C?. Thanks. const int SECOND = 1; const int MINUTE = 60 * SECOND; const int HOUR = 60 * MINUTE; const int DAY = 24 * HOUR; const int MONTH = 30 * DAY; if (delta < 1 * MINUTE) { return ts.Seconds == 1 ? "one second ago" : ts.Seconds + " seconds ago"; } if (delta < 2 * MINUTE) { return "a minute ago"; } if (delta < 45 * MINUTE) { return ts.Minutes + " minutes ago"; } if (delta < 90 * MINUTE) { return "an hour ago"; } if (delta < 24 * HOUR) { return ts.Hours + " hours ago"; } if (delta < 48 * HOUR) { return "yesterday"; } if (delta < 30 * DAY) { return ts.Days + " days ago"; } if (delta < 12 * MONTH) { int months = Convert.ToInt32(Math.Floor((double)ts.Days / 30)); return months <= 1 ? "one month ago" : months + " months ago"; } else { int years = Convert.ToInt32(Math.Floor((double)ts.Days / 365)); return years <= 1 ? "one year ago" : years + " years ago"; }

    Read the article

  • Pointer to NSWindow Xib after loading it?

    - by Brock Woolf
    In my code below, CustomWindow is a subclass of NSWindow. CustomWindow *window = [[CustomWindow alloc] init]; if (![NSBundle loadNibNamed:@"NibName" owner:window]) [window center]; // doesn't work How do you get a pointer to control your XIB after you load it so you can do things such as centering the XIB? What am i doing wrong here?

    Read the article

  • In a digital photo, how can I detect if a mountain is obscured by clouds?

    - by Gavin Brock
    The problem I have a collection of digital photos of a mountain in Japan. However the mountain is often obscured by clouds or fog. What techniques can I use to detect that the mountain is visible in the image? I am currently using Perl with the Imager module, but open to alternatives. All the images are taken from the exact same position - these are some samples. My naïve solution I started by taking several horizontal pixel samples of the mountain cone and comparing the brightness values to other samples from the sky. This worked well for differentiating good image 1 and bad image 2. However in the autumn it snowed and the mountain became brighter than the sky, like image 3, and my simple brightness test started to fail. Image 4 is an example of an edge case. I would classify this as a good image since some of the mountain is clearly visible. UPDATE 1 Thank you for the suggestions - I am happy you all vastly over-estimated my competence. Based on the answers, I have started trying the ImageMagick edge-detect transform, which gives me a much simpler image to analyze. convert sample.jpg -edge 1 edge.jpg I assume I should use some kind of masking to get rid of the trees and most of the clouds. Once I have the masked image, what is the best way to compare the similarity to a 'good' image? I guess the "compare" command suited for this job? How do I get a numeric 'similarity' value from this?

    Read the article

  • In a digital photo, detecting if a mountain is obscured by clouds.

    - by Gavin Brock
    The problem I have a collection of digital photos of a mountain in Japan. However the mountain is often obscured by clouds or fog. What techniques can I use to detect that the mountain is visible in the image? I am currently using Perl with the Imager module, but open to alternatives. All the images are taken from the exact same position - these are some samples. My naïve solution I started by taking several horizontal pixel samples of the mountain cone and comparing the brightness values to other samples from the sky. This worked well for differentiating good image 1 and bad image 2. However in the autumn it snowed and the mountain became brighter than the sky, like image 3, and my simple brightness test started to fail. Image 4 is an example of an edge case. I would classify this as a good image since some of the mountain is clearly visible.

    Read the article

  • Using Excel to work with SQL data (read/write)

    - by Tyler Brock
    I have a ton of data in a sql database which I would like to be able to import and display in excel (I can already do this) and additionally modify or append to the dataset within excel and write the changes/additions back to the database. What is the best way to go about doing something like this? Please let me know, thanks!

    Read the article

  • Freemarker template not found

    - by brock
    Hi, I'm currently trying to get Freemarker to work with my application using Spring. No matter what I try I keep getting template not found. I am not sure if I have the configuration set up properly, but it never finds my template. Here is my spring bean config: <bean id="freemarkerConfig" class="org.springframework.web.servlet.view.freemarker.FreeMarkerConfigurer"> <property name="templateLoaderPath" value="/WEB-INF/freemarker/"/> </bean> Whenever I try to call getTemplate on the freemaker configuration it always sends back a template not found error. So if I do configuration.getTemplate("testTemplate.ftl") it always throws an IOException. I'm not sure if anyone has an idea of what I'm doing wrong. Thanks for all your help!

    Read the article

  • Alternative Control Structures

    - by Brock Woolf
    I've been wondering about alternative ways to write control structures. One that you learn early on for if statements is a replacement for this: if ( x ) { // true } else { // false } with this (sometimes this is more readable compared to lots of brackets): x ? true : false It got me thinking. Can we replace anything else incase it's more readable. We of course replace if statements like this: if (a < b) { return true; } else { return false; } with things like this: return a < b; We can save a long if with something like this (pretty much same as the one above): bool xCollisionTrue = (object.xPos < aabb.maxX && object.xPos > aabb.minX); So those are the ones I can think of off the top of my head for the if statement and doing comparisons. So I'm wondering what about looping constructs, for, while, etc. Maybe the code obfuscators might have some ideas.

    Read the article

  • How can I Convert XML to an Object using Spring 3.0 mvc while making RESTful request

    - by brock
    Hi, I'm using the Spring 3.0 RC1 framework and I'm currently testing out Spring mvc. I wanted to use Spring mvc to handle restful requests. I have set up my controller to handle the URI request. I am passing in xml with the request. So on the controller I have a method like follows: public void request(RequestObject request) { doSomething(); } I am having a hard time converting the xml to the RequestObject. I haven't seen much documentation on this and I was wondering if anyone could point me in the right direction. I'm guess that you would have to annotate the RequestObject using JAXB or something in order to tell Spring to convert the xml file to RequestObject but I'm not sure. Thanks for all of your help!!

    Read the article

  • Dynamicly Inject img alt attribute jQuery

    - by Brock
    I need some help, and before we get going, I know it is probably not best practice, but I am doing some maintenance to an existing site and need to accomplish the following for a fix. <a rel="lightbox" href="site.com" title="a generated title"><img src="site.com/img" class="post-image" alt="a long description"/></a> Okay, so I am trying to figure out how to use jQuery or any other method to take the "alt" attribute from my image, and dynamically overwrite the "title" attribute of my "a" tag. Any help would be awesome, I am kinda lost at this juncture.

    Read the article

  • How do I get the window id and tab number of a Terminal window using AppleScript via the ScriptingBr

    - by Gavin Brock
    I can open a Terminal tab using the following AppleScript: tell application "Terminal" set myTab to do script "exec sleep 1" get myTab end tell This returns a string like: tab 1 of window id 3263 of application "Terminal". This is great, I can see the window id 3263 and tab number 1 (although I don't know how to query myTab to get only these values). In the Cocoa ScriptingBridge, I can do: SBApplication *terminal; SBObject *tab; terminal = [SBApplication applicationWithBundleIdentifier:@"com.apple.terminal"] tab = [terminal doScript:@"exec sleep 1" in:nil] How do I get the window id and tab number from the tab object?

    Read the article

  • Initialisation of Objects Syntax question

    - by Brock Woolf
    When I initialise a struct in C (Node is the struct): struct Node { /* Non-Relevant code */ }; This works: Node *rootNode = new Node(); but so does this: Node *rootNode = new Node; Is there a difference, and what is the difference between using () or not using the brackets? Just off memory, I think the same applies above for C++ object initialisations. What is happening here?

    Read the article

  • Greasemonkey is getting an empty document.body on select Google pages.

    - by Brock Adams
    Hi, I have a Greasemonkey script that processes Google search results. But it's failing in a few instances, when xpath searches (and document body) appear to be empty. Running the code in Firebug's console works every time. It only fails in a Greasemonkey script. Greasemonkey sees an empty document.body. I've boiled the problem down to a test, greasemonkey script, below. I'm using Firefox 3.5.9 and Greasemonkey 0.8.20100408.6 (but earlier versions had the same problem). Problem: Greasemonkey sees an empty document.body. Recipe to Duplicate: Install the Greasemonkey script. Open a new tab or window. Navigate to Google.com (http://www.google.com/). Search on a simple term like "cats". Check Firefox's Error console (Ctrl-shift-J) or Firebug's console. The script will report that document body is empty. Hit refresh. The script will show a good result (document body found). Note that the failure only reliably appears on Google results obtained this way, and on a new tab/window. Turn javascript off globally (javascript.enabled set to false in about:config). Repeat steps 2 thru 5. Only now the Greasemonkey script will work. It seems that Google javascript is killing the DOM tree for greasemonkey, somehow. I've tried a time-delayed retest and even a programmatic refresh; the script still fails to see the document body. Test Script: // // ==UserScript== // @name TROUBLESHOOTING 2 snippets // @namespace http://www.google.com/ // @description For code that has funky misfires and defies standard debugging. // @include http://*/* // ==/UserScript== // function LocalMain (sTitle) { var sUserMessage = ''; //var sRawHtml = unsafeWindow.document.body.innerHTML; //-- unsafeWindow makes no difference. var sRawHtml = document.body.innerHTML; if (sRawHtml) { sRawHtml = sRawHtml.replace (/^\s\s*/, ''). substr (0, 60); sUserMessage = sTitle + ', Doc body = ' + sRawHtml + ' ...'; } else { sUserMessage = sTitle + ', Document body seems empty!'; } if (typeof (console) != "undefined") { console.log (sUserMessage); } else { if (typeof (GM_log) != "undefined") GM_log (sUserMessage); else if (!sRawHtml) alert (sUserMessage); } } LocalMain ('Preload'); window.addEventListener ("load", function() {LocalMain ('After load');}, false);

    Read the article

  • caching previous return values of procedures in scheme

    - by Brock
    In Chapter 16 of "The Seasoned Schemer", the authors define a recursive procedure "depth", which returns 'pizza nested in n lists, e.g (depth 3) is (((pizza))). They then improve it as "depthM", which caches its return values using set! in the lists Ns and Rs, which together form a lookup-table, so you don't have to recurse all the way down if you reach a return value you've seen before. E.g. If I've already computed (depthM 8), when I later compute (depthM 9), I just lookup the return value of (depthM 8) and cons it onto null, instead of recursing all the way down to (depthM 0). But then they move the Ns and Rs inside the procedure, and initialize them to null with "let". Why doesn't this completely defeat the point of caching the return values? From a bit of experimentation, it appears that the Ns and Rs are being reinitialized on every call to "depthM". Am I misunderstanding their point? I guess my question is really this: Is there a way in Scheme to have lexically-scoped variables preserve their values in between calls to a procedure, like you can do in Perl 5.10 with "state" variables?

    Read the article

  • How do I generate a connection reset programatically?

    - by Brock Adams
    Hi, I'm sure you've seen the "the connection was reset" message displayed when trying to browse web pages. (The text is from Firefox, other browsers differ.) I need to generate that message/error/condition on demand, to test workarounds. So, how do I generate that condition programmatically? (How to generate a TCP RST from PHP -- or one of the other web-app languages?) Caveats and Conditions: It cannot be a general IP block. The test client must still be able to see the test server when not triggering the condition. Ideally, it would be done at the web-application level (Python, PHP, Coldfusion, Javascript, etc.). Access to routers is problematic. Access to Apache config is a pain. Ideally, it would be triggered by fetching a specific web-page. Bonus if it works on a standard, commercial web host. Update: Sending RST is not enough to cause this condition. See my partial answer, below. I've a solution that works on a local machine, Now need to get it working on a remote host.

    Read the article

  • How to check for an active Internet Connection on iPhone SDK?

    - by Brock Woolf
    I would like to check to see if I have an Internet connection on the iPhone using the Cocoa Touch libraries. I came up with a way to do this using an NSUrl. The way I did it seems a bit unreliable (because even Google could one day be down and relying on a 3rd party seems bad) and while I could check to see for a response from some other websites if Google didn't respond, it does seem wasteful and an unnecessary overhead on my application. - (BOOL) connectedToInternet { NSString *URLString = [NSString stringWithContentsOfURL:[NSURL URLWithString:@"http://www.google.com"]]; return ( URLString != NULL ) ? YES : NO; } Is what I have done bad? (Not to mention 'stringWithContentsOfURL' is deprecated in 3.0) And if so what is a better way to accomplish this?

    Read the article

  • March 2012 - SSIS Training in London!

    - by andyleonard
    I am honored to announce I will be delivering From Zero To SSIS! in London, England 5-9 Mar 2012. This course is delivered in cooperation with my friends at TechniTrain who provide awesome training by talented technologists like Chris Webb ( Blog ), Gavin Payne ( Blog ), and Christian Bolton ( Blog ). This opportunity grew out of conversations at SQLBits 9 in Liverpool in September 2011. I had an awesome time at SQLBits and encourage everyone to attend the conference if you have the opportunity to...(read more)

    Read the article

  • MVC Partial View to Call Display Pop-up window using jquery

    - by Gavin campbell
    Hi I have a index page the renders objects from my database as a treeview, each item has a link href="/MessageGroupType/Edit/1002 that makes an Ajax call to display a partial view in a DIV. Within the partial view there is a delete button which calls my controller to delete the item. However, i do a check to make sure the item can be deleted, if the item cant be deleted then i wish a pop-up to appear back on the edit form telling the user they cant delete this record. In my Edit partial view i have the following code " type="text/javascript" $(function() { $("#dialog").dialog(); }); <% if (Boolean.Parse(ViewData["DisplayWindow"].ToString())){% This Mesage group Type Cannot be deleted as is linked to other message group Types <% }% So my main questions are Can i make a reference to a javascript script within my Partial View (i dont want my master page to be called on the partial view) When i dynamically load the partial view data into my DIV - can i then after calling my controller insert another DIV into the first DIV. I am i doing this the wrong way - so any pointers is appreciated Cheers

    Read the article

  • Cannot find System.Web.Script.Service namespace error after upgrading to Visual studio 2010

    - by Gavin
    I've just upgraded a VS 2008 project to VS 2010, converting the project but keeping the target as .NET 3.5 (SP1 is installed). My project worked without issue under VS 2008 on another machine. I've added references to System.Web.Extensions.dll but I'm still getting the following errors from code in the App_Code folder: 1) Cannot find System.Web.Script.Service namespace 2) Type 'System.Web.Script.Services.ScriptService' is not defined. 3) Type 'System.Runtime.Serialization.Json.DataContractJsonSerializer' is not defined. Anyone have any ideas what the problem might be as I'm pretty stumped? :(

    Read the article

  • Setting Session Variable from UpdatePanel

    - by Gavin
    I am using ASP.NET 2.0 AJAX Extensions 1.0 with the version v1.0.20229 of the AJAX Control Toolkit (which to my knowledge is the latest for .NET 2.0/Visual Studio 2005). My web page (aspx) has a DropDownList control on an UpdatePanel. In the handler for the DropDownList's SelectedIndexChanged event I attempt to set a session variable. The first time the event is fired, I get a Sys.WebForms.PageRequestManagerParserErrorException: "The message received from the server could not be parsed". If I continue, subsequent SelectedIndexChanged's are handled successfully. I have stumbled upon a solution whereby if I initialise the session variable in my Page_Load (so the event handler is just setting the value of a session variable that already exists as opposed to creating a new one) the problem goes away. I'm happy to do this, but I'm curious as to exactly what the underlying cause is. Can anyone explain? (My suspicion is that setting the session variable receives a response from the server which is then returned to the 'caller', but it's not the sort of response it knows how to deal with causing the exception?) EDIT: I reproduced the problem in a seperate little project: Default.aspx <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="SessionTest._Default" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" > <head runat="server"> <title>Untitled Page</title> </head> <body> <form id="form1" runat="server"> <asp:ScriptManager ID="ScriptManager1" runat="server" /> <div> <asp:UpdatePanel id="upCategorySelector" runat="server"> <ContentTemplate> Category: <asp:DropDownList ID="ddlCategory" runat="server" AutoPostBack="true" OnSelectedIndexChanged="ddlCategories_SelectedIndexChanged"> <asp:ListItem>Item 1</asp:ListItem> <asp:ListItem>Item 2</asp:ListItem> <asp:ListItem>Item 3</asp:ListItem> </asp:DropDownList> </ContentTemplate> </asp:UpdatePanel> </div> </form> </body> </html> Default.aspx.cs using System; using System.Data; using System.Configuration; using System.Collections; using System.Web; using System.Web.Security; using System.Web.UI; using System.Web.UI.WebControls; using System.Web.UI.WebControls.WebParts; using System.Web.UI.HtmlControls; namespace SessionTest { public partial class _Default : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { // If I do this, the exception does not occur. if (Session["key"] == null) Session.Add("key", 0); } protected void ddlCategories_SelectedIndexChanged(object sender, EventArgs e) { // If Session["key"] has not been created, setting it from // the async call causes the excaption Session.Add("key", ((DropDownList)sender).SelectedValue); } } }

    Read the article

  • Using Git with VB6

    - by Gavin Schultz
    Our company has a large codebase in VB6, and we currently use VSS which, for all that we hate about it, at least integrates into the VB6 IDE. My own team, which is using .NET, are now looking into alternative SCMs like my personal favourite, Git. With Git Extensions, it seems we will be able to integrate Git commands into the Visual Studio IDE pretty well. However, the question has been asked: could Git be used for our VB6 codebase too? Of course I assume the files themselves would work fine in git repositories, but no doubt developers would complain if they had to use the command-line to do all their source control. But has anyone had any experience using VB6 and Git? Any integration available from within the VB6 IDE? Or is it perhaps not that much of a hassle to not have the IDE integration? And do I get a badge for being the first to create the absurd tag combination of [vb6] and [git]?

    Read the article

  • Are web-safe colors still relevant?

    - by Gavin Miller
    Since the vast majority of monitors are 16-bit color or more, including mobile devices, does it make sense to even consider web-safe colors when choosing color schemes? Or is it something that ought to be relegated to history as a piece of trivia? For those of you that don't know what web-safe colors are: Another set of 216 color values is commonly considered to be the "web-safe" color palette, developed at a time when many computer displays were only capable of displaying 256 colors. A set of colors was needed that could be shown without dithering on 256-color displays; the number 216 was chosen partly because computer operating systems customarily reserved sixteen to twenty colors for their own use; it was also selected because it allows exactly six shades each of red, green, and blue (6 × 6 × 6 = 216). The list of colors is often presented as if it has special properties that render them immune to dithering. In fact, on 256-color displays applications can set a palette of any selection of colors that they choose, dithering the rest. These colors were chosen specifically because they matched the palettes selected by the then leading browser applications. [Wikipedia]

    Read the article

  • ColdFusion 8: Database Connection Reset Error

    - by Gavin
    I have been getting these intermittent ColdFusion Database connection reset errors and was wondering if anyone had experience with this and had a particular solution that worked? Here is the error: Error Executing Database Query.[Macromedia][SQLServer JDBC Driver]A problem occurred when attempting to contact the server (Server returned: Connection reset). Please ensure that the server parameters passed to the driver are correct and that the server is running. Also ensure that the maximum number of connections have not been exceeded for this server. This doesn't happen with any particular query, the code breaks in different queries every time, returning a SQLState error 08s01. These query's logic are fine, no logic errors etc. I checked the network logs and there were no database server connection refusals at the time of the error. Once the first error occurs, it keeps happening for no more than a minute or so at random times of the day, every few days. I've googled this thing and so far anyone that has had this issue was only on CF6 or 7, which the fixes coldFusion put out are only for CF6 or 7. Server configuration wise: The ColdFusion server is version 8 The database server is SQL Server 2005 Standard The database connections allowed setting is set to unlimited on both SQL Server and ColdFusion Any help would be greatly appreciated, Thanks!

    Read the article

< Previous Page | 1 2 3 4 5 6  | Next Page >