text
stringlengths
0
30.5k
title
stringclasses
1 value
embeddings
listlengths
768
768
it's only $50.
[ 0.24201983213424683, 0.3624773621559143, 0.2755906879901886, -0.05463352054357529, 0.527877151966095, 0.2809591591358185, 0.22065378725528717, 0.20605601370334625, 0.3283228874206543, -0.43508613109588623, 0.6279112696647644, 0.45234215259552, 0.31353625655174255, -0.2319408357143402, 0....
For my day job, I live in Emacs. Utterly. I also have become pretty dependent on CScope to help me find things in the code. Normally, I have 2 windows in a split (C-x 3): [alt text http://bitthicket.com/files/emacs-2split.JPG](http://bitthicket.com/files/emacs-2split.JPG) And I use the right window for code buffers and the left window for the CScope search buffer. When you do a CScope search and select a result, it automatically updates the right-side window to show the buffer referred to by the result. This is all well and good, except that it causes me to lose my place in some other buffer that I was
[ 0.4147741496562958, 0.23978069424629211, 0.35605862736701965, -0.09092747420072556, 0.07863500714302063, 0.019849829375743866, 0.4795600175857544, 0.07558966428041458, -0.29017752408981323, -0.6407871842384338, -0.12504194676876068, 0.2579140365123749, -0.1864791214466095, 0.12668153643608...
studying. Sometimes this is no biggie, because [C-s u] gets me back to where I was. What would be better, though, is to have 3 split windows like this ([C-x 2] in the left window): [alt text http://bitthicket.com/files/emacs-3split.jpg](http://bitthicket.com/files/emacs-3split.jpg) And have the bottom left window contain the CScope search buffer, and the top left window be the only buffer that CScope ever updates. That way, I can see my CScope searches and navigate around the code without losing the buffer I'm focused on. Anyone know how I can do that? Put this in your .emacs file: ``` ;; Toggle window dedication (defun toggle-window-dedicated () "Toggle whether the current active window
[ 0.340057909488678, 0.05811068415641785, 0.5281838774681091, -0.0002169000217691064, 0.14389657974243164, 0.00322527252137661, 0.48642632365226746, -0.030984625220298767, -0.5936263203620911, -0.6101951599121094, 0.11160283535718918, 0.5080947875976562, -0.23261822760105133, -0.071031063795...
is dedicated or not" (interactive) (message (if (let (window (get-buffer-window (current-buffer))) (set-window-dedicated-p window (not (window-dedicated-p window)))) "Window '%s' is dedicated" "Window '%s' is normal") (current-buffer))) ``` Then bind it to some key - I use the Pause key: ``` (global-set-key [pause] 'toggle-window-dedicated) ``` And then use it to "dedicate" the window you want locked. then cscope can only open files from its result window in some OTHER window. Works a charm. I specifically use it for exactly this purpose - keeping one source file always on screen,
[ 0.13935554027557373, -0.09315482527017593, 0.6912290453910828, 0.1067814975976944, 0.09325509518384933, -0.45277372002601624, 0.2721349895000458, 0.2183728665113449, -0.0511159710586071, -0.9449440836906433, -0.4541065990924835, 0.6425550580024719, -0.3533889651298523, 0.2192409336566925, ...
while using cscope in a second buffer/window, and looking at cscope results in a third.
[ 0.03975207358598709, -0.138933926820755, 0.04914534091949463, -0.12981970608234406, -0.010994854383170605, 0.0024042788427323103, 0.20253877341747284, -0.1929829865694046, -0.13373415172100067, -0.9728740453720093, -0.2863813638687134, 0.1539507806301117, -0.31623074412345886, 0.0377043262...
This is what I've got. It works. But, is there a simpler or better way? ASPX Page… ``` <asp:Repeater ID="RepeaterBooks" runat="server"> <HeaderTemplate> <table class="report"> <tr> <th>Published</th> <th>Title</th> <th>Author</th>
[ 0.15193387866020203, -0.05017064884305, 0.5063241720199585, 0.2147766500711441, 0.19750505685806274, -0.2752739489078522, 0.22548048198223114, -0.06533476710319519, -0.2195509970188141, -0.843633770942688, 0.30604568123817444, 0.20051155984401703, 0.13320675492286682, -0.07661719620227814,...
<th>Price</th> </tr> </HeaderTemplate> <ItemTemplate> <tr> <td><asp:Literal ID="LiteralPublished" runat="server" /></td> <td><asp:Literal ID="LiteralTitle" runat="server" /></td> <td><asp:Literal ID="LiteralAuthor" runat="server" /></td>
[ 0.3424409031867981, -0.18984317779541016, 0.31102457642555237, 0.3103957772254944, -0.29156118631362915, 0.29389986395835876, -0.19158601760864258, -0.46182143688201904, 0.19460180401802063, -0.3505447506904602, -0.1874319463968277, 0.5853027701377869, 0.011540992185473442, -0.024231664836...
<td><asp:Literal ID="LiteralPrice" runat="server" /></td> </tr> </ItemTemplate> <FooterTemplate> </table> </FooterTemplate> </asp:Repeater> ``` ASPX.VB Code Behind… ``` Protected Sub Page_Load( ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load Dim db As New BookstoreDataContext RepeaterBooks.DataSource = From b In db.Books _
[ 0.08933395147323608, -0.054870739579200745, 0.794849693775177, -0.02575746551156044, -0.10856728255748749, 0.14933300018310547, 0.24435843527317047, -0.38155698776245117, -0.024476805701851845, -0.39554864168167114, -0.2755453884601593, 0.6618083119392395, 0.01805393397808075, 0.4704199135...
Order By b.Published _ Select b RepeaterBooks.DataBind() End Sub Sub RepeaterBooks_ItemDataBound( ByVal sender As Object, ByVal e As System.Web.UI.WebControls.RepeaterItemEventArgs) Handles RepeaterBooks.ItemDataBound If e.Item.ItemType = ListItemType.Item Or e.Item.ItemType = ListItemType.AlternatingItem Then Dim b As Book = DirectCast(e.Item.DataItem, Book) DirectCast(e.Item.FindControl("LiteralPublished"), Literal).Text = "<nobr>" + b.Published.ToShortDateString
[ 0.10445039719343185, -0.16342413425445557, 0.8680282235145569, 0.05711119621992111, -0.10096518695354462, 0.1728990077972412, 0.21676909923553467, -0.33527734875679016, -0.20950648188591003, -0.4030317962169647, -0.4739719033241272, 0.24827361106872559, -0.3164142072200775, 0.7726566791534...
+ "</nobr>" DirectCast(e.Item.FindControl("LiteralTitle"), Literal).Text = "<nobr>" + TryNbsp(HttpContext.Current.Server.HtmlEncode(b.Title)) + "</nobr>" DirectCast(e.Item.FindControl("LiteralAuthor"), Literal).Text = "<nobr>" + TryNbsp(HttpContext.Current.Server.HtmlEncode(b.Author)) + "</nobr>" DirectCast(e.Item.FindControl("LiteralPrice"), Literal).Text = "<nobr>" + Format(b.Price, "c") + "</nobr>" End If End Sub Function TryNbsp(ByVal s As String) As String If s = "" Then Return "&nbsp;" Else Return s End If End Function ``` @Geoff That sort of Eval statement
[ -0.11346236616373062, -0.06644655764102936, 0.7712906002998352, -0.2756192684173584, -0.301613986492157, -0.029174454510211945, 0.39045217633247375, -0.5585184693336487, -0.06458750367164612, -0.030200481414794922, -0.5238256454467773, 0.4737718403339386, -0.5020579099655151, 0.17876580357...
was actually added in 2.0, but if performance is important Eval should be avoided since it uses Reflection. The repeater is a pretty good way of doing it, although it might be faster to generate the table in code: ASPX Page: ``` <table class="report" id="bookTable" runat="server"> <tr> <th>Published</th> <th>Title</th> <th>Author</th> <th>Price</th>
[ 0.06392265856266022, -0.2598608732223511, 0.7097984552383423, -0.016113270074129105, -0.3450024724006653, -0.2300201803445816, 0.23964163661003113, -0.5040570497512817, -0.4102877378463745, -0.2869110405445099, 0.13460421562194824, 0.3825400471687317, -0.12981697916984558, -0.0272289700806...
</tr> </table> ``` Code Behind: ``` Protected Sub Page_Load( ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load If Not Page.IsPostback Then BuildTable() End If End Sub Private Sub BuildTable() Dim db As New BookstoreDataContext Dim bookCollection = from b in db.Books _ Order By b.Published _
[ 0.025160981342196465, 0.08323081582784653, 0.9322862029075623, -0.09196527302265167, -0.07520491629838943, -0.0051901331171393394, 0.31882980465888977, -0.3659701645374298, -0.021998148411512375, -0.4383108913898468, -0.45721304416656494, 0.6270342469215393, -0.17685653269290924, 0.6276826...
Select b Dim row As HtmlTableRow Dim cell As HtmlTableCell For Each book As Books In bookCollection row = New HtmlTableRow() cell = New HtmlTableCell With { .InnerText = b.Published.ToShortDateString } row.Controls.Add(cell) cell = New HtmlTableCell With { .InnerText = TryNbsp(HttpContext.Current.Server.HtmlEncode(b.Title)) }
[ -0.13017722964286804, -0.38547471165657043, 0.7928913831710815, -0.20789353549480438, -0.5448988676071167, 0.19196350872516632, 0.053043123334646225, -0.6723039746284485, -0.02372952550649643, -0.21181952953338623, -0.27091750502586365, 0.016652382910251617, -0.6096847057342529, 0.06961641...
row.Controls.Add(cell) cell = New HtmlTableCell With { .InnerText = TryNbsp(HttpContext.Current.Server.HtmlEncode(b.Author)) row.Controls.Add(cell) cell = New HtmlTableCell With { .InnerText = Format(b.Price, "c") } row.Controls.Add(cell) bookTable.Controls.Add(row) Next ``` I guess it depends on how important speed is to you. For simplicity's sake I think I would go with the Repeater.
[ -0.14600807428359985, -0.056257084012031555, 0.8324819803237915, 0.17943646013736725, -0.05175458639860153, 0.06469836086034775, 0.08979067951440811, -0.319113552570343, -0.3206998109817505, -0.7986121773719788, 0.1324455589056015, 0.6228920221328735, -0.3099329471588135, 0.265373855829238...
I have a distributed Java application running on 5 application servers. The servers all use the same Oracle 9i database running on a 6th machine. The application need to prefetch a batch of 100 IDs from a sequence. It's relatively easy to do in a single-threaded, non-distributed environment, you can just issue these queries: ```sql SELECT seq.nextval FROM dual; ALTER SEQUENCE seq INCREMENT BY 100; SELECT seq.nextval FROM dual; ``` The first select fetches the first sequence ID that the application can use, the second select returns the last one that can be used. Things get way more interesting in a multithreaded environment. You can't be sure that
[ 0.23686295747756958, 0.25483548641204834, 0.3397926688194275, -0.0404777005314827, 0.047528088092803955, 0.08136041462421417, 0.16103066504001617, -0.17132380604743958, 0.062051355838775635, -0.8820780515670776, 0.2607905864715576, 0.12122596055269241, -0.3430291712284088, 0.49884390830993...
before the second select another thread doesn't increase the sequence by 100 again. This issue can be solved by synchronizing the access on the Java side - you only let one thread begin fetching the IDs at one time. The situation becomes really hard when you can't synchronize because parts of the application doesn't run on the same JVM, not even on the same physical machine. I found some references on forums that others have problems with solving this problem too, but none of the answers are really working not to mention being reasonable. Can the community provide a solution for this
[ 0.15157431364059448, -0.32608386874198914, 0.13594336807727814, 0.2662990987300873, -0.22302210330963135, -0.1376029998064041, 0.22226785123348236, -0.2309298813343048, -0.11088189482688904, -0.8913191556930542, 0.3044857084751129, 0.4060679078102112, -0.2863912284374237, 0.017735287547111...
problem? Some more information: * I can't really play with the transaction isolation levels. I use JPA and the change would affect the entire application, not only the prefetching queries and that's not acceptable for me. * On PostgreSQL I could do the following: `SELECT setval('seq', NEXTVAL('seq') + n - 1)` * The solution by Matthew works when you can use a fixed increment value (which is perfectly acceptable in my case). However is there a solution when you don't want to fix the size of the increment, but want to adjust it dynamically? Why not just have the sequence as increment by 100 all the
[ -0.33469074964523315, -0.024688363075256348, 0.31648552417755127, -0.062143344432115555, 0.10585274547338486, 0.19204118847846985, 0.20857110619544983, -0.1375829577445984, -0.4097226858139038, -0.6807296872138977, 0.04062842205166817, 0.528951108455658, -0.6352280974388123, 0.120535500347...
time? each "nextval" gives you 100 sequence numbers to work with ``` SQL> create sequence so_test start with 100 increment by 100 nocache; Sequence created. SQL> select so_test.nextval - 99 as first_seq, so_test.currval as last_seq from dual; FIRST_SEQ LAST_SEQ ---------- ---------- 1 100 SQL> / FIRST_SEQ LAST_SEQ ---------- ---------- 101 200 SQL> / FIRST_SEQ LAST_SEQ ---------- ---------- 201 300 SQL> ``` A note on
[ -0.16500337421894073, -0.09970556944608688, 0.5888354778289795, 0.06759712845087051, 0.1447916328907013, 0.2664671540260315, 0.19512683153152466, -0.48836901783943176, 0.048083700239658356, -0.9512844681739807, -0.201199471950531, 0.34369081258773804, 0.24198682606220245, -0.12179270386695...
your example.. Watch out for DDL.. It will produce an implicit commit **Example of commit produced by DDL** ``` SQL> select * from xx; no rows selected SQL> insert into xx values ('x'); 1 row created. SQL> alter sequence so_test increment by 100; Sequence altered. SQL> rollback; Rollback complete. SQL> select * from xx; Y ----- x SQL> ```
[ 0.3149621784687042, 0.054811883717775345, 0.22277577221393585, -0.003380628302693367, 0.012426636181771755, 0.12516175210475922, 0.30406084656715393, -0.2896183133125305, -0.15520717203617096, -0.7983142137527466, 0.024596570059657097, 0.5469610691070557, -0.3997207283973694, -0.0193363092...
I'm about to create a web application that requires a lot of different web forms where the user needs to be able to input a lot of different types of information. What I mean is that one of those forms may require some text input fields, some integer input fields, some decimal input fields, some date input fields, some datetime input fields, etc. I would like to have a, maybe JavaScript-based, control library that I can simple provide with some text labels, input types and default values. The control library would then somehow render the form in HTML without me having
[ 0.5572113990783691, 0.0989946648478508, 0.2716464698314667, 0.2961725890636444, 0.07009939849376678, -0.05446868762373924, -0.16475628316402435, -0.0069452631287276745, -0.009324632585048676, -0.6489087343215942, 0.14262554049491882, 0.27711454033851624, -0.23267927765846252, 0.07156831026...
to create an HTML table, select the appropriate standard web controls and all that. I have used [dhtmlxGrid](http://www.dhtmlx.com/) to create quite a lot of tables and that works well for me. What I need now is something that can help me in a similar way when creating something like card forms. I have also found [ActiveWidgets](http://www.activewidgets.com/), but it looks like it will require a lot of work on my behalf. I'm not only looking for individual web controls, but rather something like a library that can help me with the overall card. I'm guessing many of you have had this problem before. Looking
[ 0.4700792133808136, -0.0011044814018532634, 0.535622239112854, 0.34424567222595215, -0.19055084884166718, -0.2092714160680771, -0.000573482015170157, -0.1387486606836319, -0.3980979323387146, -0.8408355712890625, 0.30929505825042725, 0.37674230337142944, -0.08880752325057983, 0.01774955540...
forward to hearing what solutions you have found to be the best. BTW: I'm working in VisualStudio with ASP.NET. I would be tempted to look at Ext JS for this. [Ext JS](http://extjs.com/products/extjs/)
[ 0.7323386669158936, -0.08533591777086258, 0.3864033818244934, 0.05707734078168869, -0.08302216976881027, 0.12484592944383621, 0.17013801634311676, 0.4328547716140747, -0.22158844769001007, -0.8672857880592346, -0.3251064419746399, 0.2868707478046417, 0.45165807008743286, -0.092157073318958...
Why do I need two of them? When I have to use one or another? [Quote by @DAC](https://stackoverflow.com/a/43883/6571020) > In short: SID = the unique name of > your DB, ServiceName = the alias used > when connecting Not strictly true. SID = unique name of the INSTANCE (eg the oracle process running on the machine). Oracle considers the "Database" to be the files. Service Name = alias to an INSTANCE (or many instances). The main purpose of this is if you are running a cluster, the client can say "connect me to `SALES.acme.com`", the DBA can on the fly change the number of instances which
[ 0.40125706791877747, 0.1323230117559433, 0.08412861824035645, 0.20539338886737823, -0.10366913676261902, -0.13382039964199066, -0.07088758051395416, -0.14376941323280334, -0.23684436082839966, -0.4575587213039398, 0.06315657496452332, 0.5826892256736755, -0.25838902592658997, 0.53106236457...
are available to `SALES.acme.com` requests, or even move `SALES.acme.com` to a completely different database without the client needing to change any settings.
[ 0.6137897968292236, 0.19474968314170837, 0.37138500809669495, 0.17303483188152313, 0.31471359729766846, -0.2183404266834259, -0.2462809681892395, 0.19017672538757324, -0.16237100958824158, -0.28966236114501953, -0.20912404358386993, 0.5319334268569946, 0.10414879769086838, 0.33552297949790...
I have a multiple selection SELECT field which I don't want the end user to be able to change the value of. For UI reasons, I would like to be able to do this without using the disabled="true" attribute. I've tried using onmousedown, onfocus, onclick and setting each to blur or return false but with no success. Can this be done or am I trying to do the impossible? I know you mentioned that you don't want to, but I actually think that using the `disabled` attribute is a better solution: ``` <select multiple="multiple"> <option value="volvo" selected="true" disabled="disabled">Volvo</option>
[ 0.4403473138809204, -0.29860565066337585, 0.1581474393606186, 0.09488800168037415, -0.07234659790992737, 0.24559953808784485, 0.2630007863044739, -0.10984715074300766, -0.2835626006126404, -0.5513920187950134, 0.19145485758781433, 0.7677392363548279, -0.11757808178663254, 0.207774728536605...
<option value="saab" disabled="disabled">Saab</option> <option value="opel" disabled="disabled">Opel</option> <option value="audi" disabled="disabled">Audi</option> </select> ``` If necessary, you can always give the `select` a `class` and style it with CSS. This solution will work in all browsers regardless of scripting capabilities.
[ -0.07454506307840347, -0.11937375366687775, 0.008147081360220909, -0.22664695978164673, -0.18522536754608154, 0.3902589976787567, 0.0481882244348526, 0.005865993909537792, -0.16276270151138306, -0.8947160243988037, -0.37239816784858704, 0.19855250418186188, -0.3816365599632263, -0.20827426...
**Original Question** I want to be able to generate a new (fully valid) MP3 file from an existing MP3 file to be used as a preview -- try-before-you-buy style. The new file should only contain the first *n* seconds of the track. Now, I know I could just "chop the stream" at *n* seconds (calculating from the bitrate and header size) when delivering the file, but this is a bit dirty and a real PITA on a VBR track. I'd like to be able to generate a proper MP3 file. Anyone any ideas? **Answers** Both `mp3split` and `ffmpeg` are both good solutions. I chose ffmpeg
[ 0.6962651014328003, 0.05720122531056404, 0.1547982394695282, 0.2554236352443695, -0.23353451490402222, 0.0731557086110115, 0.16876818239688873, -0.14232972264289856, -0.1836419701576233, -0.49767300486564636, 0.1635136753320694, 0.7201077342033386, -0.01055622473359108, -0.0232860334217548...
as it is commonly installed on linux servers and is also [easily available for windows](http://sourceforge.net/project/showfiles.php?group_id=205275&package_id=248632). Here's some more good command line parameters for generating previews with ffmpeg * **`-t <seconds>`** chop after specified number of seconds * **`-y`** force file overwrite * **`-ab <bitrate>`** set bitrate e.g. *-ab 96k* * **`-ar <rate Hz>`** set sampling rate e.g. *-ar 22050* for 22.05kHz * **`-map_meta_data <outfile>:<infile>`** copy track metadata from infile to outfile instead of setting -ab and -ar, you can copy the original track settings, as Tim Farley suggests, with: * **`-acodec copy`** I also recommend ffmpeg, but the command line suggested by John Boker has an unintended side
[ 0.20970959961414337, -0.19399617612361908, -0.0600406639277935, 0.17588461935520172, -0.18698036670684814, -0.08435270935297012, 0.1192857101559639, -0.34033605456352234, -0.25007593631744385, -0.6655600666999817, -0.16997401416301727, 0.5848326086997986, -0.23619188368320465, -0.007073354...
effect: it re-encodes the file to the default bitrate (which is 64 kb/s in the version I have here at least). This might give your customers a false impression of the quality of your sound files, and it also takes longer to do. Here's a command line that will slice to 30 seconds without transcoding: ``` ffmpeg -t 30 -i inputfile.mp3 -acodec copy outputfile.mp3 ``` The -acodec switch tells ffmpeg to use the special "copy" codec which does not transcode. It is lightning fast. NOTE: the command was updated based on comment from Oben Sonne
[ 0.4368242919445038, 0.04629731923341751, 0.4723333716392517, -0.038819387555122375, -0.09364194422960281, 0.25759047269821167, 0.4127647578716278, -0.6430699825286865, -0.22922596335411072, -0.5771061778068542, -0.05374260991811752, 0.688683271408081, -0.15036123991012573, 0.20903740823268...
I'd like to build a pretty simple plug-in for Visual Studio, but I don't really know how this has to be done. Is this doable in (non-managed) C++? I'd like to know what resources you'd recommend me. I've never tried, so I don't know about doing it in C++, but this website has loads of information: <http://msdn.microsoft.com/en-us/vsx/default.aspx>
[ 0.5956911444664001, -0.11546933650970459, 0.0713185966014862, 0.0928989052772522, 0.10858093202114105, 0.018847260624170303, 0.18108080327510834, 0.13715706765651703, -0.0972130075097084, -0.6765003800392151, 0.09373767673969269, 0.749274730682373, 0.06169232353568077, -0.11537068337202072...
Is it possible to modify the title of the message box the confirm() function opens in JavaScript? I could create a modal popup box, but I would like to do this as minimalistic as possible. I would like to do something like this: ``` confirm("This is the content of the message box", "Modified title"); ``` The default title in Internet Explorer is "Windows Internet Explorer" and in Firefox it's "[JavaScript-program]." Not very informative. Though I can understand from a browser security stand point that you shouldn't be able to do this. This is not possible, as you say, from a security stand point. The only way
[ 0.549979031085968, 0.2833251655101776, 0.4262452721595764, -0.029311176389455795, 0.22939306497573853, -0.7037296295166016, 0.07465863227844238, 0.15959560871124268, 0.27143749594688416, -0.3643958568572998, -0.21732839941978455, 0.7203424572944641, -0.35671374201774597, -0.095533363521099...
you could simulate it, is by creating a modeless dialog window. There are many third-party javascript-plugins that you could use to fake this effect so you do not have to write all that code.
[ 0.5808619260787964, -0.06106964126229286, 0.21110856533050537, 0.3685510754585266, 0.06374726444482803, -0.1617146134376526, 0.323214590549469, 0.29824182391166687, -0.2578660845756531, -0.5776441097259521, 0.3425656259059906, 0.34813547134399414, -0.44261136651039124, 0.006672857794910669...
I want to allow my users to embed their own Flash animations in their posts. Usually the actual file is hosted on some free image hosting site. I wouldn't actually load the flash unless the user clicked a button to play (so that nothing auto-plays on page load). I know people can make some really annoying crap in flash, but I can't find any information about potential *serious* damage a flash app could cause to the viewer. Is it unsafe to embed just any flash file from the internets? If so, how can I let users embed innocent animations but still
[ 0.9421047568321228, 0.3691609501838684, 0.1123679131269455, 0.27598100900650024, -0.07625168561935425, -0.20483800768852234, 0.1661645919084549, 0.511741578578949, -0.18166875839233398, -0.526718258857727, 0.18331584334373474, 0.3383566439151764, -0.1664740890264511, 0.2703567445278168, ...
keep out the harmful apps? edit: From what I can gather, the most obvious threat is for actionscript to redirect you to a malicious site. Adobe [says](http://www.adobe.com/devnet/flashplayer/articles/secure_swf_apps_04.html) you can set **allowScriptAccess=never** and **allowNetworking=none** and the swf should have no access to anything outside of itself. **Will this solve all my problems?** Adobe says you can set **allowScriptAccess**=never and **allowNetworking**=none and the swf should have no access to anything outside of itself. Although allowNetworking is only in Flash Player 9, so users with earlier versions of Flash would still be susceptible to some exploits. [Creating more secure SWF web applications : Security Controls Within the HTML
[ 0.02042805776000023, 0.3830651342868805, 0.7467667460441589, -0.16037839651107788, -0.0028987738769501448, -0.42231106758117676, 0.6056272983551025, -0.021122638136148453, -0.33153292536735535, -0.318433940410614, -0.2289871722459793, 0.596127986907959, -0.8161561489105225, -0.051349472254...
Code](http://www.adobe.com/devnet/flashplayer/articles/secure_swf_apps_04.html) [How to restrict SWF content from HTML](http://blogs.adobe.com/stateofsecurity/2007/07/how_to_restrict_swf_content_fr_1.html)
[ 0.3719120919704437, 0.18227000534534454, 0.39795514941215515, -0.15922658145427704, -0.12589406967163086, -0.44067949056625366, 0.1431211531162262, -0.3952395021915436, -0.3342558443546295, -0.38552355766296387, -0.47722986340522766, 0.5080516338348389, -0.6140835881233215, -0.244404077529...
Is it possible to pass a reference to a function to another function in F#? Specifically, I'd like to pass lambda functions like foo(fun x -> x \*\* 3) More specifically, I need to know how I would refer to the passed function in a function that I wrote myself. Yes, it is possible. The [manual](http://research.microsoft.com/fsharp/manual/spec2.aspx#_Toc207785549) has this example: ``` > List.map (fun x -> x % 2 = 0) [1 .. 5];; val it : bool list = [false; true; false; true; false] ```
[ 0.044055256992578506, 0.14253011345863342, 0.508978009223938, -0.10342017561197281, -0.11043544113636017, -0.27290910482406616, 0.26111289858818054, -0.09029959887266159, -0.25819897651672363, -0.3043244779109955, -0.11668909341096878, 0.5062015652656555, -0.44034919142723083, -0.137140780...
I am trying to write a regular expression to strip all HTML with the exception of links (the `<a href` and `</a>` tags respectively. It does not have to be 100% secure (I am not worried about injection attacks or anything as I am parsing content that has already been approved and published into a [SWF](http://en.wikipedia.org/wiki/SWF) movie). The original "strip tags" regular expression I'm using was `<(.|\n)+?>`, and I tried to modify it to `<([^a]|\n)+?>`, but that of course will allow any tag that has an **a** in it rather than one that has it in the beginning, with a space. Not
[ 0.5051500797271729, 0.02021244913339615, 0.6450698375701904, -0.2565247118473053, -0.1440361738204956, -0.20910020172595978, 0.2231747806072235, 0.024800550192594528, -0.20540180802345276, -0.5182130336761475, -0.31076622009277344, 0.4023910462856293, -0.5148022770881653, -0.04762455821037...
that it should really matter, but in case anyone cares to know I am writing this in [ActionScript 3.0](http://en.wikipedia.org/wiki/ActionScript#ActionScript_3.0) for a [Flash](http://en.wikipedia.org/wiki/Adobe_Flash) movie. ``` <(?!\/?a(?=>|\s.*>))\/?.*?> ``` Try this. Had something similar for p tags. Worked for them so don't see why not. Uses negative lookahead to check that it doesn't match a (prefixed with an optional / character) where (using positive lookahead) a (with optional / prefix) is followed by a > or a space, stuff and then >. This then matches up until the next > character. Put this in a subst with ``` s/<(?!\/?a(?=>|\s.*>))\/?.*?>//g; ``` This should leave only the opening and closing a tags
[ 0.20276181399822235, 0.1667664498090744, 0.3802107870578766, -0.2631266713142395, -0.0671653226017952, -0.052432894706726074, 0.11772624403238297, -0.4023487865924835, -0.16481313109397888, -0.18583476543426514, -0.26799753308296204, 0.3506324291229248, -0.5625513195991516, -0.386712461709...
This is a fairly trivial matter, but I'm curious to hear people's opinions on it. If I have a Dictionary which I'm access through properties, which of these formats would you prefer for the property? ``` /// <summary> /// This class's FirstProperty property /// </summary> [DefaultValue("myValue")] public string FirstProperty { get { return Dictionary["myKey"]; } set { Dictionary["myKey"] = value; } ``` This is probably the typical way of doing it. It's fairly efficient, easy to understand, etc. The only disadvantage is with
[ -0.13795386254787445, -0.20024749636650085, 0.10487805306911469, 0.0059774392284452915, 0.14883041381835938, -0.0418318472802639, 0.05453994497656822, -0.08175960928201675, 0.06458175182342529, -0.7867106199264526, -0.43457552790641785, 0.7170695066452026, -0.1261129379272461, 0.2935621738...
a longer or more complex key it would be possible to misspell it or change only one instance or something, leading me to this: ``` /// <summary> /// This class's SecondProperty property /// </summary> [DefaultValue("myValue")] private const string DICT_MYKEY = "myKey" public string SecondProperty { get { return Dictionary[DICT_MYKEY]; } set { Dictionary[DICT_MYKEY] = value; } ``` Which is marginally more complicated, but seems to offer additional safety, and is closer to what I would think of as the "Code Complete" solution. The
[ -0.23776432871818542, -0.40189117193222046, 0.1474524438381195, -0.09013932198286057, 0.13628855347633362, 0.025938265025615692, 0.48629090189933777, -0.2618124783039093, 0.13578113913536072, -0.5274202823638916, -0.5363487005233765, 0.5241827368736267, -0.15075501799583435, 0.101946301758...
downside is that when you also have a /// block and a [DefaultValue()] block above the property already, it starts getting a bit crowded up there. So which do you like better, and why? Does anybody have any better ideas? I like the second one purely because any avoidance of magic strings/numbers in code is a good thing. IMO if you need to reference a number or string literal in code more than once, it should be a constant. In most cases even if it's only used once it should be in a constant
[ 0.19492411613464355, -0.14361228048801422, 0.22934535145759583, 0.027055716142058372, -0.3201374113559723, -0.2927224040031433, 0.16619236767292023, -0.10205525159835815, -0.44835296273231506, -0.5539171099662781, 0.11898846179246902, 0.5936104655265808, -0.1192634180188179, -0.10512931644...
I am working on a site where users can login to get more private information. My client has another site else where that uses *nt authentication* for accessing it. What they want to do is have a `button` on the site I am working on under the private area that will send them to the *nt authenticated* site, but not require them to log on to that site instead passing the *username* and *password* that they used to log into my site to the other site for them. Is it possible to do this? and how would I accomplish it? Is there
[ 0.6162686347961426, 0.2938213050365448, 0.20678210258483887, 0.05521901696920395, 0.16727983951568604, -0.06110364943742752, 0.3352459669113159, -0.12423314154148102, -0.26870957016944885, -0.6084660291671753, 0.025020187720656395, 0.29625362157821655, 0.09724248200654984, 0.26293456554412...
a better way to do this? Here's an (untested) theory, the details of which will greatly depend on what types of authentication the Sharepoint site will accept. I'll tackle [Basic](http://en.wikipedia.org/wiki/Basic_access_authentication), since it's the easiest. You'll write out some JavaScript that uses XMLHttpRequest to submit a request to the Sharepoint site, and add their username and password to the request headers. Their browser will run that JavaScript, and get logged into the Sharepoint site. Now, when they click the link, the client's browser should have the cached credentials to send to the Sharepoint site. Possible issues: * XMLHttpRequest does not allow cross domain auth * Browser and
[ 0.15261965990066528, -0.017381638288497925, 0.3380354344844818, 0.12198342382907867, -0.200496643781662, -0.17445340752601624, 0.3649439513683319, -0.3282472789287567, 0.1143387109041214, -0.6310402750968933, -0.013848270289599895, 0.6323996186256409, -0.1265055239200592, -0.01003952696919...
XHR don't share auth info * Sharepoint and XHR can't agree on auth method Another option is to proxy the connection to Sharepoint, which allows you to login server side (bypassing XHR limitations and browser security) - but requiring load on your server and possibly some URL target issues.
[ 0.35164833068847656, 0.049568481743335724, 0.3630349338054657, 0.2443850338459015, -0.19870314002037048, -0.15546968579292297, 0.4027455449104309, 0.24184098839759827, 0.07967120409011841, -0.6972008943557739, -0.06729365140199661, 0.2738533914089203, -0.34719985723495483, 0.42002731561660...
What's the best way to extend the User model (bundled with Django's authentication app) with custom fields? I would also possibly like to use the email as the username (for authentication purposes). I've already seen a [few](http://scottbarnham.com/blog/2008/08/21/extending-the-django-user-model-with-inheritance/) [ways](http://www.b-list.org/weblog/2006/jun/06/django-tips-extending-user-model/) to do it, but can't decide on which one is the best. The least painful and indeed Django-recommended way of doing this is through a `OneToOneField(User)` property. > [Extending the existing User model](https://docs.djangoproject.com/en/dev/topics/auth/customizing/#extending-the-existing-user-model) > ------------------------------------------------------------------------------------------------------------------------------------- > > > … > > > If you wish to store information related to `User`, you can use a [one-to-one relationship](https://docs.djangoproject.com/en/dev/ref/models/fields/#ref-onetoone) to a model containing the fields for additional information. This one-to-one
[ 0.06950303912162781, 0.24601727724075317, 0.4528621733188629, -0.2462892383337021, -0.1206490769982338, -0.34639623761177063, -0.13025304675102234, -0.09654054790735245, -0.28720420598983765, -0.3773461580276489, 0.1716131865978241, 0.630192220211029, -0.16311629116535187, -0.2497795522212...
model is often called a profile model, as it might store non-auth related information about a site user. That said, extending `django.contrib.auth.models.User` and supplanting it also works... > [Substituting a custom User model](https://docs.djangoproject.com/en/dev/topics/auth/customizing/#substituting-a-custom-user-model) > ----------------------------------------------------------------------------------------------------------------------------------- > > > Some kinds of projects may have authentication requirements for which Django’s built-in `User` model is not always appropriate. For instance, on some sites it makes more sense to use an email address as your identification token instead of a username. > > > *[Ed: **Two warnings and a notification follow**, mentioning that this is **pretty drastic**.]* I would definitely stay away from changing the actual User class in
[ 0.2520768344402313, -0.025207627564668655, 0.21546567976474762, -0.07677670568227768, -0.07788712531328201, -0.37375181913375854, 0.312580943107605, -0.01426090206950903, -0.24128393828868866, -0.6127055287361145, 0.11912237852811813, 0.496534526348114, -0.263051301240921, -0.0651596710085...
your Django source tree and/or copying and altering the auth module.
[ 0.5202621817588806, 0.2666451632976532, 0.040980566293001175, 0.1778867244720459, 0.027417631819844246, -0.37791815400123596, -0.006921796128153801, 0.13261336088180542, 0.0062825423665344715, -0.5995262265205383, -0.12901191413402557, 0.958380401134491, -0.22088763117790222, -0.0667733699...
A friend of mine told me there was a way to connect two private IPs without using a proxy server. The idea was that both computers connected to a public server and some how the server joined the private connections and won't use any more bandwidth. Is this true? How's this technique named? There is a technique called "[Hole Punching](http://en.wikipedia.org/wiki/Hole_punching)" that works well with "Cone" NAT (Cone is a technical familly of router). That's not an 100% sure technique, today, it works well with UDP on about 80% of the router. There is some implementations of library to realize Hole Punching: [STUN](http://sourceforge.net/projects/stun/) ([wikipedia](http://en.wikipedia.org/wiki/STUN))
[ 0.4971226751804352, -0.12571559846401215, 0.0021626839879900217, 0.3585818409919739, -0.5341484546661377, -0.00831647776067257, 0.14585497975349426, -0.001497063785791397, -0.4608286917209625, -0.6488675475120544, 0.33537358045578003, 0.2153017818927765, -0.5066416263580322, 0.088234610855...
I have a database with two tables (`Table1` and `Table2`). They both have a common column `[ColumnA]` which is an `nvarchar`. How can I select this column from both tables and return it as a single column in my result set? So I'm looking for something like: ``` ColumnA in Table1: a b c ColumnA in Table2: d e f Result set should be: a b c d e f ``` ``` SELECT ColumnA FROM Table1 UNION Select ColumnB FROM Table2 ORDER BY 1 ``` Also, if you know the contents of Table1 and Table2 will **NEVER** overlap, you can use UNION ALL in place of UNION instead. Saves a little bit of resources that way. -- Kevin Fairchild
[ 0.19396938383579254, 0.4178250730037689, -0.11246483027935028, -0.08774174004793167, 0.06759309023618698, 0.21117320656776428, 0.11134181171655655, -0.02051563188433647, -0.14279092848300934, -0.6243363618850708, -0.10477139055728912, 0.4659629166126251, -0.15015217661857605, -0.0436778031...
I am looking for a simple JavaScript example that updates DOM. Any suggestions? Here is a short pure-javascript example. Assume you have a div with the id "maincontent". ``` var newnode = document.createTextNode('Here is some text.'); document.getElementById('maincontent').appendChild(newnode); ``` Of course, things are a lot easier (especially when you want to do more complicated things) with jQuery.
[ 0.13731680810451508, -0.001679652719758451, 0.3315925896167755, -0.19734787940979004, -0.08082900196313858, -0.32366594672203064, 0.2816002368927002, -0.06524445116519928, -0.009272126480937004, -0.8786026835441589, -0.1879873275756836, 0.6979445815086365, -0.3082893490791321, 0.1058274134...
This is what I've got. It works. But, is there a simpler or better way? One an ASPX page, I've got the download link... ``` <asp:HyperLink ID="HyperLinkDownload" runat="server" NavigateUrl="~/Download.aspx">Download as CSV file</asp:HyperLink> ``` And then I've got the Download.aspx.vb Code Behind... ``` Public Partial Class Download Inherits System.Web.UI.Page Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load 'set header Response.Clear() Response.ContentType = "text/csv" Dim FileName As String = "books.csv"
[ -0.060066547244787216, 0.008049123920500278, 0.9455704689025879, 0.1251395344734192, 0.05748535320162773, -0.1200040876865387, 0.08509755879640579, -0.14274035394191742, -0.3049246668815613, -0.7396082878112793, -0.400706946849823, 0.49421265721321106, -0.11679139733314514, 0.2144039869308...
Response.AppendHeader("Content-Disposition", "attachment;filename=" + FileName) 'generate file content Dim db As New bookDevelopmentDataContext Dim Allbooks = From b In db.books _ Order By b.Added _ Select b
[ 0.15275926887989044, -0.28710129857063293, 0.7778833508491516, 0.027631497010588646, -0.30262744426727295, -0.02161879651248455, 0.28581923246383667, -0.4583929777145386, -0.12114743143320084, -0.42893657088279724, -0.5088692307472229, 0.38428953289985657, -0.41980335116386414, 0.412651062...
Dim CsvFile As New StringBuilder CsvFile.AppendLine(CsvHeader()) For Each b As Book In Allbooks CsvFile.AppendLine(bookString(b)) Next 'write the file Response.Write(CsvFile.ToString) Response.End() End Sub Function CsvHeader() As String Dim CsvLine As New
[ 0.11395980417728424, -0.4357749819755554, 0.9149768352508545, -0.30180084705352783, -0.3775585889816284, -0.015138010494410992, 0.3547351360321045, -0.4748956859111786, -0.22584956884384155, -0.27708956599235535, -0.5350240468978882, 0.18925407528877258, -0.5432314276695251, 0.091742090880...
StringBuilder CsvLine.Append("Published,") CsvLine.Append("Title,") CsvLine.Append("Author,") CsvLine.Append("Price") Return CsvLine.ToString End Function Function bookString(ByVal b As Book) As String Dim CsvLine As New StringBuilder CsvLine.Append(b.Published.ToShortDateString + ",") CsvLine.Append(b.Title.Replace(",", "") + ",") CsvLine.Append(b.Author.Replace(",", "") +
[ 0.09095896035432816, -0.06722775101661682, 1.051972508430481, -0.20355501770973206, -0.18964414298534393, 0.136090487241745, 0.08899387717247009, -0.7238583564758301, -0.06855694204568863, -0.09700281918048859, -0.5915256142616272, 0.38251182436943054, -0.428440660238266, 0.151851221919059...
",") CsvLine.Append(Format(b.Price, "c").Replace(",", "")) Return CsvLine.ToString End Function End Class ``` CSV formatting has some gotchas. Have you asked yourself these questions: * Does any of my data have embedded commas? * Does any of my data have embedded double-quotes? * Does any of my data have have newlines? * Do I need to support Unicode strings? I see several problems in your code above. The comma thing first of all... you are stripping commas: ``` CsvLine.Append(Format(b.Price, "c").Replace(",", "")) ``` Why? In CSV, you should be surrounding anything which has commas with quotes: ``` CsvLine.Append(String.Format("\"{0:c}\"", b.Price)) ``` (or something
[ 0.1660323143005371, 0.2580645978450775, 0.6371997594833374, -0.13137270510196686, -0.22360830008983612, -0.20167045295238495, 0.18871834874153137, -0.38382580876350403, -0.12710192799568176, -0.26041364669799805, -0.4689154624938965, 0.568972110748291, -0.4609529376029968, -0.0602426417171...
like that... my VB is not very good). If you're not sure if there are commas, but put quotes around it. If there are quotes in the string, you need to escape them by doubling them. `"` becomes `""`. ``` b.Title.Replace("\"", "\"\"") ``` Then surround this by quotes if you want. If there are newlines in your string, you need to surround the string with quotes... yes, literal newlines *are* allowed in CSV files. It looks weird to humans, but it's all good. A good CSV writer requires some thought. A good CSV reader (parser) is just plain hard (and no, regex not good enough
[ 0.39577004313468933, 0.25351080298423767, 0.4413595497608185, -0.012019996531307697, 0.0960645005106926, -0.3181767761707306, 0.15289756655693054, -0.12121427059173584, -0.28195756673812866, -0.49583303928375244, -0.20550064742565155, 0.3545408546924591, -0.5212652087211609, 0.033732488751...
for parsing CSV... it will only get you about 95% of the way there). And then there is Unicode... or more generally I18N (Internationalization) issues. For example, you are stripping commas out of a formatted price. But that's assuming the price is formatted as you expect it in the US. In France, the number formatting is reversed (periods used instead of commas, and *vice versa*). Bottom line, use culture-agnostic formatting wherever possible. While the issue here is *generating* CSV, inevitably you will need to parse CSV. In .NET, the best parser I have found (for free) is [Fast CSV Reader](http://www.codeproject.com/KB/database/CsvReader.aspx) on [CodeProject](http://www.codeproject.com).
[ 0.17188426852226257, 0.11061921715736389, 0.20160752534866333, 0.18340136110782623, -0.2481670081615448, -0.14664742350578308, 0.11097893118858337, 0.22978872060775757, -0.42939141392707825, -0.7115957736968994, -0.20195958018302917, 0.3862455487251282, -0.11287137120962143, -0.15995468199...
I've actually used it in production code and it is really really fast, and very easy to use!
[ 0.4416694939136505, 0.23883026838302612, -0.13869211077690125, 0.2596060037612915, 0.3514961898326874, -0.16139572858810425, 0.07341159135103226, 0.2814769744873047, 0.21842798590660095, -0.43381422758102417, 0.3090727925300598, 0.4368080496788025, 0.25621509552001953, -0.02902352623641491...
I have been told that there is a performance difference between the following code blocks. ``` foreach (Entity e in entityList) { .... } ``` and ``` for (int i=0; i<entityList.Count; i++) { Entity e = (Entity)entityList[i]; ... } ``` where ``` List<Entity> entityList; ``` I am no CLR expect but from what I can tell they should boil down to basically the same code. Does anybody have concrete (heck, I'd take packed dirt) evidence one way or the other? foreach creates an instance of an enumerator (returned from GetEnumerator) and that enumerator also keeps state throughout the course of the foreach loop. It then repeatedly calls for the Next() object on
[ 0.20636793971061707, 0.2790999114513397, 0.3663908839225769, -0.06306327879428864, 0.06956471502780914, 0.053483571857213974, 0.2449822723865509, -0.38514792919158936, -0.0434747152030468, -0.5832177400588989, -0.18423962593078613, 0.5254566669464111, -0.12075097858905792, 0.25350859761238...
the enumerator and runs your code for each object it returns. They don't boil down to the same code in any way, really, which you'd see if you wrote your own enumerator.
[ 0.3031965494155884, 0.32224124670028687, 0.07156037539243698, 0.37872031331062317, -0.1927090585231781, 0.028578873723745346, 0.1540873795747757, 0.1298510730266571, -0.0585477352142334, -0.44846969842910767, -0.05166398361325264, 0.43708425760269165, -0.25810885429382324, 0.02938207797706...
As a project manager, you are required to organize time so that the project meets a deadline. Is there some sort of equations to use for estimating how long the development will take? let's say the database `time = sql storedprocedures * tables manipulated or something similar` Or are you just stuck having to get the experience to get adequate estimations? There's no set formula out there that I've seen that would really work. Fogbugz has its monte carlo simulator which has somewhat of a concept for this, but really, experience is going to be your best point of reference. Every developer and every project
[ 0.2644149661064148, 0.10934173315763474, -0.06680135428905487, 0.2747189700603485, 0.2243797332048416, -0.2568795084953308, 0.22865337133407593, 0.04008340835571289, -0.3447781801223755, -0.4369509518146515, 0.11288401484489441, 0.6717200875282288, 0.14053133130073547, 0.0869913101196289, ...
will be different!
[ 0.4131630063056946, -0.28880032896995544, 0.24256163835525513, 0.08879329264163971, 0.3621811866760254, -0.1432366967201233, 0.2925611138343811, 0.12932080030441284, -0.13804295659065247, -0.6376477479934692, -0.0005262456834316254, 0.14943425357341766, -0.11826696991920471, -0.00764776673...
We've got an interesting case where we are trying to determine how different instances of our app were launched. Is there any way for .NET to be able to query another running instance and get the command line parameters passed to that instance? I've not been able to find any way to do it in .NET so far, so I thought I'd check here to see if anyone had done anything like this before. You can retrieve this information through WMI. See the [Win32\_Process](http://msdn.microsoft.com/en-us/library/aa394372.aspx) class, in particular its command line property. This [Code Project article](http://www.codeproject.com/KB/cs/EverythingInWmi02.aspx) provides pointers on how to do this,
[ 0.46895113587379456, -0.040940482169389725, 0.04847986623644829, 0.27882346510887146, 0.10126250237226486, 0.04427114501595497, 0.21431060135364532, 0.052941884845495224, -0.3822781443595886, -0.5730172395706177, 0.031830303370952606, 0.4309910833835602, -0.22516536712646484, 0.15049238502...
Comparing string in C# is pretty simple. In fact there are several ways to do it. I have listed some in the block below. What I am curious about are the differences between them and when one should be used over the others? Should one be avoided at all costs? Are there more I haven't listed? ``` string testString = "Test"; string anotherString = "Another"; if (testString.CompareTo(anotherString) == 0) {} if (testString.Equals(anotherString)) {} if (testString == anotherString) {} ``` (Note: I am looking for equality in this example, not less than or greater than but feel free to comment on that as well) Here are the rules for
[ -0.11605661362409592, 0.09389569610357285, 0.15356118977069855, -0.37228408455848694, -0.47592341899871826, 0.01920645870268345, 0.1511058360338211, -0.5179275870323181, 0.18147730827331543, -0.570793628692627, 0.330364465713501, 0.5381381511688232, -0.42621687054634094, -0.130278691649436...
how these functions work: **`stringValue.CompareTo(otherStringValue)`** 1. `null` comes before a string 2. it uses `CultureInfo.CurrentCulture.CompareInfo.Compare`, which means it will use a culture-dependent comparison. This might mean that `ß` will compare equal to `SS` in Germany, or similar **`stringValue.Equals(otherStringValue)`** 1. `null` is not considered equal to anything 2. unless you specify a `StringComparison` option, it will use what looks like a direct ordinal equality check, i.e. `ß` is not the same as `SS`, in any language or culture **`stringValue == otherStringValue`** 1. Is not the same as `stringValue.Equals()`. 2. The `==` operator calls the static `Equals(string a, string b)` method (which in turn goes to an internal `EqualsHelper` to do
[ 0.11530059576034546, -0.015108857303857803, 0.5133130550384521, -0.16926847398281097, -0.1472180336713791, 0.04753994941711426, 0.26365891098976135, -0.2353387176990509, 0.13250967860221863, -0.5655978322029114, -0.04475555941462517, 0.21986503899097443, -0.40833011269569397, 0.17164467275...
the comparison. 3. Calling `.Equals()` on a `null` string gets `null` reference exception, while on `==` does not. **`Object.ReferenceEquals(stringValue, otherStringValue)`** Just checks that references are the same, i.e. it isn't just two strings with the same contents, you're comparing a string object with itself. --- Note that with the options above that use method calls, there are overloads with more options to specify how to compare. My advice if you just want to check for equality is to make up your mind whether you want to use a culture-dependent comparison or not, and then use `.CompareTo` or `.Equals`, depending on the choice.
[ 0.028141658753156662, 0.17098368704319, 0.08382715284824371, 0.09719227254390717, -0.6250465512275696, 0.1699306070804596, 0.2661869525909424, -0.3433389961719513, 0.20788045227527618, -0.7847607731819153, 0.357408732175827, 0.7214174866676331, -0.3933870792388916, 0.06614314019680023, -...
I have the vmware server with this error, anyone knows how to fix it?[VMware Server Error http://soporte.cardinalsystems.com.ar/errorvmwareserver.jpg](http://soporte.cardinalsystems.com.ar/errorvmwareserver.jpg) In the Network Connections on the host PC, you might try repairing the connections that are created by VMWare. Something like "VMWare Network Adapter VMnet1" I'm assuming that the network connections (to a LAN/Internet) are working on the host computer. If not, I'd start by fixing the host first.
[ 0.25657206773757935, 0.2582304775714874, 0.012104340828955173, 0.11679638177156448, -0.12791189551353455, -0.0668201819062233, 0.3313577473163605, 0.3749743700027466, -0.41051924228668213, -0.7538444995880127, 0.016184940934181213, 0.985604465007782, -0.41913095116615295, 0.227361813187599...
I have a databound TextBox in my application like so: (The type of `Height` is `decimal?`) ```xml <TextBox Text="{Binding Height, UpdateSourceTrigger=PropertyChanged, ValidatesOnExceptions=True, Converter={StaticResource NullConverter}}" /> ``` ```cs public class NullableConverter : IValueConverter { public
[ -0.036633823066949844, 0.19749188423156738, 0.5020171999931335, 0.016367919743061066, 0.0031418397556990385, 0.10781574249267578, 0.15737284719944, -0.3247576057910919, -0.2876509726047516, -0.43481066823005676, -0.034360505640506744, 0.368903785943985, -0.06823965162038803, 0.222147405147...
object Convert(object o, Type type, object parameter, CultureInfo culture) { return o; } public object ConvertBack(object o, Type type, object parameter, CultureInfo culture) { if (o as string == null || (o as string).Trim() == string.Empty) return null;
[ -0.07901790738105774, -0.17642715573310852, 0.30799296498298645, -0.33751243352890015, -0.023950286209583282, 0.1807074099779129, 0.30737099051475525, -0.1875905841588974, 0.3491709232330322, -0.549064576625824, -0.35741710662841797, 0.7356685400009155, -0.3985692262649536, 0.2228581160306...
return o; } } ``` Configured this way, any non-empty strings which cannot be converted to decimal result in a validation error which will immediately highlight the textbox. However, the TextBox can still lose focus and remain in an invalid state. What I would like to do is either: 1. Not allow the TextBox to lose focus until it contains a valid value. 2. Revert the value in the TextBox to the last valid value. What is the best way to do this? **Update:** I've found a way to do #2. I don't love it, but it
[ 0.13285337388515472, 0.25744450092315674, 0.31312820315361023, -0.19909006357192993, 0.15427640080451965, -0.1682625412940979, 0.36892494559288025, 0.3031418025493622, 0.0016637940425425768, -0.5527717471122742, -0.16014094650745392, 0.7074396014213562, -0.14651522040367126, 0.010311175137...
works: ``` private void TextBox_LostKeyboardFocus(object sender, RoutedEventArgs e) { var box = sender as TextBox; var binding = box.GetBindingExpression(TextBox.TextProperty); if (binding.HasError) binding.UpdateTarget(); } ``` Does anyone know how to do this better? (Or do #1.) You can force the keyboard focus to stay on the `TextBox` by handling the `PreviewLostKeyBoardFocus` event like this: ```xml <TextBox PreviewLostKeyboardFocus="TextBox_PreviewLostKeyboardFocus" /> ``` ```cs private void TextBox_PreviewLostKeyboardFocus(object sender, KeyboardFocusChangedEventArgs e) { e.Handled = true; } ```
[ 0.13790565729141235, 0.08650124818086624, 0.7247733473777771, -0.27512985467910767, 0.10066568851470947, -0.11572752147912979, 0.48758795857429504, -0.587605357170105, -0.26119691133499146, -0.7835193872451782, -0.3482941687107086, 0.6962185502052307, -0.35713574290275574, 0.02448816038668...
As an exercise for myself, I was translating a sample program into various languages. Starting in C#, I had a visitor-pattern interface like so: ``` interface Visitor { void Accept(Bedroom x); void Accept(Bathroom x); void Accept(Kitchen x); void Accept(LivingRoom x); } ``` Moving to ruby (or python, or whatever), I no longer get dispatch from the compiler based on type. Should I do the dispatch in the visitor itself? ``` class Cleaner
[ 0.14675988256931305, 0.10712534189224243, 0.24070535600185394, -0.2569766640663147, -0.16828252375125885, 0.16915860772132874, 0.4674835801124573, -0.006460584234446287, -0.20097258687019348, -0.8264042139053345, -0.14941442012786865, 0.2850533723831177, -0.5062173008918762, 0.385025888681...
def accept(x) acceptBedroom(x) if Bedroom === x acceptBathroom(x) if Bathroom === x acceptKitchen(x) if Kitchen===x acceptLivingRoom(x) if LivingRoom===x end ... ``` Or should I do the dispatch in the different specializaions of the room: ``` class Bathroom<Room def initialize(name) super(name) end def accept(visitor) visitor.acceptBathroom(self) end end ``` Or is there another preferred idiom that is used in dynamic languages? You can force the keyboard focus to stay on the `TextBox` by handling the `PreviewLostKeyBoardFocus` event like this: ```xml <TextBox PreviewLostKeyboardFocus="TextBox_PreviewLostKeyboardFocus"
[ -0.25163647532463074, 0.05498659238219261, 0.5685851573944092, -0.4016788899898529, -0.16224683821201324, 0.021615901961922646, 0.38453105092048645, -0.5954933166503906, 0.03567778691649437, -0.5629771947860718, -0.35296541452407837, 0.36511164903640747, -0.2511895000934601, 0.322063088417...
/> ``` ```cs private void TextBox_PreviewLostKeyboardFocus(object sender, KeyboardFocusChangedEventArgs e) { e.Handled = true; } ```
[ 0.01725987158715725, 0.05308155342936516, 0.4308011829853058, -0.18179461359977722, 0.013787460513412952, 0.08754169940948486, 0.4469052255153656, 0.1921662986278534, -0.03376929834485054, -0.676339328289032, -0.3759104907512665, 0.46764856576919556, -0.23568381369113922, 0.094846598803997...
I'm trying to be better about unit testing my code, but right now I'm writing a lot of code that deals with remote systems. SNMP, WMI, that sort of thing. With most classes I can mock up objects to test them, but how do you deal with unit testing a real system? For example, if my class goes out and gets the Win32\_LogicalDisk object for a server, how could I possibly unit test it? Assuming you meant "How do I test against things that are hard/impossible to mock": If you have a class that "goes out and gets the Win32\_LogicalDisk object for
[ 0.427773654460907, 0.029699118807911873, -0.3693884611129761, 0.2674676477909088, -0.27458879351615906, 0.003144887974485755, 0.4349837601184845, 0.04636738449335098, -0.24659177660942078, -0.5736223459243774, 0.21196304261684418, 0.476776123046875, -0.011511911638081074, 0.155608266592025...
a server" AND does something else (consumes the 'Win32\_LogicalDisk' object in some way), assuming you want to test the pieces of the class that consume this object, you can use [Dependency Injection](http://en.wikipedia.org/wiki/Dependency_injection) to allow you to mock the 'Win32\_LogicalDisk' object. For instance: ``` class LogicalDiskConsumer(object): def __init__(self, arg1, arg2, LogicalDiskFactory) self.arg1=arg1 self.arg2=arg2 self.LogicalDisk=LogicalDiskFactory() def consumedisk(self): self.LogicalDisk.someaction() ``` Then in your unit test code, pass in a 'LogicalDiskFactory' that returns a
[ 0.13071595132350922, 0.02358515001833439, 0.28816038370132446, -0.1139347031712532, -0.20110125839710236, -0.0768347978591919, 0.31499528884887695, -0.07454229146242142, -0.008791936561465263, -0.7371920347213745, 0.04305471107363701, 0.4565303325653076, -0.4620237648487091, 0.229440316557...
mock object for the 'Win32\_LogicalDisk'.
[ -0.5080941915512085, 0.16574470698833466, 0.025048939511179924, 0.2668647766113281, -0.02185208722949028, -0.06753422319889069, 0.36280593276023865, 0.2633233368396759, -0.033958643674850464, -0.26412343978881836, -0.04099418595433235, 0.2374933660030365, -0.370625376701355, 0.042781364172...
I like putting shortcuts of the form "g - google.lnk" in my start menu so google is two keystrokes away. Win, g. My eight or so most frequent applications go there. I also make links to my solution files I am always opening "x - Popular Project.lnk" Are there any better ways to automate opening frequently used applications? [AutoHotkey](http://www.autohotkey.com/) is a reasonably good program for implementing windows key shortcuts. You might instead define WIN + G to be "open browser to google" which gives you a better response time (don't have to wait for start menu to popup, etc) There are macro programs that change
[ -0.08356311917304993, 0.14328551292419434, 0.4358282685279846, 0.0007965380209498107, -0.3173755407333374, 0.08066681027412415, 0.21443964540958405, 0.34571659564971924, -0.4932711124420166, -0.624594509601593, -0.09208700805902481, 0.6276375651359558, -0.2833020091056824, -0.1064463183283...
the macros used based on the window that's in focus. I've never needed that much control, but you might want to look into that. -Adam
[ 0.6055325865745544, -0.1886652261018753, 0.08840057253837585, 0.07006306201219559, 0.29972976446151733, 0.18627621233463287, -0.30021998286247253, 0.5226144790649414, -0.4378664195537567, -0.7206827402114868, -0.1265440583229065, 0.6555410623550415, -0.0356595404446125, -0.1183056756854057...
I am looking for a method of reading emails using Pop3 in C# 2.0. Currently, I am using code found in [CodeProject](http://www.codeproject.com/KB/IP/Pop3MimeClient.aspx?fid=341657). However, this solution is less than ideal. The biggest problem is that it doesn't support emails written in unicode. I've successfully used [OpenPop.NET](http://sourceforge.net/projects/hpop/) to access emails via POP3.
[ 0.18761348724365234, 0.28013530373573303, 0.20154868066310883, 0.14778664708137512, -0.11785614490509033, 0.03478441387414932, 0.2940833270549774, 0.39750972390174866, -0.32687681913375854, -0.5365994572639465, -0.10481980443000793, 0.04986042156815529, -0.16008277237415314, -0.04466547444...
I would like to generate a random floating point number between 2 values. What is the best way to do this in C#? The only thing I'd add to [Eric](https://stackoverflow.com/questions/44408/how-do-you-generate-a-random-number-in-c#44428)'s response is an explanation; I feel that knowledge of why code works is better than knowing what code works. The explanation is this: let's say you want a number between 2.5 and 4.5. The range is 2.0 (4.5 - 2.5). `NextDouble` only returns a number between 0 and 1.0, but if you multiply this by the range you will get a number between 0 and *range*. So, this would give us random doubles
[ 0.3579965829849243, -0.0003281951358076185, 0.06187228485941887, -0.01747426763176918, -0.08091606199741364, -0.05689948424696922, -0.22029976546764374, -0.32352280616760254, -0.16558335721492767, -0.2609674632549286, 0.2543877363204956, 0.28194519877433777, -0.26046013832092285, 0.1007940...
between 0.0 and 2.0: ``` rng.NextDouble() * 2.0 ``` But, we want them between 2.5 and 4.5! How do we do this? Add the smallest number, 2.5: ``` 2.5 + rng.NextDouble() * 2.0 ``` Now, we get a number between 0.0 and 2.0; if you add 2.5 to each of these values we see that the range is now between 2.5 and 4.5. At first I thought that it mattered if b > a or a > b, but if you work it out both ways you'll find it works out identically so long as you don't mess up the order of the variables used. I like to express
[ -0.07903532683849335, -0.167962908744812, 0.44448477029800415, -0.463669091463089, 0.07817868143320084, 0.24536694586277008, 0.1106412410736084, -0.4039730429649353, -0.2801632285118103, -0.6596594452857971, 0.018890557810664177, 0.4672364890575409, 0.07929820567369461, 0.08311507105827332...
it with longer variable names so I don't get mixed up: ``` double NextDouble(Random rng, double min, double max) { return min + (rng.NextDouble() * (max - min)); } ```
[ -0.2501803934574127, -0.5861073136329651, 0.29176706075668335, -0.15945711731910706, 0.22793540358543396, 0.1777888387441635, -0.036987967789173126, 0.06145143881440163, -0.058669302612543106, -0.4396929144859314, -0.0992303192615509, 0.45741206407546997, 0.06402242183685303, 0.09361547231...
Given a small set of entities (say, 10 or fewer) to insert, delete, or update in an application, what is the best way to perform the necessary database operations? Should multiple queries be issued, one for each entity to be affected? Or should some sort of XML construct that can be parsed by the database engine be used, so that only one command needs to be issued? I ask this because a common pattern at my current shop seems to be to format up an XML document containing all the changes, then send that string to the database to be processed
[ 0.31631791591644287, 0.09036324918270111, 0.2630944848060608, 0.17388975620269775, 0.22222551703453064, -0.013773002661764622, -0.05111001059412956, -0.3037078380584717, -0.3470768928527832, -0.5269082188606262, -0.06671207398176193, 0.4961215555667877, -0.2071685492992401, -0.214628443121...
by the database engine's XML functionality. However, using XML in this way seems rather cumbersome given the simple nature of the task to be performed. It depends on how many you need to do, and how fast the operations need to run. If it's only a few, then doing them one at a time with whatever mechanism you have for doing single operations will work fine. If you need to do thousands or more, and it needs to run quickly, you should re-use the connection and command, changing the arguments for the parameters to the query during each iteration. This will minimize
[ 0.5385034084320068, 0.19422529637813568, 0.2469048798084259, 0.4066551923751831, 0.13554181158542633, -0.2337515950202942, 0.02228681743144989, -0.2331078201532364, -0.29343438148498535, -0.37046048045158386, -0.08896686136722565, 0.4096101224422455, -0.2359919548034668, -0.147024452686309...
resource usage. You don't want to re-create the connection and command for each operation.
[ 0.14872753620147705, 0.058956511318683624, -0.1560070961713791, 0.35396331548690796, 0.07642021775245667, 0.11493068188428879, 0.07719676196575165, 0.03552486002445221, -0.3476066589355469, -0.8960780501365662, -0.011573130264878273, 0.7593733668327332, -0.16805002093315125, 0.078402593731...
I'm trying to convert a multipage color tiff file to a c# CompressionCCITT3 tiff in C#. I realize that I need to make sure that all pixels are 1 bit. I have not found a useful example of this online. You need this conversion as CCITT3 and CCITT4 don't support color (if I remember right).
[ 0.35593441128730774, -0.028447473421692848, 0.31389477849006653, -0.030160631984472275, -0.08812996000051498, -0.03823234140872955, 0.0643162876367569, -0.13058388233184814, -0.09463382512331009, -0.8942723274230957, 0.0516730397939682, 0.3981779217720032, -0.3399924337863922, 0.1788040995...
Are there any tools that will spider an asp.net website and create a static site? <http://www.httrack.com/> Have used for this purpose a few times, may need to do a little tidying up of urls, and some css linked images might not make it, depends on how good a job you want to do. If you have dreamweaver, you can use that to manage the links if you need to clean up the file names afterwards. Optionally use the link checker extension for firefox to check it all afterwards.
[ 0.52052241563797, -0.29953521490097046, 0.038105688989162445, 0.3740951418876648, -0.05543085187673569, -0.37053197622299194, 0.25591832399368286, 0.3137512505054474, -0.5694823265075684, -0.7165266275405884, 0.02954545058310032, 0.41409963369369507, -0.40200600028038025, 0.028803408145904...
As [Jeff Atwood asked](https://blog.stackoverflow.com/2008/09/podcast-20/): "What’s your logging philosophy? Should all code be littered with `.logthis()` and `.logthat()` calls? Or do you inject logging after the fact somehow?" My logging philosophy is pretty easily summarized in four parts: Auditing, or business logic logging > Log those things that are required to be logged. This comes from the application requirements, and may include logging every change made to any database (as in many financial applications) or logging accesses to data (as may be required in the health industry to meet industry regulations) > > > As this is part of the program requirements many do not
[ 0.7314853668212891, 0.37986594438552856, -0.02099958248436451, -0.04365421459078789, 0.15690553188323975, -0.3072640597820282, 0.19477565586566925, -0.24335041642189026, -0.30799248814582825, -0.10807396471500397, 0.1456451416015625, 0.8968605399131775, -0.26320934295654297, -0.13518305122...
include it in their general discussions of logging, however there is overlap in these areas, and for some applications it is useful to consider all logging activities together. Program logging > Messages which will help developers test and debug the application, and more easily follow the data flow and program logic to understand where implementation, integration, and other errors may exist. > > > In general this logging is turned on and off as needed for debugging sessions. Performance logging > Add later logging as needed to find and resolve performance bottlenecks and other program issues which aren't causing the program to fail, but will
[ 0.6126248836517334, -0.0010661652777343988, 0.2982677221298218, 0.08101394027471542, -0.09048569947481155, -0.4276975393295288, 0.4025481045246124, -0.17267289757728577, -0.337891161441803, -0.523188054561615, -0.36115607619285583, 0.7108535766601562, -0.20378799736499786, -0.3683098554611...
lead to better operation. Overlaps with Program logging in the case of memory leaks and some non-critical errors. Security logging > Logging user actions and interactions with external systems where security is a concern. Useful for determining how an attacker broke a system after an attack, but may also tie into an intrusion detection system to detect new or ongoing attacks.
[ 0.34652963280677795, -0.05057157576084137, 0.0314941368997097, 0.26454633474349976, -0.04585718363523483, -0.33960795402526855, 0.4580579698085785, -0.2695971131324768, -0.5276204347610474, -0.2903056740760803, -0.10148061066865921, 0.4844420254230499, -0.15363547205924988, -0.297311842441...
I have never used octal numbers in my code nor come across any code that used it (hexadecimal and bit twiddling notwithstanding). I started programming in C/C++ about 1994 so maybe I'm too young for this? Does older code use octal? C includes support for these by prepending a 0, but where is the code that uses these base 8 number literals? I recently had to write network protocol code that accesses 3-bit fields. Octal comes in handy when you want to debug that. Just for effect, can you tell me what the 3-bit fields of this are? ``` 0x492492 ``` On the other hand, this
[ 0.06280021369457245, 0.2759866416454315, 0.25747305154800415, -0.15357474982738495, -0.19190648198127747, -0.2824133336544037, 0.14084239304065704, 0.08569969236850739, -0.19342826306819916, -0.17289818823337555, 0.12891896069049835, 0.5160028338432312, -0.34371137619018555, -0.23369070887...
same number in octal: ``` 022222222 ``` Now, finally, in binary (in groups of 3): ``` 010 010 010 010 010 010 010 010 ```
[ -0.3763698935508728, 0.09051438421010971, 0.09280683845281601, -0.26633092761039734, -0.23066754639148712, 0.42625880241394043, 0.13760101795196533, -0.14239461719989777, -0.4607326090335846, -0.48004037141799927, -0.15570907294750214, 0.06783626228570938, -0.19164490699768066, -0.04606710...
My current place of employment is currently in a transition, new ownership has taken over, things are finally getting standardized and proper guidelines are being enforced. But we are still using VSS, there really isn't any reason for using it other then that's what whats initially setup. We don't use Visual Studio, or any tool really that specifically requires it. What would be the absolute best argument I can bring up to help convince them that going to something like Subversion would be a much better solution, in the long run. VSS totally relies on the clients to manage the database.
[ 1.047896146774292, -0.050614990293979645, 0.044173914939165115, 0.06175032630562782, 0.10297094285488129, -0.16628824174404144, 0.17867974936962128, 0.38767102360725403, -0.09860362112522125, -0.47243884205818176, 0.22816826403141022, 0.38323312997817993, 0.05658521130681038, 0.07343808561...
If a client drops connection in the middle of a write over the network at just the wrong time, your file is trashed on the server. Not just the tip, but all the history. Hope you have a good backup. I've been through it. It's bad news. VSS usage over VPN or other remote connections is abysmal. It's using SMB to transfer the data, and you have to retrieve the file and all of its deltas just to get the tip. Nasty. I've seen VSS start to act up at 1GB of data. Database errors, etc. MS (somewhere in a FAQ or
[ 0.5859445929527283, 0.10107682645320892, 0.32456687092781067, 0.13092240691184998, 0.10603310912847519, -0.3285815119743347, 0.17846529185771942, 0.17712274193763733, -0.655368447303772, -0.5368672609329224, 0.12655417621135712, 0.24757744371891022, -0.2777160406112671, 0.30339354276657104...
KB) says that 2GB is really the max safe limit. There are no good management tools (the clients run the asylum), so you don't really get any warning about this. *Anything* with a server process to provide some level of transactions and integrity control is a superior solution.
[ 0.10407879948616028, 0.1596110314130783, 0.24822814762592316, 0.38712409138679504, 0.014631291851401329, -0.13807952404022217, 0.3267047703266144, -0.10592715442180634, -0.39952632784843445, -0.24640467762947083, -0.018243683502078056, 0.2292931228876114, -0.24362003803253174, 0.2626328468...
I would like to be able to add a "message" to a unit test, such that it actually appears within the TestResult.xml file generated by NUnit. For example, this is currently generated: ``` <results> <test-case name="MyNamespace.Tests.MyTest" executed="True" success="True" time="0.203" asserts="4" /> </results> ``` I would like to be able to have an additional attribute (or node as the case may be), such as: ``` <results> <test-case name="MyNamespace.Tests.MyTest" executed="True" success="True" time="0.203" asserts="4" message="Tested that some condition was met." /> </results> ``` The idea is that "message" above would somehow be defined within the test method itself (in my case, generated at run-time). Is there a
[ 0.5490554571151733, -0.057905104011297226, 0.2967973053455353, 0.04341845586895943, 0.018718747422099113, -0.06548047065734863, 0.28174248337745667, -0.24310630559921265, 0.03128323704004288, -0.5000793933868408, -0.00606798380613327, 0.288654088973999, 0.10418999940156937, 0.1037152409553...
property somewhere that I'm missing to be able to do something like this? This may be missing the point, but how about naming the tests so they indicate what they test - then you may not even need the message. If it proves to be absolutely necessary, I think you'll need to produce your own testrunner that would (off the top of my head) read an additional attribute off the TestCase and attach it to the output.
[ 0.808823823928833, -0.04217350482940674, -0.0907907783985138, 0.47050896286964417, -0.2650953531265259, -0.1297677755355835, 0.006285367999225855, -0.3376922607421875, 0.1669902205467224, -0.4668005406856537, 0.3439246118068695, 0.4754824936389923, 0.031163835898041725, 0.09022616595029831...
At my day job we have load balanced web servers which talk to load balanced app servers via web services (and lately WCF). At any given time, we have 4-6 different teams that have the ability to add new web sites or services or consume existing services. We probably have about 20-30 different web applications and corresponding services. Unfortunately, given that we have no centralized control over this due to competing priorities, org structures, project timelines, financial buckets, etc., it is quite a mess. We have a variety of services that are reused, but a bunch that are specific to a
[ 0.5693786144256592, 0.0955042615532875, 0.39620646834373474, 0.004159805830568075, 0.08428611606359482, 0.26642605662345886, 0.11915164440870285, 0.021834325045347214, -0.19225141406059265, -0.8546346426010132, -0.015700671821832657, 0.4407563805580139, -0.11374087631702423, -0.12078048288...
front-end. Ideally we would have better control over this situation, and we are trying to get control over it, but that is taking a while. One thing we would like to do is find out more about what all of the inter-relationships between web sites and the app servers. I have used Reflector to find dependencies among assemblies, but would like to be able to see the traffic patterns between services. What are the options for trying to map out web service relationships? For the most part, we are mainly talking about internal services (web to app, app to app, batch to
[ 0.5267240405082703, 0.1927454024553299, 0.3228462040424347, 0.04801636189222336, 0.05177924782037735, 0.2953011095523834, 0.20744885504245758, -0.07874906808137894, -0.4354161024093628, -0.6967284679412842, -0.005672444589436054, 0.3921535611152649, -0.2555893063545227, 0.0293328445404768,...