text stringlengths 0 30.5k | title stringclasses 1
value | embeddings listlengths 768 768 |
|---|---|---|
I would have thought this would be an easy one to Google, but I've been unsucessful.
I want to assign a variable the value out of an attribute (easy so far) then use that variable to select another node based on the value of that attribute.
Example:
```
<xsl:variable name="myId" select="@id" />
<xsl value-of select="//Root/Some/Other/Path/Where[@id='{@myId}']/@Name />
```
That does not work. If I replace the {@myId} with the value that is in the variable then it does find the right node, but doign it this way produces nothing. I'm sure I'm missing something, or perhaps there is a different way to do it.
The context is that there | [
-0.08407807350158691,
-0.041153740137815475,
0.12110240012407303,
0.0102117620408535,
0.01026021409779787,
-0.18537308275699615,
0.2474672794342041,
0.052680354565382004,
-0.004970399662852287,
-0.6550437211990356,
0.17280426621437073,
0.4241541922092438,
-0.30649805068969727,
0.2343337386... | |
is related data under different top-level nodes that share the same id value so I need to get the related nodes in my template.
Ok, I finally figured it out. Silly problem really, I simply needed to leave out the quotes and the braces. One of those times when I *thought* that I'd already tried that. :D Oh, and I mistyped @myId in the first example, the code was actually $myId.
```
<xsl:variable name="myId" select="@id" />
<xsl value-of select="//Root/Some/Other/Path/Where[@id=$myId]/@Name" />
``` | [
-0.06534596532583237,
0.07899395376443863,
0.5088189244270325,
0.2311241775751114,
-0.05622917786240578,
-0.04804118350148201,
0.04083557054400444,
0.0023234689142555,
-0.047342441976070404,
-0.6291987895965576,
0.3980877995491028,
0.2812173068523407,
-0.36702024936676025,
0.33201742172241... | |
I'm using IIS in Windows 2003 Server for a SharePoint intranet.
External incoming requests will be using the host header `portal.mycompany.com` and be forced to use SSL.
I was wondering if there's a way to set up an alternate host header such as
`http://internalportal/`
which only accepts requests from the internal network, but doesn't force the users to use SSL.
Any recommendations for how to set this up?
Daniel, keep in mind that just because something is possbile in IIS, and via any number of off box solutions (like hardware load balancers and SSL) doesn't mean that | [
0.1005590483546257,
0.09810657054185867,
0.29925185441970825,
0.08873201906681061,
-0.13504426181316376,
-0.3977336883544922,
0.01183246448636055,
0.3492252826690674,
-0.3347153961658478,
-0.8198992609977722,
-0.025095615535974503,
0.35204413533210754,
-0.44811779260635376,
0.2935067117214... | |
it is supported by SharePoint, **or** that it is implemented in the same way.
You can do what you are asking for, however you should do it via SharePoint Central Administration, and "Create or Extend a Web Application" and then "Extend and Existing Application".
In this way you can create a **new** web site (in IIS) for accessing your existing SharePoint Web Application, one that can be accessed via a different hostheader, port, using SSL, Authentication mechanism, etc.
As a general rule, if you can do something in IIS AND in SharePoint, you should do it only in SharePoint. | [
0.44575831294059753,
-0.2794136703014374,
0.2835576832294464,
0.15659886598587036,
0.031116869300603867,
-0.5496358275413513,
0.0316348671913147,
-0.04149720445275307,
-0.28211668133735657,
-0.960831880569458,
-0.3188309967517853,
0.3763987421989441,
-0.17300128936767578,
0.227196365594863... | |
Does it make sense, having all of the C#-managed-bliss, to go back to Petzold's Programming Windows and try to produce code w/ pure WinAPI?
What can be learn from it? Isn't it just too outdated to be useful?
This question is bordering on religious :) But I'll give my thoughts anyway.
I do see value in learing the Win32 API. Most, if not all, GUI libraries (managed or unmanaged) result in calls to the Win32 API. Even the most thorough libraries don't cover 100% of the API, and hence there are always gaps which need to be plugged by direct API calls or | [
0.3777332007884979,
0.3028898537158966,
0.12469351291656494,
-0.005467702634632587,
-0.12052865326404572,
-0.20546407997608185,
0.4287106692790985,
-0.0870133712887764,
0.15301744639873505,
-0.4041244387626648,
-0.006855187937617302,
0.9738566279411316,
-0.12753435969352722,
0.106926947832... | |
P/invoking. Some of the names of the wrappers around the API calls have similar names to the underlying API calls, but those names aren't exactly self-documenting. So understanding the underlying API, and the terminology used therein, will aid in understanding the wrapper APIs and what they actually do.
Plus, if you understand the nature of the underlying APIs that are used by frameworks, then you will make better choices with regards to which library functionality you should use in a given scenario.
Cheers! | [
0.5730973482131958,
0.12142296880483627,
0.30468833446502686,
0.07500969618558884,
-0.3623897433280945,
-0.2693445384502411,
0.22609587013721466,
-0.09517382830381393,
-0.43008384108543396,
-0.3567029535770416,
-0.16036681830883026,
0.8265501260757446,
0.12615297734737396,
-0.3131961226463... | |
I encounter an error of the form: "The model item passed into the dictionary is of type FooViewData but this dictionary requires a model item of type bar" even though I am passing in an object of the correct type (bar) for the typed user control.
What @MattMitchell said is probably the reason you're seeing this error.
If you want to know *why*; it is because when you pass null as the controlData parameter when using RenderUserControl(), the framework will try to pass the view data from the current view context onto the user control instead (see UserControlExtensions.DoRendering method in System.Web.Mvc). | [
0.007819761522114277,
0.04233256354928017,
0.5052177906036377,
-0.10352868586778641,
-0.06888188421726227,
0.14900392293930054,
0.7798088788986206,
-0.14634203910827637,
0.19343510270118713,
-0.5756974816322327,
0.026509039103984833,
0.46169665455818176,
-0.5282701253890991,
0.306783050298... | |
I want some links to include a fragment identifier. Like some of the URLs on this site:
[Debugging: IE6 + SSL + AJAX + post form = 404 error](https://stackoverflow.com/questions/5619/ie6-ssl-ajax-post-form-404-error)**#5626**
Is there a way to do this with any of the built-in methods in MVC? Or would I have to roll my own HTML helpers?
We're looking at including support for this in our next release. | [
0.23008319735527039,
0.17406053841114044,
0.10932891070842743,
0.24276818335056305,
-0.1323956996202469,
-0.34628933668136597,
0.3715384006500244,
0.1585419774055481,
-0.29378560185432434,
-0.6219146251678467,
-0.0038540042005479336,
0.43969184160232544,
-0.12263727188110352,
0.05989149957... | |
It is supposed to be backwards compatible with HTML4 and XHTML. [John Resig posted about some of the benefits](http://ejohn.org/blog/html5-doctype/).
As long as we don't use any of the new and not supported yet features, would there be any downside to start building sites with this doctype?
Well consider this:
When serving as text/html, all you need a doctype for is to trigger standards mode. Beyond that, the doctype does nothing as far as browsers are concerned.
When serving as text/html, whether you use XHTML markup or HTML markup, it's treated by browsers as HTML.
So, really it comes down to using the shortest doctype that | [
0.35164785385131836,
0.2016458958387375,
0.48897677659988403,
0.021856999024748802,
-0.29461005330085754,
-0.5537097454071045,
0.46062156558036804,
-0.037046533077955246,
-0.061993833631277084,
-0.659030020236969,
-0.24580928683280945,
0.6114250421524048,
-0.3457862138748169,
-0.1460453122... | |
triggers standards mode (<!DOCTYPE html>) and using HTML markup that produces the correct result in browsers.
The rest is about conforming, validation and markup prerference.
With that said, using <!DOCTYPE html> now and trying to make your markup conform to HTML5 is not a bad idea as long as you stick to stable features that work in browsers now. You wouldn't use anything in HTML4 or XHTML 1.x that doesn't work in browsers, would you?
In other words, you use <!DOCTYPE html> with HTML4-like markup while honoring things that have been clarified in HTML5. HTML5 is about browser compatibility after all.
The downside to | [
0.6028030514717102,
-0.06055525690317154,
0.3358948230743408,
0.2757149040699005,
-0.17800483107566833,
-0.6289301514625549,
0.3794235289096832,
-0.5185021758079529,
-0.10912695527076721,
-0.4538649022579193,
0.1299438774585724,
0.7411945462226868,
-0.2165985405445099,
-0.4035457670688629,... | |
using HTML5 now is that the spec can change quite often. This makes it important for you to keep up with the spec as it actively changes. Also <http://validator.nu/> might not always be up-to-date, but <http://validator.w3.org/> isn't always up-to-date either, so don't let that stop you.
Of course, if you want to use XHTML 1.0 markup and conform to XHTML 1.0, then you shouldn't use <!DOCTYPE html>.
Personally, I always use <!DOCTYPE html> for HTML. | [
0.5142878293991089,
0.006978041958063841,
0.463167667388916,
0.12101148068904877,
-0.2869901955127716,
-0.5677813291549683,
0.016734730452299118,
-0.003921064548194408,
-0.582599401473999,
-0.6368129849433899,
-0.007745037786662579,
0.5015137195587158,
-0.04919842258095741,
0.0453270897269... | |
What's the best way to do the semantic equivalent of the traditional sleep() system call from within an Informix SPL routine? In other words, simply "pause" for N seconds (or milliseconds or whatever, but seconds are fine). I'm looking for a solution that does *not* involve linking some new (perhaps written by me) C code or other library into the Informix server. This has to be something I can do purely from SPL. A solution for IDS 10 or 11 would be fine.
@RET - The "obvious" answer wasn't obvious to me! I didn't know about the SYSTEM command. Thank you! | [
0.520828127861023,
-0.15320144593715668,
0.4668283760547638,
0.26366594433784485,
0.022564753890037537,
-0.21341608464717865,
0.4931010901927948,
0.06809072941541672,
-0.33516308665275574,
-0.5835326313972473,
-0.0007424560026265681,
0.47445300221443176,
0.007132664788514376,
-0.1755142062... | |
(And yes, I'm the guy you think I am.)
---
Yes, it's for debugging purposes only. Unfortunately, CURRENT within an SPL will always return the same value, set at the entry to the call:
> *"any call to CURRENT from inside the SPL function that an EXECUTE FUNCTION (or EXECUTE PROCEDURE) statement invokes returns the value of the system clock when the SPL function starts."*
>
>
>
> —[IBM Informix Guide to SQL](http://publib.boulder.ibm.com/infocenter/idshelp/v10/topic/com.ibm.sqls.doc/sqls1011.htm)
Wrapping CURRENT in its own subroutine does not help. You do get a different answer on the first call to your wrapper (provided you're using YEAR TO FRACTION(5) or some other | [
0.2851007282733917,
0.010844842530786991,
0.620071530342102,
0.08279949426651001,
-0.1604815423488617,
-0.2274671345949173,
0.29282841086387634,
-0.07628563791513443,
-0.4430078864097595,
0.060824181884527206,
-0.1630271077156067,
0.18742293119430542,
-0.23661649227142334,
0.20373398065567... | |
type with high enough resolution to show the the difference) but then you get that same value back on every single subsequent call, which ensures that any sort of loop will never terminate.
There must be some good reason you're not wanting the obvious answer:
`SYSTEM "sleep 5"`. If all you're wanting is for the SPL to pause while you check various values etc, here are a couple of thoughts (all of which are utter hacks, of course):
1. Make the TRACE FILE a named pipe (assuming Unix back-end), so it blocks until you choose to read from it, or
2. Create another table | [
0.6742393970489502,
-0.32242029905319214,
0.236403688788414,
0.04240762069821358,
0.2374192476272583,
-0.07567574083805084,
0.2504807412624359,
-0.208455428481102,
-0.24972787499427795,
-0.640160083770752,
-0.06082244589924812,
0.3818998634815216,
-0.45194876194000244,
0.17379562556743622,... | |
that your SPL polls for a particular entry from a WHILE loop, and insert said row from elsewhere (horribly inefficient)
3. Make SET LOCK MODE your friend: execute "SET LOCK MODE TO WAIT n" and deliberately requery a table you're already holding a cursor open on. You'll need to wrap this in an EXCEPTION handler, of course.
Hope that is some help (and if you're the same JS of Ars and Rose::DB fame, it's the least I could do ;-) | [
0.09322554618120193,
-0.09755288809537888,
0.3627004027366638,
0.13971804082393646,
0.028422296047210693,
-0.08053027838468552,
0.49290934205055237,
-0.030701719224452972,
-0.19205263257026672,
-0.5541916489601135,
-0.18738225102424622,
0.567082941532135,
-0.2012602835893631,
-0.1001159027... | |
I got this error today when trying to open a Visual Studio 2008 **project** in Visual Studio 2005:
> The imported project "C:\Microsoft.CSharp.targets" was not found.
Open your csproj file in notepad (or notepad++)
Find the line:
```
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
```
and change it to
```
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
``` | [
0.111172154545784,
0.0887296199798584,
0.4349503815174103,
-0.28011077642440796,
-0.19244444370269775,
0.045685894787311554,
0.3280746042728424,
0.1961095631122589,
-0.23730763792991638,
-0.8245532512664795,
0.1422574520111084,
0.3994356393814087,
-0.5571591258049011,
-0.19168716669082642,... | |
Why are pointers such a leading factor of confusion for many new, and even old, college level students in C or C++? Are there any tools or thought processes that helped you understand how pointers work at the variable, function, and beyond level?
What are some good practice things that can be done to bring somebody to the level of, "Ah-hah, I got it," without getting them bogged down in the overall concept? Basically, drill like scenarios.
Pointers is a concept that for many can be confusing at first, in particular when it comes to copying pointer values around and still referencing | [
0.17424839735031128,
0.1905808001756668,
-0.05754519999027252,
0.4724743068218231,
-0.06751567870378494,
-0.4076072871685028,
0.043989747762680054,
0.21489736437797546,
-0.35524114966392517,
-0.4594746530056,
0.07479728758335114,
0.4223179817199707,
0.10766839236021042,
-0.0705709904432296... | |
the same memory block.
I've found that the best analogy is to consider the pointer as a piece of paper with a house address on it, and the memory block it references as the actual house. All sorts of operations can thus be easily explained.
I've added some Delphi code down below, and some comments where appropriate. I chose Delphi since my other main programming language, C#, does not exhibit things like memory leaks in the same way.
If you only wish to learn the high-level concept of pointers, then you should ignore the parts labelled "Memory layout" in the explanation below. They | [
0.21978746354579926,
0.3887127637863159,
0.18775014579296112,
-0.09123611450195312,
-0.07136218994855881,
0.2275649607181549,
0.06264025717973709,
-0.1618296355009079,
-0.46401235461235046,
-0.652534008026123,
-0.2744295299053192,
0.19353212416172028,
-0.22756947576999664,
0.18348146975040... | |
are intended to give examples of what memory could look like after operations, but they are more low-level in nature. However, in order to accurately explain how buffer overruns really work, it was important that I added these diagrams.
*Disclaimer: For all intents and purposes, this explanation and the example memory
layouts are vastly simplified. There's more overhead and a lot more details you would
need to know if you need to deal with memory on a low-level basis. However, for the
intents of explaining memory and pointers, it is accurate enough.*
---
Let's assume the THouse class used below looks like this:
```
type | [
0.30506473779678345,
0.1286822110414505,
-0.031692516058683395,
0.05459504947066307,
-0.12418319284915924,
0.10210155695676804,
0.16826938092708588,
-0.05383966118097305,
-0.21833744645118713,
-0.6776151657104492,
-0.13980266451835632,
0.3870795667171478,
-0.2578769028186798,
-0.1270642429... | |
THouse = class
private
FName : array[0..9] of Char;
public
constructor Create(name: PChar);
end;
```
When you initialize the house object, the name given to the constructor is copied into the private field FName. There is a reason it is defined as a fixed-size array.
In memory, there will be some overhead associated with the house allocation, I'll illustrate this below like this:
```
---[ttttNNNNNNNNNN]---
^ ^
| | | [
0.1888953000307083,
0.13942646980285645,
0.209840327501297,
-0.29050543904304504,
0.12303249537944794,
0.3238697648048401,
0.2582852840423584,
-0.25593143701553345,
-0.026634348556399345,
-0.5472262501716614,
-0.21952001750469208,
0.26882055401802063,
-0.3336474597454071,
0.379817426204681... | |
| +- the FName array
|
+- overhead
```
The "tttt" area is overhead, there will typically be more of this for various types of runtimes and languages, like 8 or 12 bytes. It is imperative that whatever values are stored in this area never gets changed by anything other than the memory allocator or the core system routines, or you risk crashing the program.
---
**Allocate memory**
Get an entrepreneur to build your house, and give you the address to the house. In contrast to the real world, memory allocation cannot | [
0.43874573707580566,
0.3558361530303955,
0.08581037819385529,
0.1051177978515625,
0.3718644380569458,
0.26022234559059143,
0.20562459528446198,
-0.18538156151771545,
-0.25962772965431213,
-0.5217545032501221,
-0.43098533153533936,
0.3833974301815033,
-0.1783134490251541,
0.1592069566249847... | |
be told where to allocate, but will find a suitable spot with enough room, and report back the address to the allocated memory.
In other words, the entrepreneur will choose the spot.
```
THouse.Create('My house');
```
Memory layout:
```
---[ttttNNNNNNNNNN]---
1234My house
```
---
**Keep a variable with the address**
Write the address to your new house down on a piece of paper. This paper will serve as your reference to your house. Without this piece of paper, you're lost, and cannot find the house, unless you're already in it.
```
var
h: THouse;
begin
h := THouse.Create('My house');
...
```
Memory layout:
``` | [
0.13188348710536957,
0.2881680428981781,
0.3491075932979584,
-0.03723091632127762,
0.6305107474327087,
0.31989264488220215,
0.19070997834205627,
-0.28498756885528564,
-0.1411670595407486,
-0.8443308472633362,
-0.5619664192199707,
0.21740508079528809,
-0.07491838186979294,
0.396518945693969... | |
h
v
---[ttttNNNNNNNNNN]---
1234My house
```
---
**Copy pointer value**
Just write the address on a new piece of paper. You now have two pieces of paper that will get you to the same house, not two separate houses. Any attempts to follow the address from one paper and rearrange the furniture at that house will make it seem that *the other house* has been modified in the same manner, unless you can explicitly detect that it's actually just one house.
*Note* This is usually the concept that I have the most problem explaining to people, two | [
0.8410162329673767,
0.18952713906764984,
0.6305105090141296,
0.013354257680475712,
0.24110454320907593,
-0.12938736379146576,
0.2998703420162201,
-0.28140509128570557,
-0.3663058578968048,
-0.8031880855560303,
-0.1988113522529602,
-0.02256975881755352,
-0.04554897919297218,
0.3165576159954... | |
pointers does not mean two objects or memory blocks.
```
var
h1, h2: THouse;
begin
h1 := THouse.Create('My house');
h2 := h1; // copies the address, not the house
...
```
```
h1
v
---[ttttNNNNNNNNNN]---
1234My house
^
h2
```
---
**Freeing the memory**
Demolish the house. You can then later on reuse the paper for a new address if you so wish, or clear it to forget the address to the house that no longer exists.
```
var
h: THouse;
begin | [
-0.10750751942396164,
0.3194607198238373,
0.5531910061836243,
0.1261562556028366,
-0.04067413508892059,
0.23173454403877258,
0.32020801305770874,
-0.1594873070716858,
-0.23835423588752747,
-0.8565282225608826,
-0.22873042523860931,
0.18785910308361053,
-0.40807920694351196,
0.1765899807214... | |
h := THouse.Create('My house');
...
h.Free;
h := nil;
```
Here I first construct the house, and get hold of its address. Then I do something to the house (use it, the ... code, left as an exercise for the reader), and then I free it. Lastly I clear the address from my variable.
Memory layout:
```
h <--+
v | [
0.318417489528656,
0.461468368768692,
0.5131386518478394,
-0.20253294706344604,
0.14208513498306274,
0.3909662365913391,
0.39783787727355957,
-0.7448337078094482,
0.04217374324798584,
-0.7698674201965332,
-0.5309149622917175,
0.15754090249538422,
-0.11768794059753418,
0.4730871617794037,
... | |
+- before free
---[ttttNNNNNNNNNN]--- |
1234My house <--+
h (now points nowhere) <--+
+- after free
---------------------- | [
-0.2761630713939667,
0.24424932897090912,
0.681001603603363,
-0.28344589471817017,
0.11975691467523575,
0.03480323776602745,
0.6928110122680664,
-0.3760193884372711,
-0.1895793229341507,
-0.33085596561431885,
-0.5772330164909363,
-0.07261897623538971,
-0.07693663984537125,
0.03392656520009... | |
| (note, memory might still
xx34My house <--+ contain some data)
```
---
**Dangling pointers**
You tell your entrepreneur to destroy the house, but you forget to erase the address from your piece of paper. When later on you look at the piece of paper, you've forgotten that the house is no longer there, and goes to visit it, with failed results (see also the part about an invalid reference below).
```
var
h: THouse;
begin
h := | [
0.29644346237182617,
0.620098352432251,
0.16431157290935516,
0.014634679071605206,
0.36939048767089844,
-0.06296473741531372,
0.7445802688598633,
-0.23795567452907562,
-0.18878313899040222,
-0.581366777420044,
-0.5380546450614929,
0.1915557086467743,
-0.31077462434768677,
0.481587588787078... | |
THouse.Create('My house');
...
h.Free;
... // forgot to clear h here
h.OpenFrontDoor; // will most likely fail
```
Using `h` after the call to `.Free` *might* work, but that is just pure luck. Most likely it will fail, at a customers place, in the middle of a critical operation.
```
h <--+
v | [
0.42882654070854187,
0.4540025591850281,
0.40555840730667114,
-0.23430511355400085,
0.33577272295951843,
0.026153458282351494,
0.8986704349517822,
-0.2595767378807068,
-0.006088683847337961,
-0.8308023810386658,
-0.46390047669410706,
0.30019521713256836,
-0.14016620814800262,
0.40630564093... | |
+- before free
---[ttttNNNNNNNNNN]--- |
1234My house <--+
h <--+
v | [
-0.05289498344063759,
0.04502452537417412,
0.6097637414932251,
-0.17331846058368683,
-0.1461820900440216,
0.078551284968853,
0.6161112785339355,
-0.5730929374694824,
-0.10176829993724823,
-0.20445525646209717,
-0.47419384121894836,
0.3896312415599823,
-0.28433552384376526,
0.02082220464944... | |
+- after free
---------------------- |
xx34My house <--+
```
As you can see, h still points to the remnants of the data in memory, but
since it might not be complete, using it as before might fail.
---
**Memory leak**
You lose the piece of paper and cannot find the house. The house is still standing somewhere though, and when you later on want to construct a new house, you cannot reuse that spot.
```
var | [
0.18275035917758942,
0.4018627107143402,
0.6553272604942322,
0.1485358029603958,
0.08539262413978577,
-0.013455862179398537,
0.3235858082771301,
-0.43764930963516235,
-0.27199849486351013,
-0.47221308946609497,
-0.5116841793060303,
0.24248479306697845,
-0.05089781805872917,
0.3364318013191... | |
h: THouse;
begin
h := THouse.Create('My house');
h := THouse.Create('My house'); // uh-oh, what happened to our first house?
...
h.Free;
h := nil;
```
Here we overwrote the contents of the `h` variable with the address of a new house, but the old one is still standing... somewhere. After this code, there is no way to reach that house, and it will be left standing. In other words, the allocated memory will stay allocated until the application closes, at which point the operating system will tear | [
0.1967305839061737,
0.3413392901420593,
0.4291144013404846,
-0.05492516979575157,
0.15086884796619415,
0.23463736474514008,
0.5845168232917786,
-0.27489760518074036,
-0.12287309020757675,
-0.8209075927734375,
-0.4688996374607086,
-0.10323860496282578,
-0.128543421626091,
0.6660224199295044... | |
it down.
Memory layout after first allocation:
```
h
v
---[ttttNNNNNNNNNN]---
1234My house
```
Memory layout after second allocation:
```
h
v
---[ttttNNNNNNNNNN]---[ttttNNNNNNNNNN]
1234My house 5678My house
```
A more common way to get this method is just to forget to free something, instead of overwriting it | [
-0.43665897846221924,
0.14691993594169617,
0.2845099866390228,
0.2726067900657654,
0.32523423433303833,
-0.08529234677553177,
0.327786922454834,
-0.21650680899620056,
-0.36702126264572144,
-0.43095293641090393,
-0.42666006088256836,
0.4376460313796997,
-0.302999883890152,
0.117333658039569... | |
as above. In Delphi terms, this will occur with the following method:
```
procedure OpenTheFrontDoorOfANewHouse;
var
h: THouse;
begin
h := THouse.Create('My house');
h.OpenFrontDoor;
// uh-oh, no .Free here, where does the address go?
end;
```
After this method has executed, there's no place in our variables that the address to the house exists, but the house is still out there.
Memory layout:
```
h <--+
v | [
-0.040956344455480576,
0.3454922139644623,
0.3882841169834137,
-0.31372690200805664,
0.23355352878570557,
0.07899889349937439,
0.4399334490299225,
-0.4357263445854187,
-0.023577237501740456,
-0.6588377356529236,
-0.4872070848941803,
0.2940416634082794,
-0.23206137120723724,
0.4264778196811... | |
+- before losing pointer
---[ttttNNNNNNNNNN]--- |
1234My house <--+
h (now points nowhere) <--+
+- after | [
-0.5311599969863892,
0.4232540428638458,
0.7424222230911255,
-0.22136400640010834,
0.36378973722457886,
0.013573807664215565,
0.5458475351333618,
-0.16862007975578308,
-0.13298413157463074,
-0.4073561728000641,
-0.46540367603302,
-0.053532905876636505,
-0.030426206067204475,
0.251184523105... | |
losing pointer
---[ttttNNNNNNNNNN]--- |
1234My house <--+
```
As you can see, the old data is left intact in memory, and will not
be reused by the memory allocator. The allocator keeps track of which
areas of memory has been used, and will not reuse them unless you
free it.
---
**Freeing the memory but keeping a (now invalid) reference**
Demolish the house, erase one of the pieces of paper but you also have another piece of paper with the old address on it, | [
-0.05496547743678093,
0.3974069058895111,
0.6107292175292969,
-0.056379955261945724,
0.4895016551017761,
0.09954018145799637,
0.43020379543304443,
-0.15772613883018494,
-0.3967001140117645,
-0.49304354190826416,
-0.40864720940589905,
0.20251339673995972,
-0.20415538549423218,
0.54791069030... | |
when you go to the address, you won't find a house, but you might find something that resembles the ruins of one.
Perhaps you will even find a house, but it is not the house you were originally given the address to, and thus any attempts to use it as though it belongs to you might fail horribly.
Sometimes you might even find that a neighbouring address has a rather big house set up on it that occupies three address (Main Street 1-3), and your address goes to the middle of the house. Any attempts to treat that part of the large | [
0.47451964020729065,
0.15412768721580505,
0.12580716609954834,
0.14788420498371124,
0.3030066192150116,
-0.0031395142432302237,
0.5528132915496826,
0.19679148495197296,
-0.5940824747085571,
-0.8015440702438354,
-0.2231956124305725,
-0.0362403430044651,
-0.06264310330152512,
0.3824158310890... | |
3-address house as a single small house might also fail horribly.
```
var
h1, h2: THouse;
begin
h1 := THouse.Create('My house');
h2 := h1; // copies the address, not the house
...
h1.Free;
h1 := nil;
h2.OpenFrontDoor; // uh-oh, what happened to our house?
```
Here the house was torn down, through the reference in `h1`, and while `h1` was cleared as well, `h2` still has the old, out-of-date, address. Access to the house that is no longer standing might or might not work.
This | [
-0.05301244556903839,
0.5156817436218262,
0.48419100046157837,
-0.07548563927412033,
0.15778394043445587,
0.21485021710395813,
0.6603182554244995,
-0.6485921740531921,
-0.15294623374938965,
-0.6687091588973999,
-0.4208828806877136,
0.11590387672185898,
-0.3239087760448456,
0.38001492619514... | |
is a variation of the dangling pointer above. See its memory layout.
---
**Buffer overrun**
You move more stuff into the house than you can possibly fit, spilling into the neighbours house or yard. When the owner of that neighbouring house later on comes home, he'll find all sorts of things he'll consider his own.
This is the reason I chose a fixed-size array. To set the stage, assume that
the second house we allocate will, for some reason, be placed before the
first one in memory. In other words, the second house will have a lower
address than the first one. Also, they're allocated right | [
0.4012807011604309,
0.06095531955361366,
0.24376890063285828,
-0.17014935612678528,
0.10505297780036926,
0.2970519959926605,
-0.046433545649051666,
-0.29594969749450684,
-0.5546362996101379,
-0.636199414730072,
-0.18606317043304443,
-0.1242501363158226,
-0.1420295238494873,
0.3438431620597... | |
next to each other.
Thus, this code:
```
var
h1, h2: THouse;
begin
h1 := THouse.Create('My house');
h2 := THouse.Create('My other house somewhere');
^-----------------------^
longer than 10 characters | [
-0.26782557368278503,
0.2101154327392578,
0.3922366201877594,
-0.4013596773147583,
0.14975124597549438,
0.5835505127906799,
0.3062759339809418,
-0.2594330608844757,
0.049473561346530914,
-0.7983745336532593,
-0.34704309701919556,
-0.13240014016628265,
0.16267094016075134,
-0.04473422095179... | |
0123456789 <-- 10 characters
```
Memory layout after first allocation:
```
h1
v
-----------------------[ttttNNNNNNNNNN]
5678My house
```
Memory layout after second allocation:
```
h2 | [
-0.7656925916671753,
0.36407697200775146,
0.04595531150698662,
-0.06373271346092224,
0.0855133980512619,
0.5377045273780823,
0.28133612871170044,
-0.24836105108261108,
-0.1711008995771408,
-0.5335491299629211,
-0.5148800015449524,
0.4332638382911682,
0.036976613104343414,
-0.09665600210428... | |
h1
v v
---[ttttNNNNNNNNNN]----[ttttNNNNNNNNNN]
1234My other house somewhereouse
^---+--^
| | [
0.030681096017360687,
0.3687618672847748,
0.7371882796287537,
-0.1482481211423874,
-0.018226519227027893,
0.24236471951007843,
0.3443504273891449,
-0.5557539463043213,
-0.03086097352206707,
-0.20686163008213043,
-0.33227086067199707,
0.026374822482466698,
-0.12881986796855927,
0.0291128922... | |
+- overwritten
```
The part that will most often cause crash is when you overwrite important parts
of the data you stored that really should not be randomly changed. For instance
it might not be a problem that parts of the name of the h1-house was changed,
in terms of crashing the program, but overwriting the overhead of the
object will most likely crash when you try to use the broken object,
as will overwriting links that is stored to
other objects in the object.
---
**Linked lists** | [
0.14535759389400482,
0.49937841296195984,
0.1726849377155304,
0.12602441012859344,
-0.20318342745304108,
-0.42863985896110535,
0.29470089077949524,
-0.06512090563774109,
-0.5868703126907349,
-0.30681225657463074,
-0.2390441596508026,
0.3557966649532318,
-0.4986279010772705,
0.2398242950439... | |
When you follow an address on a piece of paper, you get to a house, and at that house there is another piece of paper with a new address on it, for the next house in the chain, and so on.
```
var
h1, h2: THouse;
begin
h1 := THouse.Create('Home');
h2 := THouse.Create('Cabin');
h1.NextHouse := h2;
```
Here we create a link from our home house to our cabin. We can follow the chain until a house has no `NextHouse` reference, which means it's the last one. To visit all our houses, we | [
0.28361213207244873,
0.2422293871641159,
0.4374675750732422,
0.06617482006549835,
0.3173987567424774,
0.04358921945095062,
0.5131804347038269,
-0.44234153628349304,
-0.3264826238155365,
-0.8846546411514282,
-0.2896888256072998,
-0.1399785727262497,
-0.11307406425476074,
0.38073447346687317... | |
could use the following code:
```
var
h1, h2: THouse;
h: THouse;
begin
h1 := THouse.Create('Home');
h2 := THouse.Create('Cabin');
h1.NextHouse := h2;
...
h := h1;
while h <> nil do
begin
h.LockAllDoors;
h.CloseAllWindows;
h := h.NextHouse;
end;
```
Memory layout (added NextHouse as a link in the object, noted with
the four LLLL's in | [
-0.1674867570400238,
0.08967746794223785,
0.5604493021965027,
-0.21016812324523926,
0.4740544259548187,
0.21764163672924042,
0.30497270822525024,
-0.4233672022819519,
0.009992542676627636,
-0.7841504812240601,
-0.3796444237232208,
0.17935600876808167,
-0.11305639892816544,
0.41773560643196... | |
the below diagram):
```
h1 h2
v v
---[ttttNNNNNNNNNNLLLL]----[ttttNNNNNNNNNNLLLL]
1234Home + 5678Cabin +
| | [
-0.2227868288755417,
0.3747560679912567,
0.7628374695777893,
-0.2541653513908386,
-0.016426721587777138,
0.14264865219593048,
0.004688737913966179,
-0.328787237405777,
-0.27796822786331177,
-0.26034054160118103,
-0.3213074207305908,
0.39152923226356506,
-0.3593772053718567,
0.4825152456760... | |
^ |
+--------+ * (no link)
```
---
**In basic terms, what is a memory address?**
A memory address is in basic terms just a number. If you think of memory
as a big array of bytes, the very first byte has the address 0, the next one
the address 1 and so on upwards. | [
-0.13294900953769684,
0.17809052765369415,
0.25150635838508606,
0.21246664226055145,
0.04791368544101715,
0.31531843543052673,
-0.17862902581691742,
0.16075029969215393,
-0.25708314776420593,
-0.5452494025230408,
-0.28527387976646423,
0.1599932760000229,
0.009338137693703175,
0.12218935787... | |
This is simplified, but good enough.
So this memory layout:
```
h1 h2
v v
---[ttttNNNNNNNNNN]---[ttttNNNNNNNNNN]
1234My house 5678My house
```
Might have these two address (the leftmost - is address 0):
* h1 = 4
* h2 = 23
Which means that our linked list above might actuall look like this:
```
h1 (=4) | [
-0.07296592742204666,
0.2386971414089203,
0.5441057085990906,
-0.05384456738829613,
0.2785476744174957,
0.17552156746387482,
0.11839254200458527,
-0.22321660816669464,
-0.2675982117652893,
-0.7313692569732666,
-0.1298404335975647,
0.3130050599575043,
-0.05652425438165665,
0.288018465042114... | |
h2 (=28)
v v
---[ttttNNNNNNNNNNLLLL]----[ttttNNNNNNNNNNLLLL]
1234Home 0028 5678Cabin 0000
| ^ | [
-0.5392552018165588,
0.30557361245155334,
0.6033115386962891,
-0.2893409729003906,
-0.045988779515028,
0.24132199585437775,
0.2128879576921463,
-0.27438634634017944,
-0.16137100756168365,
-0.3064410388469696,
-0.14875528216362,
0.4382707476615906,
-0.4123022258281708,
0.06624182313680649,
... | |
|
+--------+ * (no link)
```
It is typical to store an address that "points nowhere" as a zero-address.
---
**In basic terms, what is a pointer?**
A pointer is just a variable holding a memory address. You can typically ask the programming
language to give you its number, but most programming languages and runtimes tries to
hide the fact that there is a number beneath, just because the number itself does not
really | [
0.16732719540596008,
0.4553608298301697,
0.11158100515604019,
0.22720524668693542,
0.06537695974111557,
-0.163657546043396,
-0.04882622882723808,
0.20677320659160614,
-0.10445291548967361,
-0.28167831897735596,
-0.16437925398349762,
0.0654289647936821,
-0.1277596354484558,
0.33431559801101... | |
hold any meaning to you. It is best to think of a pointer as a black box, ie.
you don't really know or care about how it is actually implemented, just as long as it
works. | [
0.5171793699264526,
0.15666764974594116,
0.14014612138271332,
0.4090352952480316,
0.01608409732580185,
-0.3277992904186249,
0.22865882515907288,
0.43510720133781433,
-0.15724481642246246,
-0.3702932596206665,
-0.11592527478933334,
-0.08481922745704651,
-0.2470037341117859,
0.05072891712188... | |
How do I escape the underscore character?
I am writing something like the following where clause and want to be able to find actual entries with \_d at the end.
```
Where Username Like '%_d'
```
[T-SQL Reference for LIKE](https://learn.microsoft.com/en-us/sql/t-sql/language-elements/like-transact-sql?view=sql-server-ver15#using-wildcard-characters-as-literals):
> You can use the wildcard pattern matching characters as literal characters. To use a wildcard character as a literal character, enclose the wildcard character in brackets. The following table shows several examples of using the LIKE keyword and the [ ] wildcard characters.
For your case:
```
... LIKE '%[_]d'
``` | [
0.2653277814388275,
-0.12604735791683197,
0.2815951704978943,
0.3022298812866211,
0.11493005603551865,
-0.13491010665893555,
0.34002685546875,
-0.23212246596813202,
0.10451257228851318,
-0.3300092816352844,
-0.06671884655952454,
0.3594280779361725,
-0.3515869677066803,
0.2628572881221771,
... | |
I have a page upon which a user can choose up to many different paragraphs. When the link is clicked (or button), an email will open up and put all those paragraphs into the body of the email, address it, and fill in the subject. However, the text can be too long for a mailto link.
Any way around this?
---
We were thinking about having an SP from the SQL Server do it but the user needs a nice way of 'seeing' the email before they blast 50 executive level employees with items that shouldn't be sent...and of course there's the whole | [
0.6489650011062622,
0.3365059792995453,
0.27604570984840393,
0.188276007771492,
0.05321887135505676,
-0.2660684287548065,
0.020991211757063866,
0.13262934982776642,
-0.2734067738056183,
-0.5340734124183655,
0.05752943083643913,
0.3986096680164337,
-0.1209428682923317,
0.15409503877162933,
... | |
thing about doing IT for IT rather than doing software programming. 80(
When you build stuff for IT, it doesn't (some say shouldn't) have to be pretty just functional. In other words, this isn't the dogfood we wake it's just the dog food we have to eat.
---
We started talking about it and decided that the 'mail form' would give us exactly what we are looking for.
1. A very different look to let the user know that the gun is loaded
and aimed.
2. The ability to change/add text to the email.
3. Send a copy to themselves or not.
4. Can be coded quickly.
By putting | [
0.6942129135131836,
0.13808119297027588,
0.055356401950120926,
0.08278372138738632,
0.1559063345193863,
-0.07529013603925705,
0.2228240966796875,
-0.3509939908981323,
-0.2657892107963562,
-0.051745545119047165,
0.16820019483566284,
0.6588258743286133,
-0.40686458349227905,
-0.6233561038970... | |
the data into a form, I was able to make the body around 1800 characters long before the form stopped working.
The code looked like this:
```
<form action="mailto:youremail@domain.com">
<input type="hidden" name="Subject" value="Email subject">
<input type="hidden" name="Body" value="Email body">
<input type="submit">
</form>
```
---
**Edit**: The best way to send emails from a web application is of course to do just that, send it directly from the web application, instead of relying on the users mailprogram. As you've discovered, the protocol for sending information to that program is limited, but with a server-based solution you would of course | [
0.46691423654556274,
0.08565904200077057,
0.40371283888816833,
0.16996243596076965,
-0.2833230495452881,
0.2970897853374481,
0.1544535905122757,
-0.41413232684135437,
-0.0018834782531484962,
-0.6715145111083984,
0.20356570184230804,
0.16641555726528168,
-0.0012833793880417943,
-0.261560767... | |
not have those limitations. | [
0.6695943474769592,
0.0874289721250534,
-0.3616122305393219,
0.033825624734163284,
-0.032616790384054184,
-0.13355527818202972,
0.32403865456581116,
-0.010495034977793694,
0.07554823905229568,
-0.05713009089231491,
0.36201855540275574,
0.30457234382629395,
-0.2548254132270813,
-0.037253018... | |
I'm just getting into creating some WCF services, but I have a requirement to make them backward compatible for legacy (.NET 1.1 and 2.0) client applications.
I've managed to get the services to run correctly for 3.0 and greater clients, but when I publish the services using a basicHttpBinding endpoint (which I believe is required for the compatibility I need), the service refactors my method signatures. e.g.
```
public bool MethodToReturnTrue(string seedValue);
```
appears to the client apps as
```
public void MethodToReturnTrue(string seedValue, out bool result, out bool MethodToReturnTrueResultSpecified);
```
I've tried every configuration parameter I can think of in the app.config for my self-hosting console app, | [
0.06961417943239212,
0.31718409061431885,
0.41040050983428955,
-0.17129909992218018,
0.12357731908559799,
0.017080865800380707,
0.45318758487701416,
-0.32973039150238037,
0.01411651261150837,
-0.5185693502426147,
0.040829822421073914,
0.6567038893699646,
-0.2258794903755188,
0.308821976184... | |
but I can't seem to make this function as expected. I suppose this might lead to the fact that my expectations are flawed, but I'd be surprised that a WCF service is incapable of handling a bool return type to a down-level client.
My current app.config looks like this.
```
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<system.serviceModel>
<services>
<service behaviorConfiguration="MyServiceTypeBehaviors" Name="MyCompany.Services.CentreService.CentreService">
<clear />
<endpoint address="http://localhost:8080/CSMEX" binding="basicHttpBinding" bindingConfiguration="" contract="IMetadataExchange" />
<endpoint | [
-0.3791705369949341,
-0.001911384635604918,
0.7784124612808228,
-0.0884186327457428,
-0.03964157775044441,
0.06851070374250412,
0.26323220133781433,
-0.10519696027040482,
-0.3311533033847809,
-0.8507801294326782,
-0.37474414706230164,
0.38531139492988586,
-0.2722190022468567,
0.16865691542... | |
address="http://localhost:8080/CentreService" binding="basicHttpBinding" bindingName="Compatible" name="basicEndpoint" contract="MyCompany.Services.CentreService.ICentreService" />
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="MyServiceTypeBehaviors" >
<serviceMetadata httpGetEnabled="true" />
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>
</configuration>
```
Can anyone advise, please?
OK, we needed to resolve this issue in the short term, and so we came up with the idea of a "interop", or compatibility layer.
Baiscally, all we did | [
0.12022264301776886,
-0.038255658000707626,
0.6506802439689636,
0.022260041907429695,
-0.07530160993337631,
-0.08450854569673538,
0.4140189588069916,
-0.3865260183811188,
0.11913865804672241,
-0.664050281047821,
-0.11024776101112366,
0.34009450674057007,
-0.0618964359164238,
0.201167613267... | |
was added a traditional ASMX web service to the project, and called the WCF service from that using native WCF calls. We were then able to return the appropriate types back to the client applications without a significant amount of re-factoring work. I know it was a hacky solution, but it was the best option we had with such a large legacy code-base. And the added bonus is that it actually works surprisingly well. :) | [
0.3911716639995575,
-0.18495607376098633,
0.10254815965890884,
0.08200280368328094,
-0.09324391186237335,
-0.10882340371608734,
0.40633881092071533,
-0.1170002669095993,
-0.04987858980894089,
-0.41618865728378296,
0.1481046825647354,
0.7160540223121643,
-0.3077166974544525,
-0.136827439069... | |
I've been tasked (by my wife) with creating a program to allow her to track the family trees on both sides of our family.
Does anyone know of a cost-effective (free) control to represent this type of information?
What I'm looking for is a modified org-chart type chart/tree. The modification is that any node should have 2 parent nodes (E.G. a child should have a Mother/Father).
The solution I've come up with so far is to have 2 trees, an ancestor tree and a descendants tree, with the individual being inspected as the root node for each tree. It works but is sort | [
0.1534404754638672,
-0.15525174140930176,
0.09088672697544098,
0.19162188470363617,
0.48823991417884827,
0.4456542134284973,
0.289564311504364,
0.02247624471783638,
-0.5414592027664185,
-0.6456426382064819,
0.3065405786037445,
-0.334797203540802,
-0.05255432054400444,
0.46565091609954834,
... | |
of clunky.
I'm working primarily in c# WinForms, so .Net type controls or source code is preferable.
[Geni](http://www.geni.com/) is probably what your looking for. | [
-0.19648808240890503,
0.017502224072813988,
0.08616054803133011,
0.2737926244735718,
0.14365920424461365,
-0.08624471724033356,
-0.06648511439561844,
0.4817644953727722,
-0.27008286118507385,
-0.5038639903068542,
0.02848070114850998,
0.48673897981643677,
-0.23765259981155396,
0.18273639678... | |
In my web application I have a file which hold the current revision number via $Rev$. This work fine except, if I don't make any changes to that file, it doesn't get committed.
**Is there anyway I can force a single file to always get committed to the SVN server?**
*I'm using TortoiseSVN for Windows so any code or step-by-step instructions would be helpful.*
If you have TortoiseSVN installed, you also have the SubWCRev tool available. Use that tool to get the revision instead of misusing the $REV$ keyword.
1. create a template file which contains your defines, maybe something like
const long WC\_REV = | [
0.32790088653564453,
-0.12192380428314209,
0.8346254825592041,
0.0022270807530730963,
-0.09459283947944641,
-0.13089506328105927,
0.5526831746101379,
-0.11308814585208893,
-0.581351101398468,
-0.889426052570343,
0.05869188532233238,
1.1198251247406006,
0.00003896381167578511,
0.33364289999... | |
$WCREV$;
in a file named version.h.tmpl
2. on every build, call SubWCRev to create the 'real' file you can use in your application:
SubWCRev path\to\workingcopy path\to\version.h.tmpl path\to\version.h
This will create the file version.h from version.h.tmpl, with the text $WCREV$ replaced with the revision your working copy is currently at.
The [docs for SubWCRev](http://tortoisesvn.net/docs/release/TortoiseSVN_en/tsvn-subwcrev.html) might help too. | [
0.3550567626953125,
-0.18876194953918457,
0.8125879168510437,
-0.008871964178979397,
-0.09675464034080505,
-0.18295378983020782,
0.45158934593200684,
-0.22231070697307587,
-0.46290525794029236,
-0.6469616293907166,
-0.2513428032398224,
0.777554452419281,
-0.18050120770931244,
0.26759308576... | |
Basically, I've written an API to www.thetvdb.com in Python. The current code can be found [here](http://github.com/dbr/tvdb_api/tree/master/tvdb_api.py).
It grabs data from the API as requested, and has to store the data somehow, and make it available by doing:
```
print tvdbinstance[1][23]['episodename'] # get the name of episode 23 of season 1
```
What is the "best" way to abstract this data within the `Tvdb()` class?
I originally used a extended `Dict()` that automatically created sub-dicts (so you could do `x[1][2][3][4] = "something"` without having to do `if x[1].has_key(2): x[1][2] = []` and so on)
Then I just stored the data by doing `self.data[show_id][season_number][episode_number][attribute_name] = "something"`
This worked okay, but | [
0.5483832955360413,
-0.2803952693939209,
0.5772766470909119,
0.06806634366512299,
-0.19305725395679474,
-0.2509167194366455,
0.17343716323375702,
-0.26456189155578613,
0.047820813953876495,
-0.46001774072647095,
0.14429238438606262,
0.6917199492454529,
-0.327068954706192,
0.303172439336776... | |
there was no easy way of checking if `x[3][24]` was supposed to exist or not (so I couldn't raise the season\_not\_found exception).
Currently it's using four classes: `ShowContainer`, `Show`, `Season` and `Episode`. Each one is a very basic dict, which I can easily add extra functionality in (the `search()` function on `Show()` for example). Each has a `__setitem__`, `__getitem_` and `has_key`.
This works mostly fine, I can check in Shows if it has that season in it's `self.data` dict, if not, `raise season_not_found`. I can also check in `Season()` if it has that episode and so on.
The problem now is it's presenting | [
-0.13466642796993256,
0.0036453327629715204,
0.6011138558387756,
-0.1052439957857132,
-0.44903627038002014,
-0.16707031428813934,
0.3990466594696045,
0.003431576071307063,
-0.21558791399002075,
-0.6295879483222961,
-0.21747276186943054,
0.579348623752594,
-0.09629733860492706,
0.5495313405... | |
itself as a dict, but doesn't have all the functionality, and because I'm overriding the `__getitem__` and `__setitem__` functions, it's easy to accidentally recursively call `__getitem__` (so I'm not sure if extending the `Dict` class will cause problems).
The other slight problem is adding data into the dict is a lot more work than the old `Dict` method (which was `self.data[seas_no][ep_no]['attribute'] = 'something'`). See `_setItem` and `_setData`. It's not too bad, since it's currently only a read-only API interface (so the users of the API should only ever retrieve data, not add more), but it's hardly... Elegant.
I think the series-of-classes system | [
-0.09925951063632965,
-0.16838033497333527,
0.35808655619621277,
-0.028887053951621056,
-0.4003784954547882,
-0.11671791970729828,
0.2017316222190857,
-0.1427583247423172,
0.11052259057760239,
-0.45126622915267944,
-0.03918235003948212,
0.5601395964622498,
-0.2739545404911041,
-0.120555289... | |
is probably the best way, but does anyone have a better idea for storing the data? And would extending the `ShowContainer`/etc classes with `Dict` cause problems?
OK, what you need is `classobj` from new module. That would allow you to construct exception classes dynamically (`classobj` takes a string as an argument for the class name).
```
import new
myexc=new.classobj("ExcName",(Exception,),{})
i=myexc("This is the exc msg!")
raise i
```
this gives you:
```
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
__main__.ExcName: This is the exc msg!
```
remember that you can always get the class name through:
```
self.__class__.__name__
```
So, after some string mangling and concatenation, you should be able to obtain appropriate exception | [
-0.24281688034534454,
0.07144273072481155,
0.5278655290603638,
-0.0925714299082756,
0.11260125786066055,
-0.13923612236976624,
0.24661172926425934,
-0.07273080199956894,
-0.285202294588089,
-0.5035606026649475,
-0.16979841887950897,
0.6238686442375183,
-0.3756924867630005,
0.10085641592741... | |
class name and construct a class object using that name and then raise that exception.
P.S. - you can also raise strings, but this is deprecated.
```
raise(self.__class__.__name__+"Exception")
``` | [
-0.07902795821428299,
0.4346235990524292,
0.04942450672388077,
0.08350188285112381,
-0.18105673789978027,
0.004745509009808302,
0.05999266356229782,
-0.32078272104263306,
-0.3399524688720703,
-0.39835822582244873,
-0.3112025260925293,
0.44180625677108765,
-0.2852360010147095,
0.17467172443... | |
We are in the early design stages of a major rewrite of our product. Right now our customers are mostly businesses. We manage accounts. User names for an account are each on their own namespace but it means that we can't move assets between servers.
We want to move to a single namespace. But that brings the problem of unique user names.
So what's the best idea?
* Email address (w/verification) ?
* Unique alpha-numeric string ("johnsmith9234")?
* Should we look at OpenID?
**EMAIL ADDRESS**
Rational
1. Users don't change emails very often
2. Removes the step of asking for username and email address, which you'll need anyway
3. Users | [
0.4608996510505676,
0.13738666474819183,
0.36762735247612,
0.0011959548573940992,
0.224782332777977,
0.11672653257846832,
0.13069696724414825,
-0.05557478219270706,
-0.09074321389198303,
-0.6211804747581482,
0.041349586099386215,
0.5074066519737244,
-0.27813875675201416,
0.2720391154289245... | |
don't often forget their email address (see number one)
4. Email will be unique unless the user already registered for the site, in which case forward them to a forgot your password screen
5. Almost everyone is using email as the primary login for access to a website, this means the rate of adoption shouldn't be affected by the fact that you're asking for an email address
---
**Update**
After registration, be sure to ask the user to create some kind of username, don't litter a public site with their email address! Also, another benefit of using an email address as a login: you won't | [
0.4793545603752136,
0.10073643177747726,
0.43171384930610657,
0.11999525874853134,
0.1417480707168579,
-0.5368132591247559,
0.39102521538734436,
0.08343228697776794,
-0.6103851199150085,
-0.7813715934753418,
-0.20880058407783508,
0.297503799200058,
0.06639358401298523,
0.05503726750612259,... | |
need any other information (like password / password confirm), just send them a temp password through the mail, or forgo passwords altogether and send them a one-use URL to their email address every time they'd like to login (see: [mugshot.org](http://mugshot.org/main)) | [
0.6722704172134399,
0.08451498299837112,
0.22515474259853363,
0.06526189297437668,
0.15152394771575928,
-0.5351951718330383,
0.6144201755523682,
0.21936644613742828,
-0.33035215735435486,
-0.17628876864910126,
-0.11978575587272644,
0.35801178216934204,
-0.5450930595397949,
-0.2927233278751... | |
I'm using subclipse in Flex Builder 3, and recently received this error when trying to commit:
`svn: Checksum mismatch for '/Users/redacted/Documents/Flex Builder 3/path/to/my/file.mxml'; expected: 'f8cb275de72776657406154dd3c10348', actual: 'null'`
I worked around it by:
1. Committing all the other changed files, omitting the troublesome one.
2. Copying the contents of the trouble file to a TextMate window
3. Deleting my project in FlexBuilder/Eclipse
4. Checking my project out fresh from SVN
5. Copying the text of the trouble file back in from the TextMate Window
6. Committing the changes.
It worked, but I can't help but think there's a better way. What's actaully happening to cause the svn:checksum error, and what's | [
0.15772534906864166,
0.09568077325820923,
0.25632160902023315,
-0.21862086653709412,
-0.39967259764671326,
-0.0012160501210018992,
0.524529218673706,
-0.27743709087371826,
-0.3164631724357605,
-0.7176179885864258,
-0.014471014030277729,
0.7533450126647949,
-0.572194516658783,
-0.0124095873... | |
the best fix.
Maybe more important -- is this a symptom of a greater problem?
The file in the .svn directory that keeps track of what you have checked out, when, what revision, and from where, has gotten corrupted somehow, for that particular file.
This is no more dangerous or critical than the normal odd file problem, and can be because of various problems, like a subversion program dying mid-change, power-disruption, etc.
Unless it happens more I wouldn't make much out of it.
It can be fixed by doing what you did, make a copy of your work-files, check out a fresh copy, and add | [
0.27241167426109314,
0.14422032237052917,
0.32116976380348206,
0.5251833200454712,
0.2965191900730133,
-0.06748094409704208,
0.07779912650585175,
0.11822028458118439,
-0.4291699230670929,
-0.2912539839744568,
0.025971323251724243,
0.6710601449012756,
-0.28819337487220764,
0.032121490687131... | |
the modified files back in.
Note that this might cause problems if you have a busy project where you would normally have to merge in changes.
For instance, you and a collegue both check out a fresh copy, and start working on the same file. At some point, your collegue checks in his modifications. When you attempt to do the same, you get the checksum problem you have. If you now make copies of your changed files, do a fresh checkout, then subversion will lose track of how your changes should be merged back in.
If you didn't get the problem in this | [
0.4948646128177643,
-0.16683419048786163,
0.08050961792469025,
0.3634219467639923,
0.18407946825027466,
-0.36607661843299866,
-0.021465184167027473,
-0.13142095506191254,
-0.5177205801010132,
-0.7355274558067322,
-0.1226198747754097,
0.31703123450279236,
-0.6049541234970093,
0.363316118717... | |
case, when you got around to checkin in your modifications, you would need to update your working copy first, and possibly handle a conflict with your file.
However, if you do a fresh checkout, complete with your collegues changes, it now looks like you removed his changes and substituted with your own. No conflicts, and no indications from subversion that something is amiss. | [
0.41541391611099243,
-0.04947128891944885,
0.10562551766633987,
0.08391421288251877,
0.4380958676338196,
0.015058860182762146,
-0.10806892067193985,
0.007858293130993843,
-0.5077534914016724,
-0.34304431080818176,
0.022737033665180206,
0.403044193983078,
-0.44524648785591125,
0.06968074291... | |
I'm trying to customize some TFS work items via the VS2008 xml editor, but every time I open a work item xml file it jumps to the graphical designer. All that gives me is a "View XML" button that doesn't let you edit the xml directly.
I don't have TFS but I know in regular VS there is an Open With... option in most items' contextual menu that even let you change the default editor. Very useful when you are tired of the Designer opening instead of the Code file on Windows forms. | [
0.4873410165309906,
-0.14218498766422272,
0.4657154083251953,
-0.08392389118671417,
-0.3971894383430481,
-0.04801589995622635,
0.3342854678630829,
0.11622810363769531,
-0.2585907280445099,
-0.7876697778701782,
0.09176039695739746,
0.48115435242652893,
-0.3490484356880188,
0.349399626255035... | |
Has anyone had any experience in building a 'real world' application with the [Smart Client Software Factory](http://www.codeplex.com/smartclient), from Microsofts Patterns and Practices group? I'm looking for advice on how difficult it was to master, whether it decreased your time to market and any other general pitfalls.
We used SCSF for a real world app with about 10 developers. It was a steep learning curve to set up and develop a pattern of usage, but once it was set up, introducing new developers to the project was VERY easy. Using CAB and SCSF was very beneficial to our project especially getting each | [
0.4741508662700653,
0.005232746247202158,
0.06792060285806656,
0.2180205136537552,
-0.030719878152012825,
0.31674087047576904,
0.21609000861644745,
-0.16719894111156464,
-0.08525595813989639,
-0.5606098771095276,
0.2994331121444702,
0.502796471118927,
-0.30074337124824524,
-0.2889786958694... | |
developer up to speed and productive.
A downfall of SCSF is that it provides ALOT of functionality that may not be used (we probably only used 60% of the functionality).
I am also using SCSF for a new project and am considering refactoring to PRISM. PRISM allows you to cull the functionality that is not used. If you use WPF, I suggest looking into PRISM. | [
0.3976346552371979,
-0.053006116300821304,
0.3885820508003235,
0.1549086719751358,
-0.313650518655777,
-0.46012061834335327,
0.4216129779815674,
-0.19361717998981476,
-0.1953008472919464,
-0.766173243522644,
0.19729071855545044,
0.48678848147392273,
-0.3532765209674835,
-0.0238874088972806... | |
I've got a website that I've just uploaded onto the interwebs, and it's displaying differently using Firefox 3.0.1 on Ubuntu and WinXP.
Two things I've noticed on Ubuntu:
1. The favicon is missing
2. The background color isn't displaying (it's set in the stylesheet)
What have I done wrong? The CSS file is being fetched under Ubuntu, so why isn't it applying all of the stylesheet, just the bits it likes? And why isn't the favicon displaying? Are they the same problem?
---
The answer on the background color: invalid HTML. But I'd love for someone to explain why it works under Windows and not Ubuntu.
The | [
0.18841171264648438,
0.1274254322052002,
0.33135390281677246,
-0.06033949926495552,
-0.18050910532474518,
-0.1662934422492981,
0.2793973982334137,
0.004131074994802475,
-0.36650532484054565,
-0.6889346837997437,
0.053587500005960464,
0.5418088436126709,
-0.4871133267879486,
0.0740603879094... | |
answer on favicon: previously, there was no favicon. The browser cached the lack of favicon. [Clear the Firefox cache](http://pcsupport.about.com/od/maintenance/ht/clearcacheff.htm), and all is well.
I would first suggesting getting you html and css code validated. If there are any errors in your markup, these can cause errors in the rendering.
* [CSS Validator](http://jigsaw.w3.org/css-validator/)
* [HTML Validator](http://validator.w3.org/) | [
0.02266736701130867,
0.08452823013067245,
0.7492894530296326,
0.06266175210475922,
-0.049831584095954895,
-0.2191382348537445,
0.32591989636421204,
-0.2329307347536087,
-0.08652843534946442,
-0.3903529942035675,
-0.3231794238090515,
0.32738548517227173,
-0.12492889165878296,
-0.27484214305... | |
In a .net system I'm building, there is a need for automated e-mail notifications. These should be editable by an admin. What's the easiest way to do this? SQL table and WYSIWIG for editing?
---
The queue is a great idea. I've been throwing around that type of process for awhile with my old company.
From a high level, yes. :D The main thing is some place to store the templates. A database is a great option unless you're not already using one, then file systems work fine.
WSIWIG editors (such as fckeditor) work well and give you some good options regarding the features | [
0.49893879890441895,
-0.15718217194080353,
0.07951430976390839,
0.37928149104118347,
-0.0946868285536766,
-0.41480720043182373,
0.032396312803030014,
0.2202920764684677,
-0.38492560386657715,
-0.9134770631790161,
0.10864114761352539,
0.4691582918167114,
-0.33998411893844604,
0.058410950005... | |
that you allow.
Some sort of token replacement system is also a good idea if you need it. For example, if someone puts %FIRSTNAME% in the email template, the code that generates the email can do some simple pattern matching to replace known tokens with other known values that may be dynamic based on user or other circumstances. | [
0.2700537145137787,
-0.14625108242034912,
-0.20595872402191162,
0.12390117347240448,
0.19542992115020752,
-0.15324701368808746,
0.04891892150044441,
0.22777657210826874,
-0.1892925202846527,
-0.6921502947807312,
0.0346517451107502,
0.33354514837265015,
-0.0413137748837471,
0.01204779930412... | |
So I have a Sybase stored proc that takes 1 parameter that's a comma separated list of strings and runs a query with in in an IN() clause:
```
CREATE PROCEDURE getSomething @keyList varchar(4096)
AS
SELECT * FROM mytbl WHERE name IN (@keyList)
```
How do I call my stored proc with more than 1 value in the list?
So far I've tried
```
exec getSomething 'John' -- works but only 1 value
exec getSomething 'John','Tom' -- doesn't work - expects two variables
exec getSomething "'John','Tom'" -- doesn't work - doesn't find anything
exec getSomething '"John","Tom"' -- doesn't work - doesn't | [
0.05866274610161781,
0.24665488302707672,
0.3210310935974121,
-0.14999033510684967,
0.01626395806670189,
0.15198202431201935,
0.27782946825027466,
-0.41867002844810486,
-0.17695853114128113,
-0.25118836760520935,
-0.19533175230026245,
0.7271643877029419,
-0.299081027507782,
-0.068750545382... | |
find anything
exec getSomething '\'John\',\'Tom\'' -- doesn't work - syntax error
```
**EDIT:** I actually found this [page](http://vyaskn.tripod.com/passing_arrays_to_stored_procedures.htm) that has a great reference of the various ways to pas an array to a sproc
If you're using Sybase 12.5 or earlier then you can't use functions. A workaround might be to populate a temporary table with the values and read them from there. | [
0.19389761984348297,
-0.17236407101154327,
0.30817675590515137,
0.3177529275417328,
0.15995576977729797,
-0.3402732014656067,
0.19992999732494354,
-0.07994114607572556,
-0.29256492853164673,
-0.5843954086303711,
-0.13895933330059052,
0.5013655424118042,
-0.23221135139465332,
-0.12637992203... | |
I've had a hard time trying to find good examples of how to manage database schemas and data between development, test, and production servers.
Here's our setup. Each developer has a virtual machine running our app and the MySQL database. It is their personal sandbox to do whatever they want. Currently, developers will make a change to the SQL schema and do a dump of the database to a text file that they commit into SVN.
We're wanting to deploy a continuous integration development server that will always be running the latest committed code. If we do that now, it will reload | [
0.5239640474319458,
0.16181235015392303,
0.230844646692276,
0.27727600932121277,
0.3162708282470703,
-0.17838408052921295,
-0.0987369492650032,
-0.022536277770996094,
-0.2271195650100708,
-0.6587486863136292,
0.050448738038539886,
0.6957974433898926,
-0.2489653378725052,
0.0807974413037300... | |
the database from SVN for each build.
We have a test (virtual) server that runs "release candidates." Deploying to the test server is currently a very manual process, and usually involves me loading the latest SQL from SVN and tweaking it. Also, the data on the test server is inconsistent. You end up with whatever test data the last developer to commit had on his sandbox server.
Where everything breaks down is the deployment to production. Since we can't overwrite the live data with test data, this involves manually re-creating all the schema changes. If there were a large number of schema | [
0.739793062210083,
0.29169324040412903,
0.17429675161838531,
0.3395989239215851,
0.15037639439105988,
-0.14647820591926575,
0.24451646208763123,
-0.3630697727203369,
0.006984182633459568,
-0.48234930634498596,
0.01949554681777954,
0.618749737739563,
0.0456860326230526,
0.22523097693920135,... | |
changes or conversion scripts to manipulate the data, this can get really hairy.
If the problem was just the schema, It'd be an easier problem, but there is "base" data in the database that is updated during development as well, such as meta-data in security and permissions tables.
This is the biggest barrier I see in moving toward continuous integration and one-step-builds. How do ***you*** solve it?
---
A follow-up question: how do you track database versions so you know which scripts to run to upgrade a given database instance? Is a version table like Lance mentions below the standard procedure?
---
Thanks for the reference | [
0.5206100940704346,
0.13347123563289642,
0.05840655043721199,
0.3938972055912018,
0.07766807079315186,
-0.062475621700286865,
0.34794649481773376,
-0.15386466681957245,
-0.29249465465545654,
-0.7724297046661377,
0.1581360399723053,
0.8570791482925415,
-0.16742277145385742,
-0.1142864972352... | |
to Tarantino. I'm not in a .NET environment, but I found their [DataBaseChangeMangement wiki page](http://code.google.com/p/tarantino/wiki/DatabaseChangeManagement) to be very helpful. Especially this [Powerpoint Presentation (.ppt)](http://tarantino.googlecode.com/svn/docs/Database-Change-Management.ppt)
I'm going to write a Python script that checks the names of `*.sql` scripts in a given directory against a table in the database and runs the ones that aren't there in order based on a integer that forms the first part of the filename. If it is a pretty simple solution, as I suspect it will be, then I'll post it here.
---
I've got a working script for this. It handles initializing the DB if it doesn't | [
0.36149919033050537,
0.27039891481399536,
-0.2897389233112335,
0.07706467062234879,
-0.05563235282897949,
-0.13106562197208405,
-0.007584219332784414,
-0.15261106193065643,
-0.04497130215167999,
-0.39535266160964966,
0.2891199290752411,
0.39595383405685425,
-0.19631999731063843,
-0.2758984... | |
exist and running upgrade scripts as necessary. There are also switches for wiping an existing database and importing test data from a file. It's about 200 lines, so I won't post it (though I might put it on pastebin if there's interest).
There are a couple of good options. I wouldn't use the "restore a backup" strategy.
1. Script all your schema changes, and have your CI server run those scripts on the database. Have a version table to keep track of the current database version, and only execute the scripts if they are for a newer version.
2. Use a migration solution. | [
0.965682864189148,
-0.06466501206159592,
0.4384007453918457,
0.22613228857517242,
0.15491238236427307,
-0.3459952473640442,
0.38198697566986084,
0.15501797199249268,
0.0420592837035656,
-1.1645342111587524,
0.12374094873666763,
0.6465288996696472,
-0.23541782796382904,
0.06679421663284302,... | |
These solutions vary by language, but for .NET I use Migrator.NET. This allows you to version your database and move up and down between versions. Your schema is specified in C# code. | [
0.2598510980606079,
0.010574585758149624,
0.42371758818626404,
-0.06426800787448883,
0.1822516769170761,
-0.089293472468853,
-0.023698987439274788,
-0.2660622298717499,
-0.1935896873474121,
-0.7388157248497009,
0.07813740521669388,
0.5815700888633728,
-0.3883475065231323,
-0.10390248894691... | |
The following code works great in IE, but not in FF or Safari. I can't for the life of me work out why. The code is *supposed* to disable radio buttons if you select the "Disable 2 radio buttons" option. It should enable the radio buttons if you select the "Enable both radio buttons" option. These both work...
However, if you don't use your mouse to move between the 2 options ("Enable..." and "Disable...") then the radio buttons do not appear to be disabled or enabled correctly, until you click anywhere else on the page (not on the radio buttons themselves).
If | [
0.12870720028877258,
0.17666034400463104,
0.4461783170700073,
-0.04082154855132103,
0.18052548170089722,
-0.3222161829471588,
0.8990428447723389,
-0.10139159113168716,
-0.05615486577153206,
-1.0115872621536255,
-0.26156747341156006,
0.931797981262207,
-0.40590837597846985,
-0.1239992827177... | |
anyone has time/is curious/feeling helpful, please paste the code below into an html page and load it up in a browser. It works great in IE, but the problem manifests itself in FF (3 in my case) and Safari, all on Windows XP.
```js
function SetLocationOptions() {
var frmTemp = document.frm;
var selTemp = frmTemp.user;
if (selTemp.selectedIndex >= 0) {
var myOpt = selTemp.options[selTemp.selectedIndex];
if (myOpt.attributes[0].nodeValue == '1') {
frmTemp.transfer_to[0].disabled = true;
frmTemp.transfer_to[1].disabled = true;
frmTemp.transfer_to[2].checked = true; | [
0.038731351494789124,
-0.31110990047454834,
0.48725658655166626,
-0.0014073634520173073,
0.3493124842643738,
-0.03035322017967701,
0.4748663604259491,
-0.2596747875213623,
-0.1893719881772995,
-0.9829728603363037,
-0.3609141409397125,
0.6593605875968933,
-0.14411069452762604,
-0.2689564824... | |
} else {
frmTemp.transfer_to[0].disabled = false;
frmTemp.transfer_to[1].disabled = false;
}
}
}
```
```html
<form name="frm" action="coopfunds_transfer_request.asp" method="post">
<select name="user" onchange="javascript: SetLocationOptions()">
<option value="" />Choose One
<option value="58" user_is_tsm="0" />Enable both radio buttons
<option value="157" user_is_tsm="1" />Disable 2 radio buttons
</select>
<br /><br />
<input type="radio" name="transfer_to" value="fund_amount1" />Premium
<input type="radio" name="transfer_to" value="fund_amount2" />Other
<input type="radio" name="transfer_to" value="both" CHECKED />Both
<br /><br />
<input type="button" class="buttonStyle" value="Submit Request" />
</form>
```
To get | [
0.01717277057468891,
-0.14091768860816956,
0.8605865240097046,
0.13530375063419342,
0.12881822884082794,
0.0627489909529686,
0.1773841381072998,
-1.0739809274673462,
-0.3133392333984375,
-0.6736335158348083,
-0.2945844829082489,
0.853704571723938,
-0.06814861297607422,
-0.15022461116313934... | |
FF to mimic IE's behavior when using the keyboard, you can use the keyup event on the select box. In your example (I am not a fan of attaching event handlers this way, but that's another topic), it would be like this:
```
<select name="user" id="selUser" onchange="javascript:SetLocationOptions()" onkeyup="javascript:SetLocationOptions()">
``` | [
0.2638571858406067,
-0.3484092652797699,
0.16425803303718567,
-0.09773483127355576,
-0.09162747114896774,
-0.06283267587423325,
-0.16328616440296173,
-0.09435670077800751,
-0.12284336984157562,
-0.7763949036598206,
0.06989388167858124,
0.6458637118339539,
-0.5790814161300659,
-0.2924694418... | |
[Mocking sealed classes](http://www.google.com/search?q=how%20to%20mock%20sealed%20class) can be quite a pain. I currently favor an [Adapter pattern](http://en.wikipedia.org/wiki/Adapter_pattern) to handle this, but something about just keeps feels weird.
**So, What is the best way you mock sealed classes?**
*Java answers are more than welcome*. In fact, I would anticipate that the Java community has been dealing with this longer and has a great deal to offer.
But here are some of the .NET opinions:
* [Why Duck Typing Matters for C#
Develoepers](http://haacked.com/archive/2007/08/19/why-duck-typing-matters-to-c-developers.aspx)
* [Creating wrappers
for sealed and other types for
mocking](http://cs.rthand.com/blogs/blog_with_righthand/archive/2008/07/22/Creating-wrappers-for-sealed-and-other-types-for-mocking.aspx)
* [Unit tests for WCF (and Moq)](http://weblogs.asp.net/cibrax/archive/2008/05/16/unit-tests-for-wcf.aspx)
My general rule of thumb is that objects that I need to mock should | [
0.09065821021795273,
0.6444113254547119,
0.1830122023820877,
-0.10488229990005493,
-0.6852497458457947,
0.08683407306671143,
0.48332440853118896,
-0.050508227199316025,
-0.18734943866729736,
-0.5699859261512756,
0.14661678671836853,
0.4443996548652649,
-0.0687449499964714,
0.19157871603965... | |
have a common interface too. I think this is right design-wise and makes tests a lot easier (and is usually what you get if you do TDD). More about this can be read in the Google Testing Blog [latest post](http://googletesting.blogspot.com/2008/08/by-miko-hevery-so-you-decided-to.html) (See point 9).
Also, I've been working mainly in Java in the past 4 years and I can say that I can count on one hand the number of times I've created a final (sealed) class. Another rule here is I should always have a good reason to seal a class, as opposed to sealing it by default. | [
0.3424797058105469,
0.16658422350883484,
-0.19026008248329163,
-0.010266060009598732,
-0.05977005884051323,
-0.48032742738723755,
0.36322683095932007,
-0.010492121800780296,
-0.013848698697984219,
-0.5996096134185791,
0.020575452595949173,
0.20961105823516846,
0.2821727693080902,
0.1051989... | |
One of those classic programming interview questions...
You are given two marbles, and told that they will break when dropped from some certain height (and presumably suffer no damage if dropped from below that height). You’re then taken to a 100 story building (presumably higher than the certain height), and asked to find the highest floor your can drop a marble from without breaking it as efficiently as possible.
Extra info
* You must find the correct floor (not a possible range)
* The marbles are both guaranteed to break at the same floor
* Assume it takes zero time for you to change floors | [
0.5196570158004761,
-0.07381916791200638,
0.1655062437057495,
0.5540905594825745,
0.516061007976532,
-0.1008852943778038,
0.38804444670677185,
-0.24176378548145294,
-0.40984752774238586,
-0.2580666244029999,
-0.5289695262908936,
0.16434773802757263,
-0.05996262654662132,
-0.319076359272003... | |
- only the number of marble drops counts
* Assume the correct floor is randomly distributed in the building
The interesting thing here is how you can do it in the least amount of drops possible. Going to the 50th floor and dropping the first would be disastrous if the breaking floor is the 49th, resulting in us having to do 50 drops. We should drop the first marble at floor n, where n is the max amount of drops required. If the marble breaks at floor n, we may have to make n-1 drops after that. If the marble doesn't break | [
0.24233421683311462,
-0.2122374027967453,
0.30598822236061096,
0.3582766056060791,
-0.06151438504457474,
0.12538258731365204,
0.4143403172492981,
-0.5771262645721436,
-0.5718178153038025,
-0.6379192471504211,
-0.1102650985121727,
0.15104083716869354,
-0.033071666955947876,
-0.2260914295911... | |
we go up to floor 2n-1 and if it breaks here we have to drop the second marble n-2 times in the worst case. We continue like this up to the 100th floor and try to break it at 3n-2, 4n-3....
and n+(n-1)+(n-2)+...1 <=100
**n=14 Is the maximum drops required** | [
0.06883855164051056,
0.16074895858764648,
0.5297162532806396,
0.10476376116275787,
-0.029804948717355728,
0.2542792856693268,
0.5759438872337341,
-0.4658444821834564,
-0.680969774723053,
-0.7617736458778381,
-0.04412839189171791,
-0.0654645785689354,
-0.010581569746136665,
-0.1016284972429... | |
It seems that a List object cannot be stored in a List variable in C#, and can't even be explicitly cast that way.
```
List<string> sl = new List<string>();
List<object> ol;
ol = sl;
```
results in Cannot implicitly convert type `System.Collections.Generic.List<string>` to `System.Collections.Generic.List<object>`
And then...
```
List<string> sl = new List<string>();
List<object> ol;
ol = (List<object>)sl;
```
results in Cannot convert type `System.Collections.Generic.List<string>` to `System.Collections.Generic.List<object>`
Of course, you can do it by pulling everything out of the string list and putting it back in one at a time, but it is a rather convoluted solution.
Think of it this way, if you were to do such a cast, and then add an object of | [
0.027421491220593452,
-0.12604720890522003,
0.3938818573951721,
-0.08618320524692535,
-0.14057761430740356,
-0.08874084055423737,
0.22002655267715454,
-0.2889229357242584,
-0.2834829092025757,
-0.5014863610267639,
-0.23245395720005035,
0.2526625990867615,
-0.5581487417221069,
0.27899208664... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.