Search Results

Search found 467 results on 19 pages for 'brad'.

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

  • java equivalent of ruby's ||= syntax

    - by brad
    I'm brand new to java, coming from a ruby world. One thing I love about ruby is the very terse syntax such as ||=. I realize of course that a compiled language is different, but I'm wondering if Java has anything similar. In particular, what I do all the time in ruby is something like: someVar ||= SomeClass.new I think this is incredibly terse, yet powerful, but thus far the only method I can think of to achieve the same thing is a very verbose: if(someVar == null){ someVar = new SomeClass() } Just trying to improve my Java-fu and syntax is certainly one area that I'm no pro.

    Read the article

  • adldap class, need to search for user in two groups

    - by Brad
    http://adldap.sourceforge.net/wiki/doku.php?id=api_user_functions#user_ingroup_username_group_recursive_null I am using the adLDAP class above to authenticate users against our ldap server. I was wondering how I could check multiple groups to see if the user belongs to either, if they belong to either. I don't know if user_ingroup($username,$group,$recursive=NULL); can handle search two different groups for the user, need help coding it to search for the user in two different groups, and as soon as it finds it in one of those, break the operation and set a variable to true. Any help is appreciated.

    Read the article

  • Why do Firefox and Opera ignore max-width inside of display: table-cell?

    - by brad
    The following code displays correctly in Chrome or IE (the image is 200px wide). In Firefox and Opera the max-width style is ignored completely. Why does this happen and is there a good work around? Also, which way is most standards compliant? Note One possible work around for this particular situation is to set max-width to 200px. However, this is a rather contrived example. I'm looking for a strategy for a variable width container. <!doctype html> <html> <head> <style> div { display: table-cell; padding: 15px; width: 200px; } div img { max-width: 100%; } </style> </head> <body> <div> <img src="http://farm4.static.flickr.com/3352/4644534211_b9c887b979.jpg" /> <p> Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec facilisis ante, facilisis posuere ligula feugiat ut. Fusce hendrerit vehicula congue. at ligula dolor. Lorem ipsum dolor sit amet, consectetur adipiscing elit. leo metus, aliquam eget convallis eget, molestie at massa. </p> </div> </body> </html> [Update] As stated by mVChr below, the w3.org spec states that max-width does not apply to inline elements. I've tried using div img { max-width: 100%; display: block; }, but it does not seem to correct the issue.

    Read the article

  • Using outer query result in a subquery in postgresql

    - by brad
    I have two tables points and contacts and I'm trying to get the average points.score per contact grouped on a monthly basis. Note that points and contacts aren't related, I just want the sum of points created in a month divided by the number of contacts that existed in that month. So, I need to sum points grouped by the created_at month, and I need to take the count of contacts FOR THAT MONTH ONLY. It's that last part that's tricking me up. I'm not sure how I can use a column from an outer query in the subquery. I tried something like this: SELECT SUM(score) AS points_sum, EXTRACT(month FROM created_at) AS month, date_trunc('MONTH', created_at) + INTERVAL '1 month' AS next_month, (SELECT COUNT(id) FROM contacts WHERE contacts.created_at <= next_month) as contact_count FROM points GROUP BY month, next_month ORDER BY month So, I'm extracting the actual month that my points are being summed, and at the same time, getting the beginning of the next_month so that I can say "Get me the count of contacts where their created at is < next_month" But it complains that column next_month doesn't exist This is understandable as the subquery knows nothing about the outer query. Qualifying with points.next_month doesn't work either. So can someone point me in the right direction of how to achieve this? Tables: Points score | created_at 10 | "2011-11-15 21:44:00.363423" 11 | "2011-10-15 21:44:00.69667" 12 | "2011-09-15 21:44:00.773289" 13 | "2011-08-15 21:44:00.848838" 14 | "2011-07-15 21:44:00.924152" Contacts id | created_at 6 | "2011-07-15 21:43:17.534777" 5 | "2011-08-15 21:43:17.520828" 4 | "2011-09-15 21:43:17.506452" 3 | "2011-10-15 21:43:17.491848" 1 | "2011-11-15 21:42:54.759225" sum, month and next_month (without the subselect) sum | month | next_month 14 | 7 | "2011-08-01 00:00:00" 13 | 8 | "2011-09-01 00:00:00" 12 | 9 | "2011-10-01 00:00:00" 11 | 10 | "2011-11-01 00:00:00" 10 | 11 | "2011-12-01 00:00:00"

    Read the article

  • Change Variable back to original value after Regex matching.

    - by Brad Johansen
    I just "finished" expanding my Palindrome Tester, made in C#. To allow for phrases I added a simple regex match for all non-alphanumeric characters. At the end of the program it states " is(n't) a palindrome." But now with the regex it prints the no spaces/punctuation version of it. I would like to be able to print the original user input. How do I do that? Here is my program: http://gist.github.com/384565

    Read the article

  • simple div containing span won't size correctly

    - by brad
    I thought I was pretty knowledgeable about CSS but this simple problem baffles me. <div><span>sample text</span></div> results in the div's height being smaller than the height of the span if the span has padding. I realize that there are ways to use "float" to make the div size correctly, but floats always seem to introduce undesired side effects. Isn't there a clean simple way to tell the div to size to fit its contents? Seems pretty basic to me. Maybe I'm missing something.

    Read the article

  • Double encoded url being fully decoded in ASP.NET

    - by Brad R
    I have just come across something that is quite strange and yet I haven't found any mention on the interwebs of others having the same problem. If I hit my ASP.NET application with a double encoded url then the Request["myQueryParam"] will do a double decode of the query for me. This is not desirable as I have double encoded my query string for a good reason. Can others confirm I'm not doing something obviously wrong, and why this would happen. A solution to prevent it, without doing some nasty query string parsing, would be great too! As an example if you hit the url: http://localhost/MyApp?originalUrl=http%3a%2f%2flocalhost%2fAction%2fRedirect%3fUrl%3d%252fsomeUrl%253futm_medium%253dabc%2526utm_source%253dabc%2526utm_campaign%253dabc (For reference %25 is the % symbol) Then look at the Request["originalUrl"] (page or controller) the string returned is: http://localhost/Action/Redirect?Url=/someUrl?utm_medium=abc&utm_source=abc&utm_campaign=abc I would expect: http://localhost/Action/Redirect?Url=%2fsomeUrl%3futm_medium%3dabc%26utm_source%3dabc%26utm_campaign%3dabc I have also checked in Fiddler and the URL is being passed to the server correctly (one possible culprit could have been the browser decoding the URL before sending).

    Read the article

  • how to get the real bounds with google maps when fully zoomed out

    - by brad
    I have a map that shows location points based on the gbounds of the map. For example, any time the map is moved/zoomed, i find the bounds and query for locations that fall within those bounds. Unfortunately I'm unable to display all my locations when fully zoomed out. Reason being, gmaps reports the min/max long as whatever is at the edge of the map, but if you zoom out enough, you can get a longitudinal range that excludes visible locations. For instance, if you zoom your map so that you see NorthAmerica twice, on the far left and far right. The min/max long are around: -36.5625 to 170.15625. But this almost completely excludes NorthAmerica which lies in the -180 to -60 range. Obviously this is bothersome as you can actually see the continent NorthAmerica (twice), but when I query my for locations in the range from google maps, NorthAmerica isn't returned. My code for finding the min/max long is: bounds = gmap.getBounds(); min_lat = bounds.getSouthWest().lat() max_lat = bounds.getNorthEast().lat() Has anyone encountered this and can anyone suggest a workaround? Off the top of my head I can only thing of a hack: to check the zoom level and hardcode the min/max lats to -180/180 if necessary, which is definitely unacceptable.

    Read the article

  • How to validate presence of an uploaded file in rails?

    - by brad
    I'm playing around creating a rails file uploader and have struck a problem that should have an obvious solution. How do I check that a file has been selected in my form and uploaded? Here is my new.html.erb view <h2>Upload File</h2> <% form_for(@upload_file, :url => {:action => 'save'}, :html => {:multipart => true}) do |f| %> <%= f.error_messages %> <p> <%= f.label :file -%> <%= f.file_field :upload -%> </p> <p> <%= f.label :description %> <%= f.text_field :description %> </p> <p> <%= f.label :file_type %> <%= f.select :file_type, ["XML Data"] %> </p> <p><%= f.submit 'Upload File' %></p> <% end %> and here is my upload_file.rb model class UploadFile < ActiveRecord::Base validates_presence_of :description validates_presence_of :file_type validates_presence_of :upload def upload=(upload_file_field) self.name = "#{Time.now.strftime("%Y%m%d%H%M%S")}_#{upload_file_field.original_filename}" File.open("#{RAILS_ROOT}/public/upload/#{self.name}", "wb") { |f| f.write(upload_file_field.read) } end end If I use this as shown here, the validation validates_presence_of :upload always fails and I am returned to my form with an error message. I'd be very grateful if someone could explain how to do this validation correctly, and I'd be even more grateful if they could explain why it works. Thanks.

    Read the article

  • script.aculo.us autocomplete stuck behind input elements

    - by colour me brad
    I've got several script.aculo.us Ajax.Autocomplete controls on a page and when the drop down div is rendered it's always stuck behind the other text boxes on the page, no matter what I do with zIndex and positioning. The problem occurs in IE and FF. Anyone else run into this? Am I missing something, or is this just life with this control?

    Read the article

  • Skinning WinAPI Controls

    - by Brad
    If you've ever seen an application in the Adobe Creative Suite 5 (CS5), you may have noticed that it doesn't look like the native Windows GUI.. They have modified it to have a different look to it. Where would someone begin to make an application that has a custom skin? CS5 uses the Adobe Source library for it's widget/control management, so I tried downloading and compiling the Adobe Source Library to see if I could make a nice skinned app like Photoshop CS5, but after finally getting it to compile and tested it, I realized the library was only for managing widgets and not skinning the GUI, like CS5 has. Where would I begin to make a nice skinned program like Adobe Cs5 applications? Can anyone point me in the right direction? Do I simply use the WM_PAINT Message from WinAPI and render my own widgets using openGL or something?

    Read the article

  • multiple login pages in ASP.NET forms authentication

    - by Brad
    My bank's website has 2 login pages for online banking. On the first page, I enter my username. If I don't enter a valid username, I get an error message, and do not get to the 2nd page. The 2nd page displays a picture based on my user name, and has me enter my password. If I manually type a URL to a page inside the site after entering my username but before entering my password, I am redirected back to the first login page. Is there a good way to implement this in ASP.NET with Forms Authentication? I only get 1 loginUrl in my web.config. I am fairly certain my bank uses Java.

    Read the article

  • AVD Screen orientation not changing with CTRL+F11 or CTRL+F12

    - by Brad Hein
    I run my app in the AVD emulator using eclipse but I'm unable to change the screen orientation in the AVD (Android 2.0 platform on the emulator). When I press CONTROL+F11 or CONTROL+F12 on the keyboard, nothing happens. No messages are generated in the adb debuglog/logcat either when I press either hotkey. According to http://developer.android.com/guide/developing/tools/emulator.html these are the correct hotkeys to switch the emulator's screen orientation. I tried it with my app, and with the messaging app. The hotkey has no affect in any case. I'm running Fedora 12, Gnome. I checked my Keyboard Shortcuts in the System - Preferences menu, nothing's attached to either hotkey. Same problem, 3 different PCs (all running Fedora Gnome).

    Read the article

  • What are people's opinions vis-a-vis my choice of authorization plugins?

    - by brad
    I'm slowly but surely putting together my first rails app (first web-app of any kind in fact - I'm not really a programmer) and it's time to set up a user registration/login system. The nature of my app is such that each user will be completely separated from each other user (except for admin roles). When users log in they will have their own unique index page looking at only their data which they and no-one else can ever see or edit. However, I may later want to add a role for a user to be able to view and edit several other user's data (e.g. a group of users may want to allow their secretary to access and edit their data but their secretary would not need any data of their own). My plan is to use authlogic to create the login system and declarative authorization to control permissions but before I embark on this fairly major and crucial task I thought I would canvas a few opinions as to whether this combo was appropriate for the tasks I envisage or whether there would be a better/simpler/faster/cheaper/awesomer option.

    Read the article

  • Bundler http auth support

    - by brad
    does anyone know if Bundler supports http auth? I'm pretty sure rubygems does (I think i read that somewhere) but I don't see anywhere in the docs where I might specify a username/pwd for a particular repo I'm trying to run my own private gem server so as not to expose sensitive code

    Read the article

  • pickle on jruby

    - by brad
    Does anyone know if pickle is compatible with jruby? I just installed cucumber and cucumber-rails. I then tried gem install pickle and it installs, but a script/generate pickle yields Couldn't find 'pickle' generator I did everything according to the readme no dice. Anyone have any experience with this: specs jruby-1.4.0 rails-2.3.5 cucumber 0.7.2 pickle 0.2.10

    Read the article

  • Ruby assertions and disabled inputs

    - by brad
    Does anyone know how to assert that a checkbox or input is disabled? I can't find anything to indicated that this is supported I'm writing cucumber tests with webrat and test/unit. I'd like to have a step that is able to assert_disabled :some_checkbox || assert_disabled :some_input. Or some way that I can check a property of the checkbox.

    Read the article

  • Java - How to set focus the already running application ?

    - by Brad
    I am using a ServerSocket port to run one instance only of my Java Swing application, so if a user tries to open another instance of the program, i show him a warning that "Another instance is already open". This works fine, but instead of showing this message i want to set focus on the running application itself, like some programs does (MSN Messenger), even if it was minimized. Is there a solution for this for various operating systems ?

    Read the article

  • Cucumber-rails on jruby installs gem into my apps root directory with bundler

    - by brad
    Just installed cucumber 0.7.2 and cucumber-rails 0.3.1 with jruby-1.4.0 on OSX. When I run a bundle install, it places a cucumber-rails directory in my main app with all of the gem code/dependencies. First off, this is definitely not what I want and I'm not sure why this happens for cucumber-rails only. Second, if I delete this folder and just manually install cucumber-rails, when I run script/generate feature blah I get /Users/bradrobertson/.rvm/rubies/jruby-1.4.0/lib/ruby/site_ruby/1.8/rubygems/source_index.rb:344:in `refresh!': source index not created from disk (RuntimeError) from /Users/bradrobertson/.rvm/gems/jruby-1.4.0/gems/rails-2.3.5/lib/rails/vendor_gem_source_index.rb:34:in `refresh!' from /Users/bradrobertson/.rvm/gems/jruby-1.4.0/gems/rails-2.3.5/lib/rails/vendor_gem_source_index.rb:29:in `initialize' from /Users/bradrobertson/.rvm/gems/jruby-1.4.0/gems/rails-2.3.5/lib/rails/gem_dependency.rb:21:in `new' from /Users/bradrobertson/.rvm/gems/jruby-1.4.0/gems/rails-2.3.5/lib/rails/gem_dependency.rb:21:in `add_frozen_gem_path' from /Users/bradrobertson/.rvm/gems/jruby-1.4.0/gems/rails-2.3.5/lib/initializer.rb:298:in `add_gem_load_paths' from /Users/bradrobertson/.rvm/gems/jruby-1.4.0/gems/rails-2.3.5/lib/initializer.rb:132:in `process' from /Users/bradrobertson/.rvm/gems/jruby-1.4.0/gems/rails-2.3.5/lib/initializer.rb:113:in `run' from /Users/bradrobertson/Repos/app/source/trunk/config/environment.rb:13 from /Users/bradrobertson/Repos/app/source/trunk/config/environment.rb:1:in `require' from /Users/bradrobertson/.rvm/gems/jruby-1.4.0/gems/rails-2.3.5/lib/commands/generate.rb:1 from /Users/bradrobertson/.rvm/gems/jruby-1.4.0/gems/rails-2.3.5/lib/commands/generate.rb:3:in `require' from script/generate:3 Similarly running rake cucumber I get rake aborted! source index not created from disk So something obviously doesn't work. If I add that cucumber-rails directory back in, then my rake cucumber actually runs. Can someone tell me why it would need to install the gem right in my rails app? I've never seen this before. setup jruby-1.4.0 cucumber-0.7.2 cucumber-rails 0.3.1 bundler 0.9.23 webrat 0.7.1

    Read the article

  • WPF: ContextMenu item bound to a Command is enabled only after invoking the command from another so

    - by Brad
    I have a ContextMenu whose items are all bound to commands and enable\disable correctly after ANY Command is invoked from another source but prior to, they are all disabled. So if I run the app, all the MenuItems are disabled but if I invoke any of the bound commands from another source (buttons, for instance) they become synchronized with the CanExecute code. I have no idea how to debug this. Any thought would be helpful!?!

    Read the article

  • What is the Difference Between Learning HTML and Learning a Programming Language?

    - by Brad Johansen
    I learned HTML and CSS about 8 months ago, and recently, about 2 months ago I started learning Python and Ruby. I find it much harder/time consuming to understand and be able to put Python and Ruby into practice than it was HTML or CSS. How is learning/understanding HTML and CSS, and being able to use them different from learning a programming language like Python or Ruby, and being able to put them in practice.

    Read the article

  • TextBox.TextChanged & ICommandSource

    - by Brad Leach
    I am following the M-V-VM pattern for my WPF UI. I would like to hook up a command to the TextChanged event of a TextBox to a command that is in my ViewModel class. The only way I can conceive of completing this task is to inherit from the TextBox control, and implement ICommandSource. I can then instruct the command to be fired from the TextChanged event. This seems to be too much work for something which appears to be so simple. Is there an easier way (than subclassing the TextBox and implementing ICommandSource) to hook up the TextChanged event to my ViewModel class?

    Read the article

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