Daily Archives

Articles indexed Tuesday April 6 2010

Page 5/122 | < Previous Page | 1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >

  • Duplicate an element on button-push with jQuery

    - by paracaudex
    I'm new to jQuery, and I'm trying to cause another identical dropdown menu to appear each time the user presses a button. I thought this would work, where #append is the button id and #foo is the dropdown id: <script type="text/javascript"> $(document).ready(function(){ $("#append").click(function(){ $("#foo").append($("#foo")); }); }); </script> However, rather than duplicating the original dropdown, it causes it to disappear! What am I doing wrong?

    Read the article

  • Help with password complexity regex

    - by Alex
    I'm using the following regex to validate password complexity: /^.*(?=.{6,12})(?=.*[0-9]{2})(?=.*[A-Z]{2})(?=.*[a-z]{2}).*$/ In a nutshell: 2 lowercase, 2 uppercase, 2 numbers, min length is 6 and max length is 12. It works perfectly, except for the maximum length, when I'm using a minimum length as well. For example: /^.*(?=.{6,})(?=.*[0-9]{2})(?=.*[A-Z]{2})(?=.*[a-z]{2}).*$/ This correctly requires a minimum length of 6! And this: /^.*(?=.{,12})(?=.*[0-9]{2})(?=.*[A-Z]{2})(?=.*[a-z]{2}).*$/ Correctly requires a maximum length of 12. However, when I pair them together as in the first example, it just doesn't work!! What gives? Thanks!

    Read the article

  • setting ruby hash .default to a list

    - by matpalm
    i thought i understood what the default method does to a hash... give a default value for a key if it doesn't exist irb(main):001:0> a = {} => {} irb(main):002:0> a.default = 4 => 4 irb(main):003:0> a[8] => 4 irb(main):004:0> a[9] += 1 => 5 irb(main):005:0> a => {9=>5} all good. but if i set the default to be a empty list, or empty hash, i dont understand it's behaviour at all.... irb(main):001:0> a = {} => {} irb(main):002:0> a.default = [] => [] irb(main):003:0> a[8] << 9 => [9] # great! irb(main):004:0> a => {} # ?! would have expected {8=>[9]} irb(main):005:0> a[8] => [8] # awesome! irb(main):006:0> a[9] => [9] # unawesome! shouldn't this be [] ?? i was hoping / expecting the same behaviour as if i had used the ||= operator... irb(main):001:0> a = {} => {} irb(main):002:0> a[8] ||= [] => [] irb(main):003:0> a[8] << 9 => [9] irb(main):004:0> a => {8=>[9]} irb(main):005:0> a[9] => nil can anyone explain what is going on ???

    Read the article

  • Rewrite only external requests to a certain URL

    - by Cyclone
    I want to rewrite from http://example.com/blah/<something>/<somethingelse> to http://<something>.example.com/<somethingelse>, but only if the request is not an internal redirect. How can I achieve this effect? I know I can use %{THE_REQUEST}, but I can't seem to find any good examples. Thanks for the help!

    Read the article

  • Authlogic with nested attributes and polymorphic associations

    - by ferparra
    Hi all! I'm having trouble with the following code: User < AR acts_as_authentic belongs_to :owner, :polymorphic => true end Worker < AR has_one :user, :as => :owner accepts_nested_attributes_for :user end Employer < AR has_one :user, :as => :owner accepts_nested_attributes_for :user end I'd like to create registration forms based on user types, and to include authentication fields such as username and password. I currently do this: UserRegistrationController < AC #i.e. a new Employer def new @employer = Employer.new @employer.build_user end ... end I then include User fields with fields_for. All views render fine, but here's the catch: I cannot build a User, it tells me :password is a wrong method, so I guess the authentication logic was bypassed. What should I do? Am I doing it wrong altogether? Should I drop polymorphic associations in favor of Single Table Inheritance? Whatever I do, I have to make sure it plays nicely with Authlogic.

    Read the article

  • How do I check if a user is a fan of my facebook page on my website?

    - by Tony
    I want to check if my users are fans of my facebook page. I think something like this should do it: <script type="text/javascript" src="http://static.ak.connect.facebook.com/js/api_lib/v0.4/FeatureLoader.js.php/en_US"></script> <script type="text/javascript">FB.init("my api key","xd_receiver.htm");</script> <script type="text/javascript"> //<![CDATA[ FB_RequireFeatures(["Api"], function(){ var api = FB.Facebook.apiClient; api.pages_isFan(PAGE_ID,gigyaUser.FACEBOOK_USER_ID,function(response){ alert(response); }); }); //]]> </script> However, for some reason I keep getting null even though the user is in fact a fan of the page. Am I missing something?

    Read the article

  • An existing connection was forcibly closed by the remote host

    - by peter
    I am working with a commercial application which is throwing a SocketException with the message, An existing connection was forcibly closed by the remote host This happens with a socket connection between client and server. The connection is alive and well, and heaps of data is being transferred, but it then becomes disconnected out of nowhere. Has anybody seen this before? What could the causes be? I can kind of guess a few causes, but also is there any way to add more into this code to work out what the cause could be? Any comments / ideas are welcome. Thanks.

    Read the article

  • SoundChannel, removeEventHandler, AS3

    - by pixelGreaser
    Is there a better way to use the sound channel is AS3? This works, but I hate it when I tap the play button twice and it starts doubling. Please advise. var mySound:Sound = new Sound(); playButton.addEventListener (MouseEvent.CLICK, myPlayButtonHandler); var myChannel:SoundChannel = new SoundChannel(); function myPlayButtonHandler (e:MouseEvent):void { myChannel = mySound.play(); } stopButton.addEventListener(MouseEvent.CLICK, onClickStop); function onClickStop(e:MouseEvent):void{ myChannel.stop(); } /*-----------------------------------------------------------------*/ //global sound buttons, add instance of 'killswitch' and 'onswitch' to stage killswitch.addEventListener(MouseEvent.CLICK, clipKillSwitch); function clipKillSwitch(e:MouseEvent):void{ var transform1:SoundTransform=new SoundTransform(); transform1.volume=0; flash.media.SoundMixer.soundTransform=transform1; } onswitch.addEventListener(MouseEvent.CLICK, clipOnSwitch); function clipOnSwitch(e:MouseEvent):void{ var transform1_:SoundTransform=new SoundTransform(); transform1_.volume=1; flash.media.SoundMixer.soundTransform=transform1_; }

    Read the article

  • How do I track a branch of another repository on the same machine?

    - by Daniel Stutzbach
    I have two private repositories on one machine. Let's call them repo-A and repo-B, which are the directories ~/repo-A and ~/repo-B, respectively. repo-A has two relevant branches: master and live. I'd like to set up repo-B to track repo-A's live branch, so that git pull will pull any updates from repo-A's live branch into repo-B's master branch. Right now, I have the following in repo-B's .git/config: [remote "origin"] url = /home/stutzbach/repo-A/ fetch = +refs/heads/live:refs/remotes/origin/live [branch "master"] remote = origin merge = refs/heads/master However, when I run git pull, it seems to pull from repo-A's master branch. Obviously, I don't have it set up right. What's the right way?

    Read the article

  • Apache2 ignores ServerAlias

    - by Galen
    the www versions of all my sites work. the non-www version don't work. All non-www versions go to my default vhost (galengrover.com) Here are the first 2 virtual hosts in httpd.conf. ServerName galengrover.com NameVirtualHost *:80 <VirtualHost *:80> ServerAdmin [email protected] DocumentRoot /var/www/sites/galengrover.com/html ServerName www.galengrover.com ServerAlias galengrover.com </VirtualHost> <VirtualHost *:80> ServerAdmin [email protected] DocumentRoot /var/www/sites/skatevideosonline.net/html ServerName www.skatevideosonline.net ServerAlias skatevideosonline.com </VirtualHost> Im clueless. Thanks

    Read the article

  • Smoothing Small Data Set With Second Order Quadratic Curve

    - by Rev316
    I'm doing some specific signal analysis, and I am in need of a method that would smooth out a given bell-shaped distribution curve. A running average approach isn't producing the results I desire. I want to keep the min/max, and general shape of my fitted curve intact, but resolve the inconsistencies in sampling. In short: if given a set of data that models a simple quadratic curve, what statistical smoothing method would you recommend? If possible, please reference an implementation, library, or framework. Thanks SO!

    Read the article

  • Cocoa-Touch Fun. Name the Alphanumerically Longest Method Name?

    - by dugla
    So, as I get comfortable with Cocoa/Cocoa-Touch I, like others can't help but notice the rather verbose method names. What is the absolutely longest method in Cocoa-Touch that you have come across? To kick things off, I submit that perennial favorite from UITableViewController - tableView:accessoryButtonTappedForRowWithIndexPath: Cheers, Doug

    Read the article

< Previous Page | 1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >