Search Results

Search found 366 results on 15 pages for 'closure cowboy'.

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

  • Google I/O 2011: JavaScript Programming in the Large with Closure Tools

    Google I/O 2011: JavaScript Programming in the Large with Closure Tools Michael Bolin Most developers who have tinkered with JavaScript could not imagine writing 1000 lines of code in such a language, let alone 100000. Yet that is exactly what Google engineers have done using a suite of JavaScript tools named "Closure" to produce many of the most popular and sophisticated applications on the Web, such as Gmail and Google Maps. From: GoogleDevelopers Views: 4915 35 ratings Time: 57:07 More in Science & Technology

    Read the article

  • getting started with Google Closure if you don't care about minifying/compiling?

    - by Tim
    If you don't care about minifying your code, is there a way to get started using the Google Closure library without having to set up a subversion client and use the compiler? The Notepad sample program on Google's website refers to <script src="closure-library/base.js" > </script > Can you simply download closure-library/base.js somewhere and start playing with the UI examples? The Closure Lite quick-start version doesn't appear to include goog.ui

    Read the article

  • getting started with Google Closure if you don't compare about minifying/compiling?

    - by Tim
    If you don't care about minifying your code, is there a way to get started using the Google Closure library without having to set up a subversion client and use the compiler? The Notepad sample program on Google's website refers to <script src="closure-library/base.js" > </script > Can you simply download closure-library/base.js somewhere and start playing with the UI examples? The Closure Lite quick-start version doesn't appear to include goog.ui

    Read the article

  • Javscript closure questions

    - by Shuchun Yang
    While I was reading the book Javascript: The Good Parts. I can not understand the piece of code bellow: We can generalize this by making a function that helps us make memoized functions. The memoizer function will take an initial memo array and the fundamental function. It returns a shell function that manages the memo store and that calls the fundamental function as needed. We pass the shell function and the function's parameters to the fundamental function: var memoizer = function (memo, fundamental) { var shell = function (n) { var result = memo[n]; if (typeof result !== 'number') { result = fundamental(shell, n); memo[n] = result; } return result; }; return shell; }; We can now define fibonacci with the memoizer, providing the initial memo array and fundamental function: var fibonacci = memoizer([0, 1], function (test, n) { return test(n - 1) + test(n - 2); }); My question is what is the test function? When does it get defined and invoked? It seems very confusing to me. Also I think this statement: memo[n] = result; is useless. Please correct if I am wrong.

    Read the article

  • CustomRenderer for AutoComplete using google closure library

    - by Paul
    I'm looking to use one of the AutoComplete subclasses(Rich,Remote,RichRemote) and I'd like to use a CustomRenderer, however I don't see instructions for this and reading the documentation/source it appears that the Remote subclass is instantiated with a renderer of "var renderer = new goog.ui.AutoComplete.Renderer();" leaving me no option to change it while instantiating. Is there a setRenderer method on the AutoComplete base class similar to that on the goog.ui.Controls classes? Thanks, Paul

    Read the article

  • scoping problem in recursive closure

    - by wiso
    why this work: def function1(): a = 10 def function2(): print a function2() but this not: def function1(): a = 10 def function2(): print a a -= 1 if a>0: function2() function2() error: UnboundLocalError: local variable 'a' referenced before assignment

    Read the article

  • Problem with Closure properties of context free languages

    - by altius
    hello i have the following sentence a language L1={a^n * b^n : n=0} and L2={b^n * a^n : n=0} are context free languages so they are close a=under the L1L2 so L={a^n * b^2n A^n : n=0} must be context free too because it is generated by a close property I have to prove if this sentence is true or not so i check the L language and i do not think that it is context free then i also saw that L2 is L1 reversed do i have to check if L1, L2 are deterministic ? please help because i am in a dead end

    Read the article

  • Closure and nested lambdas in C++0x

    - by DanDan
    Using C++0x, how do I capture a variable when I have a lambda within a lambda? For example: std::vector<int> c1; int v = 10; <--- I want to capture this variable std::for_each( c1.begin(), c1.end(), [v](int num) <--- This is fine... { std::vector<int> c2; std::for_each( c2.begin(), c2.end(), [v](int num) <--- error on this line, how do I recapture v? { // Do something }); });

    Read the article

  • jQuery async ajax query and returning value problem (scope, closure)

    - by glebovgin
    Hi. Code not working because of async query and variable scope problem. I can't understand how to solve this. Change to $.ajax method with async:false - not an option. I know about closures, but how I can implement it here - don't know. I've seen all topics here about closures in js and jQuery async problems - but still nothing. Help, please. Here is the code: var map = null; var marker; var cluster = null; function refreshMap() { var markers = []; var markerImage = new google.maps.MarkerImage('/images/image-1_32_t.png', new google.maps.Size(32, 32)); $.get('/get_users.php',{},function(data){ if(data.status == 'error') return false; var users = data.users; // here users.length = 1 - this is ok; for(var i in users) { //here I have every values from users - ok var latLng = new google.maps.LatLng(users[i].lat, users[i].lng); var mark = new google.maps.Marker({ position: latLng, icon: markerImage }); markers.push(mark); alert(markers.length); // length 1 } },'json'); alert(markers.length); // length 0 //if I have alert() above - I get result cluster = new MarkerClusterer(map, markers, { maxZoom: null, gridSize: null }); } Thanks.

    Read the article

  • Perl, "closure" using Hash

    - by Mike
    I would like to have a subroutine as a member of a hash which is able to have access to other hash members. For example sub setup { %a = ( txt => "hello world", print_hello => sub { print ${txt}; }) return %a } my %obj = setup(); $obj{print_hello}; Ideally this would output "hello world"

    Read the article

  • Google Closure Compiler - what does the name mean?

    - by mikez302
    I am curious about the Google Closure Compiler. Why did they name it that? Does it have anything to do with lexical closures? EDIT: I tried researching it in the FAQ and documentation, as well as doing Google searches such as "closure compiler name". I couldn't find anything definite, hence the reason I am asking. I don't think I will get a profoundly helpful answer but I was hoping that I could at least satisfy my curiosity. I am not trying to solve a specific problem. I am just curious.

    Read the article

  • I need help with some terminology

    - by Christine
    I'm not a programmer; I'm a freelance writer and researcher. I have a client who'd looking for stats on certain "threats" to the apps market. One of them is cowboy coding. (I know what that means; that's not my question.) Specifically, he wants to see numbers regarding how many apps have failed/crashed/removed because of errors made by, in essence, sloppy coding. (I'm not here to debate the merits of cowboy coding, and whether or not it is sloppy; work with me here.) I've used every possible search term/phrase I can think of, but I can't find any hard numbers, just anecdotal evidence. Have any of you seen any reports that have this kind of data?

    Read the article

  • Closure Tables - Is this enough data to display a tree view?

    - by James Pitt
    Here is the table I have created by testing the closure table method. | id | parentId | childId | hops | | | | | 270 | 6 | 6 | 0 | 271 | 7 | 7 | 0 | 272 | 8 | 8 | 0 | 273 | 9 | 9 | 0 | 276 | 10 | 10 | 0 | 281 | 9 | 10 | 1 | 282 | 7 | 9 | 1 | 283 | 7 | 10 | 2 | 285 | 7 | 8 | 1 | 286 | 6 | 7 | 1 | 287 | 6 | 9 | 2 | 288 | 6 | 10 | 3 | 289 | 6 | 8 | 2 | 293 | 6 | 9 | 1 | 294 | 6 | 10 | 2 I am trying to create a simple tree of this using PHP. There does not seem to be enough data to create the table. For example, when I look purely at parentId = 6: -Part 6 -Part 7 - ? - ? -Part 9 - ? - ? We know that parts 8 and 10 exists below Part 7 or 9, but not which. We know that part 10 exists at both 3 and 4 nodes deep but where? If I look at other data in the table it is possible to tell it should be: - Part 6 - Part 7 - Part 9 - Part 10 - Part 9 - Part 10 I thought one of the benefits of closure tables was there was no need for recursive queries? Could you help explain what I am doing wrong? EDIT: For clarification, this is a mapping table. There is another table called "parts" which has a column called part_id that correlates to both the parentId and childId columns in the "closure" table. The "id" column in the table above (closure) is just for the purposes of maintaining a primary key. It is not really necessary. The methods I have used to create this closure table is described in the following article: http://dirtsimple.org/2010/11/simplest-way-to-do-tree-based-queries.html EDIT2: It can have two and three hops. I will explain easier by assigning names to the items. Part 6 = Bicycle Part 7 = Gears Part 8 = Chain Part 9 = Bolt Part 10 = Nut Nut is part of Bolt. The Bolt and Nut combo exists directly within Bicycle and within Gears which is part of Bicycle. In relation to what method to use I have looked at Adjacency, Edges, Enum Paths, Closures, DAGS(networks) and the Nested Set Model. I am still trying to work out what is what, but this is an extremely complex component database where there are multiple parents and any modification to a sub-tree must propogate through the other trees. More importantly there will be insertions, deletions and tree views that I wish to avoid recursion during general use, even at the cost of database space and query time during entry.

    Read the article

  • Make a flowchart to demonstrate closure behavior

    - by thomas
    I saw below test question the other day in which the author's used a flow chart to represent the logic of loops. And I got to thinking it would be interesting to do this with some more complex logic. For example, the closure in this IIFE sort of boggles me. while (i <= qty_of_gets) { // needs an IIFE (function(i) promise = promise.then(function(){ return $.get("queries/html/" + product_id + i + ".php"); }); }(i++)); } I wonder if seeing a flowchart representation of what happens in it could be more elucidating. Could such a thing be done? Would it be helpful? Or just messy? I haven't the foggiest clue where to start, but thought maybe someone would like to take a stab. Probably all the ajax could go and it could just be a simple return within the IIFE.

    Read the article

  • is jQuery 1.4.2 compatible with Closure Compiler?

    - by Mohammad
    According to the official release statement version 1.4 has been re-written to be compressed with Closure Compiler yet when I use the online version of closure compiler I get 130 warnings. This is the code I use. // ==ClosureCompiler== // @compilation_level ADVANCED_OPTIMIZATIONS // @output_file_name default.js // @code_url http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.js // ==/ClosureCompiler== And as far as I know you get the real benefit of Closure Compiler if you include the library with your code also, so it removes the unused functions. Yet my testing show that I can't get any further than compressing the library itself.. What am I doing wrong? Any kind of insight will be much appreciated.

    Read the article

  • Safely defining variables for public callback functions in javascript

    - by djreed
    I am working with the YouTube iFrame API to embed a number of videos on a page. Documentation here: https://developers.google.com/youtube/iframe_api_reference#Requirements In summary, you load the API asynchronously using the following snippet: var tag = document.createElement('script'); tag.src = "http://www.youtube.com/player_api"; var firstScriptTag = document.getElementsByTagName('script')[0]; firstScriptTag.parentNode.insertBefore(tag, firstScriptTag); Once loaded, the API fires the predefined callback function onYouTubePlayerAPIReady. For additional context: I am defining a library file for this in Google Closure. I am providing a namespace: goog.provide('yt.video'); I then use goog.exportSymbol so that the API can find the function. That all works fine. My challenge is that I would like to pass 2 variables to the callback function. Is there any way to do this without defining these 2 variables in the context of the window object? goog.provide('yt.video'); goog.require('goog.dom'); yt.video = function(videos, locales) { this.videos = videos; this.captionLocales = locales; this.init(); }; yt.video.prototype.init = function() { var tag = document.createElement('script'); tag.src = "http://www.youtube.com/player_api"; var firstScriptTag = document.getElementsByTagName('script')[0]; firstScriptTag.parentNode.insertBefore(tag, firstScriptTag); }; /* * Callback function fired when YT API is ready * This is exported using goog.exportSymbol in another file and * is being fired by the API properly. */ yt.video.prototype.onPlayerReady = function(videos, locales) { window.console.log('this :' + this); //logs window window.console.log('this.videos : ' + this.videos); //logs undefined /* * Video settings from Django variable */ for(i=0; i<this.videos.length; i++) { var playerEvents = {}; var embedVars = {}; var el = this.videos[i].el; var playerVid = this.videos[i].vid; var playerWidth = this.videos[i].width; var playerHeight = this.videos[i].height; var captionLocales = this.videos[i].locales; if(this.videos[i].playerVars) var embedVars = this.videos[i].playerVars; } if(this.videos[i].events) { var playerEvents = this.videos[i].events; } /* * Show captions by default */ if(goog.array.indexOf(captionLocales, 'es') >= 0) { embedVars.cc_load_policy = 1; }; new YT.Player(el, { height: playerHeight, width: playerWidth, videoId: playerVid, events: playerEvents, playerVars: embedVars }); }; }; To intialize this, I am currently using the following within a self-executing anonymous function: var videos = [ {"vid": "video_id", "el": "player-1", "width": 640, "height": 390, "locales": ["es", "fr"], "events": {"onStateChange": stateChanged}}, {"vid": "video_id", "el": "player-2", "locales": ["es", "fr"], "width": 640, "height": 390} ]; var locales = ['es']; var videoTemplate = new yt.video(videos, locales);

    Read the article

  • How can CSS be applied to components from Google Closure Library?

    - by Jason
    I'm getting my feet wet with Google's Closure Library. I've created a simple page with a Select Widget, but it clearly needs some styling (element looks like plain text, and in the example below the menu items pop up beneath the button). I'm assuming the library supports styles -- how can I hook into them? Each example page in SVN seems to use its own CSS. Abbreviated example follows: <body> <div id="inputContainer"></div> <script src="closure-library-read-only/closure/goog/base.js"></script> <script> goog.require('goog.dom'); goog.require('goog.ui.Button'); goog.require('goog.ui.MenuItem'); goog.require('goog.ui.Select'); </script> <script> var inputDiv = goog.dom.$("inputContainer"); var testSelect = new goog.ui.Select("Test selector"); testSelect.addItem(new goog.ui.MenuItem("1")); testSelect.addItem(new goog.ui.MenuItem("2")); testSelect.addItem(new goog.ui.MenuItem("3")); var submitButton = new goog.ui.Button("Go"); testSelect.render(inputDiv); submitButton.render(inputDiv); </script> </body>

    Read the article

  • Javascript + Firebug : "cannot access optimized closure" What does it mean?

    - by interstar
    I just got the following error in a piece of javascript (in Firefox 3.5, with Firebug running) cannot access optimized closure I know, superficially, what caused the error. I had a line options.length() instead of options.length Fixing this bug, made the message go away. But I'm curious. What does this mean? What is an optimized closure? Is optimizing an enclosure something that the javascript interpretter does automatically? What does it do?

    Read the article

  • How to access a method of a closure's parent object?

    - by Bytecode Ninja
    I have defined a class named MyClass and I have defined two methods myMethod1 and myMethod2 for it: function MyClass() {} MyClass.prototype.myMethod1 = function() {...}; MyClass.prototype.myMethod2 = function() {...}; Inside myMethod1, I use jQuery and there's a callback closure defined there: MyClass.prototype.myMethod2 = function() { $.jQuery({success: function(data) { this.myMethod2(); }, ...}); } Now the problem is that this no longer is referring to MyClass. The question is how can I refer to it? At the moment I have assigned it to a variable named thisObj and access it this way: MyClass.prototype.myMethod2 = function() { var thisObj = this; $.jQuery({success: function(data) { thisObj.myMethod2(); }, ...}); } Is there a better way to access MyClass.this from the closure nested in myMethod2? Thanks in advance.

    Read the article

  • How to stop Lean programming becoming Cowboy Coding?

    - by Matt Howells
    My team has been progressively adopting more and more lightweight methodologies, moving from Scrum to Lean/Kanban where there is less and less formal process. At some point we will be back to Cowboy Coding; indeed I fear we may already be on the border line. Where can the line be drawn between a very lightweight Lean and Agile process and anarchy? How will we know when we have crossed the line? And how can we prevent ourselves from crossing the line? The question might also be phrased as, 'what processes cannot be safely eliminated in Lean's drive to eliminate waste'?

    Read the article

  • 13.10 Desktop - Stop Suspension on Lid Closure

    - by bpmitche
    I'm having a problem with power management settings on my ASUS K52-F Laptop. Upgraded from 13.04 to 13.10 earlier today; closing the laptop lid puts the laptop into suspension (even on AC Power - tried fixing it in gnome power settings, tried fixing it in Cinnamon power settings, tried changing it in DCONF-Editor, but no matter where I change the setting the laptop lid still suspends). After resuming from suspend, I restore to the gnome window/login manager (instead of Cinnamon login manager). Wifi doesn't reconnect, but the icon in Cinnamon shows that I'm connected. IFCONFIG shows that the interface is up and working normally, but still not reconnecting. ifconfig wlan0 down / up doesn't change anything. Any help would be greatly appreciated.

    Read the article

  • groovy closure parameters

    - by Don
    Hi, The following example of using the sendMail method provided by the grails mail plugin appears in this book. sendMail { to "[email protected]" subject "Registration Complete" body view:"/foo/bar", model:[user:new User()] } I understand that the code within {} is a closure that is passed to sendMail as a parameter. I also understand that to, subject and body are method calls. I'm trying to figure out what the code that implements the sendMail method would look like, and my best guess is something like this: MailService { String subject String recipient String view def model sendMail(closure) { closure.call() // Code to send the mail now that all the // various properties have been set } to(recipient) { this.recipient = recipient } subject(subject) { this.subject = subject; } body(view, model) { this.view = view this.model = model } } Is this reasonable, or am I missing something? In particular, are the methods invokedwithin the closure (to, subject, body), necessarily members of the same class as sendMail? Thanks, Don

    Read the article

  • How can this closure test be written in other languages?

    - by Jian Lin
    I wonder how the following closure test can be written in other languages, such as C and Java. Can the same result be expected also in Perl, Python, and PHP? Ideally, we don't need to make a new local variable such as x and assign it the value of i inside the loop, but just so that i has a new copy in the new scope each time. (if possible). (some discussion is in this question.) The following is in Ruby, the "1.8.6" on the first line of result is the Ruby version which can be ignored. p RUBY_VERSION $foo = [] (1..5).each do |i| $foo[i] = lambda { p i } end (1..5).each do |j| $foo[j].call() end the print out is: [MacBook01:~] $ ruby scope.rb "1.8.6" 1 2 3 4 5 [MacBook01:~] $ Contrast that with another test, with i defined outside: p RUBY_VERSION $foo = [] i = 0 (1..5).each do |i| $foo[i] = lambda { p i } end (1..5).each do |j| $foo[j].call() end the print out: [MacBook01:~] $ ruby scope2.rb "1.8.6" 5 5 5 5 5 [MacBook01:~] $

    Read the article

  • How to create a closure and pass in variable length argument list?

    - by Jian Lin
    We can create a closure p by capturing the arguments in the scope in the following code: var p = function() { }; if (typeof(console) != 'undefined' && console.log) { p = function() { console.log(arguments); }; } but the arguments are passed like an array to console.log, instead of passed one by one as in console.log(arguments[0], arguments[1], arguments[2], ... Is there a way to expand the arguments and pass to console.log like the way above? Note that p = console.log; works well in Firefox and IE 8 but not on Chrome.

    Read the article

  • Codeigniter Open Source Applications for Coding References

    - by Hafizul Amri
    I choose codeigniter to be my first framework to work with. Now I'm looking for open source applications built based on this framework to be my references for good coding practices and standards. From my previous experiences in application development, it was hard for me to maintain, upgrade, or modify existing applications due to my bad coding practices. Do you have any suggestion of application based on codeigniter framework for me to be referred? So that it can help me to write better coding by referring to their good and maybe best coding pratices. Thank you!

    Read the article

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