Search Results

Search found 1578 results on 64 pages for 'adam cameron'.

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

  • Python: How efficient is subtring extraction?

    - by Cameron
    I've got the entire contents of a text file (at least a few KB) in string myStr. Will the following code create a copy of the string (less the first character) in memory? myStr = myStr[1:] I'm hoping it just refers to a different location in the same internal buffer. If not, is there a more efficient way to do this? Thanks!

    Read the article

  • How do I use a custom authentication mechanism for a Java web application with Spring Security?

    - by Adam
    Hi, I'm working on a project to convert an existing Java web application to use Spring Web MVC. As a part of this I will migrate the existing log-on/log-off mechanism to use Spring Security. The idea at this stage is to replicate the existing functionality and replace only the web layer, leaving the service classes and objects in place. The required functionality is simple. Access is controlled to URLs and to access certain pages the user must log on. Authentication is performed with a simple username and password along with an extra static piece of information that comes from the login page. There is no notion of a role: once a user has logged on they have access to all of the pages. Behind the scenes, the service layer has a class with a simple authentication method: doAuthenticate(String username, String password, String info) throws ServiceException An exception is thrown if the login fails. I'd like to leave this existing service object that does the authentication intact but to "plug it into" the Spring Security mechanism. Can somebody suggest the best approach to take for this please? Naturally, I'd like to take the path of least resistance and leave the work where possible to Spring... Thanks in advance, Adam.

    Read the article

  • WordPress query posts into two Divs

    - by Cameron
    I want to display my wordpress posts in a category in two divs. So for example: <div id="left"> POST 1 POST 3 POST 5 POST 7 </div> <div id="right" POST 2 POST 4 POST 6 POST 8 </div> So want I need to do is tell the query_posts to somehow start spitting out the first 4 posts oddly and then evenly for each div. I don't want to have two seperate WP_Queries as this is a category.php file and needs to have the default loop. Not quite sure how to do this. Any help much appreciated.

    Read the article

  • Python many-to-one mapping (creating equivalence classes)

    - by Adam Matan
    Hi, I have a project of converting one database to another. One of the original database columns defines the row's category. This coulmn should be mapepd to a new category in the new databse. For example, let's assume the original categories are:parrot, spam, cheese_shop, Cleese, Gilliam, Palin Now that's a little verbose for me, And I want to have these rows categorized as sketch, actor - That is, define all the sketches and all the actors as two equivalence classes. >>> monty={'parrot':'sketch', 'spam':'sketch', 'cheese_shop':'sketch', 'Cleese':'actor', 'Gilliam':'actor', 'Palin':'actor'} >>> monty {'Gilliam': 'actor', 'Cleese': 'actor', 'parrot': 'sketch', 'spam': 'sketch', 'Palin': 'actor', 'cheese_shop': 'sketch'} That's quite awkward- I would prefer having something like: monty={ ('parrot','spam','cheese_shop'): 'sketch', ('Cleese', 'Gilliam', 'Palin') : 'actors'} But this, of course, sets the entire tuple as a key: >>> monty['parrot'] Traceback (most recent call last): File "<pyshell#29>", line 1, in <module> monty['parrot'] KeyError: 'parrot' Any ideas how to create an elegant many-to-one dictionary in Python? Thanks, Adam

    Read the article

  • winForms Booking Class Help

    - by cameron
    Hi, I am using C# Windows Forms in visual studio with different classes performing different functions in my program. I have a "Program" main class with the following information: static class Program { /// <summary> /// The main entry point for the application. /// </summary> [STAThread] static void Main() { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Application.Run(new Form1()); } } and a Screen class with the following information class Screen { public List<Show> shows { get; private set; } public int ScreenNumber { get; private set; } public Screen(int screenNumber, params Show[] schedule) { this.ScreenNumber = screenNumber; this.shows = schedule.ToList<Show>(); } } and a Seat class with the following information public class Seat { private string name; public bool IsAvailable { get; set; } public decimal Price { get; private set; } public int Number { get; private set; } public Seat(bool isAvailable, int number) { this.IsAvailable = isAvailable; this.name = String.Format("Seat {0}",number); this.Price = 7.50m; this.Number = number; } public override string ToString() { return this.name; } } and finally a Show class with the following information public class Show { private List<Seat> seats = new List<Seat>(); public string Title { get; private set; } public string Time { get; private set; } public int ScreenNumber { get; private set; } public List<Seat> Seats { get { return this.seats; } } public Show(string title, DateTime time, int screenNumber, int numberOfSeats) { this.Title = title; this.Time = time.ToShortTimeString(); this.ScreenNumber = screenNumber; this.initSeats(numberOfSeats); } private void initSeats(int numberOfSeats) { for (int i = 0; i < numberOfSeats; i++) this.seats.Add(new Seat(true, i + 1)); } }` these all feed into two different winForms to create a booking system for shows. therefore i need to collate the data given in program and output it into a txt file. any help will be much appreciated NOTE: the code for FORM1 which allows the user to select which show they want is: namespace CindysSeats { public partial class Form1 : Form { private Cinema cinema = new Cinema(); //booked show could be added to booking object when you create it so that it is easily writable to the external file private Show selectedShow; public Form1() { InitializeComponent(); this.showList_dg.DataSource = this.cinema.GetShowList(); } private void showList_dg_RowHeaderMouseClick(object sender, DataGridViewCellMouseEventArgs e) { Show selectedShow = this.selectedShow = this.cinema.GetShowList()[e.RowIndex]; this.showTitle_lbl.Text = selectedShow.Title; this.showTime_lbl.Text = selectedShow.Time; this.showScreen_lbl.Text = selectedShow.ScreenNumber.ToString(); } private void confirmShow_btn_Click(object sender, EventArgs e) { if (this.selectedShow == null) return; Form2 seats = new Form2(this.selectedShow); seats.Show(); } And the code for FORM2 which is where the user selects their seats they want is: namespace CindysSeats { public partial class Form2 : Form { //booked seats could be added to booking object when you create it so that it is easily writable to the external file private List<Seat> bookedSeats = new List<Seat>(); private Show selectedShow; public Form2(Show selectedShow) { InitializeComponent(); this.selectedShow = selectedShow; this.showSeats_dg.DataSource = this.selectedShow.Seats; } private void showSeats_dg_RowHeaderMouseClick(object sender, DataGridViewCellMouseEventArgs e) { Seat selectedSeat = this.selectedShow.Seats[e.RowIndex]; if(this.bookedSeats.Contains(selectedSeat)) return; if(!selectedSeat.IsAvailable) return; this.bookedSeats.Add(selectedSeat); this.bookedSeats_lv.Items.Add(selectedSeat.ToString() + " " + selectedSeat.Price.ToString()+"\n"); this.bookedSeats_lv.Invalidate(); } private void bookSeats_btn_Click(object sender, EventArgs e) { } } thank you for helping

    Read the article

  • How to load JPG file into NSBitmapImageRep?

    - by Adam
    Objective-C / Cocoa: I need to load the image from a JPG file into a two dimensional array so that I can access each pixel. I am trying (unsuccessfully) to load the image into a NSBitmapImageRep. I have tried several variations on the following two lines of code: NSString *filePath = [NSString stringWithFormat: @"%@%@",@"/Users/adam/Documents/phoneimages/", [outLabel stringValue]]; //this coming from a window control NSImageRep *controlBitmap = [[NSImageRep alloc] imageRepWithContentsOfFile:filePath]; With the code shown, I get a runtime error: -[NSImageRep imageRepWithContentsOfFile:]: unrecognized selector sent to instance 0x100147070. I have tried replacing the second line of code with: NSImage *controlImage = [[NSImage alloc] initWithContentsOfFile:filePath]; NSBitmapImageRep *controlBitmap = [[NSBitmapImageRep alloc] initWithData:controlImage]; But this yields a compiler error 'incompatible type' saying that initWithData wants a NSData variable not an NSImage. I have also tried various other ways to get this done, but all are unsuccessful either due to compiler or runtime error. Can someone help me with this? I will eventually need to load some PNG files in the same way (so it would be nice to have a consistent technique for both). And if you know of an easier / simpler way to accomplish what I am trying to do (i.e., get the images into a two-dimensional array), rather than using NSBitmapImageRep, then please let me know! And by the way, I know the path is valid (confirmed with fileExistsAtPath) -- and the filename in outLabel is a file with .jpg extension. Thanks for any help!

    Read the article

  • Using Bundler along with preinstalled gems

    - by Rob Cameron
    So I've got thin installed the old fashioned way: gem install thin I put an app on the server and installed all of its required gems via bundler: bundle install But, when I tried to start the app with thin start, it can't find any of the bundler-installed gems since they're not installed in the default gems directory. My question is: how do I make this work? Do I need to install thin via bundler as well? Will that still set up the thin executable in /usr/bin so I can start it from the command line like normal? Thanks!

    Read the article

  • SEO redirects for removed pages

    - by adam
    Hi, Apologies if SO is not the right place for this, but there are 700+ other SEO questions on here. I'm a senior developer for a travel site with 12k+ pages. We completely redeveloped the site and relaunched in January, and with the volatile nature of travel, there are many pages which are no longer on the site. Examples: /destinations/africa/senegal.aspx /destinations/africa/features.aspx Of course, we have a 404 page in place (and it's a hard 404 page rather than a 30x redirect to a 404). Our SEO advisor has asked us to 30x redirect all our 404 pages (as found in Webmaster Tools), his argument being that 404's are damaging to our pagerank. He'd want us to redirect our Senegal and features pages above to the Africa page (which doesn't contain the content previously found on Senegal.aspx or features.aspx). An equivalent for SO would be taking a url for a removed question and redirecting it to /questions rather than showing a 404 'Question/Page not found'. My argument is that, as these pages are no longer on the site, 404 is the correct status to return. I'd also argue that redirecting these to less relevant pages could damage our SEO (due to duplicate content perhaps)? It's also very time consuming redirecting all 404's when our site takes some content from our in-house system, which adds/removes content at will. Thanks for any advice, Adam

    Read the article

  • Rack throwing an error when trying to serve a static file.

    - by Cameron
    use Rack::Static, :urls => ['/stylesheets', '/images'], :root => 'public' run proc { |env| [200, { 'Content-Type' => 'text/html', 'Cache-Control' => 'public, max-age=86400' }, File.open('public/index.html')] } I get private method `open' called for Rack::File:Class when I rackup. Really can't see where the problem is. Running rack 1.1. Help please...

    Read the article

  • Show only Parent Forums on bbPress front page

    - by Cameron
    I want to show only the very top level forums on my front page. I have tried: <?php if ( bb_forums("depth=1") ) : ?> But that didn't work and all the forums still show up. I only want to show the very top level, so for example if I have the following forums: Main - Sub Forum 1 - Sub Forum 2 --- Sub Forum 2.1 --- Sub Forum 2.1 - Sub Forum 3 Community - Sub Forum 1 - Sub Forum 2 --- Sub Forum 2.1 --- Sub Forum 2.1 - Sub Forum 3 Only Main and Community would appear on the home page. I would seem I need to create a custom loop on the front page that will only show the very top level forums, but I need some help. Thanks.

    Read the article

  • Agile Approach for WCM

    - by cameron.f.logan
    Can anyone provide me with advice, opinions, or experience with using an agile methodology to delivery an enterprise-scale Web Content Management system (e.g., Interwoven TeamSite, Tridion)? My current opinion is that to implement a CM system there is a certain--relatively high--amount of upfront work that needs to happen to make sure the system is going to be scalable and efficient for future projects for the multi-year lifespan an WCM is expected to have. This suggests a hybrid approach at best, if not a more waterfall-like approach. I'm really interested to learn what approaches others have taken. Thanks.

    Read the article

  • Best reporting engine for WPF without a database?

    - by Cameron MacFarland
    Does anyone know of a Reporting Engine for WPF? Most of the ones I could find are still for WinForms. I'm happy enough using a WinForms one in WPF with a WinForms host so long as the tool has a UserControl that can be embedded in a window. Also, I'm not using a database and all my data is in XML so the Reporting Engine needs to be able to handle that. Any suggestions?

    Read the article

  • strange run time error message from CIImage initWithContentsOfURL

    - by Adam
    When executing the following code I receive a run time error when the code executes the second line of code. The error (which shows up in the debugger) says: [NSButton initWithContentsOfURL:]: unrecognized selector sent to instance 0x100418e10. I don't understand this message, because it looks to me (based on my source code) like the initWithContentsOfURL message is being sent to the myImage instance (of the CIImage class) ... not NSButton. Any idea what is going on? If it matters ... this code is in the Application Controller class module of an Xcode project (a Cocoa application) -- within a method that is called when I click on a button on the application window. There is only the one button on the window ... // Step1: Load the JPG file into CIImage NSURL *myURL = [NSURL fileURLWithPath:@"/Users/Adam/Documents/Images/image7.jpg"]; CIImage *myImage = [myImage initWithContentsOfURL: myURL]; if (myImage = Nil) { NSLog(@"Creating myImage failed"); return; } else { NSLog(@"Created myImage successfully"); }

    Read the article

  • Unexpected T_STRING, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR

    - by Cameron
    Hi I'm trying to run a WordPress plugin and I get the following error: Parse error: syntax error, unexpected T_STRING, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in /nfs/c03/h05/mnt/52704/domains/creathive.net/html/wp-content/plugins/qr-code-tag/lib/qrct/QrctWp.php on line 13 What would be the problem here? Line 13 is the public bit EDIT: Here is some code: class QrctWp { public $pluginName = 'QR Code Tag';

    Read the article

  • jQuery Show a Textbox When an Option is Selected

    - by Cameron
    I have the following code: <select> <option value="Type 1">Type 1</option> <option value="Type 2">Type 2</option> <option value="Type 3">Type 3</option> <option value="Other">Other</option> </select> <input type="text" id="other" /> What I want to do is using jQuery make the textbox below hidden by default, and then show it if a user selects the other option from the dropdown.

    Read the article

  • Maven Java Source Code Generation for Hibernate

    - by Adam
    Hi, I´m busy converting an existing project from an Ant build to one using Maven. Part of this build includes using the hibernate hbm2java tool to convert a collection of .hbm.xml files into Java. Here's a snippet of the Ant script used to do this: <target name="dbcodegen" depends="cleangen" description="Generate Java source from Hibernate XML"> <hibernatetool destdir="${src.generated}"> <configuration> <fileset dir="${src.config}"> <include name="**/*.hbm.xml"/> </fileset> </configuration> <hbm2java jdk5="true"/> </hibernatetool> </target> I've had a look around on the internet and some people seem to do this (I think) using Ant within Maven and others with the Maven plugin. I'd prefer to avoid mixing Ant and Maven. Can anyone suggest a way to do this so that all of the .hbm.xml files are picked up and the code generation takes place as part of the Maven code generation build phase? Thanks! Adam.

    Read the article

  • Creating a VS 2010 Project with only content files.

    - by Cameron Peters
    I have some content files that I would like to share between a number of projects in Visual Studio. I have put these files in their own project, set the build action to "Content", and the copy to output directory to "Copy if newer". I would like all these files to be copied to the bin/debug directory of the projects that reference them. I can get it to work by including a reference to the "contents" project in each of the projects that need the files, but that requires that a minimal assembly be generated (3K). I assume there is a way, using MSBuild, to make this all work without creating the empty assembly?

    Read the article

  • I seek a PDF paginator

    - by Cameron Laird
    More precisely, I need software that will allow me to consume existing PDF instances, decorate them with page numbers, or page-number-like writing, then write them back to the filesystem. I'll happily pay for an application, or program it myself. I almost certainly require the software run under Linux (Ubuntu, more specifically). iText comes close. iText certainly can read existing PDF instances. While iText is, for this purpose, only a library, and requires me to program a tiny amount to specify where on the page the numbers should appear, I'm happy to do that. I hesitate with iText only because the latest iText license is a headache at certain government agencies (in practice, I'd probably request and pay for a special license), and because, over the last few years, I've observed cases where iText doesn't appear to keep up with the standard, that is, it has more troubles than I expect reading PDFs observed "in the wild". Similarly, every other possibility I know has at least one difficulty: ReportLab would likely require a disproportionate licensing fee for the small value it provides in this situation, and so on. This application requires no particular sophistication with Unicode, fonts, ... I recognize there are plenty of executables and libraries that do some or all of what I require. I welcome any tips on software that is reliable, generally current with PDF practice, flexible/programmable/configurable/..., and "automatable". In the absence of any new insight, I'll likely go with a specific open-source library I don't want to mention now for which I've already contracted enhancements, or perhaps revisit iText.

    Read the article

  • Focus on textbox based on URL.

    - by Cameron
    I have two forms on one page and want to have the input boxes focused based on the URL. So for example: domain.com/Default.aspx#login and domain.com/Default.aspx#register and the javascript I have this: window.document.getElementById('<%=txtUserName.ClientID %>').focus(); window.document.getElementById('<%=txtEmail.ClientID %>').focus(); it might be better if the urls are Default.aspx?action=login actually (not sure if this effects the way in which it would work)

    Read the article

  • UTF-8 HTML and CSS files with BOM (and how to remove the BOM with Python)

    - by Cameron
    First, some background: I'm developing a web application using Python. All of my (text) files are currently stored in UTF-8 with the BOM. This includes all my HTML templates and CSS files. These resources are stored as binary data (BOM and all) in my DB. When I retrieve the templates from the DB, I decode them using template.decode('utf-8'). When the HTML arrives in the browser, the BOM is present at the beginning of the HTTP response body. This generates a very interesting error in Chrome: Extra <html> encountered. Migrating attributes back to the original <html> element and ignoring the tag. Chrome seems to generate an <html> tag automatically when it sees the BOM and mistakes it for content, making the real <html> tag an error. So, using Python, what is the best way to remove the BOM from my UTF-8 encoded templates (if it exists -- I can't guarantee this in the future)? For other text-based files like CSS, will major browsers correctly interpret (or ignore) the BOM? They are being sent as plain binary data without .decode('utf-8'). Note: I am using Python 2.5. Thanks!

    Read the article

  • PHP/WordPress Session CountDown

    - by Cameron
    I have the following code to show how long a user has left before their session will expire, I am using WordPress. How can I do this? Thanks <script> var obj_Span; var n_Seconds = 0; var n_Minutes = 0; var n_Hours = 0; function F_ConvertNumberToString ( n_Num ) { var str_Num = String(n_Num); if ( str_Num.length < 2 ) str_Num = "0" + str_Num; return str_Num; } function F_CountDown () { if ( n_Hours == 0 && n_Minutes == 0 && n_Seconds == 0 ) { obj_Span.innerHTML = "(Sorry, your session has expired.)"; } else { if ( n_Seconds >= 0 ) n_Seconds --; if ( n_Seconds < 0 ) { n_Minutes --; n_Seconds = 59; } if ( n_Minutes >= 0 ) { window.setTimeout ( "F_CountDown()", 1000 ); } if ( n_Minutes < 0 ) { n_Hours --; n_Minutes = 59; window.setTimeout ( "F_CountDown()", 1000 ); } F_UpdateDisplay (); } } function F_UpdateDisplay ( ) { if ( document.getElementById ) { if (n_Hours > 0 ) obj_Span.innerHTML = "(Remaining " + F_ConvertNumberToString(n_Hours) + ":" + F_ConvertNumberToString(n_Minutes) + ":" + F_ConvertNumberToString(n_Seconds) + ")"; else obj_Span.innerHTML = "(Remaining " + F_ConvertNumberToString(n_Minutes) + ":" + F_ConvertNumberToString(n_Seconds) + ")"; } } function F_StartCountDown ( n_Session ) { obj_Span = document.getElementById ( "CountDown" ); n_Minutes = n_Session; n_Hours = Math.floor(n_Minutes/60); n_Minutes = n_Minutes - (60*n_Hours); F_CountDown (); } </script> <script> F_StartCountDown ( " code here... " ); </script> <span id="CountDown"></span>

    Read the article

  • Any way to have delayed_job execute some run-once code at startup and use across all jobs?

    - by Rob Cameron
    So I've got a delayed_job task that pushes some info to an XMPP server. Ideally you create a connection to XMPP once and then constantly push data to it, rather than creating a new connection every time you have some data to send. Is there any kind of facility in delayed_job for running a sort of 'setup' method when a worker starts, have it set some instance variables (like the XMPP connection object) that can then be used by all the jobs that come up? It's okay if each worker runs its own setup method. I just don't want every job (thousands per day) connecting to the XMPP server from scratch every time. Thanks for any help!

    Read the article

  • Where to wire up events?

    - by Jeffrey Cameron
    I'm using Ninject (1.5 ... soon to be 2) and I'm curious how other people use Ninject or other IoC containers to help wire up events to objects? It seems to me in my code that I'm doing it herky-jerky all over the place and would love some advice on how to clean it up a bit.

    Read the article

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