text
stringlengths
0
30.5k
title
stringclasses
1 value
embeddings
listlengths
768
768
probably have to delve into some of the topics they mention such as: prediction, compensation, and interpolation.
[ 0.39376428723335266, 0.29053887724876404, -0.1422632783651352, 0.49376827478408813, 0.22671958804130554, 0.05292904004454613, 0.10422563552856445, 0.08163899928331375, -0.09979227185249329, -0.4330986738204956, 0.15366236865520477, 0.37301674485206604, 0.4027121365070343, -0.13602574169635...
Inspired by [Raymond Chen's post](https://devblogs.microsoft.com/oldnewthing/20080902-00/?p=21003), say you have a 4x4 two dimensional array, write a function that rotates it 90 degrees. Raymond links to a solution in pseudo code, but I'd like to see some real world stuff. ``` [1][2][3][4] [5][6][7][8] [9][0][1][2] [3][4][5][6] ``` Becomes: ``` [3][9][5][1] [4][0][6][2] [5][1][7][3] [6][2][8][4] ``` **Update**: Nick's answer is the most straightforward, but is there a way to do it better than n^2? What if the matrix was 10000x10000? Here it is in C# ```csharp int[,] array = new int[4,4] { { 1,2,3,4 }, { 5,6,7,8 }, { 9,0,1,2 }, { 3,4,5,6 } }; int[,] rotated = RotateMatrix(array, 4); static int[,] RotateMatrix(int[,]
[ 0.14975158870220184, 0.16322988271713257, 0.3485366106033325, 0.1062844842672348, -0.071245476603508, 0.2591973543167114, 0.22307755053043365, -0.3334188461303711, -0.35024529695510864, -0.3477238118648529, -0.06360870599746704, 0.27556270360946655, -0.3376302719116211, 0.02185571566224098...
matrix, int n) { int[,] ret = new int[n, n]; for (int i = 0; i < n; ++i) { for (int j = 0; j < n; ++j) { ret[i, j] = matrix[n - j - 1, i]; } } return ret; } ```
[ 0.1294422149658203, -0.053489696234464645, 0.6520863175392151, -0.538044810295105, 0.131001278758049, 0.31353846192359924, 0.6234111785888672, -0.8695545792579651, -0.22368688881397247, -0.23856835067272186, -0.7138311862945557, 0.7614814639091492, -0.5247492790222168, 0.22068952023983002,...
I once worked with an architect who banned the use of SQL views. His main reason was that views made it too easy for a thoughtless coder to needlessly involve joined tables which, if that coder tried harder, could be avoided altogether. Implicitly he was encouraging code reuse via copy-and-paste instead of encapsulation in views. The database had nearly 600 tables and was highly normalised, so most of the useful SQL was necessarily verbose. Several years later I can see at least one bad outcome from the ban - we have many hundreds of dense, lengthy stored procs that verge on unmaintainable. In
[ 0.3677728772163391, 0.44188958406448364, 0.0701836422085762, 0.21407614648342133, -0.15289027988910675, 0.1099768802523613, 0.17756862938404083, 0.08469578623771667, -0.14591285586357117, -0.38652682304382324, 0.1892964243888855, 0.4040178656578064, -0.2686271369457245, 0.3242364823818207,...
hindsight I would say it was a bad decision, but what are your experiences with SQL views? Have you found them bad for performance? Any other thoughts on when they are or are not appropriate? There are some very good uses for views; I have used them a lot for tuning and for exposing less normalized sets of information, or for UNION-ing results from multiple selects into a single result set. Obviously any programming tool can be used incorrectly, but I can't think of any times in my experience where a poorly tuned view has caused any kind of drawbacks from a
[ 0.29115280508995056, 0.19958281517028809, -0.05140431970357895, 0.2314593344926834, -0.20698554813861847, 0.13150787353515625, 0.11606982350349426, 0.26744699478149414, 0.03893740102648735, -0.5325408577919006, 0.6311265826225281, 0.6982945799827576, -0.02463928423821926, 0.019320320338010...
performance standpoint, and the value they can provide by providing explicitly tuned selects and avoiding duplication of complex SQL code can be significant. Incidentally, I have never been a fan of architectural "rules" that are based on keeping developers from hurting themselves. These rules often have unintended side-effects -- the last place I worked didn't allow using NULLs in the database, because developers might forget to check for null. This ended up forcing us to work around "1/1/1900" dates and integers defaulted to "0" in all the software built against the databases, and introducing a litany of bugs caused by devs
[ 0.3443402945995331, 0.5476637482643127, -0.12216611951589584, 0.14623191952705383, -0.0013960478827357292, -0.18182985484600067, 0.5760526061058044, 0.012171031907200813, -0.021014980971813202, -0.5069296360015869, 0.2085786908864975, 0.43848636746406555, -0.04381667822599411, 0.2364506423...
working around places where NULL was the appropriate value.
[ 0.17801879346370697, 0.055374544113874435, -0.8766018152236938, 0.40632033348083496, -0.42341578006744385, -0.11722840368747711, 0.09132608771324158, -0.013107015751302242, -0.15543057024478912, -0.13182063400745392, 0.03265048563480377, 0.2819853127002716, -0.41545411944389343, -0.3355310...
I am looking to write some C# code for linux/windows/mac/any other platform, and am looking for best practices for portable code. Project [mono](http://go-mono.org) has some great [porting](http://www.mono-project.com/Category:Porting) resources. What are the best practices for portable C#? I've actually used winforms and it was fine. It was BUTT UGLY, but it worked. Obviously, don't use P/Invoke, or any win32 stuff like the registry. Also be aware of any third party DLL's. For example, we use a third party SQLite dll which actually contains native code in it which we have to swap out if we want to run on OSX/linux.
[ 0.5874776840209961, 0.295284628868103, -0.10117082297801971, 0.07331205159425735, -0.23525261878967285, -0.2882465124130249, 0.10607403516769409, 0.23096047341823578, -0.08796367049217224, -0.5174517035484314, 0.15785829722881317, 0.692649245262146, -0.20934002101421356, 0.1188403367996215...
I'd like to create a script that will configure the Visual Studio IDE the way I like it. Nothing vastly complicated, just a few Tools/Options settings, adding some External Tools, that kind of thing. I know that this can be done inside VS with Import/Export Settings, but I'd like to be able to automate it from outside of VS. Is this possible, and if so, how? --- Edited to add: doing it from *outside* of VS is important to me -- I'm hoping to use this as part of a more general "configure this newly-Ghosted PC just the way I like it"
[ 0.8231372237205505, -0.04963814467191696, 0.14056184887886047, -0.012048245407640934, -0.03582547605037689, -0.186519593000412, 0.02880222722887993, 0.23434118926525116, -0.09499439597129822, -0.7315634489059448, -0.011698774062097073, 0.8590409159660339, -0.2805776596069336, -0.0178782790...
script. --- Edited again: the solution seems to be to hack CurrentSettings.vssettings, or use [AutoIt](http://www.autoitscript.com/). Details below. Answering my own question, in two ways: 1. In VS2005/8, the things I mentioned (Tools/Options, External Tools) are all stored in the CurrentSettings.vssettings file, in the folder "Visual Studio 200{5|8}\Settings". This file is just XML, and it can be edited programmatically by anything that knows how to parse XML. You can also just paste a new vssettings file over the top of the default one (at least, this works for me). 2. The larger question of configuring a virgin PC. It turns out that not everything I want
[ 0.10519400238990784, -0.14987270534038544, 0.43746504187583923, 0.050869643688201904, 0.057590555399656296, 0.0038524388801306486, 0.20691291987895966, 0.09710594266653061, -0.20068837702274323, -0.6694819331169128, 0.260905385017395, 0.6341235041618347, -0.09041403979063034, -0.1552522927...
to change has an API, so I need some way of pretending to be a user who is actually sitting there clicking on things. The best approach to this seems to be [AutoIt](http://www.autoitscript.com/), whose scripting language I will now have to learn in my Copious Free Time.
[ 0.4405473470687866, -0.1473659723997116, 0.4673570692539215, -0.15091252326965332, 0.261574923992157, 0.1652713567018509, 0.11615291982889175, 0.4012563228607178, -0.2798059284687042, -0.7108240127563477, 0.09631438553333282, 0.6127406358718872, -0.5250334143638611, -0.14983876049518585, ...
I'd like to take some time to learn more about dynamic languages built on top of the DLR and I'm not sure which language would be better to learn. Having limited time, I really only have time to look learn one of them. Any opinions on which of the two (Iron Ruby or Iron Python) would be more useful in the long run? If this is 'Which language runs better on the CLR,' then right now, IronPython wins hands down. For the long term though, 'which language will teach me more, and serve me better in my career as a programmer', I would definitely
[ 0.10503183305263519, 0.29837003350257874, 0.0904606357216835, 0.09397926181554794, -0.04170401394367218, 0.16806095838546753, 0.1540766954421997, 0.4317941963672638, -0.2526167929172516, -0.4382448196411133, 0.0015153486747294664, 0.7492711544036865, 0.059016983956098557, 0.027453804388642...
say IronRuby (this would be true of CPython vs CRuby also) Ruby will expose you to more 'concepts' than python does, due to it being more liberal in how it handles things like lambda functions, code blocks, eval, and so on. Anyway, this is probably going to descend into a flame-war. Sorry
[ 0.34825608134269714, 0.26427072286605835, -0.05654504522681236, 0.11880297213792801, -0.47666963934898376, -0.3272436559200287, 0.48820745944976807, 0.2484830766916275, -0.19401371479034424, -0.33814099431037903, 0.023216787725687027, 0.7788991928100586, -0.15618444979190826, 0.04139495640...
What's the best way to get user input in a C program where the choices are of a limited number? Say for example the choices are: A) Print the list. B) Add 99 to the end of the list. C) Delete all duplicates. 5) Reset 5 times. Entering "A" and then Enter is OK. Or, just a single keystroke would work as well. `getchar()`, or `cgetc()`, depending on the platform
[ 0.30679577589035034, -0.05813830718398094, 0.31963658332824707, 0.20839601755142212, 0.28828513622283936, 0.132279172539711, 0.14385324716567993, -0.12543508410453796, -0.41435298323631287, -0.1596456915140152, -0.29169145226478577, 0.6648409962654114, -0.1827857345342636, -0.0618623197078...
I am using sp\_send\_dbmail in SQL2005 to send an email with the results in an attachment. When the attachment is sent it is UCS-2 Encoded, I want it to be ANSI or UTF-8. Here is the SQL ``` EXEC msdb.dbo.sp_send_dbmail @recipients = 'temp@example.com' , @query = 'DECLARE @string_to_trim varchar(60);SET @string_to_trim = ''1234''; select rtrim(@string_to_trim), ''tom''' , @query_result_header=0 , @subject = 'see attach' , @body= 'temp body' , @profile_name= N'wksql01tAdmin' , @body_format = 'HTML' ,@query_result_separator = ','
[ 0.3372357189655304, 0.0717046707868576, 0.8717167377471924, -0.22443079948425293, -0.13799628615379333, 0.05545451119542122, 0.12279408425092697, -0.6392530202865601, -0.1408434808254242, -0.685630738735199, -0.14838050305843353, 0.4384635388851166, -0.3117065727710724, 0.05092036724090576...
,@query_attachment_filename = 'results.csv' ,@query_no_truncate = '0' ,@attach_query_result_as_file = 1 ``` I have seen some comments on the internet that this is fixed with sql2005 SP2, but do not find it to be the case. I think the only way to get around what you are seeing is to use BCP to dump the data to a flat file and then attach that file. Sorry I couldn't be more help. :(
[ 0.29603180289268494, 0.41008850932121277, 0.6498668193817139, 0.07086823880672455, -0.023254625499248505, -0.39701077342033386, -0.05568598583340645, -0.12832655012607574, -0.4165158271789551, -0.5144184827804565, -0.18053288757801056, 0.46396589279174805, -0.39635443687438965, 0.373891055...
I'm using `Ctrl`+`Left` / `Ctrl`+`Right` in a GreaseMonkey script as a hotkey to turn back / forward pages. It seems to works fine, but I want to disable this behavior if I'm in a text edit area. I'm trying to use document.activeElement to get the page active element and test if it's an editable area, but it always returns "undefined". document.activeElement works for me in FF3 but the following also works ``` (function() { var myActiveElement; document.onkeypress = function(event) { if ((myActiveElement || document.activeElement || {}).tagName != 'INPUT') // do your magic }; if (!document.activeElement) {
[ 0.10345159471035004, 0.00629136897623539, 0.8860976696014404, -0.34275493025779724, 0.255351185798645, -0.032229334115982056, 0.4770090579986572, -0.4111041724681854, -0.21287901699543, -0.584877073764801, 0.05451788753271103, 0.7792673707008362, -0.24060754477977753, -0.24746155738830566,...
var elements = document.getElementsByTagName('input'); for(var i=0; i<elements.length; i++) { elements[i].addEventListener('focus',function() { myActiveElement = this; },false); elements[i].addEventListener('blur',function() { myActiveElement = null; },false); } } })(); ```
[ 0.1250307559967041, -0.23900608718395233, 0.8614665269851685, -0.3444848358631134, 0.3224097192287445, 0.20672279596328735, 0.38099589943885803, -0.5041688084602356, -0.07717671990394592, -0.5035758018493652, -0.4025700092315674, 0.5563507080078125, -0.4134669601917267, -0.0511528104543685...
Is [CPAN DBI](http://cpan.uwinnipeg.ca/dist/DBI) the best database interface to use in Perl for general database use? Are there some better options? If you're just looking for low-level database access—you feed it any SQL string (optionally with place-holders and bind values) and it runs your query and gives you back the results—then yes, [DBI](http://search.cpan.org/dist/DBI/) is your best bet, by far. If you want a higher-level interface (i.e., one that requires little or no use of raw SQL in your code) then there are several ORMs ([object-relational mappers](http://en.wikipedia.org/wiki/Object-relational_mapping)) available for Perl. Check out the [ORM](http://www.perlfoundation.org/perl5/index.cgi?orm) page at the Perl Foundation's Perl 5 wiki for more
[ 0.30908718705177307, 0.09643904864788055, 0.19693611562252045, 0.12814070284366608, -0.17488698661327362, 0.11912579089403152, -0.09431150555610657, 0.017313621938228607, -0.16625182330608368, -0.20277805626392365, 0.05843846872448921, 0.2626422941684723, -0.11227328330278397, 0.0268083605...
information and links. (If you want help choosing among them or have specific questions, you could narrow the focus of this question or perhaps post another one.)
[ 0.48962345719337463, -0.03534334897994995, 0.25279882550239563, 0.6922931671142578, 0.08221393823623657, -0.342923641204834, -0.06619393080472946, 0.469501793384552, -0.4122154116630554, -0.7458312511444092, -0.22038628160953522, 0.05123453959822655, 0.15642768144607544, -0.041705250740051...
I will elaborate somewhat. Jsf is kind-of extremely painful for working with from designer's perspective, somewhat in the range of trying to draw a picture while having hands tied at your back, but it is good for chewing up forms and listing lots of data. So sites we are making in my company are jsf admin pages and jsp user pages. Problem occurs when user pages have some complicated forms and stuff and jsf starts kickin' in. Here is the question: I'm on pure jsp page. I need to access some jsf page that uses session bean. How can I
[ 0.8576183915138245, 0.3006862699985504, 0.07900926470756531, 0.11981992423534393, -0.38883647322654724, -0.4863441586494446, 0.10687436908483505, 0.18473725020885468, -0.005384229589253664, -0.47203201055526733, 0.1263483464717865, 0.47242072224617004, -0.27099162340164185, 0.1741234064102...
initialize that bean? If I was on jsf page, I could have some commandLink which would prepare data. Only thing I can come up with is having dummy jsf page that will do the work and redirect me to needed jsf page, but that's kind of ugly, and I don't want to end up with 50 dummy pages. I would rather find some mechanism to reinitialize bean that is already in session with some wanted parameters. Edit: some more details. In this specific situation, I have a tests that are either full or filtered. It's a same test with same logic
[ 0.1991794854402542, -0.1641228199005127, -0.15853512287139893, 0.19035840034484863, -0.46226558089256287, -0.016092276200652122, 0.09592054784297943, -0.07771765440702438, -0.009426266886293888, -0.6498996615409851, 0.4557270109653473, -0.022662002593278885, -0.35988372564315796, 0.0017195...
and everything, except if test is filtered, it should eliminate some questions depending on answers. Upon a clicking a link, it should start a requested test in one of the two modes. Links are parts of main menu-tree and are visible on many sibling jsp pages. My task is to have 4 links: testA full, testA filtered, testB full, testB filtered, that all lead on same jsf page and TestFormBean should be reinitialized accordingly. Edit: I've researched facelets a bit, and while it won't help me now, I'll definitely keep that in mind for next project. To solve this one I'd probably
[ 0.3908134400844574, -0.1712501496076584, 0.3542022109031677, 0.2425413280725479, -0.3791046142578125, -0.05602118745446205, 0.48941561579704285, -0.1726488322019577, 0.06764980405569077, -0.6033041477203369, -0.10832256823778152, 0.2957569360733032, -0.005552952643483877, -0.13868191838264...
create a JSF fragment that only includes your form, then use a `<c:import>` tag to include it in my JSF page. That solution is probably a little fragile depending on your environment though. EDIT: See Chris Hall's answer, `FacesContext` is not available outside the `FacesServlet`.
[ 0.17274457216262817, 0.1697770208120346, 0.2019079625606537, 0.012380946427583694, -0.15728774666786194, -0.30527299642562866, 0.32169049978256226, -0.029560383409261703, -0.30581921339035034, -0.4082266688346863, -0.4487769901752472, 0.11817195266485214, -0.397012323141098, -0.19709561765...
In the web-application I'm developing I currently use a naive solution when connecting to the database: ``` Connection c = DriverManager.getConnection("url", "username", "password"); ``` This is pretty unsafe. If an attacker gains access to the sourcecode he also gains access to the database itself. How can my web-application connect to the database without storing the database-password in plaintext in the sourcecode? You can store the connection string in Web.config or App.config file and encrypt the section that holds it. Here's a very good article I used in a previous project to encrypt the connection string: <http://www.ondotnet.com/pub/a/dotnet/2005/02/15/encryptingconnstring.html>
[ -0.05867096781730652, 0.460147500038147, 0.10667304694652557, 0.040239155292510986, -0.0969357043504715, -0.01900048553943634, 0.42725861072540283, -0.049104370176792145, -0.10712353140115738, -0.7914701700210571, 0.06064774841070175, 0.7306230664253235, -0.557344377040863, 0.2070418745279...
Why does the following code not work as I was expecting? ``` <?php $data = array( array('Area1', null, null), array(null, 'Section1', null), array(null, null, 'Location1'), array('Area2', null, null), array(null, 'Section2', null), array(null, null, 'Location2') ); $root = array(); foreach ($data as $row) { if ($row[0]) { $area = array(); $root[$row[0]] =& $area; } elseif ($row[1]) { $section = array();
[ -0.010935993865132332, 0.19298416376113892, 0.5031994581222534, -0.15745681524276733, -0.06127438321709633, 0.32975760102272034, 0.5316369533538818, -0.5522708296775818, -0.08510014414787292, -0.0436742790043354, -0.06101374700665474, 0.16693858802318573, -0.3436526358127594, 0.29405254125...
$area[$row[1]] =& $section; } elseif ($row[2]) { $section[] = $row[2]; } } print_r($root); ``` Expected result: ``` Array( [Area1] => Array( [Section1] => Array( [0] => Location1
[ -0.032500460743904114, 0.008240103721618652, 0.5463557839393616, -0.36460554599761963, 0.3561718463897705, 0.02989579550921917, 0.08516102284193039, -0.6103479862213135, -0.2791292369365692, -0.256815105676651, -0.3972059488296509, 0.2992749810218811, -0.28073883056640625, 0.18255719542503...
) ) [Area2] => Array( [Section2] => Array(
[ 0.0505497083067894, -0.11923886090517044, 0.2713136672973633, -0.4400102496147156, 0.27787113189697266, -0.096720390021801, 0.4006304442882538, -0.6550500988960266, -0.29598718881607056, -0.09877327084541321, -0.4546114504337311, 0.22484634816646576, -0.43591606616973877, -0.01540742442011...
[0] => Location2 ) ) ) ``` Actual result: ``` Array( [Area1] => Array( [Section2] => Array(
[ -0.2408178746700287, -0.131683811545372, 0.5188523530960083, -0.20047584176063538, 0.3321201205253601, -0.16119800508022308, 0.2154763638973236, -0.50666743516922, 0.0045822178944945335, -0.3611854016780853, -0.5665503740310669, 0.2585025131702423, -0.20089085400104523, 0.08427710831165314...
[0] => Location2 ) ) [Area2] => Array( [Section2] => Array(
[ -0.013985888101160526, -0.19631639122962952, 0.26331692934036255, -0.34798356890678406, 0.3981201946735382, -0.0945451557636261, 0.30184322595596313, -0.3874700367450714, -0.09842826426029205, -0.24594126641750336, -0.4604113698005676, 0.05329696089029312, -0.2707211971282959, 0.1661487370...
[0] => Location2 ) ) ) ``` If you modify your code on two lines as follows: ``` $area = array(); $section = array(); ``` to this: ``` unset($area); $area = array(); unset($section); $section = array(); ``` it will work as expected. In the first version, `$area` and `$section` are
[ 0.06853394955396652, -0.18761380016803741, 0.5736479163169861, -0.3928067982196808, 0.2132125347852707, -0.07330045104026794, 0.26770323514938354, -0.3656820058822632, -0.11273371428251266, -0.411807656288147, -0.42269304394721985, 0.2103482186794281, -0.5065805315971375, 0.200351968407630...
acting as "pointers" to the value inside the `$root` array. If you reset the values first, those variables can then be used to create brand new arrays instead of overwriting the previous arrays.
[ 0.47788235545158386, -0.14821462333202362, 0.10187776386737823, 0.057523127645254135, 0.22915220260620117, 0.05601215735077858, 0.3403870165348053, 0.04971969500184059, -0.20295965671539307, -0.3705953061580658, 0.012697642669081688, 0.7258561849594116, -0.13334150612354279, 0.359849840402...
Is there a way using Python's standard library to easily determine (i.e. one function call) the last day of a given month? If the standard library doesn't support that, does the dateutil package support this? [`calendar.monthrange`](https://docs.python.org/library/calendar.html#calendar.monthrange) provides this information: > calendar.**monthrange**(year, month) > >     Returns weekday of first day of the month and number of days in month, for the specified *year* and *month*. ``` >>> import calendar >>> calendar.monthrange(2002, 1) (1, 31) >>> calendar.monthrange(2008, 2) # leap years are handled correctly (4, 29) >>> calendar.monthrange(2100, 2) # years divisible by 100 but not 400 aren't leap years (0, 28) ``` so: ``` calendar.monthrange(year, month)[1] ``` seems like the simplest way to go.
[ -0.04302534833550453, -0.049335137009620667, 0.5089990496635437, -0.041982684284448624, 0.024989597499370575, 0.20747873187065125, 0.08872499316930771, -0.21267224848270416, -0.4204599857330322, -0.1303969770669937, -0.055783092975616455, 0.2295343428850174, 0.09861128777265549, -0.1246146...
I am looking for a regex that will match a string that starts with one substring and does not end with a certain substring. Example: ``` // Updated to be correct, thanks @Apocalisp ^foo.*(?<!bar)$ ``` Should match anything that starts with "foo" and doesn't end with "bar". I know about the [^...] syntax, but I can't find anything that will do that for a string instead of single characters. I am specifically trying to do this for Java's regex, but I've run into this before so answers for other regex engines would be great too. Thanks to @Kibbee for verifying that this works in C# as
[ 0.2619493901729584, 0.1001073569059372, 0.10157603025436401, -0.16710264980793, -0.10073256492614746, -0.031163835898041725, 0.3016679286956787, 0.17221461236476898, -0.047097787261009216, -0.7802351713180542, -0.005346383899450302, 0.6172594428062439, -0.490885853767395, -0.16268743574619...
well. I think in this case you want **negative lookbehind**, like so: ``` foo.*(?<!bar) ```
[ 0.6749803423881531, 0.6553428173065186, 0.10092706233263016, -0.5130171179771423, -0.11531956493854523, 0.0684964507818222, 0.02970557101070881, 0.34812480211257935, -0.12517142295837402, -0.19717860221862793, -0.12590259313583374, 0.7050254344940186, -0.49492594599723816, 0.00119334028568...
Starting a new project and would like to use one of the MVC framworks. [ASP.NET MVC](http://www.asp.net/mvc/) is still in preview but [Spring.net](http://springframework.net/) is in production and has a history with Java. I'd like to know the general lowdown between the two. Current questions.. What are the major feature differences? What about deployment/hosting issues? Future support? Do you think Spring.net will fade once ASP.NET MVC is in production. Current Support? I saw the Jeff twitting about a breaking change in the next preview. Thanks! I am a little confused by the question. Spring.Net is a dependency injection framework that
[ 0.27449285984039307, -0.22620722651481628, 0.18763945996761322, -0.1052180677652359, -0.22680796682834625, 0.013130640611052513, 0.024837052449584007, 0.17602095007896423, -0.4717700183391571, -0.5278795957565308, -0.04441899061203003, 0.2305649071931839, 0.03288782015442848, -0.0575488656...
you can use in ASP.NET MVC. I kind of based my answer off what you are actually asking though. The difference between ASP.NET MVC and another MVC framework that runs in ASP.NET. If you are worried about using ASP.NET MVC in production since it is not even in beta yet, then you may want to check out [MonoRail](http://www.castleproject.org/MonoRail/) as an alternate. There are some differences in features, but the two are pretty close in terminology and how MVC is implemented. To learn differences, [here is a question](https://stackoverflow.com/questions/24165/from-monorail-to-aspnet-mvc) that was posted, that you might want to monitor. I think once ASP.NET hits
[ 0.35233911871910095, -0.5021047592163086, 0.3312438130378723, 0.06238837167620659, -0.08304385840892792, -0.0776389092206955, 0.27665749192237854, -0.18993793427944183, -0.294726699590683, -0.5154838562011719, 0.02334841713309288, 0.2933192551136017, -0.34262508153915405, 0.218475773930549...
release, that most Microsoft shops will switch to it. With ASP.NET MVC still being developed, you will run into breaking changes that you will have to change when you upgrade to the next release. That goes with the territory of living on the edge. You just need to read the release notes before jumping to the latest release.
[ 0.3274593651294708, -0.325044721364975, 0.4815925061702728, 0.26519426703453064, -0.10750289261341095, -0.23075395822525024, 0.12193849682807922, 0.06573254615068436, -0.25926417112350464, -0.5366562008857727, -0.004995160736143589, 0.31737908720970154, -0.13131730258464813, 0.071299694478...
I'm working with the SerialPort class in the Compact Framework, but I can't recive more than 2047 bytes. Exists any limit for the amount of bytes that I can recive? or How can I setup the object? I was trying with the WriteBufferSize and ReadBufferSize properties but they didn't work. My guess is that it is either a processor or platform limitation. [This post](http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=22421&SiteID=1) from the MSDN forums seems to confirm my suspicions.
[ 0.28271013498306274, -0.021199773997068405, 0.14255276322364807, 0.10316300392150879, 0.07191862165927887, -0.1772463321685791, 0.3761132061481476, 0.16126491129398346, -0.41580063104629517, -0.6610086560249329, 0.06671998649835587, 0.105558380484581, -0.13303495943546295, 0.09239709377288...
I have upgraded a MS Visual Studio Application from VS 2003 to VS 2008 (Targeting .NET 2.0). As part of the conversion process the wizard said I needed to take the additional step of Converting my Project to a Website by Right-Clicking and blah blah blah... I didn't follow directions and the web application seems to be working fine. My question is, should I be concerned about pushing this to a production system? What exactly is going on here? There are two types of web applications in ASP.NET: The Web Site and Web Application Project. The difference between the two are discussed here: [Difference
[ 0.3113611042499542, -0.2156704068183899, 0.5076209902763367, -0.2112409621477127, -0.5478305816650391, 0.13872148096561432, 0.19957701861858368, -0.18343769013881683, -0.2666465938091278, -0.7473978400230408, 0.15886889398097992, 0.859104573726654, -0.07102824002504349, -0.1195932179689407...
between web site and web applications in Visual Studio 2005](http://www.dotnetspider.com/resources/1520-Difference-between-web-site-web-application.aspx) Convert to Website allows you to convert a Web Application Project to a Web Site. Visual Studio 2003 used the Web Application Project style, but initially VS2005 only supported web sites. VS2005 SP1 brought back Web Applications. If you don't want to convert your project to a web site, apply SP1 if you're using VS2005. VS2008 can support either.
[ 0.24824261665344238, -0.23468847572803497, 0.680594801902771, -0.11858298629522324, -0.3300890326499939, 0.17154479026794434, 0.09390778094530106, -0.3046301007270813, -0.4077317416667938, -0.7366006374359131, 0.14403045177459717, 0.5379751920700073, -0.26592835783958435, -0.23013418912887...
I'm looking for a simple algorithm to generate a large number of random, aesthetically pleasing colors. So no crazy neon colors, colors reminiscent of feces, etc. I've found solutions to this problem but they rely on alternative color palettes than RGB. I would rather just use straight RGB than mapping back and forth. These other solutions also can at most generate only 32 or so pleasing random colors. Any ideas would be great. You could average the RGB values of random colors with those of a constant color: *(example in Java)* ``` public Color generateRandomColor(Color mix) { Random random = new Random();
[ 0.5338117480278015, -0.13211733102798462, -0.1123412474989891, -0.004200261551886797, -0.03208435699343681, 0.011830955743789673, -0.04839727282524109, -0.21999870240688324, -0.10594378411769867, -0.8311249613761902, 0.09027698636054993, 0.6746940016746521, -0.553979754447937, 0.2148082107...
int red = random.nextInt(256); int green = random.nextInt(256); int blue = random.nextInt(256); // mix the color if (mix != null) { red = (red + mix.getRed()) / 2; green = (green + mix.getGreen()) / 2; blue = (blue + mix.getBlue()) / 2; } Color color = new Color(red, green, blue); return color; } ``` Mixing random colors with
[ 0.3779164254665375, -0.25467830896377563, 0.21999233961105347, -0.13548211753368378, 0.1360924392938614, 0.05115733668208122, 0.32216230034828186, -0.7504098415374756, -0.14256739616394043, -0.44995445013046265, -0.42755594849586487, 0.6019755601882935, -0.6727405190467834, 0.2144378721714...
white (255, 255, 255) creates neutral pastels by increasing the lightness while keeping the hue of the original color. These randomly generated pastels usually go well together, especially in large numbers. Here are some pastel colors generated using the above method: ![First](https://i.stack.imgur.com/8jKGx.jpg) You could also mix the random color with a constant pastel, which results in a tinted set of neutral colors. For example, using a light blue creates colors like these: ![Second](https://i.stack.imgur.com/zI406.jpg) Going further, you could add heuristics to your generator that take into account complementary colors or levels of shading, but it all depends on the impression you want to achieve with your
[ 0.37303924560546875, -0.05469803512096405, -0.1379294991493225, -0.014510326087474823, -0.23853735625743866, 0.18939515948295593, 0.0037641290109604597, -0.17463122308254242, -0.24053166806697845, -0.5960848927497864, 0.06665034592151642, 0.3324343264102936, -0.4137910306453705, 0.03448944...
random colors. Some additional resources: * <http://en.wikipedia.org/wiki/Color_theory> * <http://en.wikipedia.org/wiki/Complementary_color>
[ 0.3988208770751953, -0.5575907230377197, -0.2765982747077942, 0.22428388893604279, -0.003957479260861874, -0.026366690173745155, -0.18930283188819885, -0.1473388373851776, -0.2779045104980469, -0.5206166505813599, -0.010594900697469711, 0.33202221989631653, -0.46546605229377747, 0.25479418...
I have the following C# code: ``` byte rule = 0; ... rule = rule | 0x80; ``` which produces the error: > *Cannot implicitly convert type 'int' to 'byte'. An explicit conversion exists (are you missing a cast?)* [Update: first version of the question was wrong ... I misread the compiler output] Adding the cast **doesn't** fix the problem: ``` rule = rule | (byte) 0x80; ``` I need to write it as: ``` rule |= 0x80; ``` Which just seems weird. Why is the `|=` operator any different to the `|` operator? Is there any other way of telling the compiler to treat the constant as a byte? --- **@ Giovanni Galbo** : yes and no. The
[ 0.11444822698831558, 0.3063167333602905, 0.2715267241001129, -0.21937642991542816, -0.029912002384662628, 0.12502595782279968, 0.24867811799049377, -0.217526376247406, -0.278497576713562, -0.21078723669052124, 0.022088592872023582, 0.6438758969306946, -0.44940492510795593, 0.09179525077342...
code is dealing with the programming of the flash memory in an external device, and logically represents a single byte of memory. I could cast it later, but this seemed more obvious. I guess my C heritage is showing through too much! **@ Jonathon Holland** : the 'as' syntax looks neater but unfortunately doesn't appear to work ... it produces: > *The as operator must be used with a reference type or nullable type ('byte' is a non-nullable value type)* ``` int rule = 0; rule |= 0x80; ``` <http://msdn.microsoft.com/en-us/library/kxszd0kx.aspx> The | operator is defined for all value types. I think this will produced the intended result.
[ 0.2602449655532837, 0.2967066466808319, 0.11309143900871277, -0.1655702143907547, -0.08330889791250229, 0.2400519698858261, 0.43703553080558777, -0.23778566718101501, -0.09621714055538177, -0.5663506388664246, -0.3882177174091339, 0.43363264203071594, -0.2768757939338684, -0.05510912463068...
The "|=" operator is an or then assign operator, which is simply shorthand for rule = rule | 0x80. One of the niftier things about C# is that it lets you do crazy things like abuse value types simply based on their size. An 'int' is exactly the same as a byte, except the compiler will throw warnings if you try and use them as both at the same time. Simply sticking with one (in this case, int) works well. If you're concerned about 64bit readiness, you can specify int32, but all ints are int32s, even running in x64 mode.
[ 0.18805404007434845, -0.1253843754529953, -0.0570228211581707, -0.15695181488990784, -0.24591101706027985, -0.4094928503036499, 0.35102662444114685, -0.1898541897535324, -0.20690615475177765, -0.01854568161070347, -0.2644251585006714, 0.5958667993545532, -0.5483468770980835, -0.21346902847...
What is the best way to multi-thread in the C language? I want something that is very efficient and not a CPU hog. Thanks. The correct (standard) way to do this on C and Windows is with [\_\_beginthreadex](http://msdn.microsoft.com/en-us/library/kdzttdcb.aspx). This is usually preferred to calling [CreateThread](http://msdn.microsoft.com/en-us/library/kdzttdcb.aspx) directly as CreateThread doesn't init C runtime support for the thread. So if you create a thread using CreateThread, and call a CRT function, bad stuff can/will happen. Note that \_\_beginthreadex calls CreateThread internally, but performs some other work behind the scenes.
[ 0.4082281291484833, 0.08886251598596573, 0.1802029311656952, -0.05653635784983635, -0.04198819771409035, -0.266633003950119, 0.1443186104297638, -0.04612497240304947, -0.36345356702804565, -0.6599195003509521, -0.09007123112678528, 0.6151764988899231, -0.4030025005340576, 0.313592940568923...
Simple question, but one that I've been curious about...is there a functional difference between the following two commands? ``` String::class String.class ``` They both do what I expect -- that is to say they return `Class` -- but what is the difference between using the `::` and the `.`? I notice that on those classes that have constants defined, IRB's auto-completion will return the constants as available options when you press tab after `::` but not after `.`, but I don't know what the reason for this is... The `.` operator basically says "send this message to the object". In your example it is calling that particular
[ -0.19449298083782196, -0.42923620343208313, 0.08504609018564224, -0.08916227519512177, -0.35059428215026855, 0.06865125149488449, 0.28390878438949585, 0.11367140710353851, -0.1464816927909851, -0.4525958001613617, -0.11355400830507278, 0.7681336998939514, -0.5533528923988342, 0.30613431334...
member. The `::` operator "drills down" to the scope defined to the left of the operator, and then calls the member defined on the right side of operator. When you use `::` you have to be referencing members that are defined. When using `.` you are simply sending a message to the object. Because that message could be anything, auto-completion does not work for `.` while it does for `::`.
[ -0.2126382440328598, 0.010429549030959606, 0.162389874458313, -0.006996030453592539, -0.03707848861813545, -0.2068912535905838, 0.3660205006599426, -0.3816187381744385, -0.18922489881515503, -0.27104657888412476, -0.1363307535648346, 0.2842195928096771, -0.6048402786254883, 0.1863532662391...
I was surprised to find today that I couldn't track down any simple way to write the contents of an `InputStream` to an `OutputStream` in Java. Obviously, the byte buffer code isn't difficult to write, but I suspect I'm just missing something which would make my life easier (and the code clearer). So, given an `InputStream` `in` and an `OutputStream` `out`, is there a simpler way to write the following? ``` byte[] buffer = new byte[1024]; int len = in.read(buffer); while (len != -1) { out.write(buffer, 0, len); len = in.read(buffer); } ``` Java 9 ====== Since Java 9, `InputStream` provides a method called
[ -0.3122779130935669, 0.0879935547709465, 0.08725406974554062, -0.2983248233795166, -0.20466436445713043, 0.16937971115112305, 0.2226819396018982, -0.0414760559797287, -0.35653743147850037, -0.48364871740341187, 0.0008235420100390911, 0.41119804978370667, -0.5361056923866272, -0.03528274223...
`transferTo` with the following signature: ``` public long transferTo(OutputStream out) throws IOException ``` As the [documentation](https://docs.oracle.com/javase/9/docs/api/java/io/InputStream.html#transferTo-java.io.OutputStream-) states, `transferTo` will: > Reads all bytes from this input stream and writes the bytes to the > given output stream in the order that they are read. On return, this > input stream will be at end of stream. This method does not close > either stream. > > > This method may block indefinitely reading from the > input stream, or writing to the output stream. The behavior for the > case where the input and/or output stream is asynchronously closed, or > the thread interrupted during
[ -0.24215714633464813, -0.12205002456903458, 0.5112727284431458, -0.12151328474283218, 0.07804381847381592, -0.15802012383937836, 0.011238880455493927, 0.06935760378837585, -0.06127956509590149, -0.6010172367095947, -0.43120479583740234, 0.4636201560497284, -0.6146050095558167, 0.2988385260...
the transfer, is highly input and output > stream specific, and therefore not specified So in order to write contents of a Java `InputStream` to an `OutputStream`, you can write: ``` input.transferTo(output); ```
[ -0.2311173379421234, -0.09659773111343384, 0.15344510972499847, 0.06524257361888885, 0.1400580257177353, 0.015543951652944088, -0.011855144053697586, 0.07015212625265121, 0.022956138476729393, -0.6934810280799866, -0.22164620459079742, 0.29071590304374695, -0.43892401456832886, 0.261649042...
The login page in my Tapestry application has a property in which the password the user types in is stored, which is then compared against the value from the database. If the user enters a password with multi-byte characters, such as: ``` áéíóú ``` ...an inspection of the return value of getPassword() (the abstract method for the corresponding property) gives: ``` áéíóú ``` Clearly, that's not encoded properly. Yet Firebug reports that the page is served up in UTF-8, so presumably the form submission request would also be encoded in UTF-8. Inspecting the value as it comes from the database produces the correct string, so it wouldn't appear
[ 0.33883190155029297, 0.13856269419193268, 0.5546056628227234, -0.012848551385104656, 0.17424510419368744, -0.0912141501903534, 0.45208895206451416, -0.04066687449812889, -0.057597193866968155, -0.8320622444152832, -0.31589654088020325, 0.5311688184738159, -0.1404179036617279, -0.0403838604...
to be an OS or IDE encoding issue. I have not overridden Tapestry's default value for org.apache.tapestry.output-encoding in the .application file, and the Tapestry 4 [documentation](http://tapestry.apache.org/tapestry4/UsersGuide/configuration.html#configuration.properties) indicates that the default value for the property is UTF-8. So why does Tapestry appear to botch the encoding when setting the property? Relevant code follows: Login.html ---------- ```html <html jwcid="@Shell" doctype='html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"' ...> <body jwcid="@Body"> ... <form jwcid="@Form" listener="listener:attemptLogin" ...> ...
[ 0.29389968514442444, 0.16986966133117676, 0.5189697742462158, -0.3185350000858307, -0.004049024078994989, -0.19534865021705627, 0.31458067893981934, -0.47675222158432007, -0.2731321454048157, -0.754410982131958, -0.31741827726364136, 0.6032823324203491, -0.0478646345436573, 0.1723023951053...
<input jwcid="password"/> ... </form> ... </body> </html> ``` Login.page ---------- ```jsp <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE page-specification PUBLIC "-//Apache Software Foundation//Tapestry Specification 4.0//EN" "http://jakarta.apache.org/tapestry/dtd/Tapestry_4_0.dtd"> <page-specification class="mycode.Login"> ... <property name="password" /> ... <component id="password" type="TextField"> <binding name="value" value="password"/> <binding name="hidden" value="true"/>
[ 0.08795928955078125, 0.1784278005361557, 0.45111462473869324, -0.22626855969429016, -0.16016170382499695, -0.1868322193622589, 0.10749310255050659, -0.5692979693412781, -0.26471492648124695, -0.6099522113800049, -0.2929375171661377, 0.45755746960639954, -0.17320744693279266, -0.08630943298...
... </component> ... </page-specification> ``` Login.java ---------- ``` ... public abstract class Login extends BasePage { ... public abstract String getPassword(); ... public void attemptLogin() { // At this point, inspecting getPassword() returns // the incorrectly encoded String. } ... } ``` Updates ------- @Jan Soltis: Well, if I inspect the value that comes from the database, it displays the correct string, so it would seem that my editor,
[ -0.04976406320929527, 0.15814079344272614, 0.2576999366283417, -0.031477659940719604, 0.18940287828445435, -0.0015713074244558811, 0.5025562047958374, -0.4865576922893524, -0.18618598580360413, -0.7403677701950073, -0.3241700232028961, 0.4504380524158478, -0.5589038133621216, -0.1138998568...
OS and database are all encoding the value correctly. I've also checked my .application file; it does not contain an org.apache.tapestry.output-encoding entry, and the Tapestry 4 [documentation](http://tapestry.apache.org/tapestry4/UsersGuide/configuration.html#configuration.properties) indicates that the default value for this property is UTF-8. I have updated the description above to reflect the answers to your questions. @myself: Solution found. VPC to Hyper-V is one way.
[ -0.07793625444173813, -0.03077269159257412, 0.5962085127830505, 0.12989948689937592, 0.24906502664089203, -0.04244821518659592, 0.33278992772102356, 0.05307893455028534, -0.48679119348526, -0.8559088706970215, -0.2857111096382141, 0.5023062825202942, -0.2915954887866974, 0.3214487433433532...
I'm working on a C#/ASP.NET project that has all the javascript files in a /Javascript folder. If I refer to the JS file using this syntax: src="/Javascript/jsfile.js" then the file is correctly picked up if the project is deployed to the root of the URL. However, if this "web site" is deployed to a sub-folder of the main url this won't work. So the solution could be to use relative urls - but there's a problem with that as well because the master pages reference many of the javascript files and these master pages can be used by pages in the
[ 0.5400190949440002, 0.2703987658023834, 0.10959145426750183, -0.0651659220457077, -0.1799832433462143, -0.24197198450565338, 0.0589110441505909, 0.05983930453658104, -0.23758873343467712, -0.5821024775505066, 0.003400776768103242, 0.16532884538173676, -0.07102081924676895, 0.18847748637199...
root and in subfolders many levels deep. Does anybody have any ideas for resolving this? If you reference the JS-file in a section that is "runat=server" you could write src="~/Javascript/jsfile.js" and it will always work. You could also do this in your Page\_Load (In your masterpage): ``` Page.ClientScript.RegisterClientScriptInclude("myJsFile", Page.ResolveClientUrl("~/Javascript/jsfile.js")) ```
[ -0.23652960360050201, -0.04289677366614342, 0.32349929213523865, 0.014254868030548096, 0.13253119587898254, -0.033169180154800415, 0.5640091896057129, -0.0197849553078413, -0.36752015352249146, -0.8984199166297913, 0.13607235252857208, 0.3779403567314148, -0.1525460183620453, 0.15461298823...
In Django's template language, you can use `{% url [viewname] [args] %}` to generate a URL to a specific view with parameters. How can you programatically do the same in Python code? What I need is to create a list of menu items where each item has name, URL, and an active flag (whether it's the current page or not). This is because it will be a lot cleaner to do this in Python than the template language. If you need to use something similar to the `{% url %}` template tag in your code, Django provides the `django.core.urlresolvers.reverse()`. The `reverse` function
[ 0.1448916643857956, 0.4189605116844177, 0.23582616448402405, -0.318805456161499, -0.391949862241745, -0.03239557147026062, -0.009651154279708862, -0.06032771244645119, 0.011007007211446762, -0.34448379278182983, 0.4358040392398834, 0.446397602558136, -0.5782922506332397, 0.2116839140653610...
has the following signature: ``` reverse(viewname, urlconf=None, args=None, kwargs=None) ``` <https://docs.djangoproject.com/en/dev/ref/urlresolvers/> At the time of this edit the import is `django.urls import reverse`
[ -0.24163326621055603, 0.5988907217979431, 0.35976606607437134, -0.5732452869415283, -0.3872900605201721, 0.1538989245891571, 0.1060963049530983, 0.1603829264640808, -0.2654132544994354, -0.007360280491411686, -0.0790647640824318, 0.33592021465301514, -0.2780406177043915, 0.431596040725708,...
I know that I can do something like ``` $int = (int)99; //(int) has a maximum or 99 ``` To set the variable `$int` to an integer and give it a value of `99`. Is there a way to set the type to something like `LongBlob` in MySQL for `LARGE` Integers in PHP? No. PHP does what is called automatic type conversion. In your example ``` $int = (int)123; ``` the "(int)" just assures that at that exact moment 123 will be handled as an int. I think your best bet would be to use a class to provide some sort of type safety.
[ 0.3415384590625763, 0.1662987470626831, 0.15862025320529938, -0.05871828272938728, -0.18325254321098328, -0.23572379350662231, 0.1238185465335846, -0.23325452208518982, -0.14518393576145172, -0.1199912279844284, 0.1987338662147522, 0.5639112591743469, -0.30561313033103943, 0.01172558311372...
Plug-in systems in C++ are hard because the ABI is not properly defined, and each compiler (or version thereof) follows its own rules. However, COM on Windows shows that it's possible to create a minimal plug-in system that allows programmers with different compilers to create plug-ins for a host application using a simple interface. Let's be practical, and leave the C++ standard, which is not very helpful in this respect, aside for a minute. If I want to write an app for Windows and Mac (and optionally Linux) that supports C++ plug-ins, and if I want to give plug-in authors a
[ 0.10190596431493759, 0.2479015439748764, 0.032452650368213654, 0.0040290467441082, 0.022624287754297256, -0.1829414814710617, -0.08855954557657242, 0.0513528473675251, -0.01975429058074951, -0.5860595107078552, -0.3241916596889496, 0.870948076248169, -0.37159544229507446, -0.35308286547660...
reasonably large choice of compilers (say less than 2 year old versions of Visual C++, GCC or Intel's C++ compiler), what features of C++ could I count on? Of course, I assume that plug-ins would be written for a specific platform. Off the top of my head, here are some C++ features I can think of, with what I think is the answer: * vtable layout, to use objects through abstract classes? (yes) * built-in types, pointers? (yes) * structs, unions? (yes) * exceptions? (no) * extern "C" functions? (yes) * stdcall non-extern "C" functions with built-in parameter types? (yes) * non-stdcall non-extern "C" functions with user-defined parameter types?
[ -0.1759483516216278, 0.019223984330892563, -0.07754571735858917, 0.19530853629112244, -0.30942532420158386, 0.2035677582025528, 0.07659687846899033, -0.12758347392082214, -0.257375031709671, -0.46370041370391846, -0.08740402013063431, 0.6961745023727417, -0.1992519199848175, -0.35124531388...
(no) I would appreciate any experience you have in that area that you could share. If you know of any moderately successful app that has a C++ plug-in system, that's cool too. Carl Dr Dobb's Journal has an article [Building Your Own Plugin Framework: Part 1](http://www.ddj.com/cpp/204202899?cid=RSSfeed_DDJ_Cpp) which is pretty good reading on the subject. It is the start of a series of articles which covers the architecture, development, and deployment of a C/C++ cross-platform plugin framework.
[ 0.36817336082458496, 0.15027034282684326, 0.13555695116519928, 0.15730218589305878, -0.14134147763252258, -0.25388169288635254, 0.06947876513004303, 0.021066706627607346, -0.5749379992485046, -0.5047608613967896, -0.19158829748630524, 0.3428293466567993, -0.25384682416915894, -0.0808283835...
I'm using the Yahoo Uploader, part of the Yahoo UI Library, on my ASP.Net website to allow users to upload files. For those unfamiliar, the uploader works by using a Flash applet to give me more control over the FileOpen dialog. I can specify a filter for file types, allow multiple files to be selected, etc. It's great, but it has the following documented limitation: > Because of a known Flash bug, the Uploader running in Firefox in Windows does not send the correct cookies with the upload; instead of sending Firefox cookies, it sends Internet Explorer’s cookies for the respective
[ 0.11567249894142151, 0.1509726494550705, 0.4555003046989441, -0.11732051521539688, -0.1835000067949295, -0.31585919857025146, 0.19859018921852112, -0.05686168745160103, -0.11594752222299576, -0.7192603349685669, -0.08860687911510468, 0.6645078659057617, -0.4946911334991455, -0.037962969392...
domain. As a workaround, we suggest either using a cookieless upload method or appending document.cookie to the upload request. So, if a user is using Firefox, I can't rely on cookies to persist their session when they upload a file. I need their session because I need to know who they are! As a workaround, I'm using the Application object thusly: ``` Guid UploadID = Guid.NewGuid(); Application.Add(Guid.ToString(), User); ``` So, I'm creating a unique ID and using it as a key to store the `Page.User` object in the Application scope. I include that ID as a variable in the POST when the file is uploaded. Then,
[ 0.3143087923526764, 0.10397832095623016, 0.844439685344696, -0.005340252071619034, 0.008038775995373726, -0.31418436765670776, 0.1744350790977478, -0.22759877145290375, -0.20539158582687378, -0.8089190125465393, -0.040532130748033524, 0.6521120071411133, -0.5206521153450012, 0.421919077634...
in the handler that accepts the file upload, I grab the User object thusly: ``` IPrincipal User = (IPrincipal)Application[Request.Form["uploadid"]]; ``` This actually works, but it has two glaring drawbacks: * If IIS, the app pool, or even just the application is restarted between the time the user visits the upload page, and actually uploads a file, their "uploadid" is deleted from application scope and the upload fails because I can't authenticate them. * If I ever scale to a web farm (possibly even a web garden) scenario, this will completely break. I might not be worried, except I do plan on scaling this app in
[ -0.10539435595273972, 0.14451384544372559, 0.484009325504303, -0.057559382170438766, -0.15356118977069855, 0.15964803099632263, 0.31685352325439453, -0.46502187848091125, -0.37315934896469116, -0.7761837840080261, 0.08518993854522705, 0.4812741279602051, -0.529287576675415, -0.032300837337...
the future. Does anyone have a better way? Is there a way for me to pass the actual ASP.Net session ID in a POST variable, then use that ID at the other end to retrieve the session? I know I can get the session ID through `Session.SessionID`, and I know how to use YUI to post it to the next page. What I don't know is how to use that `SessionID` to grab the session from the state server. Yes, I'm using a state server to store the sessions, so they persist application/IIS restarts, and will work in a web farm scenario. [Here](http://swfupload.org/forum/generaldiscussion/98) is
[ 0.3473857343196869, -0.5161327719688416, 0.3984532356262207, 0.24110902845859528, 0.4315156936645508, -0.045967284590005875, 0.051223643124103546, 0.18162241578102112, -0.23416727781295776, -0.9825643301010132, -0.07339008897542953, 0.5076285600662231, -0.04995906352996826, 0.0611036345362...
a post from the maintainer of [SWFUpload](http://swfupload.org) which explains how to load the session from an ID stored in Request.Form. I imagine the same thing would work for the Yahoo component. Note the security disclaimers at the bottom of the post. --- > By including a Global.asax file and the following code you can override the missing Session ID cookie: ``` using System; using System.Web; public class Global_asax : System.Web.HttpApplication { private void Application_BeginRequest(object sender, EventArgs e) { /* Fix for the Flash Player Cookie bug in
[ -0.06298915296792984, 0.07645033299922943, 0.07098271697759628, 0.0900317132472992, -0.12073614448308945, -0.31208622455596924, 0.42240893840789795, 0.2223060131072998, -0.3083081841468811, -0.7496401071548462, -0.20869986712932587, 0.5985735058784485, -0.3606405556201935, 0.22173984348773...
Non-IE browsers. Since Flash Player always sends the IE cookies even in FireFox we have to bypass the cookies by sending the values as part of the POST or GET and overwrite the cookies with the passed in values. The theory is that at this point (BeginRequest) the cookies have not been ready by the Session and Authentication logic and if we update the cookies
[ 0.07319103181362152, 0.08841314911842346, 0.3880249559879303, -0.12922175228595734, -0.07465393096208572, -0.5928980112075806, 0.5728257298469543, 0.06988552212715149, 0.21370524168014526, -0.9017131924629211, -0.27776414155960083, 0.5128944516181946, -0.4199824333190918, -0.01787889376282...
here we'll get our Session and Authentication restored correctly */ HttpRequest request = HttpContext.Current.Request; try { string sessionParamName = "ASPSESSID"; string sessionCookieName = "ASP.NET_SESSIONID"; string sessionValue = request.Form[sessionParamName] ?? request.QueryString[sessionParamName];
[ -0.09666462242603302, -0.23851211369037628, 0.7630698680877686, -0.027521148324012756, 0.08280324935913086, -0.0587288998067379, 0.7743462324142456, -0.42576247453689575, -0.09395704418420792, -0.5226761102676392, -0.22502122819423676, 0.6963818073272705, 0.033120688050985336, 0.0581831000...
if (sessionValue != null) { UpdateCookie(sessionCookieName, sessionValue); } } catch (Exception ex) { // TODO: Add logging here.
[ 0.04928777739405632, -0.3269374966621399, 0.20883159339427948, -0.09040747582912445, 0.35993292927742004, -0.28723084926605225, 0.7732433080673218, -0.1368607133626938, -0.31924840807914734, -0.18459083139896393, -0.20258578658103943, 0.7529844641685486, -0.28696611523628235, 0.07230102270...
} try { string authParamName = "AUTHID"; string authCookieName = FormsAuthentication.FormsCookieName; string authValue = request.Form[authParamName] ?? request.QueryString[authParamName]; if (authValue != null) {
[ -0.19374044239521027, -0.11293138563632965, 0.29166415333747864, -0.29028162360191345, 0.2964671850204468, 0.2655991315841675, 0.6973717212677002, -0.23376482725143433, 0.33657392859458923, -0.5860176086425781, -0.4527948200702667, 0.5364399552345276, -0.27485254406929016, 0.07160335034132...
UpdateCookie(authCookieName, authValue); } } catch (Exception ex) { // TODO: Add logging here. } } private void UpdateCookie(string cookieName, string cookieValue) { HttpCookie cookie =
[ 0.008349678479135036, -0.3310832977294922, 0.2056044191122055, 0.02925572358071804, 0.1614445000886917, -0.23488056659698486, 0.46781468391418457, 0.07268145680427551, -0.023297982290387154, -0.6610930562019348, -0.12131597101688385, 0.7908273339271545, -0.38852012157440186, 0.057291701436...
HttpContext.Current.Request.Cookies.Get(cookieName); if (cookie == null) { HttpCookie newCookie = new HttpCookie(cookieName, cookieValue); Response.Cookies.Add(newCookie); } else { cookie.Value = cookieValue; HttpContext.Current.Request.Cookies.Set(cookie);
[ -0.259231835603714, -0.3497578501701355, 0.7500355839729309, -0.17700625956058502, -0.07909131795167923, 0.005628097802400589, 0.5641091465950012, -0.27189958095550537, -0.2262519747018814, -0.9367846250534058, -0.5333937406539917, 0.5899630188941956, -0.29124927520751953, 0.21230472624301...
} } } ``` > **Security Warning:** Don't just copy and paste this code in to your ASP.Net application without knowing what you are doing. It introduces security issues and possibilities of Cross-site Scripting.
[ 0.4840686321258545, 0.21273602545261383, -0.11472713202238083, -0.006579381879419088, 0.29622018337249756, -0.5432140231132507, 0.6509507298469543, 0.4158921241760254, 0.008485843427479267, -0.6175437569618225, -0.3601399064064026, 0.40073975920677185, -0.3242289423942566, 0.18231472373008...
When it comes to web-design, I am horrible at producing anything remotely good looking. Thankfully there are a lot of free [sources](http://www.mantisatemplates.com/web-templates.php) for [design](http://www.freecsstemplates.org/) [templates](http://www.oswd.org/). However, a problem with these designs is that they just cover a single page, and not many use cases. If you take a look at [CSS Zen Gardens](http://www.csszengarden.com/), they have 1 single HTML file, and can radically style it differently by just changing the CSS file. Now I am wondering if there is a standard HTML layout (tags and ids), that covers alot of use cases, and can be generically themed with different CSS files like
[ 0.6748325228691101, 0.17903725802898407, 0.033557768911123276, 0.005656912922859192, -0.09091833233833313, -0.27110525965690613, 0.2613472640514374, 0.005967207718640566, -0.4378657937049866, -0.6115609407424927, -0.07585081458091736, -0.046935439109802246, 0.0032694325782358646, 0.1496250...
Zen Garden. What I am imagining is a set of rules off how you write your html, and what boxes, lists, menus and styles you are supposed to use. A set of standard test pages covering the various uses can be created, and a new CSS file while have to support all the different pages in a nice view. Is there any projects that covers anything similar to what I am describing? I've used [Bluprint CSS](http://www.blueprintcss.org/), it's easy and useful as you'll see. It also has some ruby scripts that allow you to change the number of columns and the distance between
[ 0.936251699924469, -0.05452718213200569, -0.07479720562696457, -0.09805779159069061, 0.23089410364627838, -0.3111036419868469, -0.02630646526813507, -0.16344092786312103, -0.012584957294166088, -0.35288897156715393, 0.3033338785171509, 0.23121976852416992, -0.12720605731010437, -0.16690292...
them. By default it's 950px for a span-24 element.
[ 0.2247641384601593, -0.042092930525541306, 0.7006391286849976, 0.11050305515527725, -0.10393407195806503, 0.3071112036705017, 0.2683860957622528, 0.027515500783920288, -0.3132607638835907, -0.5999836921691895, -0.22315749526023865, 0.7548556923866272, -0.027499020099639893, -0.293695479631...
For example, I issued an ALTER TABLE statement to create an index on a MEDIUMTEXT field in an InnoDB table that has 134k rows where the size of the index was 255 bytes and the average size of the data in the field is 30k. This command has been running for the last 15 minutes or so (and is the only thing running on the database). Is there any way for me to determine if it is going to finish in closer to 5 minutes, 5 hours, or 5 days? This is a pretty common request apparently - requested as far
[ 0.21035896241664886, -0.022871466353535652, 0.6853634119033813, 0.2091323286294937, 0.03857387229800224, 0.022581664845347404, 0.2830973267555237, -0.026287930086255074, -0.3846122622489929, -0.4705405533313751, 0.019230324774980545, 0.17227666079998016, 0.007966744713485241, 0.24736146628...
back as 2005 on [bugs.mysql.com](http://bugs.mysql.com). It exists in Oracle already, and is listed as useful, but ["it is not a simple thing to do, so don't expect it to be implemented soon."](http://bugs.mysql.com/bug.php?id=3926). Although that was 2005 :) That said, the chap who asked the original question later released a [patch](http://jcole.us/blog/archives/2007/02/08/progress-in-mysql-process-list/) for MySQL 5.0, backported to 4.1, which might help you out.
[ 0.2758289873600006, 0.03771494701504707, 0.22057324647903442, -0.007883557118475437, 0.16707676649093628, -0.11637866497039795, 0.2267673760652542, -0.008185969665646553, -0.3697676956653595, -0.3385868966579437, 0.01710720919072628, 0.30134317278862, -0.047196611762046814, 0.0396279953420...
In the business I work for we are discussion methods to reduce the read load on our primary database. One option that has been suggested is to have live one-way replication from our primary database to a slave database. Applications would then read from the slave database and write directly to the primary database. So... * Application Reads From Slave * Application Writes to Primary * Primary Updates Slave Automatically What are the major pros and cons for this method? A few cons: * 2 points of failure * Application logic will have to take into account the delay between writing something and then reading it, since it
[ 0.7073729634284973, 0.2890513837337494, 0.40183568000793457, -0.03858371451497078, 0.06995232403278351, 0.09334548562765121, 0.3770638108253479, -0.1596733182668686, -0.20945706963539124, -0.46954289078712463, 0.17805102467536926, 0.6662111282348633, -0.31677255034446716, 0.282264471054077...
won't be available immediately from the secondary database A strategy I have used is to send key reporting data to a secondary database nightly, de-normalizing it on the way, so that beefy queries can run on that database instead of locking up tables and stealing resources from the OLTP server. I'm not using any formal data warehousing or replication tools, rather I identify problem queries that are Ok without up-to-the-minute data and create data structures on the secondary server specifically for those queries. There are definitely pros to the "replicate everything" approach: * You can run any ad-hoc query on the secondary, since
[ 0.5842527747154236, -0.08251173049211502, 0.3275251090526581, 0.2837277352809906, -0.03987130522727966, -0.3208197057247162, 0.4806404411792755, 0.3093211054801941, -0.1112482026219368, -0.6219311356544495, -0.11000843346118927, 0.38403719663619995, -0.17305250465869904, 0.3873840272426605...
it has all of your data * If your primary server dies, you can re-purpose the secondary quickly to take over
[ 0.1726302057504654, -0.0737612247467041, 0.5186414122581482, 0.5047920942306519, 0.06385023891925812, -0.2824286222457886, 0.201835036277771, 0.4159437119960785, -0.2422216534614563, -0.6544069051742554, -0.23185791075229645, -0.11696305125951767, -0.11384747922420502, 0.6320849657058716, ...
I have seen simple example Ajax source codes in many online tutorials. What I want to know is whether using the source code in the examples are perfectly alright or not? Is there anything more to be added to the code that goes into a real world application? What all steps are to be taken to make the application more robust and secure? Here is a sample source code I got from the web: ``` function getChats() { xmlHttp=GetXmlHttpObject(); if (xmlHttp==null) { return; }
[ 0.6249029040336609, 0.10207956284284592, -0.04264950752258301, -0.02643229067325592, -0.12753093242645264, -0.2832737863063812, 0.5565745234489441, -0.22359605133533478, -0.16416525840759277, -0.5453153252601624, 0.04153359681367874, 0.6278331279754639, -0.24105708301067352, -0.38223084807...
var url="getchat.php?latest="+latest; xmlHttp.onreadystatechange=stateChanged; xmlHttp.open("GET",url,true); xmlHttp.send(null); } function GetXmlHttpObject() { var xmlHttp=null; try { xmlHttp=new XMLHttpRequest(); } catch (e) { try { xmlHttp=new ActiveXObject("Msxml2.XMLHTTP"); } catch
[ -0.16989879310131073, -0.42276719212532043, 0.7937455177307129, -0.07541999965906143, -0.0638386607170105, 0.11100267618894577, 0.27508124709129333, -0.32858341932296753, -0.21428707242012024, -0.4871138036251068, -0.4792293310165405, 0.375169575214386, -0.43703731894493103, 0.107799090445...
(e) { xmlHttp=new ActiveXObject("Microsoft.XMLHTTP"); } } return xmlHttp; } ``` The code you posted is missing one important ingredient: the function stateChanged. If you don't quite understand the code you posted yourself, then what happens is when the call to getchats.php is complete, a function "stateChanged" is called and that function will be responsible for handling the response. Since the script you're calling and the function itself is
[ 0.13894042372703552, -0.14087064564228058, 0.448716402053833, 0.099355049431324, -0.104804627597332, -0.24277611076831818, 0.22382938861846924, -0.042663056403398514, -0.18275059759616852, -0.5597554445266724, -0.24161386489868164, 0.5695280432701111, -0.3870926797389984, -0.04571773111820...
prefixed with "gets" then I'm pretty sure the response is something you're going to be interested in. That aside, there are a number of ways to improve on the code you posted. I'd guess it works by declaring a single "xmlHttp" object and then making that available to every function (because if it doesn't, the stateChanged function has no way of getting the response). This is fine until you run an AJAX request before the last one (or last few) haven't replied yet, which in that case the object reference is overwritten to the latest request each time. Also, any AJAX
[ 0.3298039436340332, -0.21962718665599823, 0.531864583492279, 0.4813566505908966, -0.4652976095676422, -0.23186682164669037, 0.13690629601478577, 0.1867951899766922, -0.3377370238304138, -0.5680694580078125, -0.26794004440307617, 0.30706971883773804, -0.009724012576043606, 0.081586226820945...
code worth its salt provides functionality for sucess and failure (server errors, page not found, etc.) cases so that the appriopiate message can be delivered to the user. If you just want to use AJAX functionality on your website then I'd point you in the direction of [jQuery](http://www.jquery.com) or a [similar](http://www.prototypejs.org) [framework](http://www.mootools.net). BUT if you actually want to understand the technology and what is happening behind the scenes, I'd continue doing what you're doing and asking specific questions as you try to build a small lightweight AJAX class on your own. This is how I done it, and although I use the
[ 0.5640242099761963, 0.1897127330303192, -0.06445096433162689, 0.023225020617246628, -0.12431663274765015, -0.12398622930049896, 0.34823906421661377, 0.013396458700299263, 0.10851877182722092, -0.5056928992271423, 0.37761324644088745, 0.5198550820350647, 0.09679921716451645, -0.099339067935...
jQuery framework today.. I'm still glad I know how it works behind the scenes.
[ 0.4493526220321655, -0.004954095464199781, 0.39609295129776, 0.09463611990213394, -0.4805332124233246, -0.25755658745765686, 0.11518294364213943, 0.5285325050354004, -0.1599908322095871, -0.6160346269607544, 0.10308989137411118, 0.693827211856842, 0.49110648036003113, -0.2750062346458435, ...
Older versions of the .Net Framework used to install "Microsoft .NET Framework v1.0 / v1.1 / v2.0 Configuration" in the Control Panel, under Administrative Tools. I just noticed that there isn't a v3.0 or v3.5 version of this. Is this functionality now hiding somewhere else, or do I have to use the command-line tools instead? The .NET Framework versions 3.0 and 3.5 have been built incrementally on the .NET Framework version 2.0. This version can be used to manage code access security policy for the .NET Framework 3.0, 3.5, and later versions as well.
[ 0.2764724791049957, 0.051102038472890854, 0.21645022928714752, -0.13109512627124786, -0.16572530567646027, -0.3002398908138275, 0.25043579936027527, -0.27661821246147156, 0.03616589307785034, -0.7191142439842224, -0.12154676765203476, 0.5661309957504272, -0.3802550733089447, 0.053456332534...
For some strange, bizarre reason, my images in my website just will not display on webkit based languages (such as safari and chrome). This is the image tag ``` <img src="images/dukkah.jpg" class="imgleft"/> ``` Not only does it not display in the website, it wont display when accessed directly at `http://kilkin.massiveatom.com/kilkin/images/dukkah.jpg` ...Why? Imagemagick reports that this particular image is saved in CMYK colorspace instead of the more standard RGB. Try converting it, it should be more compatible with the webkit rendering engine. Imagemagick is available for download from [<http://www.imagemagick.org/script/index.php>](http://www.imagemagick.org/script/index.php) - it's available for windows and \*NIX systems.
[ 0.3198899030685425, 0.034814536571502686, 0.4561083912849426, -0.04782900586724281, -0.48012134432792664, -0.273652046918869, 0.2809028625488281, 0.2600453495979309, -0.13575507700443268, -0.7941725254058838, -0.13163433969020844, 0.4501717686653137, -0.33051973581314087, 0.346174776554107...
I'm trying to the the flv Flash player [from here](http://www.jeroenwijering.com/?item=JW_FLV_Player) in a windows forms application. I currently have it playing 1 .flv file with no problems but I really need to be able to play multiple files. Has anyone had experienace of using the playlists that this control offers or is there a better way to do this? Can you get the control to run the way you want it in a webpage/browser? If yes (and the problem is with winforms, I'd just embed it in a browser control. If no, I'd as the creators directly.
[ 0.5116821527481079, -0.0723024383187294, 0.4686996638774872, -0.007264106068760157, -0.08655457198619843, -0.3170906603336334, -0.07053539901971817, 0.15442584455013275, -0.5584724545478821, -0.6296696066856384, 0.06594405323266983, 0.9293367266654968, -0.1296796202659607, -0.0247607175260...
I've got some (C#) code that relies on today's date to correctly calculate things in the future. If I use today's date in the testing, I have to repeat the calculation in the test, which doesn't feel right. What's the best way to set the date to a known value within the test so that I can test that the result is a known value? My preference is to have classes that use time actually rely on an interface, such as ``` interface IClock { DateTime Now { get; } } ``` With a concrete implementation ``` class SystemClock: IClock { DateTime
[ 0.21127021312713623, -0.1502498835325241, 0.19928938150405884, 0.2611158788204193, 0.4339315891265869, -0.11842911690473557, 0.0932222381234169, 0.09732254594564438, -0.09072482585906982, -0.8317322731018066, 0.09013888984918594, 0.3610375225543976, -0.1569921374320984, 0.1320364773273468,...
Now { get { return DateTime.Now; } } } ``` Then if you want, you can provide any other kind of clock you want for testing, such as ``` class StaticClock: IClock { DateTime Now { get { return new DateTime(2008, 09, 3, 9, 6, 13); } } } ``` There may be some overhead in providing the clock to the class that relies on it, but that could be handled by any number of dependency injection solutions (using an Inversion of Control container, plain old constructor/setter injection, or even a [Static Gateway Pattern](http://codebetter.com/blogs/jean-paul_boodhoo/archive/2007/10/15/the-static-gateway-pattern.aspx)). Other mechanisms of delivering an object or method that provides desired times
[ 0.27844494581222534, -0.17520204186439514, 0.6752820611000061, -0.05297992378473282, 0.34069475531578064, 0.03277352824807167, 0.08985299617052078, -0.06819546967744827, -0.47217464447021484, -0.40931257605552673, -0.1676456332206726, 0.4181000888347626, -0.2731301188468933, 0.235279932618...
also work, but I think the key thing is to avoid resetting the system clock, as that's just going to introduce pain on other levels. Also, using `DateTime.Now` and including it in your calculations doesn't just not feel right - it robs you of the ability to test particular times, for example if you discover a bug that only happens near a midnight boundary, or on Tuesdays. Using the current time won't allow you to test those scenarios. Or at least not whenever you want.
[ 0.7250068187713623, 0.08853793889284134, 0.19142647087574005, 0.16825059056282043, 0.38764774799346924, -0.14363618195056915, 0.4944899380207062, 0.15757358074188232, -0.23582245409488678, -0.3553812801837921, 0.4385043978691101, 0.28719937801361084, 0.06054028496146202, 0.0947467237710952...
I want to use SQL Profiler to trace the queries executed agains my database, track performance, etc. However it seems that the SQL Profiler is only available in the Enterprise edition of SQL Server 2005. Is this the case indeed, and can I do something about it? You don't need **any** SQL license to run the client tools (Management Studio, Profiler, etc). If your organization has a copy of the installation media for Developer, Standard, or Enterprise, you can install the client tools on your local machine under the same license. If you're working solo, I would recommend [purchasing](http://www.microsoft.com/products/info/product.aspx?view=22&pcid=f544888c-2638-48ed-9f0f-d814e8b93ca0&crumb=catpage&catid=cd1daedd-9465-4aef-a7bf-8f5cf09a4dc0#HowToBuy) SQL Developer edition,
[ 0.27443385124206543, 0.09602866321802139, 0.2859233021736145, 0.08157361298799515, -0.001091115758754313, -0.3139532208442688, 0.2606702744960785, -0.09562180936336517, -0.24692387878894806, -0.5268594026565552, 0.1275104284286499, 0.6399919986724854, -0.006181458476930857, -0.053907096385...