Search Results

Search found 4632 results on 186 pages for 'kevin major'.

Page 42/186 | < Previous Page | 38 39 40 41 42 43 44 45 46 47 48 49  | Next Page >

  • Where do I put the Current user query so as to not repeat per controller?

    - by Kevin
    I have a standard query that gets the current user object: @user = User.find_by_email(session[:email]) but I'm putting it as the first line in every single controller action which is obviously not the best way to do this. What is the best way to refactor this? Do I put this as a method in the Application controller (and if so, can you just show me a quick example)? Do I put the entire @user object into the session (has about 50 columns and some sensitive ones like is_admin)? Or is there another way to remove this kind of redundancy?

    Read the article

  • Java: Are these 2 codes the same?

    - by Kevin Duke
    for (Player p : players) { p.addCard(deck.dealCard()); p.addCard(deck.dealCard()); } and for (int i = 0; i < players.size() ; i++) { Player p = players.get(i); p.addCard(deck.dealCard()); p.addCard(deck.dealCard()); } The second code yeilds a null pointer exception, what can be done to make the bottom one equivalent ?

    Read the article

  • Using Google Map Headers (YM4R) on Heroku

    - by Kevin
    I have the following at the top of my view: <%= GMap.header %> Heroku is giving me an ActionView::TemplateError on that line.... this works on my own machine but not on Heroku.... why is that? Is there something about Heroku that doesn't allow? In the final compile on the browser, the above code translates into this on the client side: <script src="http://maps.google.com/maps?file=api&amp;v=2.x&amp;key=XXXXX;hl=&amp;sensor=false" type="text/javascript"> </script> <script src="/javascripts/ym4r-gm.js" type="text/javascript"></script>

    Read the article

  • How do I get the users location latitude and longitude?

    - by kevin Mendoza
    I need to access the users location in this method contained in the mainViewController -(void)loadAnnotations{ [mapView removeAnnotations:mapView.annotations]; CLLocationCoordinate2D workingCoordinate; workingCoordinate.latitude= //here i need the users latitude workingCoordinate.longitude= //here i need the users longitude NSLog(@" this is %@", workingCoordinate.latitude); iProspectLiteAnnotation *tempMine = [[iProspectLiteAnnotation alloc] initWithCoordinate:workingCoordinate]; [tempMine setTitle:@"Present Location"]; [tempMine setAnnotationType:iProspectLiteAnnotationTypeUser]; [mapView addAnnotation:tempMine]; } however the mainViewController is already set to <fipsideViewControllerDelegate> What should I add to the header file and the implementation file to poll the location Manager for the users current latitude and longitude?

    Read the article

  • C++ cin returns 0 for integer no matter what the user inputs

    - by kevin dappah
    No matter the cin it continues to to output 0 for score. Why is that? I tried returning the "return 0;" but still no go :/ #include "stdafx.h" #include <iostream> using namespace std; // Variables int enemiesKilled; const int KILLS = 150; int score = enemiesKilled * KILLS; int main() { cout << "How many enemies did you kill?" << endl; cin >> enemiesKilled; cout << "Your score: " << score << endl; return 0; }

    Read the article

  • jQuery validation: .each with form

    - by Kevin Brown
    If I have a form of about 40 questions, how do I apply the same rules to questions 1-20, and 21-40? For example: $("#form_survey").validate({ rules: { a_ +i: {max:12, maxlength:2}, }, messages: { a_ +i:{ max: "That's too much!" } } Where the "+i" is the ideal increment of +1... Should be easy, I'm just stuck on syntax...

    Read the article

  • How does Rails Plugin Storage work?

    - by Kevin
    Trying to figure out how to install rails plugins manually on windows so I have a few questions. What does the directory need to be named in vendor/plugins? Is it arbitrary or is it linked to something within the plugin config files or is that what you set in the environment.rb? Once I've copied the files to the correct directory, do I always need to run something inside like init.rb or is it good to go? What's the difference between 'require' and 'include'? Thanks!

    Read the article

  • String vectors not working as expected with newline and iterators? (C++)

    - by kevin
    I have a text file made of 3 lines: Line 1 Line 3 (Line 1, a blank line, and Line 3) vector<string> text; vector<string>::iterator it; ifstream file("test.txt"); string str; while (getline(file, str)) { if (str.length() == 0) str = "\n"; // since getline discards the newline character, replacing blank strings with newline text.push_back(str); } // while for (it=text.begin(); it < text.end(); it++) cout << (*it); Prints out: Line 1 Line 3 I'm not sure why the string with only a newline was not printed out. Any help would be appreciated. Thanks.

    Read the article

  • How to copy files without slowing down my app?

    - by Kevin Gebhardt
    I have a bunch of little files in my assets which need to be copied to the SD-card on the first start of my App. The copy code i got from here placed in an IntentService works like a charm. However, when I start to copy many litte files, the whole app gets increddible slow (I'm not really sure why by the way), which is a really bad experience for the user on first start. As I realised other apps running normal in that time, I tried to start a child process for the service, which didn't work, as I can't acess my assets from another process as far as I understood. Has anybody out there an idea how a) to copy the files without blocking my app b) to get through to my assets from a private process (process=":myOtherProcess" in Manifest) or c) solve the problem in a complete different way Edit: To make this clearer: The copying allready takes place in a seperate thread (started automaticaly by IntentService). The problem is not to separate the task of copying but that the copying in a dedicated thread somehow affects the rest of the app (e.g. blocking to many app-specific resources?) but not other apps (so it's not blocking the whole CPU or someting) Edit2: Problem solved, it turns out, there wasn't really a problem. See my answer below.

    Read the article

  • Html newbie! background-image question

    - by Kevin Li
    Hi! I'm learning HTML and I wanted to practice by recreating a invoice sent to me by Electronics Expo. However, I used the background-image property and repeated it by repeat-x and now, the background stretches across the page so much that it has a horizontal bar to drag. http://htmlpocketreference.110mb.com/index.html You can see what I did in my link above. Also, I would really appreciate some advice on simplifying my CSS coding. It seems really messy and I have to move every element once something changes. -.- Thanks!

    Read the article

  • jQuery: if value is true without user action

    - by Kevin Brown
    I want to show a div if the value of an input =='CP'. Right now this is my code: $(".register-type").change(function(){ var value = $(this).val(); if(value == 'CP'){ $('.cp-show').show(); This works fine if they change the input, but if things get validated false and the page reloads, this input is still 'CP', but the div doesn't show... Is there a way to correct this so that jquery checks if this is set on the page load?

    Read the article

  • Is there a file diff tool that allows for exceptions?

    - by Kevin
    We currently use Beyond Compare 3.0 and I am quite pleased with it. However, it would be great if I could easily specify an exclusion for a specific one-time case. This is needed when I am doing a code review of some refactoring. For instance: Old code doSomething(ConstantsInterface.FOOBAR); New code: doSomething(BetterEnumeration.FOOBAR); In this case, I have hundreds of changes that I am reviewing that are essentially all the same exact change and I just want to see the exceptions. It would be great if I could easily specify an exception that indicates these two cases are equal. I know of a way to do it in the grammar, but it is tedious and cumbersome in the case where there are ten or so exceptions. Any other tips?

    Read the article

  • Challenging yourself as a programmer?

    - by Kevin
    We used to be a Coldfusion development shop before hopping over to PHP in 2008, now we primarily develop custom Drupal websites. I enjoyed going from CF to PHP, but I feel like I am getting a bit stale. I have been looking at different things like Ruby, Python, Obj C (iPhone). The problem is, there just isn't enough time in the day. What would be a fun new thing to learn that would refresh me a bit and challenge myself to learn more?

    Read the article

  • Added a Facebook badge, throwing off footer placement

    - by Kevin
    Added the for the facebook badge to the site and now it's thrown my placement for the footer off .. it's working fine in Chrome, but IE, FFox and Opera all experiencing problems... Here is a screenshot: The footer (brown bar) is supposed to be at the bottom... Here is the CSS : /* footer */ #footer{ background:url(../images/bg-footer.png) no-repeat; height:26px; overflow:hidden; padding:35px 0 0 55px; font-size:11px; } #footer p{ margin:0; display:inline; color:#766623; } #footer ul{ margin:0; padding:0; list-style:none; display:inline; } #footer li{ display:inline; background:url(../images/sep-f-nav.gif) no-repeat 100% 55%; padding:0 6px 0 0; position:relative; } * html #footer li{ padding:0 3px 0 3px; } *+html #footer li{ padding:0 3px 0 3px; } #footer a{ color:#30481f; text-decoration:none; } #footer a:hover{ text-decoration:underline; /*Facebook badge Holder*/ .fb-area{ width:287px; padding:0 0; margin:0 0; min-height:100%; }

    Read the article

  • How can I make this simple C# generics factory work?

    - by Kevin Brassen
    I have this design: public interface IFactory<T> { T Create(); T CreateWithSensibleDefaults(); } public class AppleFactory : IFactory<Apple> { ... } public class BananaFactory : IFactory<Banana> { ... } // ... The fictitious Apple and Banana here do not necessarily share any common types (other than object, of course). I don't want clients to have to depend on specific factories, so instead, you can just ask a FactoryManager for a new type. It has a FactoryForType method: IFactory<T> FactoryForType<T>(); Now you can invoke the appropriate interface methods with something like FactoryForType<Apple>().Create(). So far, so good. But there's a problem at the implementation level: how do I store this mapping from types to IFactory<T>s? The naive answer is an IDictionary<Type, IFactory<T>>, but that doesn't work since there's no type covariance on the T (I'm using C# 3.5). Am I just stuck with an IDictionary<Type, object> and doing the casting manually?

    Read the article

  • Is long long in C++ known to be very nasty in terms of precision?

    - by Kevin
    The Given Problem: Given a theater with n rows, m seats, and a list of seats that are reserved. Given these values, determine how many ways two friends can sit together in the same row. So, if the theater was a size of 2x3 and the very first seat in the first row was reserved, there would be 3 different seatings that these two guys can take. The Problem That I'm Dealing With The function itself is supposed to return the number of seatings that there are based on these constraints. The return value is a long long. I've gone through my code many many times...and I'm pretty sure that it's right. All I'm doing is incrementing this one value. However, ALL of the values that my function return differ from the actual solution by 1 or 2. Any ideas? And if you think that it's just something wrong with my code, please tell me. I don't mind being called an idiot just as long as I learn something.

    Read the article

  • jQuery: exclude class on click

    - by Kevin Brown
    //Table select $("#reports-table tr").click( function() { var detail_id = $(this).attr('id'); $(this).addClass("selected"); $(this).siblings().removeClass("selected"); $('#reports-right').show().load('/members/details/'+detail_id); $('#reports-table').width(680); } ); I currently am using this code to add a selected class to a table row and show details of the row clicked in a right 'aside'. The problem is, I have action buttons in the row--when they are clicked, becausee they are children of the tr, this function still runs... How can I exclude a certain class?

    Read the article

  • EditText and Button on the same line with Textiew underneath?

    - by Kevin
    Hi, I am trying to have an EditText widget next to a button with a text view underneath. The EditText should resize and fill the screen accordingly, while the button's width is always only what it needs to be by setting the width to wrap_content. The layout should not be relative. Below is the code I have so far some of which was found here on StackOverflow. Removing the text view gives the desired appearance for the EditText and button, but when the TextView is added the view goes to ... well. Not sure why the code is not showing? I put it into a < code< pre block without success. http://pastebin.com/WgH6qrTm

    Read the article

  • MySql - set of time stamped data (timestamp,event) calculating events per day

    - by Kevin Ohashi
    I have a table: id, datetime, event i also have table dates: date (Y-m-d format) the problem is some days don't have any events, I would like them to show 0 (or null) SELECT DATE_FORMAT(table.timestamp, '%Y-%m-%d') ydm, count(table.fkUID) FROM `table` where table.fkUID=$var group by ydm; is there some way to join or use conditional statements to make the result show: date|count ---------- 2010-05-23| 5 2010-05-24| 0 <--- this line just doesn't exist in my query. 2010-05-26| 3

    Read the article

  • How do I register a Javascript function to run with every postback?

    - by Kevin
    I have a treeview in a user control. I need to run a javascript function with every synch postback to scroll the div it's in to the right position. I've got it working, but I think there has to be a "cleaner" way to do it. In the Page_Load function of the control, I have the following code. Is there a better way to do it? ScriptManager.RegisterStartupScript(this.UpdatePanel1, this.GetType(), "key" + DateTime.Now.Ticks, "RestorePosition();", true);

    Read the article

  • Finding files with bash and copy to another location and reducing depth of folders

    - by Kevin F
    I'm trying to recover a mates hard drive, there is no structure what so ever so music and images are everywhere but in named folders sometimes 5 folders deep, I've managed to write a one-liner that finds the files and copies them to a mounted drive but it preserves the file structure completely. What I'm after is a bit of code that searches the drive and copies to another location and copies just the parent folder with the mp3/jpg files within and not the complete path. The other issue I have is the music is /folder/folder/folder/Artist/1.mp3..2.mp3..10.mp3 etc etc so I have to preserve the folder 'Artist' to give him any hope of finding his tracks again. What I have working currently: find /media/HP/ -name *.mp3 -fprintf /media/HP/MUSIC/Script.sh 'mkdir -p "/media/HP/MUSIC/%h" \n cp "%h/%f" "/media/HP/MUSIC/%h/"\n' I then run the script.sh and it does all the copying. Many Thanks

    Read the article

  • Codeigniter: URI segments

    - by Kevin Brown
    How do I create an if statement saying something like this? $segment = "segment 2 or 3"; if($segment == 1{ do stuff } I know this is pretty elementary, but I don't totally understand the URI class...

    Read the article

  • Split text files Accross threads

    - by Kevin
    The problem: I have a few text files (10) with numbers in them on every line. I need to have them split across some threads I create using the pthread library. these threads that are created (worker threads) are to find the largest prime number that gets sent to them (and over all the largest prime from all of the text files). My current thoughts on solutions: I am thinking myself to have two arrays and all of the text files in one array and the other array will contain a binary file that I can read say 1000 lines and send the pointer to the index of that binary file in a struct that contains the id, file pointer, and file position and let it crank through that. a little bit of what I am talking about pthread_create(&threads[index],NULL,calc_sqrt,(void *)threadFields[index]);//Pass struct to each worker Struct: typedef struct threadFields{ int *id, *position; FILE *Fin; }tField; If anyone has any insight or a better solution it would be greatly appreciated Thanks

    Read the article

  • How to write multiple files from one NSData object?

    - by Kevin Cupp
    Hi there! I'm writing an iPhone app that includes in-app purchasing. It downloads a zip file, then I unzip the file using the popular NSData category (zlibDeflate) which outputs the uncompressed file into an NSData object. The zip file contains multiple files in it which I need to write to the Documents directory. How can I write each file separately from this one NSData object? writeToFile just writes the whole thing to one file. Thank you and let me know if you need any more information.

    Read the article

< Previous Page | 38 39 40 41 42 43 44 45 46 47 48 49  | Next Page >