text
stringlengths
0
30.5k
title
stringclasses
1 value
embeddings
listlengths
768
768
Linq.EntitySets created by FK relationships are present and non-null. Got it. Rather than creating a class that inherits from the DataContext's class, I extend the DC class itself with a partial class in the Business Logic layer. From there I can add whatever constructors and methods I wish. In this case, it is necce...
[ -0.10949546843767166, -0.07472091168165207, 0.9405307173728943, 0.06755466759204865, 0.13117653131484985, -0.11589931696653366, -0.07184165716171265, -0.4459191858768463, -0.27813416719436646, -0.16911163926124573, 0.15005996823310852, 0.2815783619880676, -0.25933313369750977, 0.0625644028...
now :)
[ 0.10580393671989441, 0.28877732157707214, 0.673419177532196, -0.09001937508583069, 0.32848018407821655, -0.15546555817127228, 0.0357215516269207, -0.029266612604260445, -0.10471700876951218, -0.23130688071250916, -0.2595660090446472, 0.4365904927253723, 0.03851122781634331, 0.4016087949275...
I want to build a custom control to reuse in my project which consists of two UITextFields that are linked together + a label. It is starting to become repetitive across my App and smells of code duplication ;) However, I wonder what is the best aproach here. Is it best do everything by code in a controller or is p...
[ 0.25195690989494324, -0.13085313141345978, 0.03545570746064186, 0.2879542112350464, -0.25762835144996643, -0.19649893045425415, 0.18037442862987518, 0.10188164561986923, -0.10067690163850784, -0.7613255381584167, 0.26568174362182617, 0.4111061096191406, -0.11221780627965927, 0.023331528529...
started. Apple recommends creating a plug-in to IB for just your case...
[ 0.11676912754774094, 0.1790260225534439, 0.07237385958433151, -0.22739851474761963, 0.29426810145378113, 0.15902286767959595, -0.09177723526954651, 0.04284834489226341, -0.0556739941239357, -0.30539920926094055, 0.030358826741576195, 0.49345237016677856, -0.1843932867050171, -0.13730929791...
I have this java string: ``` String bla = "<my:string>invalid_content</my:string>"; ``` How can I replace the "invalid\_content" piece? I know I should use something like this: ``` bla.replaceAll(regex,"new_content"); ``` in order to have: ``` "<my:string>new_content</my:string>"; ``` but I can't discover how...
[ 0.34581243991851807, 0.041691455990076065, 0.29639068245887756, -0.22167140245437622, -0.07036219537258148, -0.2330968677997589, 0.3976534605026245, -0.45327797532081604, -0.15261727571487427, -0.734635591506958, 0.03458801656961441, 0.36220794916152954, -0.2804569602012634, 0.009591258130...
I have a number of tables in my DB that hold references to an key value pair: types of phone numbers: * 1 - Home * 2 - Work * 3 - Mobile * 4 - Fax etc So I have a table for the types and when they are used in other tables they reference the int value as a foreign key. When I have been pulling them out I have been s...
[ 0.264127254486084, 0.41197702288627625, 0.04215863347053528, -0.04420378431677818, -0.1570516675710678, 0.21625083684921265, 0.2394808530807495, -0.21737632155418396, 0.1449488252401352, -0.655222475528717, 0.029154401272535324, 0.3207050859928131, -0.14390096068382263, 0.30805516242980957...
two different types of data types to get the same data. My problem has arrived when I need to populate a dropdownlist within a gridview when I am using the edittemplate bit. If I use a datasource to pull this out it will write [1 Home] in the text rather than put the int as the value and Home as the text to display. ...
[ 0.1808975636959076, -0.024572737514972687, 0.10689201205968857, -0.07817526906728745, -0.07992801815271378, -0.2078835368156433, 0.32865700125694275, -0.08145902305841446, -0.17305999994277954, -0.6098839640617371, 0.38743624091148376, 0.2954920530319214, -0.24019291996955872, 0.1977206915...
datatable? I didn't like to put it all in datatable. I have my DAL taking to my BLL and have tried to encapsulate everything as objects or `List<>`'s of objects rather than tables of everything. Most the time this has worked well. Two: If I was using some object rather than a datatable to bind into my objectdatasourc...
[ -0.000249416014412418, -0.06820616126060486, 0.14642687141895294, 0.30165573954582214, -0.4114161431789398, -0.03841882944107056, -0.0673651173710823, -0.03913476690649986, -0.39456748962402344, -0.46144646406173706, 0.1297517716884613, 0.36671286821365356, -0.25089696049690247, 0.15829114...
dropdownlist to bind I just had to do: ``` SelectedValue='<%# DataBinder.Eval(Container, "DataItem.PhoneType.Key") %>' ``` The reason I didn't see that one straight away was because it was not showing up in my intellisense but when I manually typed it in, it worked. Use a Dictionary<int, string> and set your DropDow...
[ -0.21552729606628418, -0.23171265423297882, 0.7368562817573547, -0.2562391459941864, -0.05265131965279579, 0.13944436609745026, 0.12193752825260162, -0.5781546235084534, -0.004925421439111233, -0.5465989112854004, -0.33488789200782776, 0.3800128996372223, -0.5077310800552368, -0.0249218773...
dropDown.DataTextField = "Value"; dropDown.DataValueField = "Key"; dropDown.DataSource = dictionary; //Dictionary<int, string> dropDown.DataBind(); ```
[ -0.2020702362060547, -0.24781732261180878, 0.37398019433021545, -0.19580979645252228, 0.24320414662361145, -0.014171354472637177, 0.34420719742774963, -0.021382853388786316, 0.0025720109697431326, -0.19143424928188324, -0.7275927066802979, 0.6052889227867126, -0.19476419687271118, 0.275412...
I am making a litte php-file to log some ip addresses. It is going to write the ips and date/time into a html-file. The html-file is going to be a table. So I want to mak it like this: ``` <table cellpadding="6" rules="groups" frame="no"> <thead> <tr><th>IP</th><th>Date</th><th>Time</th></tr> </thead> <tbody> <tr><t...
[ 0.11453361809253693, 0.24121512472629547, 1.0265625715255737, -0.2708674669265747, -0.16181117296218872, -0.03286454826593399, 0.39259254932403564, -0.2886427044868469, 0.04079623892903328, -0.6983547806739807, 0.11020145565271378, 0.12931354343891144, -0.15509580075740814, 0.1858458966016...
$time = date("H:i:s"); $file = fopen('./iplogg.html', 'a', 1); $text="<tr><td>{$ip}</td><td>{$date}</td><td>{$time}</td></tr> \n"; fwrite($file, $text); fclose($file); ?> ``` I'm going to assume that there's only a single table in the file. If there's more than one, this will add it to each. ``` <?php $ip = $_SE...
[ 0.13646367192268372, -0.0553043968975544, 0.7320287227630615, -0.11010105162858963, 0.34042832255363464, 0.05794035643339157, 0.2649199962615967, -0.4913422465324402, -0.222798153758049, -0.8179638981819153, -0.32175832986831665, 0.11088350415229797, -0.496504545211792, 0.3255021274089813,...
I am struck by the ambition and creativity of Charles Simonyi's efforts to establish the field of Intentional Programming, first at Microsoft and then with his own company. [What exactly is Intentional Programming](https://stackoverflow.com/questions/201386/what-exactly-is-intentional-programming) <http://en.wikipedi...
[ 0.3188208341598511, 0.19722191989421844, -0.21930591762065887, -0.09042145311832428, 0.08051545917987823, 0.1664285957813263, 0.14302150905132294, -0.3018675446510315, -0.029893003404140472, -0.2441093474626541, -0.14662708342075348, 0.5234740972518921, -0.2634187340736389, -0.013590586371...
program. Successive > changes are only done at the WYSIWYG > level. It seems to be such a useful and practical approach to programming, potentially circumventing many of the problems with current approaches to software development. Essentially it seems to facilitate the creation of domain-specific languages by non...
[ 0.021336277946829796, -0.33865875005722046, 0.71855628490448, 0.182968869805336, -0.004469793755561113, -0.21629735827445984, 0.26259031891822815, 0.04881070926785469, -0.4210784137248993, -0.7083070278167725, -0.21456116437911987, 0.17393793165683746, -0.1954435259103775, 0.21654063463211...
delay in releasing his product has to do with the fact that he is dealing with simplifying a much higher level of abstraction because he has to essentially allow for the encapsulation of all domain languages at once. So, my question is **(a) whether [Antlr](http://en.wikipedia.org/wiki/ANTLR) could be an alternative...
[ 0.3161832094192505, -0.09976863116025925, 0.1415722370147705, 0.025099558755755424, -0.41754019260406494, -0.10657919943332672, 0.23555196821689606, -0.028513293713331223, -0.3764813244342804, -0.24616804718971252, -0.059148844331502914, 0.20828212797641754, -0.48626747727394104, 0.0821120...
can it not do? Also, I don't understand why it's called a "language parser" rather than a "language generator" - since the latter describes what it is used for while the former describes how it achieves its end result.** and **(b) if Antlr is different from Intentional Programming, is there anything similar to Inten...
[ 0.26363861560821533, -0.11191122233867645, -0.05876235291361809, 0.182158425450325, -0.3610117435455322, -0.13794884085655212, 0.4990250766277313, -0.24028567969799042, -0.03281916305422783, -0.2539215683937073, -0.01893402263522148, 0.3027574121952057, -0.49080517888069153, 0.057470653206...
what ANTLR generates a parser from.
[ -0.4827711880207062, 0.22074058651924133, 0.11833354830741882, 0.19133877754211426, -0.1771644502878189, 0.07957123965024948, 0.1977929025888443, -0.08639026433229446, -0.005127460230141878, -0.23694851994514465, 0.04247276112437248, 0.1612132042646408, -0.3367049992084503, -0.414509654045...
I have a site that has a simple HTML button in a form. All browsers show this button correctly. However, in Firefox 2 and Seamonkey it appears just as a solid grey square that cannot be clicked on and that has no text. ``` <input id="getaudiobutton" type="button" value="Get Audio" onclick="convert()" /> ``` For thos...
[ 0.10680122673511505, 0.07492928206920624, 0.6606593728065491, -0.30487585067749023, -0.12818177044391632, -0.13077153265476227, 0.11094062775373459, -0.19469374418258667, -0.10069755464792252, -0.8136559724807739, -0.2859446108341217, 0.740766167640686, -0.5463535189628601, -0.019919963553...
and Seamonkey managed to find this a bit troublesome. Thank you all for your help. :) From what I can see just by viewing it in Seamonkey and looking at the contents of the page and your CSS, you may want to check the style for the div that the button is contained in. I can see the button in Seamoney, but it is cut of...
[ 0.3652167022228241, -0.1730283498764038, 0.5219997763633728, 0.19210860133171082, -0.2491660714149475, -0.012894715182483196, 0.27568766474723816, 0.3388536870479584, -0.24191607534885406, -0.8020246028900146, -0.10509712994098663, 0.4541492760181427, -0.12280033528804779, -0.0560737028717...
to the parent div of the button, it is cutting off most of the button.
[ 0.2647378444671631, -0.34696605801582336, 0.49265727400779724, 0.0066945552825927734, 0.0314255990087986, 0.11754883080720901, 0.24649356305599213, -0.047713249921798706, -0.0650542750954628, -0.4268379211425781, -0.3191870450973511, 0.24212495982646942, -0.264933317899704, 0.1635654568672...
This is a follow up to [this question](https://stackoverflow.com/questions/493311/how-to-write-safe-correct-multi-threaded-code-in-net), where I didn't get any input on this point. Here is the brief question: **Is it possible to detect and debug problems coming from multi-threaded code?** Often we have to tell our cu...
[ 0.2969065308570862, 0.28280773758888245, -0.028070975095033646, 0.27806341648101807, -0.08664530515670776, -0.077810138463974, 0.30244532227516174, 0.1859026551246643, -0.4801250398159027, -0.5331323742866516, 0.11976782977581024, 0.5395654439926147, -0.23735761642456055, 0.247861862182617...
to know if there are any special logging frameworks, or debugging techniques, or code inspectors, or anything else to help solving such issues. General approaches are welcome. If any answer should be language related then keep it to .NET and Java. **Threading/concurrency problems** are notoriously difficult to replicat...
[ 0.41516682505607605, 0.18148183822631836, -0.21793845295906067, 0.30647069215774536, -0.12332479655742645, -0.3662054240703583, 0.6455053687095642, 0.16627788543701172, -0.4850209355354309, -0.656646728515625, -0.07323966175317764, 0.523396909236908, -0.46481460332870483, 0.079692773520946...
design of object hand-over, rather than "shared" objects. For the latter, use fully synchronized control objects (which are easier to reason about), and avoid having a synchronized object utilize other objects which must also be synchronized - that is, try to keep them self contained. Your best defense is a good design...
[ 0.18181779980659485, -0.11605136841535568, 0.15243315696716309, 0.4672269821166992, 0.043790049850940704, -0.21791981160640717, 0.3585495054721832, -0.12997481226921082, -0.5067318081855774, -0.6819888949394226, -0.25673988461494446, 0.360685795545578, -0.26574116945266724, 0.1579833775758...
to be a problem acquiring the same locks in different orders. **Live locks** are harder - being able to observe the system while in the error state is your best bet there. **Race conditions** tend to be extremely difficult to replicate, and are even harder to identify from manual code review. With these, the path I u...
[ 0.6963692307472229, 0.12137886136770248, -0.11232127249240875, 0.3921664357185364, 0.38338690996170044, 0.04629009589552879, 0.6889458298683167, -0.23378488421440125, -0.5285552144050598, -0.42903947830200195, 0.04990279674530029, 0.5671669244766235, -0.13721394538879395, -0.13958144187927...
complex the system, the harder it is to find concurrency errors, and to reason about it's behavior. Make use of tools like JVisualVM and remote connect profilers - they can be a life saver if you can connect to a system in an error state and inspect the threads and objects. Also, beware the differences in possible beh...
[ 0.18655268847942352, 0.09870290756225586, 0.1683175265789032, 0.24704289436340332, 0.016925808042287827, -0.11785358190536499, 0.3756029009819031, 0.3053964376449585, -0.6712079644203186, -0.7466521263122559, 0.24258998036384583, 0.5942277908325195, -0.333757609128952, 0.3208097219467163, ...
distributed with the system libraries - e.g in Java `java.util.concurrent` is your friend. **Writing your own concurrency control objects is hard and fraught with danger; leave it to the experts, if you have a choice.**
[ 0.007877658121287823, 0.07827113568782806, 0.2447514683008194, 0.11249637603759766, -0.14013053476810455, -0.39736831188201904, 0.4690268039703369, 0.18228112161159515, -0.729168713092804, -0.5736252069473267, -0.004708233755081892, 0.21368855237960815, -0.41523048281669617, 0.179225072264...
I'm getting an exception in an OnTimer event handler (TTimer) that when executed increments an integer variable in the parent form. The timers need to be able to access an incremented integer used as an id. My first question is: How can I tell in Delphi 2007 which code is running in which thread? Is there a way in deb...
[ 0.09995058923959732, -0.004071851726621389, 0.12081275135278702, -0.06084870919585228, -0.20018737018108368, -0.3342173397541046, 0.26488372683525085, -0.03637618571519852, -0.39969781041145325, -0.32154494524002075, 0.2501409351825714, 0.6007658839225769, -0.3704051971435547, 0.1258403062...
access these variables "incorrectly" without giving an exception and other times it does give an exception. Just to be sure: On one hand you are talking about a timer event, on the other about multithreading. Those are two totally different ways of running code in parallel. A timer will always be run in the main threa...
[ 0.4145408868789673, -0.0599808469414711, 0.13607452809810638, 0.35060492157936096, 0.11830195039510727, -0.3361053466796875, 0.367987722158432, 0.05590837821364403, -0.538602888584137, -0.5511217713356018, 0.14546503126621246, 0.6211923360824585, -0.5346201062202454, 0.35007086396217346, ...
message. So it is either outside of any event handling code or when one of your event handlers calls Application.ProcessMessages. A thread is very different from this. In this case, the code in different threads runs independently from each other. If running on a multi-processor machine (or multi core), it is even pos...
[ 0.07445323467254639, -0.33300039172172546, 0.24012252688407898, 0.05936989188194275, -0.15685677528381348, -0.09235019981861115, 0.15734708309173584, 0.09151961654424667, -0.661305844783783, -0.46518585085868835, -0.09278468787670135, 0.33985283970832825, -0.4550902247428894, 0.37084788084...
exceptions to this rule). So, please first clarify whether you are talking about timers or true multithreading, before expecting any useful answers.
[ 0.5686995387077332, 0.02718011476099491, 0.04745624586939812, 0.17137926816940308, 0.16934682428836823, -0.2662634253501892, 0.3444730043411255, -0.08124122023582458, -0.27844715118408203, -0.43339380621910095, -0.022363122552633286, 0.7141382694244385, -0.20508404076099396, 0.003143228823...
The Web browser's Window.External object is always null! To reproduce drop a web browser on a new winform and type: ``` Option Strict Off Public Class Form1 Private Sub Form1_Load() Handles MyBase.LoadMe.WebBrowser1.Document.Window.DomWindow.External.AddFavorite("http://www.google.com") End Sub End C...
[ 0.05566771700978279, 0.15561507642269135, 0.5174136757850647, -0.27267956733703613, -0.04257747158408165, -0.09328441321849823, 0.3404158353805542, -0.09566407650709152, -0.11084539443254471, -0.6709532737731934, -0.271403968334198, 0.6856998205184937, -0.3692026734352112, 0.48361587524414...
and `-(void)release` are empty functions when the GC is on, they don't change the retain count. This means leaving it out is fine.
[ 0.10716146230697632, 0.1440572738647461, 0.3663593828678131, -0.32851964235305786, 0.21480384469032288, -0.42009785771369934, 0.018991347402334213, 0.1368233561515808, -0.14531783759593964, 0.13876034319400787, -0.4367692172527313, 0.8710975050926208, -0.17284908890724182, 0.21625401079654...
I came across a javascript puzzle asking: Write a one-line piece of JavaScript code that concatenates all strings passed into a function: ``` function concatenate(/*any number of strings*/) { var string = /*your one line here*/ return string; } ``` @ [meebo](http://www.meebo.com/jobs/openings...
[ -0.0819215476512909, 0.13942024111747742, 0.06699998676776886, -0.1586705893278122, -0.30800479650497437, 0.29326924681663513, 0.11142253130674362, -0.12951895594596863, -0.016047177836298943, -0.42204269766807556, -0.08948777616024017, 0.29416680335998535, -0.46311256289482117, 0.05386292...
if (conc.arguments.length === 0) return ""; else return conc.arguments.shift() + conc(conc.arguments); } ``` it seems as though conc.arguments is not an array, but can be accessed by a number index and has a length property??? confusing -- please share opinions and other recursive im...
[ 0.12433745712041855, 0.2319558560848236, 0.2926107943058014, 0.022838419303297997, 0.17127427458763123, -0.21216563880443573, 0.13256333768367767, -0.32082030177116394, -0.2780791223049164, -0.40313318371772766, -0.2564578056335449, 0.5154661536216736, -0.36597442626953125, -0.028414433822...
all the Array methods at your disposal. Other examples of Array-like objects are HTML collections returned by getElementsByTagName() or getElementsByClassName(). jQuery, if you've ever used it, is also an Array-like object. After querying some DOM objects, inspect the resulting jQuery object with Firebug in the DOM tab...
[ 0.021445738151669502, -0.009979980997741222, 0.41153261065483093, -0.28249549865722656, -0.19538943469524384, -0.07179242372512817, 0.3415035307407379, -0.12786291539669037, -0.17552238702774048, -0.540445864200592, -0.15829521417617798, 0.6451608538627625, -0.27086666226387024, 0.16534233...
into a veritable Array object. In Firefox `Array.slice.call(arguments)` would suffice, but it won't work in IE6 (at least), so the former version is what is usually used. Also, this trick doesn't work for collection returned by DOM API methods in IE6 (at least); it will throw an Error. By the way, instead of `call` one...
[ 0.35675445199012756, 0.02592867612838745, 0.15803010761737823, -0.32230883836746216, -0.1777281016111374, -0.1373884528875351, 0.3880394697189331, -0.09094228595495224, -0.15514551103115082, -0.38522395491600037, -0.19137997925281525, 0.5585847496986389, -0.7612292170524597, 0.059788923710...
= { bar : function() { alert('I am bar'); }, 0 : function() { alert('I am 1'); }, length : 1 } ``` The above object is an Array-like object for two reasons: 1. It has members which names are numbers, so they're like Array indexes 2. It has a `length` property, without which you ...
[ 0.1996687799692154, 0.2019827961921692, 0.42460960149765015, -0.5175607204437256, -0.2195308655500412, 0.07130815088748932, 0.21874557435512543, -0.29203957319259644, -0.06488925963640213, -0.39270028471946716, -0.2053312510251999, 0.1678529977798462, -0.7490449547767639, 0.217752337455749...
like the Foo object, only that it has its special purpose.
[ 0.29801785945892334, 0.21069186925888062, -0.04454265534877777, -0.09774661809206009, -0.22457116842269897, -0.30833783745765686, 0.22947315871715546, 0.4506741166114807, -0.015405131503939629, -0.08374244719743729, -0.3533053398132324, 0.40012308955192566, -0.37136614322662354, 0.26679489...
I've been using Javascript's Date for a project, but noticed today that my code that previously worked is no longer working correctly. Instead of producing Feb as expected, the code below produces March. My code looks something like this: ``` current = new Date(); current.setMonth(current.getMonth()+1); //If today ...
[ 0.10320921242237091, 0.23879367113113403, 0.9974820017814636, -0.36842870712280273, -0.1361914575099945, 0.05026838928461075, 0.28097692131996155, 0.22467507421970367, -0.5214639902114868, -0.541641116142273, 0.1351785808801651, 0.24602173268795013, 0.09873102605342865, 0.5643448829650879,...
day of the month, I'd expect it to be 1, 2 or 3. If it's not the same as before you added a month, roll back by one day until the month changes again. That way, the day "last day of Jan" becomes "last day of Feb". EDIT: Ronald, based on your comments to other answers, you might want to steer clear of edge-case behav...
[ 0.07602736353874207, 0.044375572353601456, 0.7887401580810547, 0.023255735635757446, -0.22080880403518677, -0.048851415514945984, 0.16677944362163544, 0.23700855672359467, -0.49242210388183594, -0.2368049919605255, 0.054125718772411346, 0.30314984917640686, 0.10501256585121155, 0.147124215...
I would explicitly code for the possibilities. Since you don't care about the day of the month (you just want the year and month to be correct for next month), something like this should suffice: ``` var now = new Date(); if (now.getMonth() == 11) { var current = new Date(now.getFullYear() + 1, 0, 1); } else { ...
[ 0.20763663947582245, 0.08887127041816711, 0.9515091776847839, -0.3755963146686554, 0.09953036904335022, 0.019885236397385597, 0.26532691717147827, 0.08358098566532135, -0.3720683455467224, -0.5291395783424377, -0.05315493419766426, 0.4044265151023865, 0.06539023667573929, 0.429842889308929...
since grown tired of coding tricks for efficiency, preferring readability unless there's a clear requirement to do otherwise.
[ 0.30194923281669617, 0.08551345765590668, 0.060971856117248535, -0.07917003333568573, 0.31063416600227356, -0.09018410742282867, 0.16987344622612, 0.344947874546051, -0.16882534325122833, -0.3488751947879791, -0.04752925783395767, 0.23800347745418549, 0.09407910704612732, -0.12813036143779...
I've coded a program in C that sends messages to the stdout using printf and I'm having trouble redirecting the output to a file (running from bash). I've tried: ``` ./program argument >> program.out ./program argument > program.out ./program >> program.out argument ./program > program.out argument ``` In each cas...
[ 0.09874328225851059, 0.5081575512886047, 0.3510577976703644, -0.505378246307373, -0.2583487033843994, 0.49615776538848877, 0.1679869294166565, -0.042656462639570236, -0.29343199729919434, -0.7983294129371643, -0.08641104400157928, 0.48933687806129456, -0.41384032368659973, 0.27993166446685...
with the program itself? with the argument passing? Where should look for the problem? Some details about the C program: * It does not read anything from stdin * It uses BSD Internet Domain sockets * It uses POSIX threads * It assigns a special handler function for SIGINT signal using sigaction * It sends lots of new...
[ 0.2832607924938202, -0.27409934997558594, 0.4196103811264038, -0.008865795098245144, -0.06567022204399109, -0.11962977051734924, 0.1915491819381714, 0.022298943251371384, -0.4085124433040619, -0.4063059389591217, 0.09887520223855972, 0.34688079357147217, -0.43667668104171753, 0.14986558258...
} while (1); /* Code never reached */ pthread_exit(EXIT_SUCCESS); } ``` Flushing after newlines only works when printing to a terminal, but not necessarily when printing to a file. A quick Google search revealed this page with further information: <http://www.pixelbeat.org/programming/stdio_buffering/> See th...
[ 0.2077673375606537, -0.4342102110385895, 0.7450203895568848, -0.13293740153312683, 0.13627007603645325, -0.14220541715621948, 0.15172496438026428, -0.04770936816930771, -0.2988639771938324, -0.7445555925369263, 0.002798293484374881, 0.5076904892921448, -0.3555329740047455, -0.0815670192241...
While investigating a reported problem with my site loading slowly, I came across an issue where I noticed (via firebug) that my flash file was loading twice. After a bit of investigation I tracked it down to a [firefox bug](https://bugzilla.mozilla.org/show_bug.cgi?id=438830) combined with the usage of SWFObject 2.0....
[ 0.3778722882270813, 0.08479874581098557, 0.24760940670967102, -0.18165747821331024, -0.3455711901187897, -0.3526628017425537, 0.5803399682044983, -0.10989803075790405, -0.5768139362335205, -0.6372373700141907, -0.008055542595684528, 0.623802900314331, -0.694905698299408, 0.0287836045026779...
to schedule your plugin scripting code > to run after all pending browser events using window.setTimeout with a timeout > of zero. Honestly, I have no clue what they're saying and am hoping someone can give me a code example that will work. Do you know of a way to make this work and what the code would look like? A...
[ 0.34646329283714294, -0.17231231927871704, 0.6527895331382751, -0.14825820922851562, 0.25470176339149475, -0.15320143103599548, 0.5436030030250549, -0.16999459266662598, -0.22736485302448273, -0.9036738276481628, -0.25336742401123047, 0.6704308986663818, -0.3865389823913574, -0.24227440357...
<param name="movie" value="style.swf"> <param NAME=FlashVars VALUE="url={{stylelist}}"> <!--[if !IE]>--> <object type="application/x-shockwave-flash" data="style.swf" width="778" height="198"> <param name="flashvars" value="url={{stylelist}}"> <!--<![endif]--> <a href="http://www.adobe.com...
[ 0.05898350104689598, 0.0978669747710228, 0.33616524934768677, -0.09399339556694031, -0.6204364895820618, -0.0895787924528122, 0.24266639351844788, -1.064672827720642, -0.48283159732818604, 0.0019232357153669, -0.39849919080734253, 0.46143966913223267, -0.057308129966259, 0.0709206908941268...
I've looked around but haven't been able to figure out if I should use both an ETag **and** an Expires Header **or** one or the other. What I'm trying to do is make sure that my flash files (and other images and what not only get updated when there is a change to those files. I don't want to do anything special like ...
[ 0.5267085433006287, 0.19393151998519897, 0.1325584501028061, 0.183673694729805, -0.17526626586914062, -0.14764820039272308, 0.310086190700531, 0.34961387515068054, -0.1779322773218155, -0.5559433102607727, 0.34270361065864563, 0.26644617319107056, -0.13910959661006927, 0.2586362957954407, ...
is it all Apache? They are slightly different - the ETag does not have any information that the client can use to determine whether or not to make a request for that file again in the future. If ETag is all it has, it will always have to make a request. However, when the server reads the ETag from the client request, t...
[ 0.19455143809318542, -0.21697776019573212, 0.07065997272729874, 0.20693662762641907, -0.0697951391339302, -0.38238340616226196, 0.19211634993553162, -0.33488455414772034, -0.025897953659296036, -0.17274373769760132, 0.010243426077067852, 0.29832378029823303, -0.4185211658477783, -0.2502215...
content of the file changes. The Expires header is used by the client (and proxies/caches) to determine whether or not it even needs to make a request to the server at all. The closer you are to the Expires date, the more likely it is the client (or proxy) will make an HTTP request for that file from the server. So r...
[ 0.4557179808616638, -0.39560872316360474, 0.7154768109321594, 0.29247674345970154, 0.2980133593082428, -0.34577351808547974, 0.055687401443719864, -0.00587396090850234, -0.25856223702430725, -0.6494699716567993, -0.19380579888820648, 0.47856616973876953, -0.2001187652349472, -0.01251676492...
the server, it can more easily determine whether or not to send the file back. One last note about ETag - if you are using a load-balanced server setup with multiple machines running Apache you will probably want to turn off ETag generation. This is because inodes are used as part of the ETag hash algorithm which will...
[ 0.10383377969264984, -0.12483622878789902, -0.002121014054864645, 0.3656254708766937, -0.2031273990869522, -0.3813934624195099, 0.11248697340488434, -0.3436790704727173, -0.1506139636039734, -0.5871824622154236, 0.24376194179058075, 0.5111549496650696, -0.4170781075954437, -0.1103115603327...
servers.
[ -0.016292892396450043, 0.011528552509844303, 0.18860271573066711, 0.2158481776714325, 0.2900716960430145, 0.03816736489534378, -0.039759960025548935, 0.2010207176208496, -0.4749051630496979, -0.4189281761646271, -0.22120104730129242, 0.16277346014976501, 0.006260371766984463, 0.21458244323...
As per the title, I'm trying to find a way to programmatically determine the longest portion of similarity between several strings. Example: * `file:///home/gms8994/Music/t.A.T.u./` * `file:///home/gms8994/Music/nina%20sky/` * `file:///home/gms8994/Music/A%20Perfect%20Circle/` Ideally, I'd get back `file:///home/gms...
[ 0.05193391442298889, 0.09632182121276855, 0.5544182062149048, -0.0741732269525528, -0.21387451887130737, 0.14202308654785156, 0.10994084179401398, -0.09620922803878784, -0.43656855821609497, -0.4465891420841217, 0.038561753928661346, 0.3945724666118622, -0.013209706172347069, 0.47331160306...
big mistake. This string is evaluated inside Benchmark module and @str was empty there. This solution is not as fast as I presented. See correction below. I'm sorry again. Perl can be fast: ``` use strict; use warnings; package LCP; sub LCP { return '' unless @_; return $_[0] if @_ == 1; my $i ...
[ -0.08749260008335114, -0.3480933606624603, 0.4755890965461731, -0.16039755940437317, -0.0394158698618412, -0.022270357236266136, 0.6416611671447754, -0.04060099273920059, -0.30815497040748596, -0.4832395017147064, -0.04174644872546196, 0.5905651450157166, -0.3164413571357727, 0.15544322133...
$min_length = length($_) if length($_) < $min_length; } INDEX: foreach my $ch ( split //, $first ) { last INDEX unless $i < $min_length; foreach my $string (@_) { last INDEX if substr($string, $i, 1) ne $ch; } } continue { $i++ } return substr $first, 0, $i; } # Roy'...
[ -0.03635738790035248, -0.2021162509918213, 0.6543482542037964, -0.1895560473203659, 0.17849592864513397, 0.2941283881664276, 0.1978285163640976, -0.1577892005443573, -0.14412730932235718, -0.2482219636440277, -0.13081243634223938, 0.5370834469795227, -0.32691559195518494, 0.424684882164001...
'' unless @_; my $prefix = shift; for (@_) { chop $prefix while (! /^\Q$prefix\E/); } return $prefix; } 1; ``` Test suite: ``` #!/usr/bin/env perl use strict; use warnings; Test::LCP->runtests; package Test::LCP; use base 'Test::Class'; use Test::More; use Benchmark qw(:all :hireswal...
[ 0.2733602523803711, -0.22964094579219818, 0.3374878764152527, -0.12900157272815704, 0.46129927039146423, 0.2159471958875656, 0.33667415380477905, -0.32639703154563904, 0.04475244879722595, -0.6678112149238586, -0.7435573935508728, 0.4071386754512787, -0.32340237498283386, 0.287818402051925...
'', 'None of common prefix' ); is( LCP::LCP( 'abcdefgh', ('abcdefgh') x 15, 'abcdxyz' ), 'abcd', 'Some common prefix' ); my @str = map { chomp; $_ } <DATA>; is( LCP::LCP(@str), 'file:///home/gms8994/Music/', 'Test data prefix' ); is( LCP::LCP2(@str), 'file:///home/gms8994/Music/'...
[ -0.09198176115751266, -0.08349524438381195, 0.5671086311340332, -0.12171453982591629, 0.36429187655448914, 0.23622189462184906, 0.11436944454908371, -0.2223915159702301, -0.3098967671394348, -0.5935980081558228, -0.4864586293697357, 0.27581632137298584, -0.20709465444087982, 0.352308601140...
countit( 1, sub{LCP::LCP2(@str)} ); diag("LCP2: ${\($t->iters)} iterations took ${\(timestr($t))}"); } __DATA__ file:///home/gms8994/Music/t.A.T.u./ file:///home/gms8994/Music/nina%20sky/ file:///home/gms8994/Music/A%20Perfect%20Circle/ ``` Test suite result: ``` 1..7 ok 1 - use LCP; ok 2 - Without parameters o...
[ -0.22643011808395386, -0.38347673416137695, 0.8233287334442139, 0.12733393907546997, -0.19647131860256195, 0.26307758688926697, 0.32980087399482727, -0.5739861130714417, -0.2025548666715622, -0.16659964621067047, 0.04313002526760101, 0.2821755111217499, -0.2436112016439438, 0.1469284594058...
20% faster than [Roy's solution](https://stackoverflow.com/questions/499967/programmatically-determining-the-longest-similar-portion-of-several-strings/500100#500100) at your test case and one prefix finding takes about 50us. There is not necessary using XS unless your data or performance expectations are bigger.
[ -0.033670563250780106, -0.3457910716533661, 0.4896324872970581, 0.23125652968883514, 0.18376754224300385, -0.14555460214614868, 0.568466067314148, -0.4921526312828064, 0.05231032893061638, -0.7685294151306152, -0.051899150013923645, 0.11631853878498077, 0.14651168882846832, -0.232394888997...
I would like to zoom in/out an UIImage object when the user performs the standard pinch action on my application. I'm currently using a UIImageView to display my image, if that detail helps in any way. I'm trying to figure out how to do this, but no such luck so far. Any clues? Another easy way to do this is to place...
[ 0.15736457705497742, -0.2704455852508545, 0.6651915907859802, 0.12685799598693848, -0.1387888342142105, 0.027789561077952385, 0.08282337337732315, -0.06239118427038193, -0.25595858693122864, -0.9355561137199402, 0.09892696887254715, 0.5448901653289795, -0.12355999648571014, 0.2157958298921...
and `scrollViewDidEndZooming:withView:atScale:` methods to allow for pinch-zooming and image panning. This is effectively what Ben's solution does, only in a slightly more lightweight manner, as you don't have the overhead of a full web view. One issue you may run into is that the scaling within the scroll view comes ...
[ 0.19714593887329102, -0.11567602306604385, 0.8559988737106323, -0.007983934134244919, -0.1619594842195511, -0.01861806958913803, 0.301772803068161, -0.4750775992870331, -0.3108978569507599, -0.6471408605575562, 0.07355391979217529, 0.7971848845481873, -0.14044404029846191, 0.12860369682312...
your image.
[ 0.4043113589286804, 0.09606724977493286, -0.15326237678527832, 0.17185178399085999, -0.2113562971353531, 0.1807873696088791, 0.09183023869991302, 0.208284392952919, -0.29908818006515503, -0.920784056186676, 0.05680398643016815, 0.4878005385398865, -0.18312545120716095, -0.02830153703689575...
using asp.net and c# membership provider how to check if the user is registered or not? I want to handle this in code not by using "login status"? Not sure if you want to know if they are a "registered" user or have logged in (as the Login status would indicate) Here's to know if they are logged in (what the Login sta...
[ 0.6024741530418396, -0.050836194306612015, 0.37602391839027405, 0.07759905606508255, 0.07241545617580414, -0.4924977421760559, 0.33987438678741455, 0.06125511974096298, -0.46845319867134094, -0.5748323202133179, 0.07739221304655075, 0.3119725286960602, 0.05411949381232262, -0.0592968612909...
I've recently started working with RoR for some projects and I quite like the framework - however coming from an ASP.NET background I'm quite fond of the idea of being able to purchase & drop in reusable components/control such as those from telerik, without having to 'reinvent'. I suppose it would be possible to mayb...
[ 0.6770734190940857, 0.22269873321056366, 0.0760689303278923, 0.4183688759803772, 0.041693247854709625, -0.046923715621232986, -0.10342495888471603, -0.04224293306469917, -0.10862284898757935, -0.45270836353302, 0.07953262329101562, 0.44179868698120117, -0.019784802570939064, -0.02217891812...
counted them) of plugins out there freely available, to do a great many things for you, some of which would probably count as "controls". Unfortunately, there's no one place to go and find them, and the quality is depressingly variable, but there are a number of plugin indexes like <http://agilewebdevelopment.com/plugi...
[ 0.6085948348045349, -0.04431942105293274, 0.05123049020767212, 0.41252607107162476, 0.20011360943317413, 0.006927271839231253, 0.09270577877759933, 0.1186857596039772, -0.42684587836265564, -0.43350064754486084, 0.07501327991485596, 0.49773135781288147, -0.25306347012519836, 0.078215010464...
I am trying to have some clever dates since a post has been made on my site ("seconds since, hours since, weeks since, etc..") and I'm using datetime.timedelta difference between utcnow and utc dated stored in the database for a post. Looks like, according to the docs, I have to use the days attribute AND the seconds ...
[ 0.5455380082130432, 0.06874678283929825, 0.4548637866973877, 0.1805388480424881, -0.0033524734899401665, 0.24661333858966827, 0.19219273328781128, 0.3889223039150238, -0.2641681730747223, -0.556056797504425, 0.35892000794410706, -0.23220482468605042, 0.1822633296251297, 0.5498878359794617,...
that Python 2.7 has introduced a [total\_seconds()](http://docs.python.org/library/datetime.html#datetime.timedelta.total_seconds) method, which is what you were looking for, I believe!
[ 0.47876474261283875, -0.31516802310943604, 0.19743911921977997, -0.057445891201496124, 0.06512419879436493, -0.2597883641719818, 0.26621225476264954, 0.0718441978096962, -0.3882962465286255, 0.14960412681102753, -0.020766254514455795, 0.3153362572193146, -0.145292729139328, -0.369874686002...
Been doing Java for number of years so haven't been tracking C++. Has ***finally*** clause been added to C++ exception handling in the language definition? Is there a favored idiom that mimics Java's try/finally? Am also bothered that C++ doesn't have an ultimate super type for all possible exceptions that could be t...
[ -0.008653453551232815, -0.025855788961052895, 0.13278315961360931, -0.06857592612504959, -0.5931625366210938, 0.04614480957388878, 0.321803480386734, -0.29444658756256104, -0.41206273436546326, -0.5564156770706177, 0.055371273308992386, 0.38702869415283203, -0.14498281478881836, -0.1330502...
use > destructors to do cleanup. Of course, > from my own comments, it is clear I > don't entirely agree with that. > However, C++ is what it is and so in > the application endeavor I have in > mind, I'm going to more or less strive > to adhere to common community > practice. I'll use template classes to > wra...
[ 0.15994851291179657, 0.0709134191274643, 0.07736274600028992, -0.04963357746601105, -0.09491979330778122, -0.17371360957622528, 0.32166531682014465, -0.19725319743156433, -0.2519473433494568, -0.8521775603294373, -0.3557085692882538, 0.7306878566741943, -0.4172205924987793, -0.083948768675...
with > ScopeGuard approach (see one of the > answers below) would be a way to > accomplish cleanup with arbitrary > actions and access to the cleanup > code's outer scope context. Cleanup could be done in the idiom fashion that is seen in Ruby programming where they supply cleanup blocks when a resource is being o...
[ 0.27215954661369324, -0.3426257371902466, -0.09233295917510986, -0.03866944834589958, -0.2953800559043884, -0.23701706528663635, 0.45100128650665283, -0.5619655251502991, -0.15578609704971313, -0.6594895124435425, -0.16793577373027802, 0.6679101586341858, -0.7056227922439575, -0.0839021280...
where you have no idea when an object's finalizer will be called. **UPDATE**: Straight from the horse's mouth: [Why doesn't C++ provide a "finally" construct?](http://www.research.att.com/~bs/bs_faq2.html#finally)
[ -0.014438827522099018, -0.1178400069475174, 0.35516607761383057, -0.042118266224861145, -0.1441883146762848, -0.20471809804439545, 0.35105982422828674, -0.1950061023235321, -0.2413513958454132, -0.45750847458839417, -0.34127938747406006, 0.14015068113803864, 0.3336432874202728, 0.110613062...
I have a jQuery selector, which has a chained function. Inside the function I want to get access to the TEXT representing the expression for the selector. ``` $("cat dog").function() { // how do I get access to the "cat dog" string from inside THIS function ? }; ``` I've over simplified in this code sample wha...
[ 0.29361292719841003, 0.14990004897117615, 0.046794209629297256, -0.23000402748584747, 0.04056330397725105, -0.0965074822306633, 0.21384093165397644, -0.1585959643125534, 0.025454800575971603, -0.5841876864433289, -0.12235110253095627, 0.671220064163208, -0.5045115351676941, -0.002888925606...
plugin. Its a little tricky to google for this. **edit:** the 'selector' property is unfortunately now deprecated. <http://jquery.com/upgrade-guide/1.9/#selector-property-on-jquery-objects> There is a 'selector' attribute in the jQuery object, but I'm not sure it's always available.
[ -0.09248464554548264, -0.15412510931491852, 0.09611714631319046, 0.0021655710879713297, -0.1279536783695221, -0.14809831976890564, -0.045067209750413895, 0.02599289081990719, -0.17039921879768372, -0.4892135262489319, -0.14172911643981934, 0.7012042999267578, -0.00698437774553895, 0.056297...
I've searched through google (maybe I didn't look hard enough) but I could not find how to turn Math.sqrt into an int. I want to use Math.sqrt for a *for* loop and I guess I need it as an int but I can't seem to figure out how to cast the result to an int. So how do I do it? I tried something similar to Java: ``` (i...
[ -0.08164745569229126, 0.07138828933238983, 0.195964053273201, -0.08163850009441376, -0.4262600541114807, 0.25945496559143066, 0.04221265763044357, -0.15253987908363342, -0.21005605161190033, -0.6356261372566223, 0.14227768778800964, 0.3359208106994629, 0.004794977605342865, 0.0285865142941...
can be expressed as a 32 bit signed integer the bitwise operation described below might also suit."* -<http://www.jibbering.com/faq/faq_notes/type_convert.html#tcNumber>
[ 0.43397897481918335, -0.07033053040504456, 0.5672995448112488, 0.12641888856887817, -0.0705535039305687, 0.06977979093790054, -0.010328426957130432, -0.4016588032245636, -0.13825909793376923, 0.13840901851654053, 0.1752699762582779, 0.34535759687423706, -0.4292764365673065, 0.3070580661296...
I'm talking about the groove style of the text on focussed title bars, or safari's bookmarks bar for example. Is there an easy way to reproduce this style when using: ``` [string drawAtPoint:... withAttributes:...]; ``` If you want it to look perfect, you'll need to draw the text twice. As you can see when zooming i...
[ 0.1801619529724121, -0.11370497196912766, 0.3558666706085205, 0.16384488344192505, -0.046316228806972504, 0.02293492667376995, 0.15358658134937286, 0.10457752645015717, -0.09801951795816422, -0.7691097855567932, -0.029910949990153313, 0.7354966998100281, -0.251755952835083, -0.184447795152...
which it will be by default on Macs with a built-in or external Apple flat-panel display. NSShadow can not be used with sub-pixel anti-aliasing, so if you simply set an NSShadowAttributeName in the attributes dictionary you're drawing your string with, you will notice sub-pixel anti-aliasing is MIA when you zoom in on...
[ -0.09182332456111908, -0.2048593908548355, 0.3139539361000061, 0.10435361415147781, -0.10691741853952408, -0.06368652731180191, 0.4986092746257782, -0.02363494411110878, -0.01764550991356373, -0.8430959582328796, -0.25673943758010864, 0.49235013127326965, -0.3682728409767151, 0.08077509701...
white color with some transparancy, 2. Then draw it once more on top of that, a pixel higher in a shade of grey of your liking with no transparancy. Your 'shadow' will draw without sub-pixel antialiasing, but the actual text on top op of it will draw with it, giving you the exact same effect as standard Cocoa toolbar ...
[ 0.099200539290905, -0.02454691007733345, 0.2682993412017822, -0.08385948091745377, -0.22376644611358643, 0.12408707290887833, 0.1201968565583229, -0.11552594602108002, -0.2694515585899353, -0.6247351169586182, 0.13460034132003784, 0.4112336039543152, -0.29204893112182617, -0.11913903802633...
'shadow' text as well; drawback of that approach: you are tying your drawing code to only work well on a particular background color, e.g. if your elements will be used on a blue background, you'll want to set that color to a light shade of blue, to appear like it's semi-transparent white.
[ 0.5040001273155212, -0.2792317867279053, 0.13881148397922516, 0.11020451039075851, 0.051994699984788895, 0.11876806616783142, 0.15124543011188507, -0.021249771118164062, -0.14095601439476013, -0.4929335415363312, 0.06184271350502968, 0.2021017223596573, -0.518038809299469, -0.1325489729642...
As you probably know, Derek Sivers is the guy who created CD Baby and eventually sold it for some big bucks. He wrote it in PHP originally and then down the road set about rewriting it in Rails. His troubles are the stuff of legend: [**7 reasons I switched back to PHP after 2 years on Rails**](http://www.oreillynet.co...
[ 0.541702389717102, 0.041753076016902924, 0.036825429648160934, 0.17007498443126678, -0.2936432957649231, 0.04385155439376831, 0.03220595419406891, 0.37400516867637634, 0.04365478828549385, -0.23008370399475098, 0.5271266102790833, 0.4810526967048645, -0.29529085755348206, 0.135972186923027...
not offer any significant advantages over PHP?** Re-writing an existing site is almost always a bad idea. It's hard to put your heart into retreading an old wheel. I worked on a rewrite of a site from CGIs to a Java app server and saw several programmers quit because of it. For one, they preferred their old way of doin...
[ 0.43097302317619324, 0.27729442715644836, -0.09983109682798386, -0.02990083582699299, -0.25926312804222107, -0.2001316249370575, 0.6569454669952393, 0.17441275715827942, -0.3336074650287628, -0.6156997680664062, 0.2948963940143585, 0.5219613909721375, 0.10972881317138672, 0.024803321808576...
new task and see how it fares. At least then you are putting it on an even footing with PHP in the psychological motivation sweepstakes.
[ 0.11451906710863113, -0.18038927018642426, 0.36189621686935425, 0.5395157933235168, -0.14855578541755676, -0.13036403059959412, 0.3312710225582123, 0.1185229942202568, -0.35072076320648193, -0.6419205069541931, 0.5365632772445679, 0.5226454138755798, 0.6264894604682922, -0.4423447251319885...
What is the scope of variables in javascript? Do they have the same scope inside as opposed to outside a function? Or does it even matter? Also, where are the variables stored if they are defined globally? TLDR ---- JavaScript has lexical (also called static) scoping and closures. This means you can tell the scope of ...
[ 0.12174072861671448, -0.1562718003988266, 0.3228681683540344, 0.05821313336491585, -0.2825506031513214, 0.0031113754957914352, 0.09347178041934967, -0.16237808763980865, -0.27770304679870605, -0.3239436447620392, -0.3193278908729553, 0.3164839744567871, -0.488997220993042, -0.1153308227658...
global and module scope, variables are declared using `var` (function scope), `let` (block scope), and `const` (block scope). Most other forms of identifier declaration have block scope in strict mode. Overview -------- Scope is the region of the codebase over which an identifier is valid. A lexical environment is a...
[ 0.14547891914844513, 0.029409268870949745, 0.09306802600622177, 0.3320452868938446, 0.09317053854465485, -0.027186624705791473, -0.029442496597766876, -0.16496330499649048, -0.003053619060665369, -0.40182778239250183, -0.5162443518638611, 0.31058791279792786, -0.1683235615491867, 0.3361848...
matching identifier. Identifier resolution only occurs in one direction: outwards. In this way, outer lexical environments cannot "see" into inner lexical environments. There are three pertinent factors in deciding the [scope](https://en.wikipedia.org/wiki/Scope_(computer_science)) of an [identifier](https://www.ecma...
[ -0.061368174850940704, -0.10877786576747894, 0.5424360036849976, 0.0761454701423645, 0.0031732735224068165, -0.10091403126716614, 0.2612576484680176, -0.4807783365249634, -0.12214508652687073, -0.38006293773651123, -0.3986712396144867, 0.37670060992240906, -0.42809632420539856, -0.04571913...
Function body 3. Ordinary block 4. The top of a control structure (e.g., loop, if, while, etc.) 5. Control structure body 6. Modules Declaration Styles ------------------ ### var Identifiers declared using `var` **have function scope**, apart from when they are declared directly in the global context, in which case ...
[ 0.08302434533834457, -0.09823209792375565, 0.6511168479919434, 0.057139962911605835, -0.20437295734882355, -0.30645814538002014, 0.14795023202896118, -0.5681155323982239, -0.3780742883682251, -0.20461995899677277, -0.7043489217758179, 0.5163694024085999, -0.08004302531480789, -0.1649188250...
This means that their logical position of definition is the top of their enclosing scope (block or function). However, variables declared using `let` and `const` cannot be read or assigned to until control has passed the point of declaration in the source code. The interim period is known as the temporal dead zone. ``...
[ 0.04611313343048096, -0.07705869525671005, 0.5309292674064636, -0.0032016579061746597, 0.566734790802002, -0.10507524758577347, 0.013651490211486816, -0.27351731061935425, -0.21191947162151337, -0.37702617049217224, -0.6894654631614685, 0.3762820065021515, 0.07945933192968369, 0.2507454454...
are scoped to the function body. Note that there is a slight complexity to this. Functions declared as default arguments close over the [parameter list](https://stackoverflow.com/questions/61208843/where-are-arguments-positioned-in-the-lexical-environment/), and not the body of the function. ### Function declarations ...
[ -0.049235474318265915, -0.09785764664411545, 0.273555725812912, 0.0712895616889, -0.09769073873758316, -0.15825897455215454, 0.36523330211639404, -0.020471781492233276, -0.03980221971869469, -0.3357100188732147, -0.6234123110771179, 0.45321106910705566, -0.501413881778717, 0.01731982268393...
because the global object sits at the top of the scope chain. In strict mode, these are not permitted. ### eval In `eval` strings, variables declared using `var` will be placed in the current scope, or, if `eval` is used indirectly, as properties on the global object. Examples -------- The following will throw a Re...
[ -0.1010175347328186, 0.08583883941173553, 0.49439239501953125, -0.10324715077877045, 0.09424027055501938, -0.08726420998573303, 0.2661752998828888, -0.04182083159685135, -0.21441300213336945, -0.2488688975572586, -0.37213513255119324, 0.5502451062202454, -0.4312836229801178, 0.348354309797...
body of the function is a block) console.log(typeof z) // undefined (because the body of the function is a block) ``` The following will throw a ReferenceError for `y` and `z`, but not for `x`, because the visibility of `x` is not constrained by the block. Blocks that define the bodies of control structures like `if`,...
[ -0.166850745677948, -0.014652375131845474, 0.4541722238063812, 0.15798555314540863, 0.06873967498540878, -0.06721438467502594, -0.03551962599158287, -0.38858717679977417, 0.1485164761543274, -0.4474745988845825, -0.31846874952316284, 0.3397310674190521, -0.4733036160469055, 0.2555078268051...
is visible outside of the loop because `var` has function scope: ```js for(var x = 0; x < 5; ++x) {} console.log(x) // 5 (note this is outside the loop!) ``` ...because of this behavior, you need to be careful about closing over variables declared using `var` in loops. There is only one instance of variable `x` decla...
[ 0.0036789728328585625, -0.031095635145902634, 0.46184879541397095, -0.4407634139060974, 0.25907057523727417, -0.05774260312318802, 0.4777453541755676, -0.1970362663269043, -0.29725801944732666, -0.6200730204582214, -0.23337887227535248, 0.2769388258457184, -0.29742977023124695, 0.492355167...
is logically positioned at the top of the enclosing scope, above the loop } console.log(x) // note: visible outside the loop ``` The following prints `undefined` because `x` is block-scoped. The callbacks are run one by one asynchronously. New behavior for `let` variables means that each anonymous function closed over...
[ 0.028039252385497093, -0.011503626592457294, 0.4631405770778656, -0.3167771100997925, 0.37394285202026367, -0.08120277523994446, 0.1395399421453476, -0.4868010878562927, -0.08502314984798431, -0.3361358046531677, -0.2060902714729309, 0.38117584586143494, -0.5465468168258667, 0.208517104387...
NOT throw a `ReferenceError` because the visibility of `x` is not constrained by the block; it will, however, print `undefined` because the variable has not been initialised (because of the `if` statement). ```js if(false) { var x = 1 } console.log(x) // here, `x` has been declared, but not initialised ``` A vari...
[ 0.00782382395118475, 0.05365799367427826, 0.24762727320194244, -0.12867829203605652, 0.08610133081674576, -0.13319934904575348, 0.3872818350791931, -0.32065242528915405, -0.09168623387813568, -0.3853980004787445, -0.42367124557495117, 0.4000413417816162, -0.6028867959976196, 0.146781593561...
let x = 1 } console.log(typeof x) // undefined, because `x` is block-scoped ``` Variables declared using `var`, `let` or `const` are all scoped to modules: ```js // module1.js var x = 0 export function f() {} //module2.js import f from 'module1.js' console.log(x) // throws ReferenceError ``` The following will ...
[ -0.1775907576084137, -0.003953511826694012, 0.5847180485725403, -0.12928077578544617, 0.2969057261943817, -0.14475056529045105, -0.046270690858364105, -0.25263071060180664, -0.23135963082313538, -0.39605996012687683, -0.5826514363288879, 0.662885844707489, -0.37415599822998047, 0.241418644...
in the function body: ```js function f(x) {} console.log(typeof x) // undefined, because `x` is scoped to the function ``` Catch block parameters are scoped to the catch-block body: ```js try {} catch(e) {} console.log(typeof e) // undefined, because `e` is scoped to the catch block ``` Named function expressions a...
[ -0.3855222463607788, 0.03151325881481171, 0.4553050994873047, -0.09067331999540329, 0.15895803272724152, -0.03989994898438454, 0.14819850027561188, -0.1674870252609253, -0.012900141067802906, -0.3618772029876709, -0.6507228016853333, 0.6579529047012329, -0.5410075187683105, -0.103668473660...
declarations have function scope. In strict mode, they have block scope. ```js 'use strict' { function foo() {} } console.log(typeof foo) // undefined, because `foo` is block-scoped ``` How it works under the hood --------------------------- Scope is defined as the [lexical](https://stackoverflow.com/a/1047479/3...
[ 0.3908233940601349, 0.08933133631944656, 0.38547441363334656, -0.04393110051751137, -0.08950549364089966, -0.23884493112564087, 0.2587496042251587, -0.25742533802986145, -0.1724705994129181, -0.2155085802078247, -0.5604838132858276, 0.5978024005889893, -0.27651411294937134, 0.2153782099485...
environment of the function-object. It does this by copying the `[[Environment]]` value on the function-object, into an [outer reference](https://www.ecma-international.org/ecma-262/10.0/index.html#sec-lexical-environments) field on the lexical environment of the new execution context. Note that this link between the ...
[ -0.0817222073674202, -0.07650084048509598, 0.40085649490356445, -0.09908325970172882, 0.0915781706571579, -0.12237345427274704, 0.1720486283302307, -0.23828381299972534, -0.03713323920965195, -0.5670798420906067, -0.4755982458591461, 0.5104346871376038, -0.7183889150619507, -0.049990493804...
I've been told not to use `for...in` with arrays in JavaScript. Why not? The reason is that one construct: ```js var a = []; // Create a new empty array. a[5] = 5; // Perfectly legal JavaScript that resizes the array. for (var i = 0; i < a.length; i++) { // Iterate over numeric indexes from 0 to 5, as everyo...
[ 0.09939810633659363, 0.13545258343219757, 0.22488680481910706, -0.3429180085659027, 0.0032296532299369574, 0.006047599017620087, 0.5719773769378662, -0.4627269506454468, -0.20067419111728668, -0.5450860261917114, -0.06625522673130035, 0.5935263633728027, -0.3091348707675934, 0.267233312129...
x in a) { // Shows only the explicitly set index of "5", and ignores 0-4 console.log(x); } /* Will display: 5 */ ``` Also consider that [JavaScript](http://en.wikipedia.org/wiki/JavaScript) libraries might do things like this, which will affect any array you create: ```js // Somewhere deep in your J...
[ 0.20816029608249664, 0.1859143227338791, 0.22551628947257996, -0.4781590402126312, -0.06862572580575943, 0.15106318891048431, 0.2624514400959015, -0.3917241096496582, -0.26383543014526367, -0.41287294030189514, -0.21561549603939056, 0.34647825360298157, -0.6446828246116638, 0.1277557313442...