text stringlengths 0 30.5k | title stringclasses 1
value | embeddings listlengths 768 768 |
|---|---|---|
understanding correct?
There are lots of implementations of monads in dynamically typed languages:
* [The Maybe Monad in Ruby](http://Blog.PreTheory.Com/arch/2008/02/the_maybe_monad_in_ruby.php)
* [OO Monads and Ruby](http://CWilliams.TextDriven.Com/pages/monads) (site is down, but the article [is available in the Int... | [
0.04061874747276306,
0.1550339162349701,
0.32534196972846985,
0.06596476584672928,
-0.3874543309211731,
0.11307170987129211,
0.29608991742134094,
0.007597055286169052,
-0.027459753677248955,
-0.38769620656967163,
-0.16522246599197388,
0.6671198010444641,
-0.4092736840248108,
0.008931022137... | |
everything that can be done in *one* language can also be done in *every other* language.
As you can probably tell from the selection of examples above, I am (mostly) a Ruby programmer. So, just as a joke, I took one of the examples above and re-implemented it in a language that I know *absolutely nothing* about, that... | [
0.5439708828926086,
0.35410207509994507,
-0.4228466749191284,
-0.029238544404506683,
0.02956363558769226,
-0.12759268283843994,
0.6423938870429993,
0.28127944469451904,
-0.16084128618240356,
-0.4532151222229004,
-0.14655715227127075,
0.45982494950294495,
-0.2958315908908844,
-0.21893835067... | |
PHP:
```
<?php
class Identity {
protected $val;
public function __construct($val) { $this->val = $val; }
public static function m_return($a) { return new Identity($a); }
public static function m_bind($id_a, $f) { return $f($id_a->val); }
}
var_dump(Identity::m_bind(
Identity::m_return(1), function ($x) {
... | [
-0.0881311222910881,
0.07418227195739746,
0.2585490942001343,
-0.07369127124547958,
-0.35157856345176697,
0.08497241139411926,
0.24054890871047974,
-0.18078067898750305,
-0.17138731479644775,
-0.28501904010772705,
-0.26377055048942566,
0.4158787429332733,
-0.5160566568374634,
0.16310924291... | |
implementing monad should be type-checked statically. Otherwise, type errors cannot be found during compilation and "Complexity" is not controlled. Is my understanding correct?
You are right, but this has nothing to do with monads. This is just about static type checking in general, and applies equally well to arrays,... | [
0.3892093300819397,
0.10058610886335373,
-0.4539452791213989,
0.03769160062074661,
-0.31023886799812317,
-0.4083127975463867,
0.3526238799095154,
0.05039357766509056,
-0.1439889520406723,
-0.558252215385437,
0.07249078899621964,
0.4342435598373413,
-0.5826138257980347,
-0.24232354760169983... | |
the ugly truth is: C#'s, Java's and C's type systems aren't actually powerful enough to express the type of `Monad`. In particular, `Monad` is a rank-2 polymorphic type, but C# and Java only support rank-1 polymorphism (they call it "generics", but it's the same thing) and C doesn't support even that.
So, monads are i... | [
0.2914403975009918,
0.1821499913930893,
-0.006360793486237526,
0.2685762941837311,
-0.40216389298439026,
-0.2632274627685547,
0.3483971953392029,
0.2643340528011322,
-0.18107172846794128,
-0.641453206539154,
0.005079471040517092,
0.29979801177978516,
-0.5057939291000366,
0.2088933587074279... | |
the implementation much more complex, without actually helping. It requires a much more sophisticated type system such as Haskell's, to get actual type-safety for monads.
Note: what I wrote above *only* applies to the generic `monad` type itself, as @Porges points out. You can certainly express the type of any *specif... | [
0.16192682087421417,
-0.10242154449224472,
-0.1483815759420395,
0.10342376679182053,
-0.24298101663589478,
-0.2852329909801483,
0.4776831269264221,
-0.0066575524397194386,
-0.12594138085842133,
-0.681066632270813,
0.08364005386829376,
0.48350369930267334,
-0.49395233392715454,
0.0482247807... | |
addition to conforming to the monad *type* is probably too much even for Haskell's type system. You'd probably need dependent types and maybe even a full-blown automatic theorem prover for that.) | [
0.09978395700454712,
0.028730660676956177,
-0.03310007229447365,
0.2609838545322418,
-0.12368790060281754,
0.03033253364264965,
0.5597673058509827,
0.08431372791528702,
0.00383630464784801,
-0.21130278706550598,
0.0654340609908104,
0.5203118324279785,
-0.5340254902839661,
-0.16101303696632... | |
I have a table where each row has a few fields that have ID's that relate to some other data from some other tables.
Let's say it's called `people`, and each person has the ID of a `city`, `state` and `country`.
So there will be three more tables, `cities`, `states` and `countries` where each has an ID and a name.
W... | [
0.4012392461299896,
0.03520241007208824,
0.4336478114128113,
0.4305521845817566,
-0.11630938947200775,
0.3566460907459259,
-0.21950632333755493,
-0.018862590193748474,
-0.2760865092277527,
-0.8576508164405823,
0.04732850566506386,
-0.14799518883228302,
-0.15968436002731323,
0.2600019276142... | |
hard to read, and I'm wondering if there is a cleaner way. It should also be possible for the person to have those fields empty.
Assuming the following tables:
```
create table People
(
ID int not null primary key auto_increment
,FullName varchar(255) not null
,StateID int
,Country... | [
0.14295151829719543,
0.09369717538356781,
0.21661755442619324,
0.03673270717263222,
0.2604713439941406,
-0.075816310942173,
0.2764187455177307,
-0.13621139526367188,
-0.2871115803718567,
-0.8558971285820007,
-0.2312593013048172,
0.15235675871372223,
-0.3816823363304138,
0.31731554865837097... | |
not null primary key auto_increment
,Name varchar(255) not null
)
;
create table Countries
(
ID int not null primary key auto_increment
,Name varchar(255) not null
)
;
create table Cities
(
ID int not null primary key auto_increment
,Name varchar(255) not null
)
;
```
With ... | [
0.0825558453798294,
0.10804901272058487,
0.4654330611228943,
0.5688482522964478,
0.06417805701494217,
0.10661507397890091,
0.08886057883501053,
-0.2450120896100998,
-0.21339915692806244,
-0.36537861824035645,
-0.384266197681427,
-0.09346191585063934,
-0.46789878606796265,
0.362061798572540... | |
values ('Country 1'),('Country 2'),('Country 3');
insert into People(FullName,CityID,StateID,CountryID) values ('Has Nothing' ,null,null,null);
insert into People(FullName,CityID,StateID,CountryID) values ('Has City' , 1,null,null);
insert into People(FullName,CityID,StateID,CountryID) values ('Has State' ... | [
0.06669759750366211,
0.05979380011558533,
0.5704951286315918,
0.1811147779226303,
0.29083970189094543,
0.17271259427070618,
0.060285069048404694,
-0.23489497601985931,
-0.2725396752357483,
-0.8082475066184998,
-0.4773312211036682,
0.2051135003566742,
-0.15551955997943878,
0.107624195516109... | |
on St.ID = P.StateID
left Join Countries Co on Co.ID = P.CountryID
``` | [
0.12650272250175476,
0.21363532543182373,
0.42607593536376953,
0.06139982491731644,
0.21554192900657654,
0.0951189324259758,
0.010495719499886036,
0.2634483575820923,
-0.6011004447937012,
-0.47282567620277405,
-0.5560829043388367,
-0.3345906734466553,
-0.4068768620491028,
0.480910301208496... | |
I was looking a lot for method to get parent process in .NET, but found only P/Invoke way.
This code provides a nice interface for finding the Parent process object and takes into account the possibility of multiple processes with the same name:
Usage:
```
Console.WriteLine("ParentPid: " + Process.GetProcessById(697... | [
0.004684447310864925,
0.0071885716170072556,
0.6000117063522339,
-0.18421901762485504,
0.317230224609375,
0.167460098862648,
0.1375110149383545,
-0.19010259211063385,
-0.29198208451271057,
-0.7842332124710083,
0.009396645240485668,
0.34170398116111755,
-0.11091522127389908,
0.7156838178634... | |
(var index = 0; index < processesByName.Length; index++) {
processIndexdName = index == 0 ? processName : processName + "#" + index;
var processId = new PerformanceCounter("Process", "ID Process", processIndexdName);
if ((int) processId.NextValue() == pid) {
return pr... | [
-0.1323321908712387,
-0.6070619821548462,
0.576302170753479,
-0.14886249601840973,
0.3421109616756439,
0.3207195997238159,
0.3340115547180176,
-0.5833013653755188,
-0.06861527264118195,
-0.7624958157539368,
-0.14532868564128876,
0.44499796628952026,
0.12223134189844131,
0.6088441014289856,... | |
}
return processIndexdName;
}
private static Process FindPidFromIndexedProcessName(string indexedProcessName) {
var parentId = new PerformanceCounter("Process", "Creating Process ID", indexedProcessName);
return Process.GetProcessById((int) parentId.NextValue());
}
public stat... | [
-0.2618083655834198,
-0.27252402901649475,
0.538989245891571,
0.023296432569622993,
0.3920932710170746,
0.30293017625808716,
0.21038055419921875,
-0.07657670974731445,
-0.09869194030761719,
-0.9260515570640564,
-0.24827232956886292,
0.4783569574356079,
-0.04687998443841934,
0.8126360177993... | |
the two bits of SQL below get the same result
```
SELECT c.name, o.product
FROM customer c, order o
WHERE c.id = o.cust_id
AND o.value = 150
SELECT c.name, o.product
FROM customer c
INNER JOIN order o on c.id = o.cust_id
WHERE o.value = 150
```
I've seen both styles used as standard at different compa... | [
0.22286896407604218,
0.15080362558364868,
0.30507224798202515,
-0.11502020806074142,
-0.20315803587436676,
0.27181828022003174,
-0.24715138971805573,
-0.17763830721378326,
-0.016346994787454605,
-0.4149099886417389,
-0.08368641883134842,
0.6065035462379456,
-0.07845746725797653,
0.17837256... | |
first style, whereas Microsoft SQL Server users have tended to use the second, but that might just be a coincidence.
Thanks for any insight, I've wondered about this for a while.
Edit: I've changed the title from 'SQL Inner Join versus Cartesian Product' as I was using the incorrect terminlogy. Thanks for all the res... | [
0.24089999496936798,
-0.14364121854305267,
0.31871262192726135,
-0.18172018229961395,
-0.369754433631897,
-0.3648345470428467,
0.08300717920064926,
0.04224739223718643,
-0.09640385210514069,
-0.5233326554298401,
-0.14678947627544403,
0.4663406014442444,
-0.3884715139865875,
-0.144031733274... | |
before then).
The use of the JOIN syntax is strongly preferred as it separates the join logic from the filtering logic in the WHERE clause. Whilst the JOIN syntax is really syntactic sugar for inner joins it's strength lies with outer joins where the old \* syntax can produce situations where it is impossible to unamb... | [
-0.36312928795814514,
-0.22495320439338684,
0.3045276999473572,
-0.08003342896699905,
-0.21046015620231628,
-0.036630768328905106,
0.41355064511299133,
-0.08542966842651367,
0.05331288278102875,
-0.5725651979446411,
-0.22491544485092163,
0.12081131339073181,
-0.5277360677719116,
-0.2013405... | |
either
```
SELECT c.name, o.product
FROM customer c, order o
WHERE o.value = 150
```
or
```
SELECT c.name, o.product
FROM customer c CROSS JOIN order o
WHERE o.value = 150
``` | [
0.09809507429599762,
0.3995320498943329,
0.21464718878269196,
-0.2278115153312683,
0.1704872101545334,
0.8834779262542725,
-0.23554903268814087,
0.07715824991464615,
-0.030803360044956207,
-0.2820751368999481,
-0.491643488407135,
0.2964566946029663,
0.11098514497280121,
0.4523632526397705,... | |
I have the following scenario
I have a main form as MDI parent and MDI child form, the child form shows a new form (I called it mydialog).
I want to access specific function in the MDI child form from mydialog so I tried to set the Owner property in the mydialog object but exception occured (circular reference excepti... | [
0.2622910737991333,
0.17308855056762695,
0.5699480175971985,
-0.004864495247602463,
0.04038010165095329,
0.21085691452026367,
0.11658621579408646,
-0.09511687606573105,
0.10793782025575638,
-0.7123180031776428,
0.17306241393089294,
0.3492765724658966,
-0.28983011841773987,
0.49308434128761... | |
of mydialog
> > so I tried to set the Owner property in the mydialog object but exception occured (circular reference exception)
There should be no exception when setting the Owner property. Can you paste the exception ? Also could you paste your code that sets this value ? Have you set other properties like MDIParent... | [
0.18969255685806274,
0.10228205472230911,
0.6155976057052612,
-0.021802779287099838,
-0.04400459676980972,
0.15578071773052216,
0.08985041826963425,
-0.2510715126991272,
0.03781069070100784,
-0.8796537518501282,
0.12923282384872437,
0.2391139268875122,
-0.6551290154457092,
-0.0285172443836... | |
I came across [this](http://www.cs.umd.edu/%7Epugh/java/memoryModel/DoubleCheckedLocking.html) article discussing why the double-check locking paradigm is broken in Java. Is the paradigm valid for .NET (in particular, C#), if variables are declared `volatile`?
[Implementing the Singleton Pattern in C#](https://csharpin... | [
-0.002029348397627473,
-0.0888257846236229,
-0.050067365169525146,
-0.04606150835752487,
-0.10138408839702606,
-0.3672773540019989,
0.3197609782218933,
-0.1319734901189804,
-0.40386253595352173,
-0.11214254051446915,
-0.005262588616460562,
0.5407037138938904,
-0.4424663484096527,
0.0113366... | |
than other strategies and thus should not be used. | [
-0.012346883304417133,
-0.16827845573425293,
-0.025327546522021294,
0.242475226521492,
0.2446528822183609,
-0.16568824648857117,
0.30282899737358093,
-0.20088547468185425,
0.00967708695679903,
-0.763924241065979,
-0.09852855652570724,
0.5914692878723145,
-0.1011071652173996,
-0.07296429574... | |
I am writing a (very small) framework for checking pre- and postconditions of methods. Entry points are (they could be easily be methods; that doesn't matter):
```
public static class Ensures {
public static Validation That {
get { ... }
}
}
public static class Requires {
public static Validation ... | [
0.22890420258045197,
0.25139230489730835,
0.046188995242118835,
0.1776508390903473,
-0.060210444033145905,
-0.13356685638427734,
0.26788395643234253,
-0.3026597499847412,
0.11404222249984741,
-0.4017407298088074,
-0.011957865208387375,
0.42555925250053406,
-0.3468732535839081,
-0.011582789... | |
which works like this:
```
public static class Ensures {
[ConditionalCallingCode("DEBUG")]
public static Validation ThatDuringDebug {
get { ... }
}
}
```
where `ConditionalCallingCodeAttribute` means that this method should only run when the calling code is compiled with the DEBUG symbol defined.... | [
0.3955143690109253,
0.17858289182186127,
0.42305365204811096,
-0.2928473651409149,
0.12225941568613052,
-0.19019044935703278,
0.28265491127967834,
-0.3080599308013916,
-0.10418224334716797,
-0.17825639247894287,
-0.07194302976131439,
0.7088116407394409,
-0.4628766179084778,
-0.118726417422... | |
.IsNotNull(result)
.IsInRange(result, 0, 100);
Ensures.WhileDebuggingThat // only do these checks in debug mode
.IsPositive(ExpensiveCalculation(result));
return result;
}
}
```
Of course, I can simply not provide WhileDebuggingThat. Then the client code would look like t... | [
0.1707879602909088,
0.12424095720052719,
0.6499385833740234,
-0.4973785877227783,
0.3834723234176636,
0.055761098861694336,
0.4547192454338074,
-0.3591635525226593,
0.005669967271387577,
-0.26623982191085815,
-0.013418003916740417,
0.7150760889053345,
-0.3845458924770355,
0.103271029889583... | |
do some work
Ensures.That // do these checks always
.IsNotNull(result)
.IsInRange(result, 0, 100);
#ifdef DEBUG
Ensures.That // only do these checks in debug mode
.IsPositive(ExpensiveCalculation(result));
#endif
return result;
}
}
```
... | [
0.4631202816963196,
-0.11052633821964264,
0.23842203617095947,
-0.19152918457984924,
0.5095694065093994,
-0.3607505261898041,
0.58521968126297,
-0.42247331142425537,
0.2006295621395111,
-0.2518492043018341,
-0.2405472695827484,
0.79910808801651,
-0.32333165407180786,
-0.2889709174633026,
... | |
is the fallback plan if nothing else works out, but it breaks DRY really badly.
As I understand it, marking `WhileDebuggingThat` with `[Conditional("DEBUG")]` will emit (or not) this method depending on whether DEBUG is defined during the compilation of the library, *not* of the assemblies which reference this library... | [
0.29697462916374207,
0.09810174256563187,
-0.4008689820766449,
-0.09314270317554474,
-0.15020990371704102,
-0.2427181750535965,
0.6109135746955872,
-0.0664522796869278,
0.07508885115385056,
-0.3023985028266907,
-0.16477452218532562,
0.42476481199264526,
-0.19468840956687927,
0.236135795712... | |
their projects:
```
using ValidationLibrary;
public static class EnsuresWhileDebugging {
[Conditional("DEBUG")]
public static Validation That() {
return Ensures.That;
}
}
```
This should work as well, as far as I see, but still requires breaking the DRY principle, if only slightly.
Any solution t... | [
0.4653353691101074,
0.0463297963142395,
-0.1182684674859047,
0.05691858381032944,
-0.05695207417011261,
-0.055342573672533035,
0.3682996928691864,
-0.37149664759635925,
-0.016997158527374268,
-0.1721462905406952,
-0.07491391152143478,
0.7014356255531311,
-0.10420490801334381,
0.09351878613... | |
assembly to find if it is built in debug or release - but then you *must* use some sort of delegate to delay the calculation - to ensure that it is only done when needed. e.g.:
```
Ensures.WhileDebugging.That. IsPositive(() => ExpensiveCalculation(result));
```
The IsPositive function should run the lambda and check... | [
0.17860229313373566,
-0.09814950078725815,
-0.022076129913330078,
-0.11018869280815125,
0.14803673326969147,
-0.214998260140419,
0.37801381945610046,
-0.39066755771636963,
-0.0422312393784523,
-0.3939419090747833,
-0.17465537786483765,
0.8236206769943237,
-0.40179234743118286,
-0.348019242... | |
I am using SimpleModal in jQuery, and I have one confirm dialog. If the result is `Yes`, I have to call `my.php` into this dialog. However, I have done the code, and I am still searching for ideas. How can I do it?
```
$(document).ready(function () {
$('#confirmDialog input.confirm, #confirmDialog a.confirm').clic... | [
0.4752151072025299,
0.14171439409255981,
0.48725569248199463,
0.15839412808418274,
0.41166606545448303,
-0.39541539549827576,
0.12233835458755493,
-0.16085229814052582,
0.49061518907546997,
-0.5192232728004456,
0.15319958329200745,
0.7597511410713196,
-0.062345076352357864,
0.0254022553563... | |
confirm("Continue", function () {
alert("OK");
});
});
});
function confirm(message, callback) {
$('#confirm').modal({
close:false,
position: ["20%",],
overlayId:'confirmModalOverlay',
containerId:'confirmModalContainer',
onShow: function (dialog) {
... | [
0.19672444462776184,
-0.21524937450885773,
0.9515226483345032,
-0.06385397166013718,
0.5633373260498047,
-0.15835270285606384,
0.06675142049789429,
-0.2370431125164032,
0.4147076904773712,
-0.185439795255661,
-0.23355135321617126,
0.6493145227432251,
-0.1860240399837494,
0.2352506518363952... | |
// If the user clicks "yes"
dialog.data.find('.yes').click(function () {
$.get('my.php', function(data){
// Create a modal dialog with the data.
// Here: How do I write the same window? | [
0.12070062011480331,
0.19570668041706085,
0.7005400657653809,
-0.037570271641016006,
0.14112941920757294,
0.22150766849517822,
0.2952181100845337,
0.05036228150129318,
-0.01834714040160179,
-0.7264469861984253,
-0.16643546521663666,
0.5434441566467285,
-0.1385452151298523,
0.06563529372215... | |
});
// Call the callback
// Close the dialog
$.modal.close();
});
}
});
}
```
Here I have the problem of how to write it the | [
-0.14059647917747498,
0.306666761636734,
0.6879710555076599,
-0.4378410577774048,
0.291680246591568,
-0.28353428840637207,
0.3088034689426422,
-0.24403761327266693,
0.16004467010498047,
-0.5453035235404968,
-0.3898664116859436,
0.8154379725456238,
-0.4752691686153412,
0.0013263922883197665... | |
same window Confirmdialog from an Ajax result. How can I do it?
I'm not sure that the confirm function best fits your needs, but something like this should work:
```
function confirm(message, callback) {
$('#confirm').modal({
close:false,
position: ["20%",],
overlayId:'confirmModalOverlay',... | [
0.3752102553844452,
-0.11308129131793976,
0.7934941053390503,
0.17504708468914032,
0.35433781147003174,
-0.29739880561828613,
0.23006603121757507,
-0.1448402851819992,
0.5432087779045105,
-0.579781174659729,
0.2487780600786209,
0.7658098340034485,
-0.16311322152614594,
0.08557285368442535,... | |
// If the user clicks "yes"
dialog.data.find('.yes').click(function () {
$.get("my.php", function (data) {
/* Sample response:
* <div id="title">my title</div> | [
0.11979185789823532,
0.1580488234758377,
0.7118865251541138,
0.034251511096954346,
0.24256213009357452,
0.15057145059108734,
0.2811373472213745,
-0.22514896094799042,
0.09505810588598251,
-0.2848520576953888,
-0.28970086574554443,
0.3738139271736145,
0.1145319789648056,
0.3369896113872528,... | |
* <div id="message">my message</div>
*
*/
var resp = $("<div/>").append(data);
var | [
0.02678048424422741,
-0.2542547583580017,
0.7292134165763855,
-0.36708155274391174,
-0.1387062668800354,
0.6043662428855896,
0.5308812856674194,
-0.43153446912765503,
-0.0023646028712391853,
-0.6861457228660583,
-0.23515339195728302,
0.624283492565155,
-0.34640857577323914,
0.0959124565124... | |
title = resp.find("#title").html(),
message = resp.find("#message").html();
dialog.data.find(".header span").html(title);
dialog.data.find(".message").html(message);
dialog.data.find(".buttons .yes").hide(); | [
0.0370497889816761,
-0.05783544480800629,
0.792048990726471,
-0.1094193160533905,
0.07872240245342255,
0.21065174043178558,
0.1409708708524704,
-0.3599717319011688,
-0.1435748040676117,
-0.5025357604026794,
-0.3892976939678192,
0.4767654240131378,
-0.33813053369522095,
0.20883922278881073,... | |
dialog.data.find(".buttons .no").html("Close");
// No need to call the callback or $.modal.close()
});
});
}
});
}
``` | [
-0.08498256653547287,
-0.02073988877236843,
0.9169862270355225,
-0.2680869698524475,
0.34935444593429565,
-0.029509928077459335,
0.2572566866874695,
-0.2360369712114334,
-0.14267660677433014,
-0.3310624361038208,
-0.5523920059204102,
0.7604973316192627,
-0.7343604564666748,
0.0111628407612... | |
I was recently reading about artificial life and came across the statement, ["Conway’s Game of Life demonstrates enough complexity to be classified as a universal machine."](http://www.alesdar.org/oldSite/IS/chap3-9.html) I only had a rough understanding of what a [universal machine](http://en.wikipedia.org/wiki/Univer... | [
0.1464218944311142,
0.22238078713417053,
-0.2723328769207001,
0.18415968120098114,
0.35906851291656494,
0.12340038269758224,
-0.15003186464309692,
0.44689399003982544,
-0.6656255125999451,
-0.33050230145454407,
0.027641858905553818,
0.7356948256492615,
-0.19459092617034912,
0.2445583194494... | |
a Turing machine out of Conway's life - although it would be pretty horrendous.
The key is in *gliders* (and related patterns) - these move (slowly) along the playing field, so can represent streams of bits (the presence of a glider for a 1 and the absence for a 0). Other patterns can be built to take in two streams o... | [
0.02706860564649105,
-0.10757356137037277,
-0.35637006163597107,
0.19493728876113892,
0.1766541302204132,
0.15851379930973053,
0.32193318009376526,
-0.28848397731781006,
-0.17204272747039795,
-0.45372557640075684,
-0.1929587572813034,
0.24825915694236755,
-0.28164321184158325,
0.1689927428... | |
Web browsers are good as thin clients for web applications.
But if the user has to enter some code (where tabs and formatting are important) in an edit box, inside a web browser, he navigates through the webpage controls every time he hits the "tab" key, instead of printing the "tab" character.
Are there any free web... | [
0.10386791825294495,
0.05598464608192444,
0.2541680335998535,
0.23200252652168274,
-0.3631472885608673,
-0.22184573113918304,
0.30543121695518494,
0.27316731214523315,
-0.14371846616268158,
-1.1070489883422852,
-0.20079798996448517,
0.3141654431819916,
-0.3689805865287781,
-0.0074916300363... | |
by adding a onKeyPress handler to the text container. When they detect a tab character they append a tab to the container and return false to cancel the normal tab action. | [
-0.15032045543193817,
0.064967580139637,
0.41402795910835266,
-0.17024488747119904,
0.19942279160022736,
0.06395614892244339,
0.31848955154418945,
0.02095922827720642,
-0.13062095642089844,
-0.6557334661483765,
-0.39106643199920654,
0.6065306067466736,
-0.40708139538764954,
0.3442193269729... | |
So I wrote this short script (correct word?) to download the comic images from explosm.net comics because I somewhat-recently found out about it and I want to...put it on my iPhone...3G.
It works fine and all. urllib2 for getting webpage html and urllib for image.retrieve()
***Why I posted this on SO: how do I optimi... | [
0.22797206044197083,
-0.002674540039151907,
0.7457935810089111,
0.12056081742048264,
-0.06503152847290039,
-0.12422212213277817,
0.14335568249225616,
0.25228390097618103,
-0.24629224836826324,
-0.9038523435592651,
-0.1397620290517807,
0.7955985069274902,
-0.36926010251045227,
-0.3635559380... | |
eachLetter == " ":
string_link = string_link[:string_link.find(eachLetter)] + "%20" + string_link[string_link.find(eachLetter)+1:]
return string_link
start = 82
end = 1506
matchingStart = """<img alt="Cyanide and Happiness, a daily webcomic" src="http://www.explosm.net/db/files/Comics/"""
matchingEnd ... | [
-0.021714160218834877,
0.09955448657274246,
0.7178502678871155,
0.21047137677669525,
-0.30793148279190063,
0.030669907107949257,
0.09257390350103378,
-0.4940585792064667,
-0.10834771394729614,
-0.21731941401958466,
-0.4862635135650635,
0.6432982087135315,
-0.10418934375047684,
-0.074980922... | |
final = newString1[istart2 +1 : iend2 -1]
final = LinkConvert(final)
try:
image = urllib.URLopener()
image.retrieve(final, `pageNum` + ".jpg")
except:
print "Uh-oh! " + `pageNum` + " was not downloaded!"
print `pageNum` + " completed..."
```
*By the way, this is Python 2.5 co... | [
0.14924263954162598,
0.04154359549283981,
0.9968082308769226,
-0.017409227788448334,
-0.0977894514799118,
-0.24007830023765564,
0.4355825185775757,
0.08822277933359146,
-0.37060415744781494,
-0.4999050199985504,
-0.48642411828041077,
0.22967973351478577,
0.03252873197197914,
0.101671740412... | |
(after College Apps - YAY! ^-^)*
I would suggest using [Scrapy](http://scrapy.org/) for your page fetching and [Beautiful Soup](http://www.crummy.com/software/BeautifulSoup/) for the parsing. This would make your code a lot simpler.
Whether you want to change your existing code that works to these alternatives is up t... | [
0.29798534512519836,
0.050124552100896835,
0.2689289152622223,
0.06599626690149307,
-0.11735950410366058,
0.27591079473495483,
0.14616863429546356,
0.47766175866127014,
-0.4059768319129944,
-0.7053928375244141,
-0.15363308787345886,
0.2810439169406891,
-0.20558752119541168,
-0.363012254238... | |
I've been doing a lot of reading about AJAX, and wanted to know which is the better way to approach things: by using a library such as jQuery using their built-in methods or creating JavaScript without a library for AJAX?
Ajax has a lot of quirks when working with the XMLHttpRequest Object. When you start to work with ... | [
0.5231785774230957,
0.01581227220594883,
-0.1144888773560524,
0.25407838821411133,
-0.5454787611961365,
-0.55768883228302,
0.018132474273443222,
0.3112165927886963,
-0.34266069531440735,
-0.5645633339881897,
0.07471901178359985,
0.4268725514411926,
-0.1301916390657425,
-0.00091018626699224... | |
coded. Libraries tend to solve most of the problems, but they all are not perfect.
I always tell people it is great to work with a tutorial to see how the XMLHttpRequest works. After you have learned how to do it naked, work with a library that fits your needs.
Eric Pascarello | [
0.5825706124305725,
-0.12886711955070496,
-0.4678977429866791,
0.6576752066612244,
-0.3399401009082794,
-0.025722265243530273,
0.21993304789066315,
0.05996152013540268,
-0.36153271794319153,
-0.8796088099479675,
-0.21192125976085663,
-0.022534890100359917,
-0.5952603816986084,
-0.594099104... | |
Services default to starting as `root` at boot time on my RHEL box. If I recall correctly, the same is true for other Linux distros which use the init scripts in `/etc/init.d`.
What do you think is the best way to instead have the processes run as a (static) user of my choosing?
The only method I'd arrived at was to ... | [
0.14815828204154968,
-0.054034505039453506,
0.2596539258956909,
-0.1675693541765213,
-0.29526016116142273,
0.006367902271449566,
0.5256767868995667,
0.6198168396949768,
-0.2924785912036896,
-0.7989799380302429,
-0.22806009650230408,
0.46291011571884155,
0.007959434762597084,
0.642939984798... | |
processes I'm starting in this instance are either Python scripts or Java programs. I'd rather not write a native wrapper around them, so unfortunately I'm unable to call [setuid()](http://linux.die.net/man/2/setuid) as [Black](https://stackoverflow.com/users/25234/black) suggests.
On Debian we use the `start-stop-daem... | [
0.13285817205905914,
-0.11527475714683533,
0.25124043226242065,
-0.22471977770328522,
-0.03454507514834404,
-0.21333131194114685,
0.015292644500732422,
0.09979207068681717,
-0.4840288460254669,
-0.8330832719802856,
-0.18530067801475525,
0.32100021839141846,
-0.44727692008018494,
0.23643445... | |
one.
If you look around the net, there are several ready-made wrappers that you can use. Some may even be already packaged in RedHat. Have a look at [`daemonize`](http://www.clapper.org/software/daemonize/), for example. | [
0.673134446144104,
-0.20143431425094604,
-0.1919638067483902,
0.30965670943260193,
0.16816337406635284,
-0.169195756316185,
-0.08694261312484741,
0.14617830514907837,
-0.5341748595237732,
-0.7106166481971741,
0.039167288690805435,
0.20908860862255096,
-0.4308105409145355,
-0.07843895256519... | |
How to handle click event of the linkbutton in gridview in vb.net (windows application )
Thanks
You need to consume the DataGridView.CellClick Event and just check that you've got the correct column index. You can do it with the following steps:
> Create a new Windows Forms application
>
>
> Drag a DataGridView ont... | [
0.15619346499443054,
-0.220930278301239,
0.8717858791351318,
-0.023829733952879906,
-0.19120553135871887,
-0.26590824127197266,
0.047325462102890015,
-0.22128014266490936,
-0.18891841173171997,
-0.9453986883163452,
0.1270107477903366,
0.6423338651657104,
-0.2044471651315689,
-0.02553506381... | |
it would be:
```
Dim data As New DataTable()
data.Columns.Add(New DataColumn("Link", Type.GetType("System.String")))
Dim newRow As DataRow = data.NewRow()
newRow("Link") = "http://www.stackoverflow.com"
data.Rows.Add(newRow)
DataGridView1.DataSource = data
```
> Consume the DataGridView.CellClick event
```
Private ... | [
0.09427207708358765,
-0.19851486384868622,
0.8605547547340393,
-0.2746788263320923,
0.1365751326084137,
0.02060072124004364,
0.17300713062286377,
-0.5939533710479736,
-0.12305857986211777,
-0.3447987139225006,
-0.4795800745487213,
0.6291875243186951,
-0.45924267172813416,
0.291564196348190... | |
I've following problem, which I've not been able to do successfully. Your help will be appreciated. I'm using SQL 2005, and trying to do this using CTE.
Table has following 2 columns
```
DocNum DocEntry
1 234
2 324
2 746
3 876
3 | [
-0.07516534626483917,
0.3700115382671356,
0.695473849773407,
-0.20570170879364014,
-0.016450805589556694,
-0.10333891957998276,
0.14178252220153809,
-0.22830677032470703,
-0.1105039194226265,
-0.5139574408531189,
0.029068516567349434,
0.6622941493988037,
-0.35139942169189453,
0.17247188091... | |
764
4 100
4 387
```
Expected result is as follows
```
1 234
2 324, 746
3 876, 764
4 | [
-0.14252141118049622,
0.06210179626941681,
0.5200845003128052,
-0.07959330826997757,
-0.09891258925199509,
0.4040433466434479,
0.13860830664634705,
-0.46744048595428467,
-0.259078711271286,
-0.3815383315086365,
-0.19019362330436707,
0.3763398230075836,
-0.21922415494918823,
0.0838184431195... | |
100, 387
```
Thanks
Rahul Jain
---
Further explanation transcribed from the comments:
I'm using a query like following:
```
WITH ABC (DocNum, DocEntry) AS
(SELECT DocNum, Cast(DocEntry As VARCHAR(8000))
FROM Temp5
WHERE DocNum = 1
UNION ALL
SELECT a.DocNum, A.DocEntry + ', ' + B.DocEntr... | [
0.3034699857234955,
0.4232766330242157,
0.35137906670570374,
-0.2672201991081238,
-0.12590427696704865,
0.2690574526786804,
0.28272515535354614,
-0.7177246809005737,
-0.17168188095092773,
-0.3969152569770813,
-0.21083053946495056,
0.7855556607246399,
-0.4158548414707184,
0.2548778653144836... | |
above query is as follows
```
1 234
2 234, 324
2 234, 746
3 234, 746, 876
3 234, 746, 764
```
I dont want those numbers to repeat as shown in question.
```
SELECT
DocNum,
STUFF((SELECT ', ' + CAST(DocEntry AS VARCHAR(MAX)) AS [text()]
FROM Temp5 b
WHERE a.DocNum = b.DocNum
FOR XML PA... | [
0.10874771326780319,
0.200361430644989,
0.6452757716178894,
-0.16478441655635834,
-0.07333668321371078,
0.06645695120096207,
0.20575092732906342,
-0.563178300857544,
-0.14502377808094025,
-0.3959181606769562,
-0.1868896484375,
0.5027840733528137,
-0.3800291121006012,
0.22707858681678772,
... | |
screams for itself. | [
0.44147127866744995,
0.1674017459154129,
0.017929282039403915,
0.09400057792663574,
-0.4025369882583618,
0.29023200273513794,
0.12824909389019012,
0.14994817972183228,
0.04600035399198532,
-0.3815649151802063,
0.04263743758201599,
0.24255649745464325,
-0.373391330242157,
0.5210018157958984... | |
I don't really *FEEL* CSS and it doesn't always work as I think it would.
This is one of these situations:
I have a simple (2 rows, 2 columns) asp:table generated dynamically. in the right column it contains a combo box `(cell (0, 1))` and a label `(cell (1,1))`. When I change the combobox's selection, the text in t... | [
0.16775399446487427,
-0.09479383379220963,
0.3118791878223419,
-0.08894401043653488,
-0.21775443851947784,
0.31606924533843994,
0.23526223003864288,
-0.23022058606147766,
-0.09997273236513138,
-0.8499922156333923,
0.11106810718774796,
0.1351822167634964,
-0.10494436323642731,
0.03241558000... | |
I specify this in CSS style of a label or of a cell? i tried setting table's width explicitly, cell's width in CSS class but nothing works and I feel like a blind in a labyrinth.
`<label>` elements can, if you want, be set to `display: block;` and then given a fixed width via CSS. This may be the best solution for you. | [
0.19646047055721283,
-0.005232607945799828,
0.1297311782836914,
-0.07773968577384949,
-0.0766473338007927,
0.08355943113565445,
0.09190892428159714,
-0.08138334006071091,
-0.3606109917163849,
-0.8551385402679443,
0.1998315453529358,
0.0717104822397232,
-0.24913427233695984,
0.2864340245723... | |
If I was a webservice, such as Twitter, how does creating an API for people to access my data help me? I can see that they are extending your service to areas that you might not have the resources to expand to (in a way extending your own service), but is it worth all of the bandwidth and infrastructure costs associate... | [
0.8410525918006897,
-0.05575777217745781,
0.14498254656791687,
0.3894589841365814,
0.11965891718864441,
-0.1910569816827774,
0.2523276209831238,
0.1575605571269989,
-0.2052217423915863,
-0.28743883967399597,
0.47716987133026123,
0.26634177565574646,
-0.008369149640202522,
0.115206241607666... | |
the API usage (as Google does).
ANSWER 2: It is easier to add value to your service than to clone your service. This additional attraction can make/break your site. You can even charge for access.
ANSWER 3: An API is good when it extends an already-working business model. (Don't be Twitter.)
The benefit is clear and ... | [
0.6653945446014404,
-0.1016421988606453,
0.3882508873939514,
0.28090208768844604,
-0.02311122789978981,
-0.042083289474248886,
0.1044125035405159,
-0.0664137676358223,
-0.03563222289085388,
-0.4207966923713684,
-0.004357104189693928,
0.4765769839286804,
-0.25133898854255676,
-0.08882280439... | |
requests/day, for example).
This is of course no substitute for having a business plan, which Twitter seems to lack, with or without APIs.
All those Facebook apps for sure are bringing lots of revenue... | [
0.5247637629508972,
-0.1813879758119583,
0.46289876103401184,
0.3740789592266083,
0.004172672517597675,
-0.1201847493648529,
0.5698953866958618,
0.33797308802604675,
-0.40465354919433594,
-0.38422948122024536,
0.041403330862522125,
0.2348708212375641,
-0.016240308061242104,
-0.008334699086... | |
I would like vim to color "long" lines for me. Using 80 columns as an example, I would like to highlight lines that exceed that length. Here is roughly what I think the .vimrc file should contain, although it (1) doesn't work, and (2) uses Perl's regex syntax to illustrate my point, because I don't know Vim's well enou... | [
0.21808288991451263,
-0.23046407103538513,
0.6779600381851196,
-0.057086192071437836,
-0.10193625837564468,
0.05464842915534973,
0.14072656631469727,
-0.23276619613170624,
-0.10479241609573364,
-0.7797849178314209,
0.05439235270023346,
0.741696298122406,
-0.3188561797142029,
-0.00585593981... | |
if a line is 85 columns, then the 81st through the 85th columns would be highlighted.
I'm sure Vim can do this, just not with me at the helm.
I needed the autocomand to work for me:
```
augroup vimrc_autocmds
autocmd BufEnter * highlight OverLength ctermbg=darkgrey guibg=#111111
autocmd BufEnter * match OverLengt... | [
-0.16495151817798615,
-0.04803932458162308,
0.5961279273033142,
-0.16247153282165527,
-0.47180402278900146,
0.035349853336811066,
0.3247537314891815,
-0.28517812490463257,
-0.3487388789653778,
-0.7179126143455505,
-0.019925948232412338,
0.5391072630882263,
-0.2643968164920807,
-0.397374689... | |
Is it possible to switch off optimization of a specific function?
A friend of mine has the problem that the gcc optimization makes some (unknown to me) µ-controller-code not work.
We know which functions it is, but we have no clue of the code itself so the easiest and safest way would probably be to just switch it off ... | [
0.09654706716537476,
-0.15400074422359467,
0.09143215417861938,
0.18365846574306488,
0.07923556864261627,
-0.12880131602287292,
-0.04731990396976471,
-0.07939440757036209,
-0.20996001362800598,
-0.5039616227149963,
-0.023708408698439598,
0.9269309043884277,
-0.5905251502990723,
0.029809799... | |
then compile that file without the optimisation flag set. | [
0.12107991427183151,
-0.046774525195360184,
-0.2978198528289795,
0.05269334837794304,
0.2438480406999588,
-0.27599647641181946,
0.03783192113041878,
-0.38910478353500366,
0.29587045311927795,
-0.43808093667030334,
-0.28839340806007385,
0.47855404019355774,
-0.2984502613544464,
-0.231102049... | |
Is it OK - best practise wise - to use the second layer to redirect the user?
For example:
```
public static void ForceLogin()
{
HttpCookie cookie = HttpContext.Current.Request.Cookies[cookieName];
if (cookie != null)
{
if (Regex.IsMatch(cookie.Value, "^[0-9]+\\.[a-f0-9]+$"))
{
... | [
0.022377556189894676,
-0.2669890224933624,
0.7361547946929932,
-0.09650547802448273,
0.30212315917015076,
-0.3992656469345093,
0.6487923264503479,
-0.27860814332962036,
-0.026353154331445694,
-0.2801953852176666,
-0.5632173418998718,
0.6164390444755554,
-0.4081379175186157,
-0.103181116282... | |
int count = db.Logins.Count(l => l.Password == cookie.Value);
if (count == 1)
{
return;
}
}
} | [
-0.10852523148059845,
-0.22252793610095978,
0.12949496507644653,
-0.34966325759887695,
-0.017575891688466072,
0.01877656579017639,
0.35334745049476624,
-0.4343694746494293,
-0.017010757699608803,
-0.4012753367424011,
-0.24575698375701904,
0.4805770516395569,
-0.5002434849739075,
0.22192150... | |
}
HttpContext.Current.Response.Redirect("~/Login.aspx");
}
```
At the last line, I use the Business/Service Logic Layer to redirect the user to the login page.
Should this be done in the Presentation layer?
Absolutely not. The business logic layer should make the decision, the UI layer should do the redirect. T... | [
0.039730288088321686,
0.08335984498262405,
0.6451495885848999,
-0.1879112720489502,
0.041938941925764084,
-0.1879805326461792,
0.13258148729801178,
0.056313835084438324,
0.054868217557668686,
-0.8566232919692993,
-0.4360016882419586,
0.7641082406044006,
-0.3272126019001007,
0.0977629348635... | |
what if the business layer is used from a web service? How can the business layer do a redirect in that instance? Or suppose it's used with a non-web client? Redirection has no meaning in that context. If you change your UI layer, that should not affect your business logic layer, and mixing in redirects and cookie read... | [
0.13039809465408325,
-0.12203706800937653,
0.5125714540481567,
0.2645050287246704,
-0.07126713544130325,
-0.09526210278272629,
0.1824563890695572,
-0.2940036654472351,
-0.2469281405210495,
-0.5090257525444031,
-0.16589896380901337,
0.6608126759529114,
-0.3306029140949249,
0.166627928614616... | |
I've been diving into Erlang recently, and I decided to use Mnesia to do my database work given it can store any kind of Erlang data structure without a problem, scale with ease, be used with list comprehensions, etc.
Coming from standard SQL databases, most rows can and should be identified by a primary key, usually ... | [
-0.1607770025730133,
0.25640255212783813,
0.4107755124568939,
0.0910392552614212,
-0.23239567875862122,
0.1334971785545349,
-0.04068395867943764,
0.1119929775595665,
-0.3295139670372009,
-0.5723901391029358,
-0.12064748257398605,
0.046806253492832184,
-0.3449745178222656,
0.308014810085296... | |
{title, body, slug}).
-record(user_entry, {user_name, entry_title}).
```
I figure using the username may be good enough for some purposes, as with the entry title, in order to identify the resource, but how do I go about maintaining integrity?
Say the user changes its name, or that the entry's title changes after an... | [
0.3630481958389282,
0.35792726278305054,
0.19167360663414001,
0.24490845203399658,
0.1417427361011505,
0.013881351798772812,
0.0571332722902298,
-0.21081924438476562,
-0.30558326840400696,
-0.5764498114585876,
-0.005616774316877127,
0.5114608407020569,
-0.15674486756324768,
0.4965746402740... | |
table like 'user\_entry' do if the first field is usually the key? Otherwise, what would a better way be to represent a many-to-many relationship in Mnesia?
I prefer using GUIDs instead of auto-incrementing ints as artificial foreign keys. There is an [Erlang uuid module](http://github.com/travis/erlang-uuid/tree/maste... | [
-0.18347127735614777,
-0.014080758206546307,
0.41940462589263916,
-0.08121232688426971,
-0.04560991749167442,
-0.02904169261455536,
-0.03719440475106239,
-0.010589612647891045,
-0.36596056818962097,
-0.7779690027236938,
0.025724316015839577,
0.47540491819381714,
-0.29463136196136475,
0.345... | |
in Mnesia even to first normal form; in your example, I would consider the following structure:
```
-record(user, {id, name, salt, pass_hash, email, entries}).
-record(entry, {id, title, body, slug, users}).
```
where `entries` and `users` are lists of ids. Of course, this depends on the queries you want.
EDIT: fix... | [
-0.020843898877501488,
0.04534933716058731,
0.2674954831600189,
0.19231954216957092,
-0.09305126965045929,
0.30800530314445496,
-0.1076427549123764,
-0.27745509147644043,
-0.4511391818523407,
-0.7394024133682251,
-0.3321439325809479,
0.16809168457984924,
-0.43618977069854736,
0.34469419717... | |
I have three values I need to align in a dropdown box. How can I do this? I've been trying this:
`String.Format("{0,-30}{1,-15}{2,-10}{3,-8}", new object[] { cusJob, service, username, time });`
But that leaves it uneven because it's not a monospaced font. I don't really want to use a monospaced font and I've seen appl... | [
0.17804767191410065,
-0.1682153344154358,
0.5027057528495789,
-0.15816982090473175,
-0.1845688670873642,
0.25439438223838806,
0.08769328892230988,
-0.39510780572891235,
-0.14844189584255219,
-0.7850040197372437,
0.3080975115299225,
0.47435814142227173,
-0.19108141958713531,
-0.030256848782... | |
"dropdownlist ownerdraw columns drawmode". | [
-0.0038404983934015036,
-0.23942816257476807,
0.441875696182251,
0.1435967981815338,
-0.19559474289417267,
-0.44307416677474976,
0.03915496543049812,
-0.06318677216768265,
-0.14252929389476776,
-0.24289193749427795,
-0.10366006940603256,
0.015206928364932537,
-0.08515530079603195,
0.019682... | |
I have been learning to use Emacs for a little while now. So far liking it a lot.
My problem is that for little C codes I prefer using Rake instead of Make. However flymake does not seem to want anything else than Make. As it complains that it can not find Makefile. From the command line Rake is used in the same way a... | [
0.6359307765960693,
0.05825645104050636,
0.07573717832565308,
0.06946024298667908,
0.10668337345123291,
-0.08566620200872421,
-0.06210068240761757,
0.1434166133403778,
0.09409148246049881,
-0.621668815612793,
0.2505411207675934,
0.5025191903114319,
-0.35231122374534607,
0.3237485885620117,... | |
flymake-ruby does not help at all. I'm working with C code. I just use RAKE to compile the c code using gcc instead of MAKE.
Right, got it now; sorry about the earlier confusion.
Taking a quick look through flymake.el, for \*.c files, the 'make' invocation ultimately comes from here:
```
(defun flymake-get-make-cmdli... | [
0.875437319278717,
0.08675581961870193,
0.22875738143920898,
-0.29476919770240784,
0.08292265236377716,
-0.1972116380929947,
0.3957490026950836,
-0.3999840319156647,
0.15760666131973267,
-0.446921169757843,
0.11242352426052094,
0.7765173316001892,
-0.700887143611908,
-0.029661938548088074,... | |
"SYNTAX_CHECK_MODE=1"
"check-syntax")))
```
That gets called by `flymake-simple-make-init`, which is called because that's what `*.c` files are mapped to by `flymake-allowed-file-name-masks`.
So, the *right* answer would be to modify `flymake-allowed-file-name-masks` to map `*.c` files to a different init ... | [
0.46661892533302307,
-0.27947384119033813,
0.21342839300632477,
0.02868441492319107,
-0.14810684323310852,
-0.17717157304286957,
0.32823824882507324,
-0.0570385716855526,
0.11074604839086533,
-0.6561090350151062,
-0.1972929686307907,
0.6824204921722412,
-0.34718063473701477,
-0.35225936770... | |
really right* answer would be to change `flymake-simple-make-init` so that the command name was read from a defcustom variable, then submit that change back upstream...)
The quick-and-dirty answer, given that you said all you need to do is call 'rake' with the same args as 'make', would be to grab a copy of flymake.el... | [
0.5845513343811035,
-0.19756461679935455,
0.23226577043533325,
0.06893505156040192,
0.22493942081928253,
-0.10457349568605423,
0.1159563735127449,
-0.37708765268325806,
0.14837148785591125,
-0.39300134778022766,
0.06934010982513428,
0.6583595871925354,
-0.13780836760997772,
-0.044334422796... | |
I was reading the following article:
<http://msdn.microsoft.com/en-us/magazine/cc817398.aspx>
"Solving 11 Likely Problems In Your Multithreaded Code" by Joe Duffy
And it raised me a question:
"We need to lock a .NET Int32 when reading it in a multithreaded code?"
I understand that if it was an Int64 in a 32-bit SO it... | [
0.11092399805784225,
0.1910552680492401,
-0.3325256109237671,
-0.2761038839817047,
-0.16296812891960144,
0.038771409541368484,
0.3759915232658386,
-0.4012937545776367,
-0.1454068273305893,
-0.572742223739624,
-0.0977059081196785,
0.478682279586792,
-0.5843144655227661,
0.048716310411691666... | |
}
}
public int Read()
{
return example;
}
}
```
I don't see a reason to include a lock in the Read method. Do you?
**Update** Based on the answers (by Jon Skeet and ctacke) I understand that the code above still vulnerable to multiprocessor caching (each processor has its own cache, unsynchronized with... | [
0.27422934770584106,
0.3561985194683075,
-0.021656524389982224,
-0.1943276822566986,
0.37391945719718933,
-0.01157223992049694,
0.4600510001182556,
-0.37724027037620544,
-0.36297810077667236,
-0.46220582723617554,
-0.013241118751466274,
0.6705302596092224,
-0.44764044880867004,
0.265132188... | |
the most elegant solution.
Locking accomplishes two things:
* It acts as a mutex, so you can make sure only one thread modifies a set of values at a time.
* It provides memory barriers (acquire/release semantics) which ensures that memory writes made by one thread are visible in another.
Most people understand the fi... | [
0.31830456852912903,
0.01911006309092045,
0.23916229605674744,
0.18565329909324646,
0.06572994589805603,
0.043506231158971786,
0.262357622385025,
-0.4979875385761261,
-0.44470858573913574,
-0.17672330141067505,
-0.08951330929994583,
0.5114630460739136,
-0.3444184958934784,
0.17139269411563... | |
two threads calling `Add` your lock would ensure that you didn't "lose" any additions. However, it's quite possible that your `Read` thread would only ever read 0, even after `Add` had been called several times. Without any memory barriers, the JIT could just cache the value in a register and assume it hadn't changed b... | [
0.4243457317352295,
-0.09849140048027039,
0.07243696600198746,
-0.009563341736793518,
0.03411569073796272,
-0.16771842539310455,
0.26099690794944763,
0.020822685211896896,
-0.30996254086494446,
-0.5363155007362366,
0.2713055908679962,
0.4753212034702301,
-0.2498978078365326,
0.321040153503... | |
want to access shared data (for read *or* write) you'll be okay. See the [volatility/atomicity](http://www.yoda.arachsys.com/csharp/threads/volatility.shtml) part of my threading tutorial for more details. | [
0.23464442789554596,
-0.2722184956073761,
0.3507474362850189,
0.35347044467926025,
-0.019244054332375526,
-0.36620888113975525,
0.17229339480400085,
0.37783083319664,
-0.7596261501312256,
-0.5065799951553345,
-0.00704688997939229,
0.6215791702270508,
-0.08994637429714203,
0.076781645417213... | |
I know that Hpricot is still a standard but I remember hearing about a faster more expressive HTML parser for Ruby.
Does anybody know what it's called and if it is worth switching to from Hpricot??
Thanks in advance
You are probably thinking about [Nokogiri](http://nokogiri.org/).
I have not used it myself, but "ever... | [
-0.14584065973758698,
0.21293281018733978,
0.5003738403320312,
0.17964117228984833,
-0.2282341718673706,
-0.11550906300544739,
0.3172132670879364,
-0.025113968178629875,
-0.14624647796154022,
-0.5774790644645691,
-0.12917780876159668,
0.5304707288742065,
-0.23933428525924683,
-0.4738638103... | |
Silverlight has been available since quite some time, and Silverlight 2 allows .Net programming on the front-end. I've been thinking about the apps that I can make using Silverlight, but I can't decide if I should go for development in Silverlight because i am still concerned about accessibility and acceptance.
What p... | [
0.34636399149894714,
0.0005396189517341554,
0.23446162045001984,
-0.040500231087207794,
-0.3192022442817688,
-0.3169167935848236,
0.03674773871898651,
-0.14271096885204315,
-0.09632141888141632,
-0.6752363443374634,
0.15242774784564972,
0.3679797649383545,
-0.2841430902481079,
-0.210104018... | |
PhotoShop)
4. Lack of features. (Microphone support, Bitmap APIs, Printing support etc)
5. Linux support is lacking. Though Moonlight is already there or V 1.0 and 2 (Alpha).
Pros:
1. Great IDE (Visual Studio 2008) for development.
2. Existing .net languages can be used. So web developers can easily shift to Silverli... | [
0.47261470556259155,
0.09182754904031754,
0.7118949294090271,
0.3124640882015228,
-0.4468908905982971,
-0.3475382626056671,
0.1352592259645462,
-0.28855007886886597,
-0.1438586562871933,
-0.46690383553504944,
0.030075782909989357,
0.6912422180175781,
-0.39969828724861145,
-0.25908321142196... | |
I've got the following Generic usercontrol declared:
```
public partial class MessageBase<T> : UserControl
{
protected T myEntry;
public MessageBase()
{
InitializeComponent();
}
public MessageBase(T newEntry)
{
InitializeComponent(); | [
0.03666377440094948,
-0.230143740773201,
0.45398804545402527,
-0.4776769280433655,
0.3206285834312439,
0.030957721173763275,
0.3088320195674896,
0.13222944736480713,
0.05908035859465599,
-0.6723896861076355,
-0.48180606961250305,
0.37903809547424316,
-0.21379855275154114,
0.588592469692230... | |
myEntry = newEntry;
}
}
}
```
But the compiler won't allow me to do this:
```
public partial class MessageControl : MessageBase<Post>
{
public MessageControl()
{
InitializeComponent();
}
}
```
How do I create a generic user control in C#?
Try this
```
public partial class Messa... | [
-0.24099981784820557,
-0.2296321541070938,
0.46005985140800476,
-0.2604984641075134,
0.18875117599964142,
-0.09940468519926071,
0.267255961894989,
-0.05491137504577637,
0.059570882469415665,
-0.6980396509170532,
-0.41431179642677307,
0.2180558145046234,
-0.4712725877761841,
0.4965248405933... | |
}
}
public class MessageControlBase : MessageBase<Post>
{}
```
The key to getting the designer to work is that the base class of the class you are editing must not be generic. | [
0.0764334574341774,
-0.086539126932621,
-0.11676151305437088,
-0.16510944068431854,
-0.1734737902879715,
-0.29823991656303406,
0.30392253398895264,
0.17449221014976501,
0.010749312117695808,
-0.8298182487487793,
-0.16144685447216034,
0.46735990047454834,
-0.6274285316467285,
0.331189543008... | |
I've been using John Resig's `getStyle` function from Pro JavaScript Techniques to get the style of elements:
```
function getStyle(elem, name) {
// J/S Pro Techniques p136
if (elem.style[name]) {
return elem.style[name];
} else if (elem.currentStyle) {
return elem.currentStyle[name];
}... | [
0.2561807930469513,
-0.09834757447242737,
0.6609684228897095,
-0.21901510655879974,
0.19470565021038055,
-0.14464564621448517,
0.22781650722026825,
-0.777130663394928,
-0.03761487826704979,
-0.5389134883880615,
-0.11704350262880325,
0.6627708673477173,
-0.059535689651966095,
0.003880369709... | |
s = document.defaultView.getComputedStyle(elem, "");
return s && s.getPropertyValue(name);
} else {
return null;
}
}
```
However this method returns default styles for an element if no style is specified:
<http://johnboxall.github.com/test/getStyle.html>
[alt text http://img.skitch.com/20081... | [
0.2337840348482132,
-0.24856433272361755,
0.25677892565727234,
-0.049465663731098175,
-0.09891792386770248,
-0.005295310635119677,
0.32344695925712585,
-0.4131915867328644,
0.07269123196601868,
-0.44465842843055725,
-0.14468733966350555,
0.545674741268158,
-0.3047846555709839,
-0.295789241... | |
`right` - Using `getStyle` unstyled elements default to `center`. This makes it impossible to tell whether the element is centered because the user wanted it to be centered or is centered because that's the default style.
> Is it possible to get only the
> stylesheet specified styles of an
> element (and return null ... | [
0.15767474472522736,
-0.4745369553565979,
0.47479861974716187,
0.2986369729042053,
0.04584512487053871,
-0.44124796986579895,
-0.08383260667324066,
-0.06627032905817032,
0.050514526665210724,
-0.49209582805633545,
-0.33857864141464233,
0.46593254804611206,
-0.18832288682460785,
-0.19292351... | |
through *all* of the rules defining the style in question, in *all* of the stylesheets in the current view of the document, evaluate them for the element in question, and if none applied... and if none applied to a parent (or this particular style is not inherited)... then consider it undefined. This would be slow, and... | [
0.37070029973983765,
0.12157471477985382,
-0.028858400881290436,
0.005796301178634167,
0.040600646287202835,
-0.1466313749551773,
0.2688795328140259,
-0.23010334372520447,
0.10520482063293457,
-0.34444355964660645,
-0.159934863448143,
0.12184589356184006,
-0.10835613310337067,
0.1201058775... | |
I am using statfs() which gives me the free blocks available to a non-superuser.
I am unsure how to convert this into KB/MB/GB.
The values that are returned are:
```
fundamental file system block size: 4096
total data blocks in file system: 3805452
free blocks in fs: 63425
free blocks avail to non-superuser: 63425
t... | [
-0.031139491125941277,
0.4012247622013092,
0.22202961146831512,
0.10407465696334839,
0.09361140429973602,
0.3442254662513733,
0.29742902517318726,
-0.16182097792625427,
-0.4086502194404602,
-0.7675496339797974,
-0.3076460063457489,
0.4873965382575989,
-0.13021166622638702,
-0.0607665516436... | |
device, which in my case I do.
So I should be getting a value somewhere around 2G, I would think.
I ran 63425 against an online blocks to MB converter but that gives me a result of 30MB which shouldn't be the case.
Can anyone help me in figuring out how to get KB/MB/GB from this info?
Thanks.
Block size is 4096 byt... | [
-0.0604717992246151,
0.3776954710483551,
0.4464678168296814,
0.0348174013197422,
0.25097721815109253,
0.13042843341827393,
0.22597864270210266,
-0.05805192142724991,
-0.5543357133865356,
-0.8466031551361084,
-0.03415878489613533,
0.47601398825645447,
0.03487025201320648,
0.1613239943981170... | |
I have a script that I'd like to continue using, but it looks like I either have to find some workaround for a bug in Python 3, or downgrade back to 2.6, and thus having to downgrade other scripts as well...
Hopefully someone here have already managed to find a workaround.
The problem is that due to the new changes i... | [
0.2838674485683441,
0.12081193923950195,
0.13840371370315552,
0.04046028479933739,
-0.24596087634563446,
-0.3424653708934784,
0.4271709620952606,
0.2227984368801117,
-0.32850468158721924,
-0.6947789788246155,
0.10166729986667633,
0.4521062970161438,
-0.21674416959285736,
0.2544817328453064... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.