text
stringlengths
0
30.5k
title
stringclasses
1 value
embeddings
listlengths
768
768
separate array for local variables (`f_fastlocals`), which is merged into `f_locals` on access, but the converse is not true. ``` >>> def foo(): ... x = 3 ... f = sys._getframe() ... print f.f_locals['x'] ... x = 4 ... print f.f_locals['x'] ... d = f.f_locals ... x = 5 ... print d['x'] ... f.f_locals...
[ -0.24145209789276123, -0.24608060717582703, 0.4023645520210266, -0.17919470369815826, -0.05894738808274269, -0.046524450182914734, 0.29106298089027405, -0.1451185643672943, -0.19974450767040253, -0.4194444715976715, -0.313408225774765, 0.7737742066383362, -0.5439091920852661, -0.1180444657...
I need help writing a conditional where clause. here is my situation: I have a bit value that determines what rows to return in a select statement. If the value is true, I need to return rows where the import\_id column is not null, if false, then I want the rows where the import\_id column is null. My attempt at suc...
[ 0.2105170339345932, 0.0713791698217392, 0.03575671836733818, -0.38201043009757996, -0.14466343820095062, 0.06196819618344307, 0.22391895949840546, -0.2730538845062256, 0.016461897641420364, -0.2993849217891693, -0.04959673807024956, 0.8225092887878418, -0.3747446835041046, 0.20934094488620...
0 AND import_is IS NULL) ``` Thanks. Change the `AND` to `OR` ``` DECLARE @imported BIT SELECT id, import_id, name FROM Foo WHERE (@imported = 1 AND import_id IS NOT NULL) OR (@imported = 0 AND import_is IS NULL) ``` ### Decomposing your original statement you have essentially written ``` @imported ...
[ 0.37841668725013733, -0.05856885761022568, 0.3348006308078766, -0.11530005931854248, -0.1977844536304474, -0.20428484678268433, 0.550000786781311, -0.3396896421909332, 0.04904421418905258, -0.48092225193977356, -0.4255635440349579, 0.7114921808242798, -0.3888736963272095, 0.202696487307548...
IS NULL ``` what results in two pair of clauses that completely negate each other
[ 0.03385389223694801, 0.3255881667137146, -0.19914673268795013, 0.009705446660518646, -0.2694041132926941, -0.25832778215408325, 0.7776228785514832, 0.12231694906949997, -0.08224557340145111, -0.35688602924346924, -0.4653356969356537, -0.029947428032755852, -0.3776111304759979, 0.2817660570...
I've got a method which currently takes an IList as a parameter, where UserBO is similar to the following: ``` public class UserBO { public string Username { get; set; } public string Password { get; set; } public string Pin { get; set; } } public class SomeClass { // An example method giving the basi...
[ 0.5598298907279968, -0.032588060945272446, 0.3994770050048828, -0.26956549286842346, 0.22406795620918274, 0.10605905205011368, 0.006499416660517454, -0.17418767511844635, -0.16694729030132294, -0.6023595333099365, 0.014792473055422306, 0.321533203125, -0.4348093271255493, 0.309052556753158...
(var user in users) { Console.WriteLine(String.Format(User: {0}: {1}, users.Username, Hash(users.Pin)); // Now needs to optionally be users.Password } } private string Hash(string pin) { return // Hashed Pin } } ``` This method then uses the Username/Pin pairs to create some X...
[ 0.044863227754831314, 0.20642083883285522, 0.6976274847984314, -0.05495627224445343, 0.11365587264299393, -0.07304348796606064, -0.0003333196509629488, -0.28618553280830383, 0.03972690552473068, -0.6885051727294922, 0.02514806017279625, 0.5203050374984741, -0.06983774155378342, 0.445515275...
the Password field instead of the Pin field (there's a good reason for having both fields). Instead of just creating another method with a similar name, I'd prefer to refactor the code so as to remove the BO specific code from this class entirely, and make it so that the decision about what class/members to use are ma...
[ 0.23401187360286713, -0.06817785650491714, 0.11213980615139008, 0.04905543848872185, 0.06685607880353928, -0.23356252908706665, 0.12759815156459808, -0.28423449397087097, 0.044836655259132385, -0.3523583710193634, -0.16752994060516357, 0.6465054154396057, -0.3210386633872986, 0.11046674102...
(which would be nice but not essential to keep). I could use an IList or something, but that would be more difficult to convert the IList into. Does anybody have any good suggestions of how to do this? P.S. If anybody has a better idea of how to title this post, feel free to have a go at it. You could also use Expres...
[ 0.6046091318130493, 0.042937446385622025, 0.3884503245353699, 0.052938468754291534, -0.16945132613182068, -0.2747005522251129, 0.23874123394489288, 0.17685788869857788, 0.03705167397856712, -0.7162151336669922, -0.04501798376441002, 0.499733567237854, -0.31662610173225403, -0.0684159472584...
I'm trying to create a custom search interface for [Apache Solr](http://lucene.apache.org/solr/) using [Drupal](http://drupal.org), and I'm having some strange issues with the results. I have the same query yielding 8 hits when I run it from Solr's built-in web interface, and 0 hits when I run it through Drupal. Can a...
[ -0.15278898179531097, 0.2844911515712738, 0.619750440120697, -0.07167398184537888, -0.4075396955013275, 0.15338917076587677, 0.39790377020835876, -0.6838809251785278, -0.34398987889289856, -0.4182998239994049, 0.11166847497224808, 0.3540389835834503, -0.1657278686761856, 0.1397314667701721...
removing it, and that doesn't change the behavior. After lots of tweaking, I've managed to the Drupal module to send more or less the same parameters, but it still gives 0 results: > `09-Mar-2009 17:47:43 org.apache.solr.core.SolrCore execute > INFO: [] webapp=/solr path=/select params={wt=standard&rows=10&start=0&q...
[ -0.04696273431181908, -0.2463625967502594, 0.7387968301773071, -0.12596428394317627, -0.04736604541540146, -0.05490261688828468, 0.1443604677915573, -0.5619534254074097, -0.49888667464256287, -0.2235604077577591, -0.3618276119232178, 0.34426647424697876, -0.28377196192741394, 0.17321591079...
If I put a "info light" button in the lower corner of my screen on dark background and check "Shows Touch On Hightlight", I get a nice highlight effect when the user touches the icon. It gives the user positive feedback. In my app the background it white. So I selected "info dark" button. The "Shows Touch On Highlight...
[ 0.3911516070365906, -0.08405578881502151, 0.4281570017337799, -0.006194595713168383, -0.15845105051994324, -0.07747709006071091, 0.1058129146695137, 0.08698364347219467, 0.09886788576841354, -0.5508421063423157, 0.3183392286300659, 0.8456960320472717, -0.2665266692638397, 0.059872418642044...
then the info button is touched? Update: I have figured it out. Create a new image with dark glow called infoDarkHighlighted.png and set the following in the ViewController's viewDidLoad mothod. [infoButton setImage:[UIImage imageNamed:@"infoDarkHighlighted.png"] forState:UIControlStateHighlighted];
[ 0.19538064301013947, -0.3033081889152527, 0.9723257422447205, 0.1296531707048416, -0.22574728727340698, -0.07184580713510513, 0.05752502754330635, -0.02110530436038971, 0.19860726594924927, -0.800140380859375, -0.2433931678533554, 0.7107083797454834, -0.09800948202610016, -0.15817949175834...
I have an aspx page that has a control which serves as a summary for a GridView that is on the same page. When the page loads, it creates the summary control and dynamically creates links and attaches an event handler to it. Here is a snippet: ``` protected void Page_Load(object sender, EventArgs e) { LoadSummar...
[ 0.30645352602005005, -0.18677908182144165, 0.45116305351257324, -0.05918920412659645, 0.03860754147171974, -0.13828934729099274, -0.00017473667685408145, -0.15333276987075806, -0.2380760908126831, -0.7475674748420715, -0.19082078337669373, 0.45354342460632324, -0.4760323464870453, 0.001097...
+= new System.EventHandler(this.Search); lb.CommandName = "CommandName"; lb.CommandArgument = "CommandArgument"; ``` When I run the page, it loads everything fine, but I need to click the link twice for it to go into to Search method. On the first click, the page reloads, but it doesn't go into the search method. On ...
[ -0.014315124601125717, -0.27452418208122253, 0.3904024660587311, -0.28864532709121704, 0.01103610172867775, -0.15280970931053162, 0.11115223914384842, -0.4893954396247864, -0.3191531300544739, -0.31124699115753174, -0.24833185970783234, 0.6038409471511841, -0.48742470145225525, -0.17950162...
the link button, so I am stuck on understanding why I need to click it twice. Are you using any complex controls elsewhere on the page that may be injecting controls into your page? I have had this problem with pages that have certain controls from libraries that inject controls into the page. I'm using a Calendar con...
[ 0.21750003099441528, 0.03151797875761986, 0.3216083347797394, 0.28615841269493103, -0.048035915940999985, -0.28048840165138245, 0.24703937768936157, 0.428119033575058, -0.43342870473861694, -0.5335861444473267, 0.3034226596355438, 0.40532049536705017, -0.3930072486400604, 0.334694385528564...
button was identifying itself with one Control ID, but the server thought it should have a different control ID. This caused the event handler to not be matched to the control on the first post back, so the event couldn't fire. The second time, however, the controls had already been injected so my linkbutton had the n...
[ -0.3079027235507965, -0.5660626292228699, 0.31871968507766724, 0.19121205806732178, -0.06600521504878998, -0.01894930563867092, 0.3163188397884369, -0.0632551833987236, -0.19864004850387573, -0.47951963543891907, -0.1132025420665741, 0.3711051344871521, -0.784066379070282, 0.10692751407623...
May not work if your event handler MUST be on that page. Solution 3: Provide an ID that will not be altered by other controls. (This was the solution for Xaisoft)
[ 0.0019756045658141375, -0.29181867837905884, 0.3307061493396759, 0.08012384176254272, 0.1365646868944168, -0.4050837457180023, 0.47244495153427124, -0.3670428395271301, -0.09025197476148605, -0.41017428040504456, -0.40842753648757935, 0.30135855078697205, -0.6356948018074036, -0.3000361621...
I'm just trying to understand where the label 'container' came from. Anyone know? Seems like many things could be called 'containers'. Because it serves as container for objects. It is the framework that manages their lifecycle. It is responsible to instantiate, resolve references and destroy them.
[ 0.5585846304893494, 0.41245850920677185, 0.148029163479805, 0.5483505129814148, 0.1707189828157425, -0.143015056848526, -0.047156646847724915, 0.4213901460170746, -0.2800426185131073, -0.416951060295105, 0.0792267769575119, 0.1419207751750946, -0.08822673559188843, 0.7022587656974792, -0...
How can I define Wix properties and values that change depending on which Visual Studio configuration is active? e.g. For our release build, var x = 1 and for the export build, var x = 2. We pass properties into WiX from the wixproj files using ``` <DefineConstants>configuration=$(Configuration)</DefineConstants> ```...
[ 0.4172663688659668, -0.0321199893951416, 0.0812576413154602, 0.0005685464711859822, 0.08550390601158142, -0.17446257174015045, 0.23887336254119873, -0.18788912892341614, -0.010980834253132343, -1.0885051488876343, -0.0687444657087326, 0.6479045152664185, -0.08922947198152542, 0.13400839269...
Something intrigues me and I don't find any resource on this. How can FileSystemWatcher know when a file on a computer "A" is created/removed/changed/renamed ? I thought that this worked with polling, (the observer polls the server to check update), but after verifying the network activity with Wireshark I saw that ...
[ 0.34496068954467773, -0.13872811198234558, 0.452608585357666, 0.25955650210380554, -0.16433173418045044, -0.21824872493743896, 0.23084360361099243, -0.05137282609939575, -0.5674059987068176, -0.4953479766845703, 0.39670485258102417, 0.16540002822875977, -0.3562687635421753, 0.3665601611137...
to be true... > Using FileSystemWatcher on another > computer seems too easy to be true... It kinda is. The underlying API - [`ReadDirectoryChanges()`](http://msdn.microsoft.com/en-us/library/aa365465.aspx) - opens up a connection to the server, which is responsible for responding when something changes. If that conn...
[ 0.40837007761001587, -0.10593392699956894, 0.6450377106666565, 0.30461907386779785, 0.007985388860106468, -0.3155735731124878, 0.29399338364601135, -0.05872460827231407, 0.03403233364224434, -0.391634464263916, 0.10234562307596207, 0.710744321346283, -0.2495035082101822, -0.172487035393714...
On my machine when I test my webapplication (wether in debug or normal) after a javascript:history.back() triggers a postback in my app. On the other hand it does not occur when i precompile the application. Lastly, when I test the same pages on someones elses machine, the postback does not occur at all. I'm using vs2...
[ 0.30615654587745667, 0.006753592751920223, 0.26641222834587097, 0.11673477292060852, -0.11593776941299438, -0.4553225338459015, 0.7557737827301025, -0.11143575608730316, -0.16011536121368408, -0.7755723595619202, -0.004339913371950388, 0.46416765451431274, -0.21691064536571503, 0.257143169...
a connection to the server, which is responsible for responding when something changes. If that connection gets dropped for some reason, or you bump up against the connection limit of the OS you're connecting to, then you don't get notifications. I've found that it is more reliable to poll periodically (with some rat...
[ 0.128020241856575, -0.25474587082862854, 0.45859408378601074, 0.49015000462532043, -0.07646892219781876, -0.05096336454153061, 0.009528621099889278, 0.08853645622730255, -0.41508281230926514, -0.7428845763206482, -0.04926307126879692, 0.6057751178741455, -0.12213969975709915, -0.2707969844...
I would like to place an if condition within the sub that will tell it to run when the xml node STORE with attribute TEST="test.doc" does not exist. Any suggestions would be great. I'm new to vb. ``` Sub InsertNode(ByVal doc As XmlDocument) Dim City As XmlNode = doc.DocumentElement Dim Location As XmlElem...
[ 0.6406741738319397, -0.10609807074069977, 1.006666898727417, 0.033790480345487595, 0.02346084453165531, -0.10175168514251709, 0.23477858304977417, -0.4833757281303406, 0.13156940042972565, -0.7461761236190796, -0.23346111178398132, 0.38434556126594543, -0.12214646488428116, 0.1976348906755...
<store test="test.doc"> <books> "New Words" </books> </store> </city> ``` Try something like that : ``` If Not doc.SelectSingleNode("//store[@test='test.doc']") Is Nothing Then Exit Sub End If ```
[ 0.43963274359703064, 0.1079065278172493, 0.3228462040424347, -0.034714944660663605, 0.2623057961463928, -0.3555603325366974, 0.6194425821304321, -0.10400056838989258, 0.07338715344667435, -0.7559492588043213, -0.3435763120651245, 0.2426004558801651, -0.13556911051273346, 0.3878149390220642...
Can a whole operating system be written without using even one line of C/C++ code? EDIT: One more to add to the list - assembly Yes and no. First of all, it's important to remember that whatever your language of choices, in the end the compiled product is in assembly language (or more accurately, machine code). Even ...
[ 0.4029795527458191, 0.22297529876232147, -0.3508225083351135, 0.2233937382698059, -0.12733741104602814, 0.05560523271560669, 0.37165358662605286, 0.32957008481025696, -0.26411667466163635, -0.48000213503837585, -0.1675877869129181, 0.716719388961792, -0.17100566625595093, -0.35181260108947...
if don't already know how to write an operating system in a mix of assembly language and C then you have absolutely no business trying your hand at OS design. Often those new to programming have these sorts of questions because they want to do something as cool as writing a new OS without all the learning required to ...
[ 0.48555493354797363, 0.19978395104408264, -0.3053181767463684, 0.3808683454990387, 0.22084075212478638, -0.2136855125427246, 0.31514042615890503, 0.44766342639923096, -0.2469511777162552, -0.3944585919380188, -0.14319443702697754, 0.7792351245880127, 0.12102869898080826, -0.200864121317863...
are no shortcuts. Be ready to roll up your sleeves and get some carpal tunnel syndrome. That doesn't preclude following a path to eventual OS design! If that's your passion, then start at the top and work your way down. Get books on networking protocols, memory management, threading, etc, tackle each major subsystem a...
[ 0.4936259388923645, 0.3669244647026062, 0.06200126186013222, 0.47374090552330017, 0.23142391443252563, -0.1378546506166458, 0.28861740231513977, 0.3935379981994629, -0.4828346073627472, -0.8055129647254944, -0.13432547450065613, 0.8627261519432068, 0.25921300053596497, -0.11331772059202194...
of social constructs like APIs) is immense. This is a long journey and a rewarding one. If you truly love this craft like I do, you'll be glad you took the time even if you never actually write an OS. Now, the technical answer. You're going to need a bootloader, and that must be written in assembly language. After all...
[ 0.5351275205612183, 0.298656702041626, -0.0003159581683576107, 0.20654140412807465, 0.10497703403234482, 0.01798718236386776, 0.4004823565483093, 0.36781516671180725, -0.4130327105522156, -0.9148536324501038, -0.0957741066813469, 0.767382025718689, 0.11995848268270493, -0.05328110605478287...
cycles" computing environment, an OS must be lean and efficient and that's nearly impossible to achieve in a higher level language, even more so in an interpreted language. Chances are, you'll need to write your own compiler/interpreter of that given language as a core component of your OS. That core compiler would li...
[ 0.3516975939273834, 0.3796027600765228, 0.13242687284946442, 0.3076474666595459, 0.3121972680091858, 0.2137095183134079, 0.33197450637817383, 0.14632147550582886, -0.2122279405593872, -0.771377444267273, -0.0734943300485611, 0.6836239099502563, -0.27903833985328674, -0.2374153435230255, ...
lack. But if you have the drive to do so, you can easily change that, and then I'd happily debate approaches all day! If it makes you feel any better, I do know enough to write an operating system, and still I sit around daydreaming, trying to figure out how much of an OS could I get away with writing in python. ;)
[ 0.35425880551338196, 0.3259504735469818, -0.11170881986618042, 0.2055153101682663, 0.021906418725848198, 0.11024055629968643, 0.41999924182891846, 0.3561038374900818, -0.35782673954963684, -0.3217879831790924, 0.21927933394908905, 0.6570852398872375, -0.10756968706846237, 0.120901629328727...
Hopefully the last question in choosing an implementation language for this web app, but before pitching to anyone, we would like to know what your experiences are with maintaining an application. We maintained (and since moved to a hosted solution) a web portal based on Perl. The problem was that we had cases where...
[ 0.3605022430419922, -0.0034658596850931644, 0.2282020002603531, 0.2640541195869446, 0.103607177734375, -0.16695033013820648, 0.35444650053977966, 0.4019474387168884, -0.4093390703201294, -0.3288380801677704, 0.13878777623176575, 0.2889825105667114, -0.4041748642921448, 0.1580958217382431, ...
in the portal was very specific about what version module it would accept. There were a couple times where an innocuous set of security updates could cause the website to come crashing apart for a noticeable period of time. So, in deciding to create a web app based on PHP, Django, or Ruby on Rails, can people share ...
[ 0.4823675751686096, 0.0169526319950819, -0.014525446109473705, 0.3194220960140228, -0.2436508983373642, -0.2819925844669342, 0.32459557056427, -0.1912918984889984, -0.1924656629562378, -0.3680732250213623, 0.053218841552734375, 0.557247519493103, -0.14407987892627716, 0.11756382882595062, ...
isn't it really an issue? If I were deploying a python app these days, I would certainly check out [virtualenv](http://pypi.python.org/pypi/virtualenv). From their page: > virtualenv is a tool to create > isolated Python environments. > > > The basic problem being addressed is > one of dependencies and versions, ...
[ 0.11878783255815506, -0.023059310391545296, 0.03329557552933693, 0.11631333827972412, 0.08470697700977325, -0.12682496011257172, 0.1644362360239029, 0.11187395453453064, -0.5132565498352051, -0.7358624935150146, -0.1262741982936859, 0.4715699851512909, -0.364120751619339, 0.191107779741287...
a > situation where you unintentionally > upgrade an application that shouldn't > be upgraded. > > > Or more generally, what if you want to > install an application and leave it > be? If an application works, any > change in its libraries or the > versions of those libraries can break > the application.
[ 0.19106608629226685, -0.2795635759830475, -0.06105068325996399, 0.04959821328520775, 0.12230479717254639, -0.3947937786579132, 0.5957959294319153, -0.1862136274576187, -0.03238867223262787, -0.8068739771842957, -0.6167317032814026, 0.5780649781227112, -0.35253915190696716, 0.03168254718184...
I'm using TextWrangler to edit PHP code. I often run into the problem that the code just displays as a blank page in my development environment. Is there a good way to further target which place I should look in my code for the problem? Right now I'm just manually running through every line any time I run into this, ...
[ 0.28310656547546387, 0.3300199806690216, 0.14083555340766907, -0.03177094832062721, -0.2867685556411743, -0.0640948936343193, 0.33336973190307617, 0.2585819661617279, -0.16679100692272186, -0.9390702247619629, 0.24400688707828522, 0.6459638476371765, -0.26945731043815613, 0.105836719274520...
E_ALL | E_STRICT ``` Even with these on, sometimes an out-of-memory error can cause a blank page.
[ 0.037165068089962006, 0.19431178271770477, 0.2756270468235016, 0.08674459159374237, 0.09806486964225769, -0.5099040865898132, 0.2764953076839447, 0.036856915801763535, -0.2718799412250519, -0.730461597442627, -0.648256778717041, 0.5472683310508728, -0.5254959464073181, 0.26103150844573975,...
Can you give me an almost overly simplistic understanding of abstract class vs inheritance use and help me so I can truly understand the concept and how to implement? I have a project I'm trying to complete, and am lost on how to implement. I've been chatting with my professor and been told off pretty much, saying that...
[ 0.47150200605392456, -0.07391592115163803, -0.20406965911388397, 0.1663745492696762, 0.09649987518787384, 0.07821140438318253, 0.26619622111320496, -0.19371217489242554, -0.18785305321216583, -0.5395615100860596, 0.30683663487434387, 0.2517387270927429, 0.17099443078041077, 0.2499652504920...
classes etc filled out yet. Can you give me a pointer. I'm not asking for anyone to give me the "answers." I just am lost on where to go with this. I take online courses and his communication efforts with me have been troubling. I just finished with 4.0 with all my other courses, so I'm willing to put the effort in, bu...
[ 0.35646170377731323, -0.02347473055124283, 0.1367100030183792, 0.24000497162342072, 0.10725444555282593, -0.31840845942497253, 0.33595871925354004, 0.4838399589061737, 0.04311435669660568, -0.6411522030830383, 0.18359790742397308, 0.3844873905181885, 0.41602957248687744, -0.149532794952392...
> > The purpose of this exercise is to > demonstrate the use of Interfaces, > Inheritance, Abstract classes, and > Polymorphism. Your task is to take > the supplied program shell and ADD the > appropriate classes and corresponding > class members/methods to get this > program to function correctly. You may > n...
[ 0.229530930519104, 0.15915168821811676, 0.08874130994081497, 0.21828661859035492, -0.025114350020885468, -0.05873563513159752, 0.17659425735473633, -0.5798515677452087, 0.21727293729782104, -0.8712498545646667, -0.04249269887804985, 0.810218870639801, -0.08456264436244965, -0.2578538358211...
Inheritance, Abstract classes, and > Polymorphism. Again, to make clear, > you can add to the supplied code but > you cannot change or delete any of > it. The code that is supplied will > work with very little additional code > and will satisfy the requirements of > the exercise. > > > If you successfully com...
[ 0.2712341248989105, -0.11207300424575806, 0.2220856100320816, 0.004571778699755669, 0.00396645488217473, -0.22552499175071716, 0.3174026906490326, -0.5246663689613342, -0.08555009961128235, -0.6866210103034973, -0.33522361516952515, 0.5335000157356262, -0.7167140245437622, -0.1811331063508...
have an abstract base > class called 'Animal' from which the > Dog and Cat classes derive. > > > 2) The Animal base class must derive > from the Interface 'IAnimal', it is > the only class that should derive from > IAnimal. > > > 3) Since all animals have a name and a > name is not an attribute that is > sp...
[ 0.07154621183872223, -0.1360461413860321, -0.12554585933685303, 0.13490000367164612, 0.0932292565703392, -0.13099659979343414, 0.09130878001451492, -0.3412016034126282, 0.10184044390916824, -0.7077007293701172, -0.28492021560668945, 0.3643600046634674, -0.3867112696170807, -0.0386104546487...
create a Dog and a > Cat class that will derive only from > the Animal base class. > > > 5) The Dog and Cat classes should > implement the WhatAmI get-property and > return the appropriate string value. Code you can't change: ``` using System; namespace IT274_U2 { public interface IAnimal { st...
[ 0.29768693447113037, -0.18104170262813568, -0.02253502421081066, 0.15855911374092102, -0.005426914896816015, -0.0382128544151783, 0.26081398129463196, -0.5768263936042786, 0.23708824813365936, -0.47231045365333557, -0.2276693433523178, 0.4696315824985504, -0.35724571347236633, 0.1008731499...
public static void DescribeAnimal(IAnimal animal) { Console.WriteLine("My name is {0}, I am a {1}", animal.WhatIsMyName, animal.WhatAmI); } static void Main(string[] args) { Dog mydog = new Dog("Spot"); Cat mycat = new Cat("Felix");
[ 0.31227031350135803, -0.052969153970479965, 0.27902817726135254, -0.31192833185195923, 0.26819562911987305, 0.0040686773136258125, 0.4676470160484314, -0.30097219347953796, 0.22771158814430237, -0.55661940574646, -0.16462424397468567, 0.34403565526008606, -0.8008729219436646, 0.77273947000...
DescribeAnimal(mydog); DescribeAnimal(mycat); } } } ``` /////////////////////// Code I've written so far: ``` using System; namespace IT274_U2 { public interface IAnimal { string WhatAmI { get; } string WhatIsMyName { get; } } public class Dog { ...
[ 0.2606247663497925, -0.14477628469467163, 0.1961696445941925, 0.027268042787909508, 0.04518584907054901, 0.03022954799234867, 0.3178926110267639, -0.3050658106803894, 0.0651654303073883, -0.8220758438110352, -0.09049341082572937, 0.37889549136161804, -0.45810580253601074, 0.243175566196441...
{ get; set; } }//end public class Dog public class Cat { public abstract string WhatIsMyName { get; set; } }//end public class Cat public abstract class Animal :
[ 0.3333071172237396, -0.3058416247367859, -0.31694313883781433, -0.21553345024585724, 0.003741683904081583, 0.261173814535141, 0.31112927198410034, -0.10619837045669556, -0.03305606171488762, -0.42613038420677185, -0.18172457814216614, 0.48369279503822327, -0.7108185887336731, 0.00305068329...
IAnimal { // fields protected string Dog; protected string Cat; // implement WhatIsMyName //properties public abstract String Dog { get; set; } public abstract String Cat { get;
[ 0.11906168609857559, -0.3137412667274475, -0.1274491846561432, -0.20276638865470886, 0.018535951152443886, 0.20519813895225525, 0.2518519163131714, -0.31198224425315857, -0.03721974045038223, -0.3743397295475006, -0.18433132767677307, 0.42135217785835266, -0.8130214214324951, 0.00915976427...
set; } public abstract string WhatIsMyName(); } //end public abstract class Animal public class TesterClass { public static void DescribeAnimal(IAnimal animal) { Console.WriteLine("My name is {0}, I am a {1}", animal.WhatIsMyName, animal.WhatAmI); } sta...
[ 0.5608019828796387, -0.11173981428146362, -0.03934058919548988, -0.15162470936775208, 0.07791493833065033, 0.09822865575551987, 0.46444734930992126, -0.29049843549728394, 0.1862337589263916, -0.27970871329307556, -0.11320241540670395, 0.3292892873287201, -0.44078952074050903, 0.48551887273...
{ Dog mydog = new Dog("Spot"); Cat mycat = new Cat("Felix"); DescribeAnimal(mydog); DescribeAnimal(mycat); } } } ``` **EDIT:** I have taken the body of code for each class out - If you want to see my answer, have a look at the edit revisions :) First off
[ 0.3510286211967468, 0.12618586421012878, 0.6219565272331238, -0.12590934336185455, 0.21322903037071228, -0.0464312881231308, 0.24493440985679626, -0.3643236756324768, 0.11344008892774582, -0.7036120295524597, -0.24515677988529205, 0.25261983275413513, -0.4411468505859375, 0.198944106698036...
we define the [interface](http://msdn.microsoft.com/en-us/library/ms173156.aspx) ``` public interface IAnimal { string WhatAmI { get; } string WhatIsMyName { get; } } ``` Any class that implements this interface must implement these properties. An interface is like a contract; a class implementing an interfa...
[ 0.16176295280456543, -0.23301221430301666, 0.26825985312461853, -0.1265064924955368, -0.11484569311141968, 0.07366137951612473, 0.0284098032861948, -0.15775759518146515, 0.03576154634356499, -0.7396498322486877, 0.017918026074767113, 0.4205242693424225, -0.5973159074783325, 0.2223056554794...
We have implemented both properties of the interface and also have a private field to store the animal name. In addition, we have made the `WhatAmI` property accessor abstract so that we can implement our own specific property accessor logic in each derived class and have also defined a constructor that accepts a strin...
[ 0.3152904212474823, -0.1045403853058815, -0.08691701292991638, 0.13738299906253815, -0.05753130093216896, -0.0063584549352526665, 0.06734062731266022, -0.4270472824573517, 0.16554264724254608, -0.47193533182144165, -0.0894724503159523, 0.7521879076957703, -0.37228548526763916, 0.1598985046...
code } ``` Both classes inherit from `Animal` and each has a constructor that defines a string argument and passes that argument as a parameter to the base constructor. In addition, each class implements it's own property accessor for `WhatAmI`, returning a string of their type, respectively. For the rest of the cod...
[ 0.4916050434112549, 0.15167300403118134, -0.18426474928855896, -0.16133128106594086, 0.021497003734111786, -0.11999743431806564, 0.42099663615226746, -0.28819116950035095, 0.22601568698883057, -0.24865049123764038, -0.040036238729953766, 0.47147202491760254, -0.5458400845527649, 0.53908342...
Dog mydog = new Dog("Spot"); Cat mycat = new Cat("Felix"); DescribeAnimal(mydog); DescribeAnimal(mycat); Console.ReadKey(); } } ``` the static method `DescribeAnimal` accepts an `IAnimal` as an argument and writes out the values returned by the `WhatIsMyName` and `WhatAmI` property...
[ -0.032708507031202316, 0.29494330286979675, 0.4589248597621918, -0.27914267778396606, 0.07727166265249252, 0.14294523000717163, 0.08624996244907379, -0.36046290397644043, 0.32416120171546936, -0.5108727216720581, -0.3105992078781128, 0.2954648733139038, -0.5920354127883911, 0.5714148283004...
method. I hope that I have explained this clearly, If anyone feels my choice of words needs tightening up, please comment and I will be happy to edit my answer.
[ 0.48876675963401794, 0.16769778728485107, 0.13028264045715332, 0.31985729932785034, 0.037435706704854965, 0.03960024565458298, 0.34496596455574036, -0.13550260663032532, -0.03170096501708031, -0.552025318145752, 0.24044997990131378, 0.24406798183918, -0.04061591252684593, 0.021839296445250...
We have some projects that have CPPUnit tests that are build and run using an ant script to build them all (right now we're using Borland C++, but we're moving to VS2008). The problem is that the interface to run and see the result of tests is unpleasant (command prompt). It would be awesome to have them run inside ec...
[ 0.6153900027275085, 0.10058450698852539, -0.05930023267865181, 0.19745631515979767, -0.09113358706235886, -0.09226008504629135, 0.40011221170425415, -0.03579729050397873, -0.010228877887129784, -0.7394302487373352, 0.3504050076007843, 0.4502532482147217, -0.24885913729667664, -0.0923697352...
in Eclipse (for java), but is there something similar for C++ using Eclipse CDT or VS2008? A UI test runner would be usefull too, so I could launch the UI as a Post build action. **EDIT (possible answer):** I found this project: [ECUT](http://sourceforge.net/project/screenshots.php?group_id=236439), however I didn't ...
[ 0.3207448422908783, -0.08101185411214828, 0.25993281602859497, 0.23049534857273102, -0.31926631927490234, -0.1978311836719513, 0.13359434902668, -0.22367823123931885, -0.0010467801475897431, -0.750115156173706, -0.12220034003257751, 0.5451863408088684, -0.19692754745483398, -0.421383708715...
support for CPPUnit.
[ -0.15806278586387634, -0.6049697995185852, 0.22414077818393707, -0.028751539066433907, -0.6469319462776184, 0.08405411243438721, -0.2776136100292206, 0.16382695734500885, -0.13705486059188843, 0.057700615376234055, -0.26584380865097046, 0.05266496539115906, -0.27442190051078796, 0.14016458...
We've been having a problem with a mass mailer component that I wrote for a long time and the exact nature of the difficulty, how to measure it and how to mitigate it have all remained elusive. It's got to the point where these problems are becoming critical and I need some straight answers so I'm hoping someone here ...
[ 0.6059357523918152, 0.28463804721832275, 0.3761805593967438, 0.07487589865922928, 0.07752339541912079, 0.05974603071808815, 0.4402941167354584, 0.22401949763298035, -0.3357672393321991, -0.5456741452217102, 0.14973965287208557, 0.11197066307067871, -0.08368220180273056, 0.08522719144821167...
happy with that loop. What we're not happy with is that if you just leave the program to process after approx 6k emails we get an error that the "Maximum Session Size" has been reached and it's not going to send any more mails. We have no real way of knowing at present which mail it got up to, our only method of thro...
[ 0.5467333197593689, 0.13208816945552826, 0.4946162700653076, 0.052774570882320404, -0.022932499647140503, -0.10093240439891815, 0.7862331867218018, -0.05640174821019173, -0.430155873298645, -0.2255539745092392, 0.022754350677132607, 0.4553678035736084, -0.3521052598953247, -0.0102954655885...
to measure the session size or something to just allow the process to be one button press and for the widget to be self-throttling but no one seems to want to talk about it online. I've had a few suggestions to related queries that suggest completely reworking the widget or even writing a bespoke mass-mailing app. In...
[ 0.47243350744247437, 0.009661039337515831, 0.20840318500995636, 0.2376992553472519, -0.14288868010044098, -0.1414177119731903, 0.409954696893692, 0.0932433009147644, -0.15510471165180206, -0.23073847591876984, 0.21563859283924103, 0.4825044870376587, -0.05796562507748604, 0.066218040883541...
Something. Anything. Does anyone have any down to earth and practical suggestions for tracking .Net 2.0 generated emails out of the originating server? Why is the session growing? Are you doing this within a request's lifetime? I'm assuming you're "tracking" by keeping info about emails sent within the session state...
[ 0.771028995513916, -0.3977030813694, 0.24100883305072784, 0.18574774265289307, 0.08521450310945511, -0.28953590989112854, 0.18103717267513275, 0.05789494886994362, -0.4012356400489807, -0.5380330681800842, 0.19521066546440125, 0.20579318702220917, -0.1551421731710434, -0.033121492713689804...
out one at a time. Blind Carbon Copies are always personally addressed and don't reveal to the recipient that it was mass mailed. You just have to figure out the limit on the number of emails you can send via BCC. Third option is to, in your web app, drop what you need to generate these emails into a common storage lo...
[ 0.46274566650390625, -0.038398489356040955, 0.12950895726680756, 0.03737931698560715, -0.15342025458812714, 0.2824227809906006, 0.15123353898525238, -0.07215531170368195, -0.39681288599967957, -0.4315752685070038, -0.20225797593593597, -0.004449745640158653, -0.412649542093277, -0.11909186...
of thing wouldn't work on shared hosting servers...
[ 0.03395109251141548, 0.13732752203941345, 0.3380790948867798, 0.47140881419181824, 0.23538483679294586, -0.4432085156440735, 0.3015097975730896, 0.240728497505188, 0.20525765419006348, -0.3308478891849518, 0.24886827170848846, 0.1544942706823349, -0.23559881746768951, 0.3963630199432373, ...
I've just found [this interesting presentation](http://www.slideshare.net/stubbornella/object-oriented-css?type=presentation) about the concept of "object oriented CSS". It seems to be a good idea but the presentation is rather short and doesn't give a lot of examples. My questions: * is this concept relevant? * what...
[ 0.1961808055639267, 0.12018995732069016, 0.021388137713074684, 0.278590589761734, -0.3365670442581177, -0.15877647697925568, 0.11233391612768173, 0.2881721258163452, -0.1347990334033966, -0.487056702375412, 0.07101845741271973, 0.36088672280311584, 0.048514146357774734, -0.0612957850098609...
Yes. Is it easy to inherit someone else's OOCSS work? Probably not. What are the benefits of OOCSS? ------------------------------- Abstracting style attributes of a certain component is always good for style consistency over the whole of the site. Say you want to change the border style of the components for a fresh...
[ 0.6449787020683289, -0.012293990701436996, 0.4723639190196991, 0.44105738401412964, 0.09211357682943344, -0.22093766927719116, -0.0988820344209671, -0.10543425381183624, -0.03859913721680641, -0.44072943925857544, 0.05225815623998642, 0.3468533456325531, 0.02628694288432598, 0.015411114320...
widget could also lay out its contents different depending on what parent element it was placed under. This amounted to code like: `<div class="free bg_neutral form_search">` being used for each wrapper / container, with each class being: "Box Style, Background Style, Content" respectively. The developers working on t...
[ 0.37264084815979004, -0.34184834361076355, 0.352638840675354, 0.29057061672210693, -0.3750714361667633, -0.13559335470199585, 0.05106700211763382, -0.11499182134866714, 0.023499347269535065, -0.4275256395339966, 0.10447078198194504, 0.1107596680521965, -0.343929648399353, -0.02202986180782...
every unique incarnation of each 'widget'. It also makes cross-browser fixing much easier, because you can tackle the 'widgets' styles independently. (Most browser bugs are related to box dimensions and position/layout) In my opinion, more UI folks need to go thru a StyleGuide / Style Vocab exercise when designing and...
[ 0.6424099802970886, 0.12269581854343414, 0.18025454878807068, 0.3120604455471039, -0.2619099020957947, -0.11419039219617844, 0.31940728425979614, 0.05934445559978485, -0.25960174202919006, -0.8545846343040466, 0.059510983526706696, 0.38309797644615173, -0.16389109194278717, -0.005135406274...
I am not quite clear if auto\_ptr will help me in this case: ``` class A { A(const B& member) : _member(B) {}; ... const B& _member; }; A generateA() { auto_ptr<B> smart(new B()); A myA(*smart); return myA; } ``` Will the `myA._member` reference be valid when `smart` leaves its enclosing scope? I...
[ 0.18847538530826569, -0.03284722939133644, 0.4415542185306549, -0.07360523194074631, 0.30317363142967224, -0.25991716980934143, 0.3520410358905792, -0.4691062271595001, -0.13378912210464478, -0.22601431608200073, -0.28820937871932983, 0.5724384784698486, -0.4254243075847626, 0.139442831277...
is because `auto_ptr` guarantees destruction at end of scope: no more, and *no less*. There are 2 possible answers. * You can make \_member's type `boost::shared_ptr<const B>`. * Alternatively, if class B is **small**, **copyable**, **monomorphic**, and object identity **doesn't need to be preserved**, you can make \...
[ 0.29958027601242065, 0.11666900664567947, 0.16761724650859833, -0.026050180196762085, 0.03232557326555252, 0.04412619769573212, 0.26450714468955994, -0.18213708698749542, -0.19664974510669708, -0.3953731954097748, -0.3711095154285431, 0.6308882236480713, -0.4664416015148163, 0.229996427893...
local. As described, both `shared_ptr` and value semantics solve this.
[ -0.22219277918338776, -0.21507126092910767, -0.14066658914089203, 0.24039942026138306, -0.20773056149482727, -0.038050632923841476, 0.15721258521080017, 0.42165499925613403, -0.08865060657262802, -0.6027688980102539, -0.16213670372962952, 0.6610209941864014, -0.2622661888599396, 0.13108949...
I have a ComboBox in WPF whose ItemsSource is set to a list programmatically. How would I go about clearing the selection in an event handler? I've tried: ``` comboBox.SelectedIndex = -1; comboBox.SelectedItem = null; comboBox.SelectedValue = null; comboBox.SelectedValue = ""; ``` None of them have any effect. `comb...
[ -0.004385245032608509, -0.43145468831062317, 0.0840742439031601, -0.011792177334427834, -0.0879191979765892, -0.1454250067472458, 0.10750801116228104, -0.4031602442264557, -0.279597669839859, -0.6818656325340271, -0.09127634763717651, 0.4151250123977661, -0.366035521030426, -0.117429204285...
I have a service, say foo, written in C++, that runs as root. There is the usual scrip, /etc/init.d/foo start|stop|restart. At certain times, foo needs to reload itself. Normally after an upgrade has finished. But doing things like: ``` system("/etc/init.d/foo restart") ``` doesn't work since as soon as restart kil...
[ 0.12210256606340408, 0.20540936291217804, 0.09228500723838806, -0.15596075356006622, 0.029832718893885612, 0.15262548625469208, 0.10930770635604858, 0.2488112449645996, -0.005744616501033306, -0.5268288254737854, 0.01546543464064598, 0.5156904458999634, -0.2120550274848938, 0.3470174670219...
in a noncompiled .aspx, is it possible to have 2 partial class files for one aspx? I'm trying to do something like: ``` <%@ Page Language="C#" inherits="_Default" src="Default.aspx.cs" src="Default2.aspx.cs" %> ``` Both Default and Default2 have the partial class defined Upda...
[ 0.009543148800730705, -0.056513216346502304, 0.41637733578681946, -0.012636447325348854, -0.042840514332056046, -0.1275244653224945, 0.4707075357437134, 0.035286180675029755, -0.2977057099342346, -0.9522466063499451, -0.1427980363368988, 0.3491058349609375, -0.27296048402786255, 0.05715300...
because the source needs to be changed regularly. I probably could come up with a way to just update the aspx, but I'd like to not have to do that. The reason I'm using two source files is that there is a lot of source code that connects to my database and whatnot. I have one person that's gonna muck with the db stuff...
[ 0.852255642414093, 0.14891362190246582, 0.03466923534870148, 0.19461378455162048, 0.26030537486076355, -0.1569942831993103, -0.02533547766506672, -0.10995873808860779, -0.3501194715499878, -0.5554493069648743, 0.29272252321243286, 0.7717374563217163, -0.18672603368759155, 0.293806701898574...
as many partial classes as you wish. No, you cannot (nor do you have to!) specify them in your Page directive. ``` <%@ Page Language="C#" inherits="Default" %> ``` in Default.aspx.cs: ``` public partial class Default { /*yadda*/ } ``` in Default2.aspx.cs: ``` public partial class Default { /* e...
[ -0.10522471368312836, 0.13300538063049316, 0.3069591224193573, 0.011216160841286182, -0.15480518341064453, 0.0325017049908638, 0.2964383065700531, -0.003419766901060939, -0.15855522453784943, -0.8083089590072632, -0.31969764828681946, 0.43733692169189453, -0.3551417291164398, 0.11753440648...
your update that what you need is not multiple partial classes but to refactor your code. You should drop the idea of partial classes and go with dependency injection/inversion of control. Separate out your db logic and other areas of concern, define them using interfaces, and then, at runtime, inject the desired imple...
[ 0.45906442403793335, -0.2364906221628189, 0.0950448140501976, 0.004655669443309307, -0.19848260283470154, -0.06097583472728729, 0.010390880517661572, -0.17011524736881256, 0.1195797473192215, -0.8412176966667175, 0.033717185258865356, 0.43472036719322205, -0.5139269828796387, 0.19386871159...
for DI and love it. It took about a day to get up to speed on it.
[ 0.7709401249885559, -0.039100777357816696, 0.14944146573543549, -0.0508863739669323, 0.24141786992549896, 0.2715497314929962, 0.12038610130548477, 0.2974301874637604, 0.28409451246261597, -0.2215431183576584, 0.3927411139011383, 0.33807966113090515, 0.38485315442085266, 0.2817417085170746,...
How do I remove an element from a list **by index**? I found `list.remove()`, but this slowly scans the list for an item **by value**. Use `del` and specify the index of the element you want to delete: ``` >>> a = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] >>> del a[-1] >>> a [0, 1, 2, 3, 4, 5, 6, 7, 8] ``` Also supports slice...
[ -0.011238657869398594, -0.2021152824163437, 0.42525947093963623, -0.24506983160972595, -0.2553473114967346, 0.2142248898744583, -0.1137600764632225, -0.351252943277359, -0.29710572957992554, -0.44927623867988586, -0.420353502035141, 0.43217000365257263, -0.03353690728545189, -0.05135666579...
I doubt this is possible, but I was curious if you could have more than 2 items (key,value) in a dictionary. Maybe a key and 2 values. Is there a collection object that does allow this? What I am actually trying to do is to store a key and a value for the key and another value to hold the count of how many times the ke...
[ 0.588106095790863, -0.031549498438835144, -0.01794407144188881, 0.21444375813007355, 0.21952781081199646, 0.13959035277366638, 0.21851801872253418, -0.10042305290699005, -0.31353136897087097, -0.6302382946014404, 0.31633588671684265, 0.45077943801879883, -0.30139249563217163, 0.23705843091...
only want to store the color, the unique value of the color in a dictionary, but also store how many times red occurred in the list. I put in the following declaration and now I am tyring to figure out how I can test to see if it contains the value already and if it does not, add it to the list with a count of 1 and i...
[ 0.3145643174648285, 0.12436287850141525, 0.3438938856124878, -0.1816127449274063, -0.17327909171581268, 0.19488295912742615, 0.16421177983283997, -0.4425857663154602, -0.06581141799688339, -0.8033319711685181, 0.035475026816129684, 0.7609309554100037, -0.3909648358821869, 0.063031695783138...
new Dictionary<string, Dictionary<int,int>>(); ``` Here is code of how I was handling it before: ``` Dictionary<string, int> colors = new Dictionary<string, int>(); foreach (Color color in ColorList) { if (colors.ContainsKey(color.ToString())) colors[color]++; else
[ -0.22474192082881927, -0.26623886823654175, 0.5644470453262329, -0.48317602276802063, 0.20631706714630127, 0.2176777869462967, 0.20182718336582184, -0.4095253050327301, 0.09151296317577362, -0.9326701164245605, -0.3066428303718567, 0.9658627510070801, -0.3298527002334595, 0.002847428200766...
colors.Add(color, 1); } ``` Could you perhaps have a dictionary of a struct that would keep track of the color and the number of times it occurred? Edit: As suggested elsewhere, this could also be accomplished by building your own small custom class. Would essentially work in the same fashion.
[ 0.45912423729896545, -0.08712730556726456, 0.15431982278823853, 0.08848638087511063, 0.09207253158092499, 0.055379580706357956, -0.039707861840724945, -0.05828119069337845, -0.1475851833820343, -0.8663102388381958, 0.0007789644878357649, 0.7316864132881165, -0.4455101490020752, -0.07253681...
I am writing a little library with some prime number related methods. As I've done the groundwork (aka working methods) and now I'm looking for some optimization. Ofcourse the internet is an excellent place to do so. I've, however, stumbled upon a rounding problem and I was wondering how to solve this. In the loop I ...
[ 0.22851639986038208, 0.1289730966091156, 0.09007666260004044, 0.1774991899728775, 0.018557108938694, 0.3614605963230133, -0.032770637422800064, 0.0024034094531089067, -0.3573416471481323, -0.7181419730186462, 0.1993350386619568, 0.3179878890514374, -0.1319841891527176, 0.1658574938774109, ...
104729, but the 'optimized' version ends up with: 103811. Some code (it's open for more optimization, I know, but I can handle only one thing at a time): ``` /// <summary> /// Method for testing the primality of a number e.g.: return IsPrime(29); /// History: /// 1. Initial version, most basic form of testing: m smal...
[ -0.009036706760525703, -0.0560421496629715, 0.11371959000825882, -0.07300962507724762, -0.20421642065048218, 0.25771909952163696, 0.32289350032806396, -0.6619017720222473, -0.13588744401931763, -0.18292373418807983, -0.31143468618392944, 0.2631123661994934, -0.33166247606277466, 0.02888637...
== 0 || test == 1) return false; // 2 and 3 are prime numbers if (test == 2) return true; // all even numbers, save 2, are not prime if (test % 2 == 0) return false; double squared = Math.Sqrt(test); int flooredAndSquared = Convert.ToInt32(Math.Floor(squared)); // start with 5, make incr...
[ 0.20410379767417908, -0.06302647292613983, 0.42016175389289856, -0.0799819678068161, 0.0006517617730423808, 0.2151392698287964, 0.38571372628211975, -0.6730345487594604, -0.15952996909618378, -0.3973415791988373, -0.04361001402139664, 0.22478406131267548, 0.037159986793994904, 0.1473140865...
if (test % idx == 0) { return false; } } return true; } ``` I know the squared part fails me (or I fail), tried Math.Ceiling as well, with about the same results. Sadly, I haven't tried the algorithmic approaches before. But if you want to implement your approach efficiently, I'd s...
[ 0.25096258521080017, 0.17451412975788116, 0.04302259534597397, -0.028757577762007713, -0.1832251399755478, -0.048898160457611084, 0.26556283235549927, -0.4391756057739258, -0.04972332343459129, -0.5626813173294067, 0.2418418675661087, 0.5908602476119995, 0.010888091288506985, 0.08145561814...
defined threshold, fill this array, and search within/using it. In the following example, finding whether a number is prime is O(1) in the best case (namely, when the number is less than or equal to `maxPrime`, which is 821,461 for a 64K buffer), and is somewhat optimized for other cases (by checking mod over only 64K...
[ 0.023104975000023842, -0.23513396084308624, 0.08926733583211899, -0.1165207028388977, 0.16087251901626587, -0.06866994500160217, 0.22077760100364685, -0.4276197552680969, -0.21603791415691376, -0.681224524974823, -0.045276980847120285, 0.4217967987060547, -0.30131903290748596, -0.045927036...
sizeof(int) == 256 KB private static int[] primes; public static int MaxPrime { get; private set; } public static bool IsPrime(int value) { if (value <= MaxPrime) { return Array.BinarySearch(primes, value) >= 0; } else {
[ 0.04239466041326523, -0.2930092215538025, 0.43142038583755493, -0.2947472929954529, 0.22224025428295135, 0.22470241785049438, 0.3128955364227295, -0.4394032955169678, -0.35312631726264954, -0.18562453985214233, -0.4733230769634247, 0.6374414563179016, -0.4621333181858063, 0.154911190271377...
return IsPrime(value, primes.Length) && IsLargerPrime(value); } } static PrimeChecker() { primes = new int[BufferSize]; primes[0] = 2; for (int i = 1, x = 3; i < primes.Length; x += 2) { if (IsPrime(x, i))
[ -0.37067779898643494, -0.31804579496383667, 0.5454395413398743, -0.45219165086746216, 0.3539719581604004, 0.20928344130516052, 0.17193810641765594, -0.4559515118598938, -0.020655812695622444, -0.273097425699234, -0.40742066502571106, 0.5112403035163879, -0.45866796374320984, 0.078162245452...
primes[i++] = x; } MaxPrime = primes[primes.Length - 1]; } private static bool IsPrime(int value, int primesLength) { for (int i = 0; i < primesLength; ++i) { if (value % primes[i] == 0)
[ -0.22091859579086304, -0.13017641007900238, 0.43430715799331665, -0.3016132116317749, 0.23360110819339752, 0.11252966523170471, 0.3916294574737549, -0.35183224081993103, 0.06418417394161224, -0.14896975457668304, -0.33499574661254883, 0.5891833901405334, -0.5856130123138428, 0.181357711553...
return false; } return true; } private static bool IsLargerPrime(int value) { int max = (int)Math.Sqrt(value); for (int i = MaxPrime + 2; i <= max; i += 2) { if (value % i == 0)
[ -0.10233552753925323, -0.26244252920150757, 0.631458044052124, -0.22630800306797028, -0.03351251408457756, 0.21062161028385162, 0.4477953016757965, -0.294991135597229, -0.018788665533065796, 0.1780100017786026, -0.20770597457885742, 0.6141650080680847, -0.26323437690734863, 0.0131486207246...
return false; } return true; } } ```
[ -0.0903531014919281, 0.3931734561920166, -0.08115869015455246, -0.30087846517562866, 0.15680772066116333, -0.25779011845588684, 0.4968145787715912, 0.18174883723258972, 0.18496637046337128, -0.16093750298023224, -0.512929379940033, 0.8097196817398071, -0.24705399572849274, 0.26583728194236...
I am writing an extension method where I happen to need the field name that the extension method is needed within the extension method. I can not figure out how to do this. My code: -------- --- ### Extension method: ``` public static Validate Demand<T>(this T parameter) { string name = ... var field = GetF...
[ 0.44341403245925903, -0.2281249314546585, 0.5286177396774292, -0.15401333570480347, -0.07934372872114182, 0.06794402003288269, -0.07350857555866241, -0.07891746610403061, -0.03754923492670059, -0.4850119352340698, -0.002721669850870967, 0.7078806757926941, -0.16577772796154022, 0.239463835...
handy, I have this method: ``` internal static void ThrowIfNull<T>(this T argument, string name) where T : class { if (argument == null) { throw new ArgumentNullException(name); } } ``` which I have to call with: ``` foo.ThrowIfNull("foo"); ``` It's better than nothing, but it would be nic...
[ 0.3476978540420532, 0.04016755893826485, 0.3163551092147827, -0.3759399652481079, -0.049493081867694855, -0.052363477647304535, 0.13460922241210938, -0.1553095430135727, 0.023790961131453514, -0.4951487183570862, -0.043636105954647064, 0.9084413647651672, -0.28509706258773804, 0.0181915592...
benefit, I suspect :)
[ 0.24293656647205353, 0.015931613743305206, 0.28202593326568604, 0.03736569732427597, -0.11502432078123093, 0.15732023119926453, -0.4539693593978882, 0.03282371535897255, -0.04104508459568024, -0.37953054904937744, 0.06881628930568695, 0.6242843866348267, 0.19050215184688568, -0.03426243737...
I've got a textbox stacked on top of a ComboBox. The TextBox gets taller (via animation) when it gets focus, and shrinks back down when it loses focus. The problems start when the TextBox loses focus to the ComboBox. When this happens, the selection Popup (the part that "drops down") appears just below the ComboBox, a...
[ 0.43118351697921753, -0.3817198574542999, 0.6269003748893738, -0.06092299148440361, -0.07844721525907516, 0.08319257944822311, -0.16414928436279297, 0.09255343675613403, -0.29004979133605957, -0.6274175643920898, 0.002437794813886285, -0.014636127278208733, -0.08025787770748138, 0.08472278...
tree as the TextBox and ComboBox, so its layout is not recalculated as the animation progresses. How can I keep my ComboBox whole? Below is a snippet you can paste into XamlPad to reproduce this. Any help is much appreciated! ``` <Page xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:sys="clr-...
[ -0.20359894633293152, -0.4388297200202942, 0.5690066814422607, -0.008450028486549854, -0.08248887211084366, 0.19443751871585846, 0.12448840588331223, -0.11076062172651291, -0.667904794216156, -0.38181358575820923, -0.15560826659202576, 0.14146658778190613, -0.05002390593290329, -0.05755496...
<Storyboard TargetProperty="Height"> <DoubleAnimation From="19" To="100" Duration="0:0:0.2"/> </Storyboard> </BeginStoryboard> </EventTrigger.Actions> </EventTrigger> <EventTrigger RoutedEvent="UIElement.LostFocus"> <EventTrigger.Actions> ...
[ 0.20629414916038513, -0.5487263798713684, 0.24508881568908691, 0.08019042015075684, 0.34356242418289185, 0.03595719113945961, 0.2872127294540405, -0.07311702519655228, -0.47455546259880066, -0.40294235944747925, -0.0354766771197319, 0.2901829481124878, 0.2208799570798874, -0.19720356166362...
<Storyboard TargetProperty="Height"> <DoubleAnimation From="100" To="19" Duration="0:0:0.2"/> </Storyboard> </BeginStoryboard> </EventTrigger.Actions> </EventTrigger> </TextBox.Triggers> </TextBox> <ComboBox> <ComboBoxItem>Item 1</ComboBoxI...
[ -0.14666664600372314, -0.6090161204338074, 0.22795931994915009, 0.02971198596060276, 0.017485542222857475, 0.1926913559436798, 0.2275708168745041, -0.45774364471435547, -0.49660539627075195, -0.30256208777427673, -0.0701369121670723, 0.2617649435997009, 0.11909286677837372, -0.284294426441...
<ComboBoxItem>Item 2</ComboBoxItem> </ComboBox> </StackPanel> </Page> ``` This has also been posted as a bug at the Microsoft Connect site: <https://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=422254> You can't. It would be nice in a few cases, particularly for argument checking, b...
[ 0.12721961736679077, -0.08385659009218216, 0.3950081467628479, -0.15919318795204163, -0.19997863471508026, 0.026221400126814842, 0.37325090169906616, -0.1519976556301117, -0.037423036992549896, -0.6904919147491455, 0.06057996302843094, 0.4716701805591583, -0.3413298726081848, 0.22456066310...