Search Results

Search found 3096 results on 124 pages for 'scope creep'.

Page 21/124 | < Previous Page | 17 18 19 20 21 22 23 24 25 26 27 28  | Next Page >

  • how to access a firefox extension variable from the current document/window

    - by bosky101
    my firefox extension has an object myExt . myExt = { request: function(){ //makes request to server}, callback: function(json) { //do something with this } }; From a dynamically added script element, I make a call to a server that returns json, i want the json to be sent to myExt.callback that exists within my extension's js code. //from my extension, i add a script element myExt.request(); //from server i get the following response myExt.callback ( {"some":"json"}) ; //but the window doesnt find a reference to myExt how do i make a reference to myExt variable from the webpage ?

    Read the article

  • Why can't my function access a variable in an enclosing function?

    - by nailer
    I know about the LEGB rule. But a simple test of whether a function has read access to variables defined in an enclosing function doesn't seem to actually work. Ie: #!/usr/bin/env python2.4 '''Simple test of Python scoping rules''' def myfunction(): print 'Hope this works: '+myvariable def enclosing(): myvariable = 'ooh this worked' myfunction() if __name__ == '__main__': enclosing() Returns: NameError: global name 'myvariable' is not defined Am I doing something wrong? Is there more to it than the LEGB resolution order?

    Read the article

  • Variable not accessible within and if statment

    - by Chris
    I have a variable which holds a score for a game. My variable is accessible and correct outside of an if statement but not inside as shown below cout << score << endl; //works if(!justFinished){ cout << score << endl; // doesn't work prints a large negative number endTime = time(NULL); ifstream highscoreFile; highscoreFile.open("highscores.txt"); if(highscoreFile.good()){ highscoreFile.close(); }else{ std::ofstream outfile ("highscores.txt"); cout << score << endl; outfile << score << std::endl; outfile.close(); } justFinished = true; } cout << score << endl;//works

    Read the article

  • jquery document.ready multiple declaration

    - by Hendry H.
    I realized that I can specify $(document).ready(function(){}); more than once. Suppose like this $(document).ready(function(){ var abc = "1122"; //do something.. }); $(document).ready(function(){ var abc = "def"; //do something.. }); Is this standard ? Those codes work on my FF (16.0.2). I just a little afraid that other browser may not. What actually happen ? How jQuery handle those code ? Thanks.

    Read the article

  • Is it possible to restrict how a method can be called in PHP?

    - by Ashley Ward
    Given that my class looks like this: class Methods{ function a(){ return 'a'; } function b(){ $this->a(); } function c(){ $this->a(); } } Is it possible to ensure that function a can only be called from function b? In the above example function c should fail. I could just include it in function b, but in the future I may want to let a() be called by some new functions (e.g. d() or e())

    Read the article

  • Returning a private variable in JavaScript

    - by enrmarc
    I don't know why console.log(Set.current_index) shows 0 instead of 3. var Set = (function() { var set = []; var index = 0; function contains(set, e) { for (var i = 0; i < set.length; i++) { if (set[i] === e) { return true; } } return false; } var add = function(e) { if (!contains(set, e)) { set[index++] = e; } } var show = function() { for (var i = 0; i < set.length; i++) { console.log(set[i]); } } return { add: add, show: show, current_index: index }; })();? Set.add(20); Set.add(30); Set.add(40); Set.show(); console.log(Set.current_index);

    Read the article

  • How do I use a named_scope to filter records in my model

    - by kibyegon
    I have a model "Product" with a "description" field. Now I want to have a link in the index page that when clicked will show all products where the description is blank (empty). In the model I have defined a named_scope like this named_scope :no_description, :conditions => { :description => "" } I have checked that the named_scope works by calling Product.no_description.count on the console. As far as I know, the controller is then supposed to handle the filter request from the link on the "index" action but be able to distinguish it from the default which is view all products. def index @products = Product.all ... My problem is getting the controller handle the different request, what route to setup for the link on the view and the actual link on the view. Hope I explained my problem.

    Read the article

  • keeping track of multiple runs of the same function, part 2

    - by qwertymk
    This is related to this Anyway what I need is actually something slightly different I need some way of doing this: function run(arg) { this.ran = this.ran || false; if (!this.ran) init; /* code */ this.ran = true; } This works fine, I just want to make sure that this code works even when this in case it was called with call() or apply() Check this out for what I'm talking about, All of the calls after the first one should all be true, no matter the context

    Read the article

  • Using functions and environments

    - by Eduardo Leoni
    Following the recent discussions here (e.g. 1, 2 ) I am now using environments in some of my code. My question is, how do I create functions that modify environments according to its arguments? For example: y <- new.env() with(y, x <- 1) f <- function(env,z) { with(env, x+z) } f(y,z=1) throws Error in eval(expr, envir, enclos) : object 'z' not found I am using environments to keep concurrently two sets of simulations apart (without refactoring my code, which I wrote for a single set of experiments).

    Read the article

  • Python: why can't descriptors be instance variables?

    - by Continuation
    Say I define this descriptor: class MyDescriptor(object): def __get__(self, instance, owner): return self._value def __set__(self, instance, value): self._value = value def __delete__(self, instance): del(self._value) And I use it in this: class MyClass1(object): value = MyDescriptor() >>> m1 = MyClass1() >>> m1.value = 1 >>> m2 = MyClass1() >>> m2.value = 2 >>> m1.value 2 So value is a class attribute and is shared by all instances. Now if I define this: class MyClass2(object) value = 1 >>> y1 = MyClass2() >>> y1.value=1 >>> y2 = MyClass2() >>> y2.value=2 >>> y1.value 1 In this case value is an instance attribute and is not shared by the instances. Why is it that when value is a descriptor it can only be a class attribute, but when value is a simple integer it becomes an instance attribute?

    Read the article

  • Why does my simple event handling example not work?

    - by njreed
    I am trying to make a simple event handler. (Note, I'm not trying to implement a full-blown publish/subscribe model; I'm just interested in why my example doesn't work as I think it should) var myObj = (function () { var private = "X"; function triggerEvent(eventName) { if (this[eventName]) { this[eventName](); } } // Setter / Getter function getProp() { return private; } function setProp(value) { private = value; triggerEvent("onPropChange"); } // Public API return { // Events "onPropChange": null, // Fires when prop value is changed // Methods "getProp": getProp, "setProp": setProp }; })(); // Now set event handler myObj.onPropChange = function () { alert("You changed the property!"); }; myObj.setProp("Z"); // --> Nothing happens. Wrong // Why doesn't my alert show? I set the onPropChange property of my object to a simpler handler function but it is not being fired. I have debugged this and it seems that in triggerEvent the variable this is referencing the global window object. I thought it should reference myObj (which is what I need). Can someone explain the error in my thinking and how I correct this? Help much appreciated. jsFiddle here

    Read the article

  • Difference between :: and -> in PHP

    - by vrode
    I always see people in serious projects use :: everywhere, and - only occasionally in local environment. I only use - myself and never end up in situations when I need a static value outside of a class. Am I a bad person? As I understand, the only situation when -> won't work is when I try following: class StaticDemo { private static $static } $staticDemo = new StaticDemo( ); $staticDemo->static; // wrong $staticDemo::static; // right But am I missing out on some programming correctness when I don't call simple public methods by :: ? Or is it just so that I can call a method without creating an instance?

    Read the article

  • How can a Perl force its caller to return? [closed]

    - by JS Bangs
    Possible Duplicate: Is it possible for a Perl subroutine to force its caller to return? I want to write a subroutine which causes the caller to return under certain conditions. This is meant to be used as a shortcut for validating input to a function. What I have so far is: sub needs($$) { my ($condition, $message) = @_; if (not $condition) { print "$message\n"; # would like to return from the *parent* here } return $condition; } sub run_find { my $arg = shift @_; needs $arg, "arg required" or return; needs exists $lang{$arg}, "No such language: $arg" or return; # etc. } The advantage of returning from the caller in needs would then be to avoid having to write the repetitive or return inside run_find and similar functions.

    Read the article

  • What characteristic of a software determines its operational scope?

    - by Dark Star1
    How can I classify whether a software is a medium with the ability to grow into an enterprise level software or whether it is already there? And how should I use the information to choose the appropriate language/tool to create the software? At first I was asking whether Java or PHP is the best tool to design enterprise level software, however I've suddenly realized that I am unable to put the software I'm tasked with redesigning into the proper scope so I'm lost. Edit: I guess I'm looking for tell tale signs in software that may tip the favour towards enterprise level type software in the sense of functional and operational characteristics; functional: what it does (multi-functional), Architectural characteristics such as highly modular. operational: multi-sourced and multi-homed, databases, e.t.c. To be honest the reason I ask is because I'm skeptical about the use of PhP to design a piece of employee and partial accounting software. I'm more tipping towards the use of JSP and an hmvc framework such as JSF, wickets, e.t.c. where as the other guy wants to go the PhP way although I'm not experienced with PhP, as far as I know it's not an OO oriented language hence my skepticsm towards it.

    Read the article

  • Maven 2 assembly with dependencies: jar under scope "system" not included.

    - by YuppieNetworking
    Hello, I am using maven-assembly plugin to create a jar of my application, including its dependencies as follows: <assembly> <id>macosx</id> <formats> <format>tar.gz</format> <format>dir</format> </formats> <dependencySets> <dependencySet> <includes> <include>*:jar</include> </includes> <outputDirectory>lib</outputDirectory> </dependencySet> </dependencySets> </assembly> (I omitted some other stuff that is not related to the question) So far this has worked fine because it creates a lib directory with all dependencies. However, I recently added a new dependency whose scope is system, and it does not copy it to the lib output directory. i must be missing something basic here, so I call for help. The dependency that I just added is: <dependency> <groupId>sourceforge.jchart2d</groupId> <artifactId>jchart2d</artifactId> <version>3.1.0</version> <scope>system</scope> <systemPath>${project.basedir}/external/jchart2d-3.1.0.jar</systemPath> </dependency> The only way I was able to include this dependency was by adding the following to the assembly element: <files> <file> <source>external/jchart2d-3.1.0.jar</source> <outputDirectory>lib</outputDirectory> </file> </files> However, this forces me to change the pom and the assembly file whenever this jar is renamed, if ever. Also, it seems just wrong. I have tried with <scope>runtime</scope> in the dependencySets and <include>sourceforge.jchart2d:jchart2d</include> with no luck. So how do you include a system scoped jar to your assembly file in maven 2? Thanks a lot

    Read the article

  • Adding array of images to Firebase using AngularFire

    - by user2833143
    I'm trying to allow users to upload images and then store the images, base64 encoded, in firebase. I'm trying to make my firebase structured as follows: |--Feed |----Feed Item |------username |------epic |---------name,etc. |------images |---------image1, image 2, etc. However, I can't get the remote data in firebase to mirror the local data in the client. When I print the array of images to the console in the client, it shows that the uploaded images have been added to the array of images...but these images never make it to firebase. I've tried doing this multiple ways to no avail. I tried using implicit syncing, explicit syncing, and a mixture of both. I can;t for the life of me figure out why this isn;t working and I'm getting pretty frustrated. Here's my code: $scope.complete = function(epicName){ for (var i = 0; i < $scope.activeEpics.length; i++){ if($scope.activeEpics[i].id === epicName){ var epicToAdd = $scope.activeEpics[i]; } } var epicToAddToFeed = {epic: epicToAdd, username: $scope.currUser.username, userImage: $scope.currUser.image, props:0, images:['empty']}; //connect to feed data var feedUrl = "https://epicly.firebaseio.com/feed"; $scope.feed = angularFireCollection(new Firebase(feedUrl)); //add epic var added = $scope.feed.add(epicToAddToFeed).name(); //connect to added epic in firebase var addedUrl = "https://epicly.firebaseio.com/feed/" + added; var addedRef = new Firebase(addedUrl); angularFire(addedRef, $scope, 'added').then(function(){ // for each image uploaded, add image to the added epic's array of images for (var i = 0, f; f = $scope.files[i]; i++) { var reader = new FileReader(); reader.onload = (function(theFile) { return function(e) { var filePayload = e.target.result; $scope.added.images.push(filePayload); }; })(f); reader.readAsDataURL(f); } }); } EDIT: Figured it out, had to connect to "https://epicly.firebaseio.com/feed/" + added + "/images"

    Read the article

  • NSPredicates, scopes and SearchDisplayController

    - by Bryan Veloso
    Building a search with some custom objects and three scopes: All, Active, and Former. Got it working with the below code: - (void)filterContentForSearchText:(NSString*)searchText scope:(NSString *)scope { [[self filteredArtists] removeAllObjects]; for (HPArtist *artist in [self artistList]) { if ([scope isEqualToString:@"All"] || [[artist status] isEqualToString:scope]) { NSComparisonResult result = [[artist displayName] compare:searchText options:(NSCaseInsensitiveSearch|NSDiacriticInsensitiveSearch) range:NSMakeRange(0, [searchText length])]; if (result == NSOrderedSame) { [[self filteredArtists] addObject:artist]; } } } } This works fine and takes scope into account. Since I wanted to search four fields at at time, this question helped me come up with the below code: - (void)filterContentForSearchText:(NSString*)searchText scope:(NSString *)scope { [[self filteredArtists] removeAllObjects]; NSPredicate *resultPredicate = [NSPredicate predicateWithFormat:@"familyName CONTAINS[cd] %@ OR familyKanji CONTAINS[cd] %@ OR givenName CONTAINS[cd] %@ OR givenKanji CONTAINS[cd] %@", searchText, searchText, searchText, searchText]; [[self filteredArtists] addObjectsFromArray:[[self artistList] filteredArrayUsingPredicate:resultPredicate]]; } However it no longer takes scope into account. I have been playing around with if statements, adding AND scope == 'Active', etc. to the end of the statement and using NSCompoundPredicates to no avail. Whenever I activate a scope, I'm not getting any matches for it. Just a note that I've seen approaches like this one that take scope into account, however they only search inside one property.

    Read the article

  • How to reference input elements within a specific scope when there are multiple input elements of same kind?

    - by Will Merydith
    How do I select data for input elements within a specific scope? I have the same form multiple times (class "foo-form), and want to ensure I get the values for the hidden inputs within the scope of the form being submitted. Is the scope "this" implied? If not, what is the syntax for selecting input class "foo-text" within the scope of this? Feel free to point me to examples in the jquery docs - I could not find what I was looking for. $('.foo-form').submit(function() { // Store a reference to this form var $thisForm = $(this); }); <form class="foo-form"> <input type="hidden" class="foo-text"/> <input type="submit" class="button" /> </form> <form class="foo-form"> <input type="hidden" class="foo-text"/> <input type="submit" class="button" /> </form> <form class="foo-form"> <input type="hidden" class="foo-text"/> <input type="submit" class="button" /> // user clicks this submit button </form>

    Read the article

  • How to use the values from session variables in jsp pages that got saved using @Scope("session") in the mvc controllers

    - by droidsites
    Doing a web site using spring mvc. I added a SignupController to handle all the sign up related requests. Once user signup I am adding that to a session using @Scope("session"). Below is the SignupController code, SignupController.java @Controller @Scope("session") public class SignupController { @Autowired SignupServiceInter signUpService; private static final Logger logger = Logger.getLogger(SignupController.class); private String sessionUser; @RequestMapping("/SignupService") public ModelAndView signUp(@RequestParam("userid") String userId, @RequestParam("password") String password,@RequestParam("mailid") String emailId){ logger.debug(" userId:"+userId+"::Password::"+password+"::"); String signupResult; try { signUpService.registerUser(userId, password,emailId); sessionUser = userId; //adding the sign up user to the session return new ModelAndView("userHomePage","loginResult","Success"); //Navigate to user Home page if everything goes right } catch (UserExistsException e) { signupResult = e.toString(); return new ModelAndView("signUp","loginResult", signupResult); //Navigate to signUp page back if user does not exist } } } I am using "sessionUser" variable to store the signed up User Id. My understanding is that when I use @Scope("session") for the controller all the instance variables will added to HttpSession. So by that understanding I tried to access this "SessionUser" in userHomePage.jsp as, userHomepage.jsp Welcome to <%=session.getAttribute("sessionUser")%> But it throws null. So my question is how to use the values from session variables in jsp pages that got saved using @Scope("session") in the mvc controllers. Note: My work around is that pass that signed User Id to jsp page through ModelAndView, but it seems passing the value like these among the pages takes me back to managing state among pages using QueryStrings days.

    Read the article

  • How to have type hinting in PHP that specifies variable scope inside of a template? (specifically PhpStorm)

    - by Lance Rushing
    I'm looking for a doc comment that would define the scope/context of the current php template. (similar to @var) Example View Class: <?php class ExampleView { protected $pageTitle; public function __construct($title) { $this->pageTitle = $title; } public function render() { require_once 'template.php'; } } -- <?php // template.php /** @var $this ExampleView */ echo $this->pageTitle; PHPStorm gives an inspection error because the access on $pageTitle is protected. Is there a hint to give scope? Something like: <?php // template.php /** @scope ExampleView */ // <---???? /** @var $this ExampleView */ echo $this->pageTitle;

    Read the article

  • Conflicting ip routes with local table on attaching a virtual network interface

    - by user1071840
    I have an EC2 instance with these ip rules: $ sudo ip rule show 0: from all lookup local 32766: from all lookup main 32767: from all lookup default I can attach an elastic network interface to it with a private IP. Say the IP of my machine is 10.1.3.12 and the IP of the interface is 10.1.1.190. As soon as I attach the interface to my machine a new entry is added to the routing policy and local routing table: sudo ip rule show 0: from all lookup local 32765: from 10.1.1.190 lookup 10003 32766: from all lookup main 32767: from all lookup default $ sudo ip route show table local broadcast 10.1.1.0 dev eth3 proto kernel scope link src 10.1.1.190 local 10.1.1.190 dev eth3 proto kernel scope host src 10.1.1.190 broadcast 10.1.1.255 dev eth3 proto kernel scope link src 10.1.1.190 broadcast 10.1.3.0 dev eth0 proto kernel scope link src 10.1.3.12 local 10.1.3.12 dev eth0 proto kernel scope host src 10.1.3.12 broadcast 10.1.3.255 dev eth0 proto kernel scope link src 10.1.3.12 broadcast 127.0.0.0 dev lo proto kernel scope link src 127.0.0.1 local 127.0.0.0/8 dev lo proto kernel scope host src 127.0.0.1 local 127.0.0.1 dev lo proto kernel scope host src 127.0.0.1 broadcast 127.255.255.255 dev lo proto kernel scope link src 127.0.0.1 I can send traffic to this ENI directly from a host that can have the same IP as the host the ENI is attached to. This is where the problem starts. I ran tcpdump on the port in question and saw multiple SYNs going to the ENI with src '10.1.3.12' and destination '10.1.1.190' but didn't see even a single ACK. In my understanding if ACKs were being sent from the ENI they'd have destination as 10.1.3.12 i.e. the same as the local machine's IP and such packets will now be routed as local packets matching local routing policy: local 10.1.3.12 dev eth0 proto kernel scope host src 10.1.3.12 I'd like to send all the packets originating from 10.1.1.190 (my ENI) to go back on the same interface i.e. eth3 in this case. Contents of the nee table 10003 are: $ sudo ip route show table 10003 default via 10.1.1.1 dev eth3 I think I can do the following: I don't know if its possible but probably decrease the priority of local table so the packets match the table 10003. Use iptables to mangle these packets and update the local table route to include the mark information But I'm not sure if these are the right approaches.

    Read the article

  • Installing a DHCP Service On Win2k8 ( Windows Server 2008 )

    - by Akshay Deep Lamba
    Introduction Dynamic Host Configuration Protocol (DHCP) is a core infrastructure service on any network that provides IP addressing and DNS server information to PC clients and any other device. DHCP is used so that you do not have to statically assign IP addresses to every device on your network and manage the issues that static IP addressing can create. More and more, DHCP is being expanded to fit into new network services like the Windows Health Service and Network Access Protection (NAP). However, before you can use it for more advanced services, you need to first install it and configure the basics. Let’s learn how to do that. Installing Windows Server 2008 DHCP Server Installing Windows Server 2008 DCHP Server is easy. DHCP Server is now a “role” of Windows Server 2008 – not a windows component as it was in the past. To do this, you will need a Windows Server 2008 system already installed and configured with a static IP address. You will need to know your network’s IP address range, the range of IP addresses you will want to hand out to your PC clients, your DNS server IP addresses, and your default gateway. Additionally, you will want to have a plan for all subnets involved, what scopes you will want to define, and what exclusions you will want to create. To start the DHCP installation process, you can click Add Roles from the Initial Configuration Tasks window or from Server Manager à Roles à Add Roles. Figure 1: Adding a new Role in Windows Server 2008 When the Add Roles Wizard comes up, you can click Next on that screen. Next, select that you want to add the DHCP Server Role, and click Next. Figure 2: Selecting the DHCP Server Role If you do not have a static IP address assigned on your server, you will get a warning that you should not install DHCP with a dynamic IP address. At this point, you will begin being prompted for IP network information, scope information, and DNS information. If you only want to install DHCP server with no configured scopes or settings, you can just click Next through these questions and proceed with the installation. On the other hand, you can optionally configure your DHCP Server during this part of the installation. In my case, I chose to take this opportunity to configure some basic IP settings and configure my first DHCP Scope. I was shown my network connection binding and asked to verify it, like this: Figure 3: Network connection binding What the wizard is asking is, “what interface do you want to provide DHCP services on?” I took the default and clicked Next. Next, I entered my Parent Domain, Primary DNS Server, and Alternate DNS Server (as you see below) and clicked Next. Figure 4: Entering domain and DNS information I opted NOT to use WINS on my network and I clicked Next. Then, I was promoted to configure a DHCP scope for the new DHCP Server. I have opted to configure an IP address range of 192.168.1.50-100 to cover the 25+ PC Clients on my local network. To do this, I clicked Add to add a new scope. As you see below, I named the Scope WBC-Local, configured the starting and ending IP addresses of 192.168.1.50-192.168.1.100, subnet mask of 255.255.255.0, default gateway of 192.168.1.1, type of subnet (wired), and activated the scope. Figure 5: Adding a new DHCP Scope Back in the Add Scope screen, I clicked Next to add the new scope (once the DHCP Server is installed). I chose to Disable DHCPv6 stateless mode for this server and clicked Next. Then, I confirmed my DHCP Installation Selections (on the screen below) and clicked Install. Figure 6: Confirm Installation Selections After only a few seconds, the DHCP Server was installed and I saw the window, below: Figure 7: Windows Server 2008 DHCP Server Installation succeeded I clicked Close to close the installer window, then moved on to how to manage my new DHCP Server. How to Manage your new Windows Server 2008 DHCP Server Like the installation, managing Windows Server 2008 DHCP Server is also easy. Back in my Windows Server 2008 Server Manager, under Roles, I clicked on the new DHCP Server entry. Figure 8: DHCP Server management in Server Manager While I cannot manage the DHCP Server scopes and clients from here, what I can do is to manage what events, services, and resources are related to the DHCP Server installation. Thus, this is a good place to go to check the status of the DHCP Server and what events have happened around it. However, to really configure the DHCP Server and see what clients have obtained IP addresses, I need to go to the DHCP Server MMC. To do this, I went to Start à Administrative Tools à DHCP Server, like this: Figure 9: Starting the DHCP Server MMC When expanded out, the MMC offers a lot of features. Here is what it looks like: Figure 10: The Windows Server 2008 DHCP Server MMC The DHCP Server MMC offers IPv4 & IPv6 DHCP Server info including all scopes, pools, leases, reservations, scope options, and server options. If I go into the address pool and the scope options, I can see that the configuration we made when we installed the DHCP Server did, indeed, work. The scope IP address range is there, and so are the DNS Server & default gateway. Figure 11: DHCP Server Address Pool Figure 12: DHCP Server Scope Options So how do we know that this really works if we do not test it? The answer is that we do not. Now, let’s test to make sure it works. How do we test our Windows Server 2008 DHCP Server? To test this, I have a Windows Vista PC Client on the same network segment as the Windows Server 2008 DHCP server. To be safe, I have no other devices on this network segment. I did an IPCONFIG /RELEASE then an IPCONFIG /RENEW and verified that I received an IP address from the new DHCP server, as you can see below: Figure 13: Vista client received IP address from new DHCP Server Also, I went to my Windows 2008 Server and verified that the new Vista client was listed as a client on the DHCP server. This did indeed check out, as you can see below: Figure 14: Win 2008 DHCP Server has the Vista client listed under Address Leases With that, I knew that I had a working configuration and we are done!

    Read the article

< Previous Page | 17 18 19 20 21 22 23 24 25 26 27 28  | Next Page >