text stringlengths 0 30.5k | title stringclasses 1
value | embeddings listlengths 768 768 |
|---|---|---|
You'd invoke the above something like
```
java -cp js.jar org.mozilla.javascript.tools.shell.Main beautify.js file-to-pp.js
```
You can mix and match Java and Javascript in your Rhino run scripts, so if you know a little Java it shouldn't be too hard to get this running with text-streams as well. | [
0.5895951390266418,
0.14857330918312073,
0.04716356843709946,
0.030491912737488747,
-0.32469576597213745,
-0.2705635726451874,
0.02550075761973858,
-0.09003685414791107,
-0.45735159516334534,
-0.5138329863548279,
0.12389519810676575,
0.8106016516685486,
-0.19956247508525848,
-0.12399049848... | |
I am developing a J2ME application that has a large amount of data to store on the device (in the region of 1MB but variable). I can't rely on the file system so I'm stuck the Record Management System (RMS), which allows multiple record stores but each have a limited size. My initial target platform, Blackberry, limits each to 64KB.
I'm wondering if anyone else has had to tackle the problem of storing a large amount of data in the RMS and how they managed it? I'm thinking of having to calculate record sizes and split one data set accross multiple | [
-0.07745765149593353,
0.08736588805913925,
0.25597214698791504,
0.057640813291072845,
0.30751103162765503,
0.07467704266309738,
0.08884918689727783,
-0.03622129186987877,
-0.41449880599975586,
-0.354278028011322,
0.22408552467823029,
0.29982617497444153,
-0.10781111568212509,
0.19532519578... | |
stores if its too large, but that adds a lot of complexity to keep it intact.
There is lots of different types of data being stored but only one set in particular will exceed the 64KB limit.
For anything past a few kilobytes you need to use either JSR 75 or a remote server. RMS records are extremely limited in size and speed, even in some higher end handsets. If you need to juggle 1MB of data in J2ME the only reliable, portable way is to store it on the network. The HttpConnection class and the GET and POST methods are always | [
-0.0300604160875082,
0.013089291751384735,
0.5481827259063721,
0.41681185364723206,
0.12178771197795868,
-0.287468820810318,
0.34319645166397095,
-0.2890987694263458,
-0.29224610328674316,
-0.6688454151153564,
-0.038826778531074524,
0.2505967319011688,
0.08551985025405884,
0.13536232709884... | |
supported.
On the handsets that support JSR 75 FileConnection it may be valid alternative but without code signing it is an user experience nightmare. Almost every single API call will invoke a security prompt with no blanket permission choice. Companies that deploy apps with JSR 75 usually need half a dozen binaries for every port just to cover a small part of the possible certificates. And this is just for the manufacturer certificates; some handsets only have carrier-locked certificates. | [
0.3707442283630371,
0.16935686767101288,
0.615784227848053,
0.03416397422552109,
0.10593628138303757,
-0.2531189024448395,
0.3678348660469055,
-0.24301762878894806,
-0.2082367092370987,
-0.5952696204185486,
-0.5502663850784302,
0.7911854386329651,
-0.4210946559906006,
-0.5469887852668762,
... | |
I have a view that has a list of jobs in it, with data like who they're assigned to and the stage they are in. I need to write a stored procedure that returns how many jobs each person has at each stage.
So far I have this (simplified):
```
DECLARE @ResultTable table
(
StaffName nvarchar(100),
Stage1Count int,
Stage2Count int
)
INSERT INTO @ResultTable (StaffName, Stage1Count)
SELECT StaffName, COUNT(*) FROM ViewJob
WHERE InStage1 = 1
GROUP BY StaffName
INSERT INTO @ResultTable (StaffName, Stage2Count)
SELECT StaffName, COUNT(*) FROM ViewJob
WHERE InStage2 = 1
GROUP BY StaffName
```
The problem with | [
-0.24615664780139923,
0.08302419632673264,
0.4310106933116913,
-0.4185919463634491,
0.05942465364933014,
0.4295043647289276,
0.07358156144618988,
-0.33295148611068726,
-0.08485408872365952,
-0.7181783318519592,
0.10722967237234116,
0.46318182349205017,
-0.20945031940937042,
0.0671746656298... | |
that is that the rows don't combine. So if a staff member has jobs in stage1 and stage2 there's two rows in @ResultTable. What I would really like to do is to update the row if one exists for the staff member and insert a new row if one doesn't exist.
Does anyone know how to do this, or can suggest a different approach?
I would really like to avoid using cursors to iterate on the list of users (but that's my fall back option).
I'm using SQL Server 2005.
**Edit: @Lee:** Unfortunately the InStage1 = 1 was a simplification. It's really more like | [
0.0005517518147826195,
0.05850520730018616,
0.2937357425689697,
-0.21226824820041656,
0.15371190011501312,
0.05827125906944275,
0.19295910000801086,
-0.0051141297444701195,
-0.1514360010623932,
-0.6365498900413513,
0.39299967885017395,
0.5186986327171326,
-0.2988273501396179,
0.02795378305... | |
WHERE DateStarted IS NOT NULL and DateFinished IS NULL.
**Edit: @BCS:** I like the idea of doing an insert of all the staff first so I just have to do an update every time. But I'm struggling to get those UPDATE statements correct.
IIRC there is some sort of "On Duplicate" (name might be wrong) syntax that lets you update if a row exists (MySQL)
Alternately some form of:
```
INSERT INTO @ResultTable (StaffName, Stage1Count, Stage2Count)
SELECT StaffName,0,0 FROM ViewJob
GROUP BY StaffName
UPDATE @ResultTable Stage1Count= (
SELECT COUNT(*) AS count FROM ViewJob
WHERE InStage1 = 1
@ResultTable.StaffName = StaffName)
UPDATE @ResultTable | [
-0.04423162713646889,
0.13890056312084198,
0.4983553886413574,
-0.09933986514806747,
0.10125784575939178,
0.09796425700187683,
0.10223642736673355,
-0.13882312178611755,
-0.2747807800769806,
-0.4540840685367584,
-0.0009402371942996979,
0.22165215015411377,
-0.29998502135276794,
0.166002675... | |
Stage2Count= (
SELECT COUNT(*) AS count FROM ViewJob
WHERE InStage2 = 1
@ResultTable.StaffName = StaffName)
``` | [
-0.28713756799697876,
0.04159821197390556,
0.4628089666366577,
-0.3712378442287445,
0.21857473254203796,
-0.07492899149656296,
0.5322898626327515,
-0.24981582164764404,
0.13945604860782623,
-0.6720998287200928,
-0.04839484021067619,
0.4712774157524109,
-0.08049837499856949,
0.1703374981880... | |
Using C# and WPF under .NET (rather than [Windows Forms](http://en.wikipedia.org/wiki/Windows_Forms) or console), what is the correct way to create an application that can only be run as a single instance?
I know it has something to do with some mythical thing called a mutex, rarely can I find someone that bothers to stop and explain what one of these are.
The code needs to also inform the already-running instance that the user tried to start a second one, and maybe also pass any command-line arguments if any existed.
Here is a very good [article](http://sanity-free.org/143/csharp_dotnet_single_instance_application.html) regarding the Mutex solution. The approach described by the | [
0.20347024500370026,
0.14600150287151337,
0.07191580533981323,
0.21075810492038727,
0.020380081608891487,
0.07506348192691803,
0.38102781772613525,
-0.37811678647994995,
-0.2958928942680359,
-0.2797842025756836,
0.07496467232704163,
0.5824552178382874,
-0.33376526832580566,
0.1421706676483... | |
article is advantageous for two reasons.
First, it does not require a dependency on the Microsoft.VisualBasic assembly. If my project already had a dependency on that assembly, I would probably advocate using the approach [shown in another answer](https://stackoverflow.com/a/19326/3195477). But as it is, I do not use the Microsoft.VisualBasic assembly, and I'd rather not add an unnecessary dependency to my project.
Second, the article shows how to bring the existing instance of the application to the foreground when the user tries to start another instance. That's a very nice touch that the other Mutex solutions described here do not address.
---
### UPDATE
As of 8/1/2014, | [
0.16336214542388916,
0.09992611408233643,
0.48919492959976196,
-0.06413477659225464,
-0.13348689675331116,
-0.2247752845287323,
0.19859787821769714,
-0.09493928402662277,
-0.2927078306674957,
-0.6496576070785522,
-0.12094879150390625,
0.6021736860275269,
-0.2095176875591278,
0.060449320822... | |
the article I linked to above is still active, but the blog hasn't been updated in a while. That makes me worry that eventually it might disappear, and with it, the advocated solution. I'm reproducing the content of the article here for posterity. The words belong solely to the blog owner at [Sanity Free Coding](http://sanity-free.org/).
> Today I wanted to refactor some code that prohibited my application
> from running multiple instances of itself.
>
>
> Previously I had use [System.Diagnostics.Process](http://msdn.microsoft.com/en-us/library/system.diagnostics.process(v=vs.110).aspx) to search for an
> instance of my myapp.exe in the process list. While this works, it
> brings on | [
0.4969124495983124,
0.23984093964099884,
0.3539348840713501,
0.1548856645822525,
-0.13333623111248016,
-0.06370353698730469,
0.6267435550689697,
-0.0677247866988182,
-0.26926326751708984,
-0.6502634286880493,
0.07536542415618896,
0.0513935349881649,
-0.08105941116809845,
0.5458207130432129... | |
a lot of overhead, and I wanted something cleaner.
>
>
> Knowing that I could use a mutex for this (but never having done it
> before) I set out to cut down my code and simplify my life.
>
>
> In the class of my application main I created a static named [Mutex](http://msdn.microsoft.com/en-us/library/system.threading.mutex(v=vs.110).aspx):
```
static class Program
{
static Mutex mutex = new Mutex(true, "{8F6F0AC4-B9A1-45fd-A8CF-72F04E6BDE8F}");
[STAThread]
...
}
```
> Having a named mutex allows us to stack synchronization across
> multiple threads and processes which is just the magic I'm looking
> for.
>
>
> | [
0.08132007718086243,
0.00020382271031849086,
0.3723865747451782,
-0.1402197927236557,
-0.24087883532047272,
0.3804180324077606,
0.5406395792961121,
-0.3058314919471741,
-0.35119810700416565,
-0.5048598051071167,
0.2735822796821594,
0.30368226766586304,
-0.45144543051719666,
0.4274756312370... | |
[Mutex.WaitOne](http://msdn.microsoft.com/en-us/library/58195swd(v=vs.110).aspx) has an overload that specifies an amount of time for us
> to wait. Since we're not actually wanting to synchronizing our code
> (more just check if it is currently in use) we use the overload with
> two parameters: [Mutex.WaitOne(Timespan timeout, bool exitContext)](http://msdn.microsoft.com/en-us/library/85bbbxt9(v=vs.110).aspx).
> Wait one returns true if it is able to enter, and false if it wasn't.
> In this case, we don't want to wait at all; If our mutex is being
> used, skip it, and move on, so we pass in TimeSpan.Zero (wait 0
> milliseconds), and set the exitContext to true | [
0.3385651409626007,
-0.1188272088766098,
0.6110587120056152,
-0.1029805913567543,
0.2996672987937927,
0.14326214790344238,
0.5083373188972473,
-0.4866841733455658,
-0.049562860280275345,
-0.31602025032043457,
-0.09557628631591797,
0.4879274368286133,
-0.026501953601837158,
0.19616733491420... | |
so we can exit the
> synchronization context before we try to aquire a lock on it. Using
> this, we wrap our Application.Run code inside something like this:
```
static class Program
{
static Mutex mutex = new Mutex(true, "{8F6F0AC4-B9A1-45fd-A8CF-72F04E6BDE8F}");
[STAThread]
static void Main() {
if(mutex.WaitOne(TimeSpan.Zero, true)) {
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new Form1()); | [
0.3632764220237732,
-0.12215641885995865,
0.5199552178382874,
-0.27513957023620605,
0.4300934672355652,
0.25686225295066833,
0.6026448607444763,
-0.4110124111175537,
-0.030748650431632996,
-0.5368861556053162,
-0.42126211524009705,
0.6230773329734802,
-0.43755677342414856,
0.41300359368324... | |
mutex.ReleaseMutex();
} else {
MessageBox.Show("only one instance at a time");
}
}
}
```
> So, if our app is running, WaitOne will return false, and we'll get a
> message box.
>
>
> Instead of showing a message box, I opted to utilize a little Win32 to
> notify my running instance that someone forgot that it was already
> running (by bringing itself | [
0.4158715605735779,
0.10863112658262253,
0.3340551555156708,
-0.26804158091545105,
-0.02420075610280037,
0.17167368531227112,
0.7963456511497498,
-0.35691800713539124,
-0.04052285850048065,
-0.47891658544540405,
0.03024117648601532,
0.5315764546394348,
-0.697908878326416,
0.203427344560623... | |
to the top of all the other windows). To
> achieve this I used [PostMessage](http://msdn.microsoft.com/en-us/library/windows/desktop/ms644944(v=vs.85).aspx) to broadcast a custom message to every
> window (the custom message was registered with [RegisterWindowMessage](http://msdn.microsoft.com/en-us/library/windows/desktop/ms644947(v=vs.85).aspx)
> by my running application, which means only my application knows what
> it is) then my second instance exits. The running application instance
> would receive that notification and process it. In order to do that, I
> overrode [WndProc](http://msdn.microsoft.com/en-us/library/system.windows.forms.form.wndproc(v=vs.110).aspx) in my main form and listened for my custom
> notification. When I received that notification I set the form's
> TopMost property to true to bring it | [
0.12143703550100327,
-0.11358039826154709,
0.9429510831832886,
-0.1943293958902359,
-0.07194972038269043,
-0.06727448105812073,
0.6671225428581238,
-0.4162760376930237,
-0.08471037447452545,
-0.6319790482521057,
-0.16634254157543182,
0.4903142750263214,
-0.14198002219200134,
0.377459883689... | |
up on top.
>
>
> Here is what I ended up with:
>
>
> * Program.cs
```
static class Program
{
static Mutex mutex = new Mutex(true, "{8F6F0AC4-B9A1-45fd-A8CF-72F04E6BDE8F}");
[STAThread]
static void Main() {
if(mutex.WaitOne(TimeSpan.Zero, true)) {
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new Form1());
mutex.ReleaseMutex(); | [
0.09796474128961563,
-0.04177813231945038,
0.6845874786376953,
-0.17409087717533112,
0.18106195330619812,
0.32370272278785706,
0.4313328266143799,
-0.5455830097198486,
-0.5000170469284058,
-0.4270138740539551,
-0.35912296175956726,
0.3781837224960327,
-0.34478530287742615,
0.32645124197006... | |
} else {
// send our Win32 message to make the currently running instance
// jump on top of all the other windows
NativeMethods.PostMessage(
(IntPtr)NativeMethods.HWND_BROADCAST,
NativeMethods.WM_SHOWME, | [
0.12242896854877472,
-0.1865503191947937,
0.16056975722312927,
0.04424728825688362,
0.19890810549259186,
-0.12484076619148254,
0.472792387008667,
-0.033220160752534866,
-0.22378481924533844,
-0.6990000605583191,
-0.10290032625198364,
0.4194057583808899,
-0.42776551842689514,
0.269459396600... | |
IntPtr.Zero,
IntPtr.Zero);
}
}
}
```
> * NativeMethods.cs
```
// this class just wraps some Win32 stuff that we're going to use
internal class NativeMethods
{
public const int HWND_BROADCAST = 0xffff;
public static readonly int WM_SHOWME = RegisterWindowMessage("WM_SHOWME");
[DllImport("user32")]
public static extern bool PostMessage(IntPtr hwnd, int msg, IntPtr wparam, IntPtr lparam);
[DllImport("user32")]
public | [
0.18660061061382294,
-0.15410830080509186,
0.558448076248169,
-0.19061054289340973,
0.13904260098934174,
-0.23736433684825897,
0.5439631342887878,
-0.3312010169029236,
-0.20446042716503143,
-0.7502885460853577,
-0.4448963701725006,
0.5734940767288208,
-0.3082538843154907,
0.509757041931152... | |
static extern int RegisterWindowMessage(string message);
}
```
> * Form1.cs (front side partial)
```
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
protected override void WndProc(ref Message m)
{
if(m.Msg == NativeMethods.WM_SHOWME) {
ShowMe();
}
base.WndProc(ref m);
}
private void ShowMe() | [
-0.013924838975071907,
-0.3259669840335846,
0.6630343198776245,
-0.4682912528514862,
-0.08914998918771744,
0.05112862214446068,
0.5937368273735046,
-0.3429316580295563,
-0.03179575502872467,
-0.5743303894996643,
-0.626878023147583,
0.2771262228488922,
-0.38932284712791443,
0.38444662094116... | |
{
if(WindowState == FormWindowState.Minimized) {
WindowState = FormWindowState.Normal;
}
// get our current "TopMost" value (ours will always be false though)
bool top = TopMost;
// make our form jump to the top of everything
TopMost = true; | [
-0.0010146935237571597,
-0.3147631883621216,
0.7110829949378967,
-0.02014322206377983,
0.5695981383323669,
-0.428478479385376,
0.5014290809631348,
-0.3116157352924347,
0.2404291033744812,
-0.18704858422279358,
-0.4780719578266144,
0.5255573987960815,
-0.036663319915533066,
-0.3953182995319... | |
// set it back to whatever it was
TopMost = top;
}
}
``` | [
0.08710487186908722,
0.2492702305316925,
0.36553266644477844,
-0.26440829038619995,
0.3072429299354553,
-0.25469210743904114,
-0.05762716382741928,
0.1448693424463272,
-0.0029107159934937954,
-0.38603851199150085,
-0.29089128971099854,
0.6803674697875977,
-0.2537252604961395,
0.09512820839... | |
How would one create an iterative function (or iterator object) in python?
Iterator objects in python conform to the iterator protocol, which basically means they provide two methods: `__iter__()` and `__next__()`.
* The `__iter__` returns the iterator object and is implicitly called
at the start of loops.
* The `__next__()` method returns the next value and is implicitly called at each loop increment. This method raises a StopIteration exception when there are no more value to return, which is implicitly captured by looping constructs to stop iterating.
Here's a simple example of a counter:
```
class Counter:
def __init__(self, low, high): | [
-0.11345686763525009,
-0.14043022692203522,
-0.041490647941827774,
-0.11900453269481659,
-0.22812002897262573,
0.3089139759540558,
0.19691328704357147,
-0.2843208611011505,
-0.10689115524291992,
-0.3360973000526428,
-0.1276005506515503,
0.526382565498352,
-0.3670244812965393,
0.14745634794... | |
self.current = low - 1
self.high = high
def __iter__(self):
return self
def __next__(self): # Python 2: def next(self)
self.current += 1
if self.current < self.high:
return self.current
raise StopIteration
for c in Counter(3, 9):
print(c)
```
This will print:
```
3
4
5
6
7
8
```
This is easier to | [
-0.1703140288591385,
-0.006184002384543419,
0.5827366709709167,
-0.542083203792572,
0.0998007208108902,
0.1603425145149231,
0.024388257414102554,
-0.3644876778125763,
-0.10482507199048996,
-0.1870357096195221,
0.011320604011416435,
0.6842807531356812,
-0.13763044774532318,
0.04899005219340... | |
write using a generator, as covered in a previous answer:
```
def counter(low, high):
current = low
while current < high:
yield current
current += 1
for c in counter(3, 9):
print(c)
```
The printed output will be the same. Under the hood, the generator object supports the iterator protocol and does something roughly similar to the class Counter.
David Mertz's article, [Iterators and Simple Generators](https://www.ibm.com/developerworks/library/l-pycon/), is a pretty good introduction. | [
0.46466222405433655,
-0.09867432713508606,
0.11471875011920929,
-0.12620121240615845,
-0.020658819004893303,
-0.062316786497831345,
0.1259126365184784,
-0.4667522609233856,
0.020152609795331955,
-0.2706914246082306,
-0.1523343324661255,
0.855964720249176,
-0.37377873063087463,
-0.246611118... | |
If you're building an `AJA~Xy` app, are there any downsides to using `JSONP` requests/responses even if you're not planning on any `cross-domain` requests?
The only thing I can think of is that there are a couple extra bytes for the callback wrapper...
**Edit:**
I found [this](http://remysharp.com/2007/10/08/what-is-jsonp/) which also suggests `security and error handling` as potential problems...
> There's no error handling. The `script injection` either works, or it doesn't.
> If there's an error from the `injection`, it'll hit the page, and short of a window wide error handler (bad, bad, very bad), you need to be sure the return value | [
0.07802943140268326,
-0.042356934398412704,
0.258432000875473,
0.0422946996986866,
-0.23317645490169525,
0.11087670177221298,
0.36217859387397766,
-0.003138102125376463,
-0.22272509336471558,
-0.5663650035858154,
-0.46000829339027405,
0.6158183813095093,
-0.40994447469711304,
-0.3187326192... | |
is valid on the `server side`.
I don't think `error handling` is much of a problem... most of us would use a library to generate the `JSON`... the well-formedness of my response isn't a concern for this question.
**and security:**
> There are documents out on the web that can help, but as a cursory check, I would check the referrer in the `server side` script.
it seems like this is a potential problem with any type of response... certainly, there's nothing unique to `JSONP` in the security arena...?
Downside? It's fairly limited - you trigger a "GET" request and get back some script that's | [
0.2890762984752655,
0.13199079036712646,
0.4865000247955322,
0.17579765617847443,
-0.2194540798664093,
-0.1373852640390396,
0.18878047168254852,
-0.29768121242523193,
-0.19978265464305878,
-0.22631512582302094,
-0.38337600231170654,
0.5364401936531067,
0.13901087641716003,
-0.1943507641553... | |
executed. You don't get error handling if your server throws an error, so you need to wrap all errors in JSON as well. You can't really cancel or retry the request. You're at the mercy of the various browser author opinions of "correct" behavior for dynamically-generated `<script>` tags. Debugging is somewhat more difficult.
That said, i've used it on occasion, and haven't suffered. YMMV. | [
0.32156842947006226,
-0.12113449722528458,
0.13998445868492126,
-0.0764615535736084,
-0.2274271547794342,
-0.29001057147979736,
0.45982450246810913,
-0.0068740020506083965,
-0.38570308685302734,
-0.39301297068595886,
-0.27661997079849243,
0.5130618810653687,
-0.537674605846405,
-0.19296719... | |
There is some documentation on the internet that shows that Windows changes the behavior of the NotifyIcon.BalloonTipShown command if the user is currently idle and this is [detected by checking for keyboard and mouse events](http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=343411&SiteID=1). I am currently working on an application that spends most of its time in the system tray, but pop-ups up multiple balloon tips from time to time and I would like to prevent the user from missing any of them if they are currently away from the system. Since any currently displayed balloon tips are destroyed if a new one is displayed, I want to | [
0.4679626524448395,
0.22349640727043152,
0.30093541741371155,
0.03535647690296173,
-0.04730836674571037,
-0.24130211770534515,
0.32025599479675293,
-0.09031561762094498,
-0.2553946077823639,
-0.5669524669647217,
0.17438039183616638,
0.11485616862773895,
-0.29602527618408203,
0.077295124530... | |
hold off on displaying them if the user is away.
As such, is there any way to check to see if the user is currently idle if the application is minimized to the system tray?
How about the Win32 [LASTINPUTINFO](http://www.codeproject.com/KB/cs/GetIdleTimeWithCS.aspx) function?
```
using System.Runtime.InteropServices;
[DllImport("User32.dll")]
static extern bool GetLastInputInfo(ref LASTINPUTINFO plii);
struct LASTINPUTINFO
{
public uint cbSize;
public uint dwTime;
}
``` | [
0.21396617591381073,
-0.18905870616436005,
0.619573712348938,
-0.16382019221782684,
0.17566466331481934,
-0.12263815104961395,
0.11368422955274582,
0.07067057490348816,
-0.5662533044815063,
-0.6796990633010864,
-0.5190926790237427,
0.4701528549194336,
-0.24735131859779358,
0.43720924854278... | |
I have a web application that sometimes just hangs over heavy load. To make it come back I have to kill the "dllhost.exe" process. **Does someone know what to do?**
This is an Classic ASP (VBScript) app with lots of COM+ objects.
The server has the following configuration:
* Intel Core 2 Duo 2.2 GHz / 4 GB RAM
* Windows Server 2003 Web Edition SP2
* IIS 6.0
There is some errors in the event log related to the COM objects. But why errors in the COM objects would crash the whole server?
The COM objects are PowerBuilder objects deployed as COM objects.
Is IIS 7.0 (much) | [
0.0947970375418663,
0.059008676558732986,
0.31262490153312683,
0.15068183839321136,
-0.1958671361207962,
-0.21813003718852997,
0.26530730724334717,
-0.03544953837990761,
-0.27049052715301514,
-0.6615350842475891,
-0.09596971422433853,
0.8924055099487305,
-0.2751358449459076,
0.137199342250... | |
more stable than IIS 6.0?
Sounds like dodgy COM objects causing the problem .. do you load them into the "Application", if you do then are they threadsafe; or are they used and discarded on each request?
Yes, recycling every few hours would help 'hide' the problem, but they ought to be debugged and fixed properly ... have you tried divide/conquer to discover which COM object is the problem ... I can imagine this is tricky on a production environment so you need to set up some heavy automated tests to reproduce the problem locally then you can do something about it. | [
0.17207695543766022,
-0.09961605072021484,
0.22674953937530518,
0.23606202006340027,
0.34523823857307434,
-0.3381878137588501,
0.21231335401535034,
-0.1966959834098816,
-0.23590087890625,
-0.5320478677749634,
0.026749730110168457,
0.6017052531242371,
-0.5131257176399231,
-0.065946474671363... | |
I could only find the function `confirm()` that gives OK/Cancel buttons. Is there any way to give Yes/No buttons?
Javascript offers 3 modal boxes. `prompt`, `confirm` and `alert`. None of those satisfy your request.
There are a plethora of js modal popup solutions. Here's an example.
* [ModalBox](https://github.com/okonet/modalbox) | [
0.12112699449062347,
-0.03869897872209549,
0.33280402421951294,
-0.049470193684101105,
-0.08278995007276535,
0.14921751618385315,
0.24217772483825684,
-0.25082927942276,
0.00554870767518878,
-0.3634820878505707,
-0.13142767548561096,
0.6249983310699463,
-0.5152416229248047,
-0.241879716515... | |
In my code behind I wire up my events like so:
```
protected override void OnInit(EventArgs e)
{
base.OnInit(e);
btnUpdateUser.Click += btnUpateUserClick;
}
```
I've done it this way because that's what I've seen in examples.
* Does the base.OnInit() method need to be called?
* Will it be implicitly be called?
* Is it better to call it at the beginning of the method or at the end?
* What would be an example where confusion over the base method can get you in trouble?
I should clarify:
The guidelines recommend that firing an event should involve calling a virtual "On*EventName*" method, but they | [
-0.00043116166489198804,
-0.09541935473680496,
0.07278317213058472,
-0.21216745674610138,
0.05118577927350998,
0.00706506660208106,
0.4059169292449951,
-0.3029837906360626,
-0.2261243313550949,
-0.33063164353370667,
-0.12312877923250198,
0.812802255153656,
-0.4456455707550049,
-0.062958501... | |
also say that if a derived class overrides that method and forgets to call the base method, the event should still fire.
See the "Important Note" about halfway down [this page](http://msdn.microsoft.com/en-us/library/ms229011.aspx):
> Derived classes that override the protected virtual method are not required to call the base class implementation. The base class must continue to work correctly even if its implementation is not called. | [
0.1455117017030716,
-0.040552619844675064,
0.09881366789340973,
0.07624697685241699,
0.24450145661830902,
-0.4860638678073883,
0.6342012286186218,
-0.12478409707546234,
-0.14495475590229034,
-0.31411468982696533,
-0.3761154115200043,
0.8260846138000488,
-0.15223698318004608,
0.044726975262... | |
I'd like to use a database to store i18n key/value pairs so we can modify / reload the i18n data at runtime. Has anyone done this? Or does anyone have an idea of how to implement this? I've read several threads on this, but I haven't seen a workable solution.
I'm specifically refering to something that would work with the jstl tags such as
```
<fmt:setlocale>
<fmt:bundle>
<fmt:setBundle>
<fmt:message>
```
I think this will involve extending ResourceBundle, but when I tried this I ran into problems that had to do with the way the jstl tags get the resource bundle.
Are you just asking how to store UTF-8/16 characters | [
0.7971349954605103,
-0.29975488781929016,
0.232020765542984,
0.20822717249393463,
-0.005889706779271364,
-0.03804333880543709,
0.059388089925050735,
-0.1483694612979889,
-0.22154530882835388,
-0.6760716438293457,
-0.01855895295739174,
0.4891681969165802,
-0.3879043161869049,
-0.10623898357... | |
in a DB? in mysql it's just a matter of making sure you build with UTF8 support and setting that as the default, or specifying it at the column or table level. I've done this in oracle and mysql before. Create a table and cut and paste some i18n data into it and see what happens... you might be set already..
or am I completely missing your point?
edit:
to be more explicit... I usually implement a three column table... language, key, value... where "value" contains potentially foreign language words or phrases... "language" contains some language key and "key" is an | [
0.38084468245506287,
0.17878296971321106,
0.10551556199789047,
-0.12647661566734314,
-0.35166963934898376,
-0.04019247367978096,
0.3134177029132843,
-0.4736030399799347,
0.41613805294036865,
-0.5034581422805786,
-0.10991044342517853,
0.5494452118873596,
-0.41362476348876953,
-0.04347748309... | |
english key (i.e. login.error.password.dup)... language and key are indexed...
I've then built interfaces on a structure like this that shows each key with all its translations (values)... it can get fancy and include audit trails and "dirty" markers and all the other stuff you need to enable translators and data entry folk to make use of it..
Edit 2:
Now that you added the info about the JSTL tags, I understand a bit more... I've never done that myself.. but I found this old info on [theserverside](http://www.theserverside.com/discussions/thread.tss?thread_id=27390)...
```
HttpSession session = .. [get hold of the session]
ResourceBundle bundle = new PropertyResourceBundle(toInputStream(myOwnProperties)) [toInputStream just | [
0.17675094306468964,
0.05345407500863075,
0.6258333921432495,
-0.06951640546321869,
0.09347536414861679,
-0.30780547857284546,
0.4206182658672333,
-0.019151488319039345,
-0.027189550921320915,
-0.5449121594429016,
-0.27053093910217285,
0.5742591619491577,
-0.1451948583126068,
0.02098447456... | |
stores the properties into an inputstream]
Locale locale = .. [get hold of the locale]
javax.servlet.jsp.jstl.core.Config.set(session, Config.FMT_LOCALIZATION_CONTEXT, new LocalizationContext(bundle ,locale));
``` | [
-0.18235766887664795,
-0.11344216763973236,
0.3776322901248932,
-0.12980370223522186,
0.48632436990737915,
-0.17589589953422546,
0.23602767288684845,
-0.16747412085533142,
-0.2561531066894531,
-0.5733547210693359,
-0.5709519386291504,
0.35730448365211487,
-0.29751136898994446,
0.2469394654... | |
I've been using WWF for a while as part of an internal call center application (ASP.NET), and while learning it was a good practice in understanding how a state machine based workflow system *should* work, I am definitely not in love with WWF itself. In my opinion it is:
1. Overly complex, especially for use within web apps (all that threaded runtime stuff)
2. Immature (ever worked with that horrible designer?)
3. Anemic in its current feature set
Does anyone have a suggestion for a better .NET based workflow framework? Specifically, I am looking for the following features:
1. State machine based (mapping states to | [
0.1972481608390808,
0.14174404740333557,
0.11610350012779236,
0.03713387995958328,
-0.23414075374603271,
-0.3955829441547394,
-0.03214764595031738,
-0.0679922103881836,
-0.04456062987446785,
-0.35022932291030884,
0.5053396224975586,
0.20700444281101227,
-0.3276403546333313,
0.0040904087945... | |
available actions)
2. A focus on user permissions (controlling who has access to what actions)
3. The ability to run workflows as timed background tasks (for example, to send out reminders for items that have been sitting in a certain state for x days)
That's really all I need. I don't need to be able to "drag and drop" any activities or visually design the flow. I am perfectly comfortable writing actual code once a particular action is triggered.
You could try [Simple State Machine](http://www.thefreakparade.com/2008/05/simplestatemachine-codeplex-project/). You would have to implement access control and background timers yourself, but that shouldn't be a big deal. SSM | [
-0.02803441882133484,
-0.24073274433612823,
0.271478533744812,
0.061274100095033646,
-0.20821651816368103,
0.09164850413799286,
0.5381730198860168,
-0.4524129033088684,
-0.5990312695503235,
-0.6593347191810608,
-0.05075908079743385,
0.47604134678840637,
-0.1732604205608368,
-0.275123953819... | |
was also built out of frustration with WF. [There are some other state machine implementations on Codeplex](http://www.codeplex.com/Project/ProjectDirectory.aspx?ProjectSearchText=%22state%20machine%22) as well. If one of them doesn't fit he bill out of the box, they are open source and should get you close enough.
I wholeheartedly agree with you about state machines in WF - they aren't testable, are too complicated, the threading model is peculiar and hard to follow, and I'm not sure a visual designer could have been more poorly conceived for designing state machines graphically. I think this may be because the state machine concept feels tacked onto the WF | [
0.4059221148490906,
0.05356255918741226,
-0.0004337604914326221,
0.13936825096607208,
-0.27189192175865173,
0.07022517174482346,
0.23082715272903442,
-0.31787121295928955,
-0.18044595420360565,
-0.6240791082382202,
0.12036307156085968,
0.25157371163368225,
-0.4826895296573639,
0.3438968658... | |
runtime, which was designed for sequential state machines, something WF does a much better job with, in my opinion. The problem is that state machines are really not the same animal as a sequential work flow, and should have been given a first class implementation of their own, because the warping of WF to make it seem to support them turned out to be more or less unsupportable, if not actually unusable. | [
0.027282193303108215,
-0.4950401484966278,
0.17501118779182434,
0.20658554136753082,
-0.12629738450050354,
0.2405969798564911,
0.20269648730754852,
-0.08711634576320648,
-0.2349650114774704,
-0.5371962785720825,
0.012935436330735683,
0.3755691945552826,
-0.5128414034843445,
-0.066583797335... | |
At my university most of my classes have been in Java. I have also recently learned C# (and the Visual Studio environment) at a summer internship. Now I'm taking an Intro to Computer Graphics class and the grad student teaching the class prefers us to use C++ to access the OpenGL bindings via GLUT.
Does anyone have any good resources on how to make a good transition from Java/C# to C++? Obviously pointers are going to be a big issue, but any other things I should be looking out for? Any tutorials, guides, etc. would be very helpful!
Thanks!
Yeah, I got bit | [
0.40538567304611206,
0.30874598026275635,
0.14433008432388306,
0.014039618894457817,
-0.2716144919395447,
-0.13808166980743408,
0.3887673020362854,
0.5441113114356995,
-0.3159452974796295,
-0.7698104977607727,
0.20625340938568115,
0.5025802254676819,
0.46283766627311707,
0.0741669684648513... | |
by the same bug. The university tended to lean on Java, and then allowed you to choose the language you wanted to work with during projects.
The best way is to just jump in. Start small, take baby steps, and just Google things that confuse you when you get there. Also find projects that have released their source code. See how they structure their programs. Basically, just tinker with concepts. There is plenty of information around the web.
Make it fun and grab a [C++ game development book](https://rads.stackoverflow.com/amzn/click/com/1598633600) so it doesn't become mind numbing too quickly.
Here's some places that I found | [
0.3522188067436218,
0.18234758079051971,
-0.24894499778747559,
0.41369521617889404,
0.15042975544929504,
-0.21398033201694489,
0.3126579821109772,
0.35962530970573425,
-0.40040597319602966,
-0.40521734952926636,
0.06863944977521896,
0.43855538964271545,
0.007060403469949961,
0.012188253924... | |
useful while learning
<http://www.cprogramming.com/>
<http://www.wikipedia.com>
<http://www.cplusplus.com/> | [
0.2489129900932312,
-0.12527260184288025,
0.25430139899253845,
0.3234618306159973,
0.2493923008441925,
-0.22330306470394135,
0.06134190782904625,
0.13128331303596497,
-0.3938315808773041,
-0.3573477268218994,
-0.16387279331684113,
0.0242382250726223,
0.2698480784893036,
0.07372981309890747... | |
Occasionally, I find that while debugging an ASP.Net application (written in visual studio 2008, running on Vista 64-bit) the local ASP.Net development server (i.e. 'Cassini') stops responding.
A message often comes up telling me that "Data Execution Prevention (DEP)" has killed WebDev.WebServer.exe
The event logs simply tell me that "WebDev.WebServer.exe has stopped working"
I've heard that this 'problem' presents itself more often on Vista 64-bit because DEP is on by default. Hence, turning DEP off may 'solve' the problem.
But i'm wondering:
*Is there a known bug/situation with Cassini that causes DEP to kill the process?*
*Alternatively, what is the practical danger of disabling Data | [
0.23151718080043793,
0.12675665318965912,
-0.027274927124381065,
0.15138354897499084,
-0.21883463859558105,
-0.12801064550876617,
0.6476932168006897,
-0.11813711374998093,
-0.42575493454933167,
-0.44479069113731384,
-0.567095935344696,
0.5408385396003723,
-0.4810372591018677,
0.24316418170... | |
Execution Prevention?*
The only way to know for sure would be to dig through the Cassini source and see if there are any areas where it generates code on the heap and then executes it without clearing the NX flag.
However, instead of doing that, why not use IIS?
EDIT:
The danger of disabling DEP is that you open up security holes. DEP works by not allowing arbitrary generated code on the heap to be executed. This helps prevent malware programs from inserting code into the data segments of legit programs. | [
0.40645265579223633,
0.0112477270886302,
-0.4543006122112274,
0.14543190598487854,
-0.2325105220079422,
-0.08683126419782639,
0.5695297718048096,
-0.39299485087394714,
-0.434818297624588,
-0.5137642025947571,
-0.030758002772927284,
0.3559156358242035,
-0.4566172659397125,
0.072138451039791... | |
How can I request a random row (or as close to truly random as is possible) in pure SQL?
See this post: [SQL to Select a random row from a database table](http://www.petefreitag.com/item/466.cfm). It goes through methods for doing this in MySQL, PostgreSQL, Microsoft SQL Server, IBM DB2 and Oracle (the following is copied from that link):
Select a random row with MySQL:
```
SELECT column FROM table
ORDER BY RAND()
LIMIT 1
```
Select a random row with PostgreSQL:
```
SELECT column FROM table
ORDER BY RANDOM()
LIMIT 1
```
Select a random row with Microsoft SQL Server:
```
SELECT TOP 1 column FROM table
ORDER BY NEWID()
```
Select a random row with IBM DB2
```
SELECT column, RAND() as | [
-0.09866833686828613,
0.06864148378372192,
0.3050173223018646,
0.08532412350177765,
-0.15024885535240173,
0.11271402984857559,
-0.19275757670402527,
-0.33558472990989685,
0.0013770461082458496,
-0.46125826239585876,
-0.010569999925792217,
0.2862218916416168,
-0.16640955209732056,
0.3365756... | |
IDX
FROM table
ORDER BY IDX FETCH FIRST 1 ROWS ONLY
```
Select a random record with Oracle:
```
SELECT column FROM
( SELECT column FROM table
ORDER BY dbms_random.value )
WHERE rownum = 1
``` | [
-0.34867754578590393,
0.12060186266899109,
0.17054957151412964,
-0.013212630525231361,
-0.041443873196840286,
0.2613822817802429,
-0.09528106451034546,
-0.6068716049194336,
0.20978926122188568,
-0.3949596583843231,
-0.09999430179595947,
0.39045050740242004,
-0.4234006404876709,
0.130779251... | |
What is a good free library for editing MP3s/FLACs.
By editing I mean:
* Cutting audio file into multiple parts
* Joining multiple audio files together
* Increase playback speed of file without affecting the pitch (eg. podcasts up to 1.3x)
* Re-encoding audio file from Flac -> MP3 or vice versa
I don't mean software, I mean a library that I can use within another application. Programming language agnostic.
Just about every language has bindings to C, so you'll probably want to get the applicable C libraries for encoding/decoding mp3's and FLAC files. This list might include
libFLAC <http://flac.sourceforge.net/api/index.html> FLAC encoding/decoding
LAME <http://lame.sourceforge.net/index.php> MP3 encoding | [
0.38761958479881287,
0.07092426717281342,
-0.0801236480474472,
0.1806185245513916,
-0.17420081794261932,
-0.22633065283298492,
-0.04960716515779495,
-0.34894615411758423,
-0.30102792382240295,
-0.6389229893684387,
0.07040553539991379,
0.694891095161438,
-0.3152907192707062,
-0.163807436823... | |
MAD <http://www.underbit.com/products/mad/> MP3 decoding
The rest of your signal processing needs could be gathered around a single popular API such as LADSPA <http://www.ladspa.org/>.
Here's a stretching / pitch shifting library: <http://www.breakfastquay.com/rubberband/>
Most audio processing programs have a certain internal format they use. That keeps things simple. Everything coming in gets converted to the same format. Once you've standardized the internal format, cutting and splicing audio data is about as difficult as cutting and splicing strings. You don't really need a library for that. | [
0.5968902111053467,
-0.10001508891582489,
-0.11396219581365585,
0.04551278054714203,
-0.42363065481185913,
-0.06681855767965317,
0.09642180055379868,
-0.12808074057102203,
-0.20076118409633636,
-0.17534182965755463,
0.027393467724323273,
0.9679489135742188,
0.05100862309336662,
0.031937837... | |
I have a datalist with a OnDeleteCommand="Delete\_Command".
I want the delete a record with multiple primary Keys but I do not know how to access it from the Delete\_Command event.
If I use DataKeyField I'm limited to only one key.
Any workarounds for this?
You can access all of the keys:
```
gridView.DataKeys[rowNum][dataKeyName]
```
where rowNum is e.RowIndex from the gridView\_RowDeleting event handler, and dataKeyName is the key you want to get:
```
<asp:GridView ID="gridView" runat="server" DataKeyNames="userid, id1, id2, id3" OnRowDeleting="gridView_RowDeleting">
protected void gridView_RowDeleting(object sender, GridViewDeleteEventArgs e)
{
gridView.DataKeys[e.RowIndex]["userid"]...
gridView.DataKeys[e.RowIndex]["id1"]...
gridView.DataKeys[e.RowIndex]["id2"]...
gridView.DataKeys[e.RowIndex]["id3"]...
}
``` | [
0.023851053789258003,
0.05551128834486008,
0.5060938000679016,
-0.09403767436742783,
0.1219901591539383,
0.06871040910482407,
0.09901481866836548,
-0.41322165727615356,
-0.3164050579071045,
-0.717409074306488,
-0.17842315137386322,
0.7740996479988098,
-0.23315882682800293,
0.38737466931343... | |
I'm having issues with my SQL Reporting Services reports. I'm using a custom font for report headers, and when deployed to the server it does not render correctly when I print or export to PDF/TIFF. I have installed the font on the server. Is there anything else I need to do in order to use custom fonts?
When viewing the font in the browser it looks correct - since all client computers have the font installed...
---
Thanks Ryan, your post to the FAQ solved the problem. Installing the fonts on the server fixes the print problem, as well as problems with charts | [
0.15949033200740814,
0.3849653899669647,
0.4785037636756897,
0.1492978185415268,
-0.07699071615934372,
-0.032033901661634445,
0.4065735638141632,
0.268327534198761,
-0.274504154920578,
-0.7428551316261292,
0.10365363955497742,
0.5722209215164185,
-0.17894376814365387,
-0.051179565489292145... | |
(which are also rendered on the server). Like you point out (as well as being mentioned in the FAQ) Reporting Services 2005 does not do font embedding in PDF files. I guess that is okay for now - the most important part was being able to hit print and get the correct fonts.
The reason the fonts didn't show up straight away is answered in the FAQ:
> **Q: I've installed the font on my client/server but I still see ?'s or
> black boxes. Why?** A: For the client
> machine, closing all instances of the
> PDF viewer then reopening | [
0.11537156254053116,
0.5202845335006714,
0.6720179915428162,
-0.18930166959762573,
-0.32477396726608276,
0.019152428954839706,
0.457157164812088,
0.153829887509346,
-0.21684381365776062,
-0.6489375233650208,
0.03555149957537651,
0.5808210372924805,
-0.14852416515350342,
0.04126087948679924... | |
them should
> fix the issue.
>
>
> For the server, restarting the
> services should allow the PDF renderer
> to pick up the new font information.
>
>
> Unfortunately, I have also seen times
> where I needed a full machine reboot
> to get the client/server to recognize
> the newly installed font.
The PDF files served up from SSRS, like many PDF files, have embedded postscript fonts. So, the local fonts used in the report are converted to a best matching postscript font when the conversion takes place so the PDF is totally portable without relying on | [
0.10625692456960678,
0.19750110805034637,
0.7823684811592102,
0.2768198549747467,
-0.2669029235839844,
-0.030266620218753815,
0.11261624842882156,
-0.1364365667104721,
-0.38932162523269653,
-0.7840020060539246,
-0.04739959537982941,
0.6182808876037598,
-0.16666311025619507,
0.0857426375150... | |
locally installed fonts.
You can see the official MS guidelines and font requirements for SSRS PDF exports here: [SQL Server 2005 Books Online (September 2007) Designing for PDF Output](http://technet.microsoft.com/en-us/library/ms159713(SQL.90).aspx). Also, this post should provide some help as well: [Reporting Services: PDF Renderer FAQ](http://blogs.msdn.com/donovans/pages/reporting-services-pdf-renderer-faq.aspx)
---
Aspose apparently also has a component that claims to be able to add custom embedded fonts in SQL Report PDFs.
See [Aspose.Pdf for Reporting Services](http://www.aspose.com/community/blogs/aspose.pdf/archive/2008/05/02/aspose-pdf-for-reporting-services-v1-3-0-0-released.aspx)
> Aspose.Pdf for Reporting Services
> makes it possible generating PDF
> reports in Microsoft SQL Server 2000
> and 2005 Reporting Services. Some
> advanced features like XMP metadata,
> **custom embedded font** | [
0.0009327864972874522,
-0.07919059693813324,
0.3938259184360504,
0.07338958233594894,
-0.403584748506546,
0.25246429443359375,
0.13540321588516235,
-0.17055433988571167,
-0.5677069425582886,
-0.476957231760025,
-0.054634515196084976,
0.43777596950531006,
-0.08827762305736542,
-0.1044434830... | |
and rendering
> watermark for pages are now supported.
> All RDL report features including
> sections, images, charts, tables,
> matrices, headers and footers are
> converted with the highest degree of
> precision to PDF.
I've not tried this component, so I can only share what it claims to be able to do. | [
0.02103828638792038,
0.04244844987988472,
0.5784116387367249,
0.014670372940599918,
-0.4813682734966278,
-0.41949528455734253,
0.16136623919010162,
-0.10244753211736679,
-0.024152811616659164,
-0.9429644346237183,
-0.48075053095817566,
0.5093554854393005,
-0.1484529972076416,
-0.0221578292... | |
Following on from my recent question on [Large, Complex Objects as a Web Service Result](https://stackoverflow.com/questions/17725/large-complex-objects-as-a-web-service-result). I have been thinking about how I can ensure all future child classes are serializable to XML.
Now, obviously I could implement the [IXmlSerializable](http://msdn.microsoft.com/en-us/library/system.xml.serialization.ixmlserializable.aspx) interface and then chuck a reader/writer to it but I would like to avoid that since it then means I need to instantiate a reader/writer whenever I want to do it, and 99.99% of the time I am going to be working with a *string* so I may just write my own.
However, to serialize to XML, I am simply decorating the class | [
-0.060883909463882446,
-0.009333796799182892,
0.3343561589717865,
0.30338239669799805,
-0.2464078962802887,
0.06508622318506241,
0.1436336636543274,
0.13108642399311066,
-0.24115851521492004,
-0.7427327632904053,
-0.19277428090572357,
0.1722760945558548,
-0.08028348535299301,
0.37293261289... | |
and its members with the *Xml???* attributes ( *XmlRoot* , *XmlElement* etc.) and then passing it to the *XmlSerializer* and a *StringWriter* to get the string. Which is all good. I intend to put the method to return the string into a generic utility method so I don't need to worry about type etc.
The this that concerns me is this: If I do not decorate the class(es) with the required attributes an error is not thrown until run time.
**Is there any way to enforce attribute decoration? Can this be done with FxCop?** (I have not used FxCop yet)
### UPDATE:
Sorry for | [
0.2638559341430664,
-0.12556076049804688,
0.4468384385108948,
0.21688666939735413,
-0.17472010850906372,
-0.22265149652957916,
0.26495161652565,
-0.12732575833797455,
-0.27398163080215454,
-0.6192788481712341,
0.033770397305488586,
0.7238666415214539,
-0.07667741179466248,
-0.0152580495923... | |
the delay in getting this close off guys, lots to do!
Definitely like the idea of using reflection to do it in a test case rather than resorting to FxCop (like to keep everything together).. [Fredrik Kalseth's answer](https://stackoverflow.com/questions/19454/enforce-attribute-decoration-of-classesmethods#19455) was fantastic, thanks for including the code as it probably would have taken me a bit of digging to figure out how to do it myself!
+1 to the other guys for similar suggestions :)
I'd write a unit/integration test that verifies that any class matching some given criteria (ie subclassing X) is decorated appropriately. If you set up your build to run with tests, | [
0.3384435176849365,
0.10921400040388107,
0.07049405574798584,
0.25025635957717896,
-0.27194926142692566,
0.1036829873919487,
0.410516619682312,
-0.4132472276687622,
-0.3179200291633606,
-0.5199279189109802,
-0.27693215012550354,
0.33901774883270264,
0.03335212171077728,
-0.0007583589176647... | |
you can have the build fail when this test fails.
UPDATE: You said, "Looks like I will just have to roll my sleeves up and make sure that the unit tests are collectively maintained" - you don't have to. Just write a general test class that uses reflection to find all classes that needs to be asserted. Something like this:
```
[TestClass]
public class When_type_inherits_MyObject
{
private readonly List<Type> _types = new List<Type>();
public When_type_inherits_MyObject()
{
// lets find all types that inherit from MyObject, directly or indirectly | [
0.5589842796325684,
-0.0031882550101727247,
-0.11884433776140213,
-0.01932366006076336,
-0.09011708945035934,
-0.40866079926490784,
0.449980765581131,
-0.3761606216430664,
-0.07638069987297058,
-0.6527813673019409,
0.045421868562698364,
0.8634634017944336,
-0.1600055694580078,
0.0474583990... | |
foreach(Type type in typeof(MyObject).Assembly.GetTypes())
{
if(type.IsClass && typeof(MyObject).IsAssignableFrom(type))
{
_types.Add(type);
}
}
}
[TestMethod]
public void Properties_have_XmlElement_attribute
{ | [
0.28226810693740845,
-0.04515187814831734,
0.2091798037290573,
0.01375502161681652,
0.11989250034093857,
-0.04051589220762253,
0.1249663308262825,
-0.41899871826171875,
0.1795879751443863,
-0.6477804183959961,
-0.34528088569641113,
0.4645705223083496,
-0.15282729268074036,
0.11703708767890... | |
foreach(Type type in _types)
{
foreach(PropertyInfo property in type.GetProperties())
{
object[] attribs = property.GetCustomAttributes(typeof(XmlElementAttribute), false);
Assert.IsTrue(attribs.Count > 0, "Missing XmlElementAttribute on property " + property.Name + " in type " + type.FullName); | [
-0.17655378580093384,
0.07184067368507385,
0.3967711925506592,
-0.3382744789123535,
-0.026260431855916977,
0.06819818913936615,
0.4377240836620331,
-0.6475231051445007,
0.11559207737445831,
-0.24891744554042816,
-0.6048173308372498,
0.6184776425361633,
-0.22823938727378845,
0.0998780503869... | |
}
}
}
}
``` | [
-0.016344990581274033,
0.4495171308517456,
0.23163163661956787,
-0.18499617278575897,
0.39558660984039307,
-0.21481190621852875,
0.08800963312387466,
0.4133334159851074,
0.23730628192424774,
-0.5074179768562317,
-0.3644443452358246,
0.5587084293365479,
-0.3209930658340454,
0.33781036734580... | |
I was reading the example chapter from [the book by Ayende](http://www.manning.com/rahien/) and on the website of [the Boo language](http://boo.codehaus.org/) I saw a reference to the [Specter BDD Framework](http://specter.sourceforge.net/).
I am wondering if anybody is using it in their project, how that works out and if there are more examples and/or suggested readings.
Just in case you are wondering, I'm a C# developer and so I plan to use it in a C#/.NET environment.
---
A few year later visiting this question. I think we can safely assume [Specflow](http://www.specflow.org/) and some others like [NSpec](http://nspec.org/) became the tools we are using.
Create one Message table, containing a | [
0.7130269408226013,
0.3504854142665863,
0.018076878041028976,
-0.20863865315914154,
-0.3364590108394623,
-0.15501601994037628,
0.01440319325774908,
0.027859516441822052,
-0.1479259878396988,
-0.37376105785369873,
0.12402594089508057,
0.6655400991439819,
-0.24585266411304474,
-0.01229500956... | |
unique MessageId and the various properties you need to store for a message.
```
Table: Message
Fields: Id, TimeReceived, MessageDetails, WhateverElse...
```
Create two link tables - QuoteMessage and JobMessage. These will just contain two fields each, foreign keys to the Quote/Job and the Message.
```
Table: QuoteMessage
Fields: QuoteId, MessageId
Table: JobMessage
Fields: JobId, MessageId
```
In this way you have defined the data properties of a Message in one place only (making it easy to extend, and to query across all messages), but you also have the referential integrity linking Quotes and Jobs to any number of messages. Indeed, both a Quote and Job could be linked to the *same* | [
0.1140918955206871,
0.18918649852275848,
0.2807759642601013,
0.07138524949550629,
-0.1662171185016632,
0.2002367228269577,
0.002684683771803975,
-0.2778101861476898,
-0.24658596515655518,
-0.5810922980308533,
0.13684211671352386,
0.4804871380329132,
-0.27364084124565125,
0.1738990098237991... | |
message (I'm not sure if that is appropriate to your business model, but at least the data model gives you the option). | [
0.15499059855937958,
-0.34472158551216125,
0.3123898506164551,
0.2779596447944641,
0.038511231541633606,
0.052830275148153305,
0.4558109641075134,
0.647125244140625,
-0.35136955976486206,
-0.450326144695282,
-0.3011568784713745,
0.295685350894928,
-0.28430333733558655,
-0.07409320026636124... | |
Using C# .NET 3.5 and WCF, I'm trying to write out some of the WCF configuration in a client application (the name of the server the client is connecting to).
The obvious way is to use `ConfigurationManager` to load the configuration section and write out the data I need.
```
var serviceModelSection = ConfigurationManager.GetSection("system.serviceModel");
```
Appears to always return null.
```
var serviceModelSection = ConfigurationManager.GetSection("appSettings");
```
Works perfectly.
The configuration section is present in the App.config but for some reason `ConfigurationManager` refuses to load the `system.ServiceModel` section.
I want to avoid manually loading the xxx.exe.config file and using XPath but if I have to resort to that I will. Just seems | [
0.10139881074428558,
0.22046230733394623,
0.582161545753479,
-0.23283591866493225,
0.03351990133523941,
-0.07309802621603012,
0.30781954526901245,
-0.19845058023929596,
-0.08718794584274292,
-0.8517361283302307,
-0.19585812091827393,
0.6367455124855042,
-0.6223443746566772,
-0.009181063622... | |
like a bit of a hack.
Any suggestions?
The [`<system.serviceModel>`](http://msdn.microsoft.com/en-us/library/ms731354%28v=vs.90%29.aspx) element is for a configuration section **group**, not a section. You'll need to use [`System.ServiceModel.Configuration.ServiceModelSectionGroup.GetSectionGroup()`](http://msdn.microsoft.com/en-us/library/system.servicemodel.configuration.servicemodelsectiongroup.getsectiongroup%28v=vs.90%29.aspx) to get the whole group. | [
0.04142928496003151,
-0.20514455437660217,
0.4663763642311096,
0.10870196670293808,
-0.13409139215946198,
0.13789206743240356,
0.12018319219350815,
-0.1687544882297516,
-0.20333343744277954,
-0.4659576714038849,
-0.22530046105384827,
0.17857421934604645,
-0.16923777759075165,
-0.0045131924... | |
What is the best Image Manager to integrate in TinyMce editor apart the official Moxiecode commercial ones?
I'm looking to integrate a light texteditor in an asp.net mvc application and I choosed the Tinymce solution (and not the classic FCKEditor as this seems more lightweight and more jquery friendly).
Sadly TinyMce doesn't come with the Image Manager or Document Manager integrated like FCKeditor but you must buy them as plugins form Moxiecode.
I've looked other plugins but till now I've not find any decend and light solution that works with asp.net mvc framework.
Any suggestions?
There are a couple of open source plugins on | [
0.33344000577926636,
-0.23953938484191895,
0.504546582698822,
0.07753584533929825,
-0.31997063755989075,
-0.08834812045097351,
-0.10428319126367569,
-0.09168446809053421,
-0.04752456024289131,
-0.6165804266929626,
0.2026033252477646,
0.7153869867324829,
-0.3925813138484955,
0.0423261038959... | |
SourceForge,
<http://sourceforge.net/tracker/?group_id=103281&atid=738747>
(search for image)
The plugin architecture is easy to understand if you know Javascript.
If you have the time you could roll out your own. | [
0.3897731304168701,
-0.011821293272078037,
0.17188219726085663,
-0.04984687268733978,
-0.09328623116016388,
-0.12045256048440933,
-0.05439939349889755,
-0.10166830569505692,
-0.110828697681427,
-0.8753754496574402,
-0.2747323215007782,
0.5887627005577087,
-0.2781062722206116,
-0.2640407383... | |
Recently, I've been dealing with an error with accessing MAPI via the .NET framework (as described in [this article](http://blogs.msdn.com/mstehle/archive/2007/10/03/fyi-why-are-mapi-and-cdo-1-21-not-supported-in-managed-net-code.aspx)). I am now left with a series of memory access violation errors.
To get past the issues, I have been trying to use [this 3rd party component](http://www.codeproject.com/KB/IP/CMapiEx.aspx), which has a Visual C++ core. Unfortunately - we are still having the same errors.
I've personally never used Visual C++, but my question is: if the C++ library is compiled using Visual Studio 2005, using Visual C++ - does the memory of the project become managed by the .NET framework, as well, which would therefore | [
-0.10979069024324417,
0.16415882110595703,
-0.004289908334612846,
-0.08188344538211823,
-0.0017657035496085882,
-0.35529059171676636,
0.2288132905960083,
-0.012446827255189419,
-0.3665941059589386,
-0.6375428438186646,
-0.045885492116212845,
0.4735846221446991,
-0.23150399327278137,
0.1880... | |
make it subject to the same issues as the .NET libraries we're using? Or am I barking up the wrong tree?
I'm not entirely sure what you're asking, but i'll give it a shot.
Visual C++ is a pure C/C++ compiler so has none of .NET's memory management, nor any of its runtime -- You have to manually call new and delete.
.NET also provides C++/CLI, which is a slightly modified version of C++ that targets the .NET runtime, and is GC aware -- eg. its memory is managed by the .NET runtime.
Without more details about your bug I can't really make any | [
0.4412861168384552,
0.17774371802806854,
0.04012180119752884,
0.0032740661408752203,
-0.15951111912727356,
-0.2892014980316162,
0.0635143518447876,
0.20442859828472137,
-0.2514612078666687,
-0.5574511885643005,
-0.09572456032037735,
0.731694221496582,
-0.7469834685325623,
-0.00302053708583... | |
suggestions, beyond suggesting that you make sure you use the appropriate GC guards, and the provide finalizers in any place they are needed. | [
0.32966750860214233,
0.08369922637939453,
0.1616390496492386,
0.2912485599517822,
-0.02039281278848648,
0.015158100984990597,
-0.00221686321310699,
-0.08916115760803223,
0.01147384475916624,
-0.4443800151348114,
-0.3344196379184723,
0.16420559585094452,
0.029768705368041992,
-0.20408537983... | |
To grab the inode of a file in PHP, you can use this:
```
$fs = stat($file);
echo $fs['ino'];
```
The problem with this is EVERYWHERE says it's slow and you should avoid it. So the question becomes what's the fast(er) way to do it?
You could use [`fileinode()`](http://php.net/fileinode) but you should run benchmarks if you think it is slow. | [
-0.007997557520866394,
-0.26914042234420776,
0.13506388664245605,
0.109703429043293,
-0.02403692901134491,
-0.21509836614131927,
0.03924344480037689,
-0.1233760342001915,
-0.2573702037334442,
-0.6437206268310547,
0.08656404912471771,
0.6650516390800476,
-0.22708195447921753,
-0.29118332266... | |
I've just put my new server up on an IP address with a domain pointing to it. I need to be able to remote admin it. I've opened the firewall for Remote Desktop and HTTP traffic. Is this going to be secure enough? I guess I should probably rename the administrator user...
The absolute minimum you should do is change the Remote Desktop port, change the Admin username, and have a very strong admin password. | [
0.19194920361042023,
0.35342732071876526,
0.6915856003761292,
-0.05019170418381691,
-0.020579557865858078,
-0.2817406952381134,
0.35041165351867676,
0.1412351429462433,
0.022516394034028053,
-0.7909516096115112,
0.17691025137901306,
0.5175687074661255,
-0.07225482165813446,
0.3883518278598... | |
I'm leading a project where we'll be recording metrics data. I'd like to retain the data for years. However, I'd also like to keep the primary table from becoming bloated with data that, while necessary for long term trending, isn't required for short term reporting.
What is the best strategy for handling this situation? Simply archive the old data to another table? Or "roll it up" via some consolidation of the data itself (and then store it off to a different table)? Or something else entirely?
*Additional info: we are using SQL Server 2005.*
We use both methods at my work, but slightly | [
0.21452762186527252,
-0.012608364224433899,
0.23829801380634308,
0.23062361776828766,
0.030389169231057167,
-0.20393455028533936,
-0.06088734418153763,
0.14918825030326843,
-0.4408769905567169,
-0.4243931770324707,
0.2690987288951874,
0.40150976181030273,
0.14979135990142822,
0.04538721591... | |
different, we keep all sales data in the primary table for 30 days, then at night (part of the nightly jobs) the days sales are rolled up into summaries (n qty of x product sold today ect) in a separate table for reporting reasons, and sales over 30 days are archived into a different database, then once a year (we go on tax years) a new archive database is started. not exactly perfect but..
this way we get the summaries data fast, keep all current sales data at hand and have an unlimited space for the detailed archive data. we did | [
0.553604006767273,
-0.011621418409049511,
0.5827317833900452,
0.16654038429260254,
0.029518118128180504,
0.06901642680168152,
-0.2536243200302124,
-0.020226413384079933,
-0.3467506766319275,
-0.2604481279850006,
0.05746712535619736,
0.6986097693443298,
0.3661288321018219,
0.384575933218002... | |
try keeping it all in one database (in different tables) but the file size of the database (interbase) would grow so large that it would drag the system down.
the only real problem we have is accessing detailed data that spans several database, as connecting and disconnecting is slow, and analysis has to be done in code rather than sql | [
0.25380051136016846,
0.14545948803424835,
0.01364988461136818,
0.47645291686058044,
0.16414926946163177,
-0.1150648295879364,
0.13836805522441864,
-0.12262573838233948,
-0.2525850236415863,
-0.5490418076515198,
0.06880103796720505,
0.24566935002803802,
-0.31883206963539124,
0.2851820588111... | |
Is it possible to create a trigger that will not be in a transaction?
I want to update data on a linked server with a trigger but due to firewall issues we can't create a distributed transaction between the two servers.
What you probably want is a combination of a queue that contains updates for the linked server and a process that reads data from the queue and updates the remote server. The trigger will then insert a message into the queue as part of the normal transaction. This data will be read by the separate process and used to update | [
0.4367307722568512,
-0.12377075105905533,
0.29744455218315125,
0.3006148040294647,
0.06217247247695923,
0.08543362468481064,
-0.35317501425743103,
-0.2226184457540512,
-0.3632303476333618,
-0.30141982436180115,
0.4827917516231537,
0.4197235405445099,
-0.5347310900688171,
0.0467283539474010... | |
the remote server. Logic will needed in the process handle errors (and possibly retries).
The queue can be implemented with one or more tables. | [
0.00842056144028902,
-0.40925100445747375,
0.3479234278202057,
0.48233988881111145,
0.08139455318450928,
0.22991031408309937,
-0.15662813186645508,
0.251766562461853,
-0.29497745633125305,
-0.41485151648521423,
-0.24887628853321075,
0.2731706202030182,
-0.34284740686416626,
0.2473480552434... | |
What would be the best way to have a list of items with a checkbox each in Java Swing?
I.e. a JList with items that have some text and a checkbox each?
Create a custom `ListCellRenderer` and asign it to the `JList`.
This custom `ListCellRenderer` must return a `JCheckbox` in the implementantion of `getListCellRendererComponent(...)` method.
But this `JCheckbox` will not be editable, is a simple paint in the screen is up to you to choose when this `JCheckbox` must be 'ticked' or not,
For example, show it ticked when the row is selected (parameter `isSelected`), but this way the check status will no be | [
0.32712864875793457,
-0.17826414108276367,
0.3940463066101074,
-0.0011711623519659042,
-0.197391539812088,
-0.11630813777446747,
0.07047482579946518,
-0.438479483127594,
-0.35308635234832764,
-0.6246601939201355,
0.021553106606006622,
0.3147244453430176,
-0.4270192086696625,
-0.14846718311... | |
mantained if the selection changes. Its better to show it checked consulting the data below the `ListModel`, but then is up to you to implement the method who changes the check status of the data, and notify the change to the `JList` to be repainted.
I Will post sample code later if you need it
[ListCellRenderer](http://java.sun.com/javase/6/docs/api/javax/swing/ListCellRenderer.html) | [
0.19211241602897644,
-0.3051838278770447,
0.4128877520561218,
-0.17996840178966522,
-0.35914507508277893,
0.11362676322460175,
0.3387116491794586,
-0.6808315515518188,
-0.45894041657447815,
-0.5268033146858215,
-0.08683213591575623,
0.6562790870666504,
-0.4252850413322449,
-0.1566479206085... | |
Does anyone know of a good Command Prompt replacement? I've tried bash/Cygwin, but that does not really meet my needs at work because it's too heavy. I'd like a function-for-function identical wrapper on cmd.exe, but with highlighting, intellisense, and (critically) a tabbed interface. Powershell is okay, but the interface is still lacking.
*Edited*: I've been using **ConEmu** (<http://conemu.github.io/>) for quite some time now. This one is a wrapper too, since it is not really possible to replace the Windows console without rewriting the whole command interpreter. Below the line is my original answer for an earlier alternative.
---
Not exactly a replacement (actually, | [
-0.08696602284908295,
0.006086402107030153,
0.23542730510234833,
-0.06462611258029938,
-0.18145589530467987,
0.08701003342866898,
0.23609253764152527,
0.19285087287425995,
0.06236761808395386,
-0.8267356157302856,
0.06015446037054062,
0.8270271420478821,
-0.40901970863342285,
-0.0135409682... | |
it's a prettifying wrapper) but you might try **Console** (<http://sourceforge.net/projects/console/>) | [
0.08135750889778137,
-0.1225980818271637,
0.6353951096534729,
0.44296759366989136,
0.16696445643901825,
-0.26662570238113403,
0.022728564217686653,
0.2906147539615631,
0.136813223361969,
-0.7565601468086243,
-0.07970605790615082,
0.3932496905326843,
0.2264176607131958,
0.05113012716174126,... | |
I just wonder what options there are to properly measure/profile/optimize ASP.net 2.0 Web Parts, especially the ones for Sharepoint 2007?
As Web Parts are a layer on another layer of technology, getting resource usage, open handles and stuff only for the web part seems to be a bit difficult.
Does anyone know some good tools or practices for profiling and optimizing web parts?
Back when we started with SP2003, we used to worry about not closing connection in apps or web parts. We used the following query to check if the base number of connections (not counting the initial spike) would increase as | [
0.15691867470741272,
-0.015757709741592407,
0.48084375262260437,
0.22042319178581238,
-0.27988290786743164,
-0.11186602711677551,
0.1650206446647644,
-0.01660064607858658,
-0.5094234943389893,
-0.3956378996372223,
0.2888784110546112,
0.2813395857810974,
0.052631158381700516,
-0.07227869331... | |
the app is used on the development server:
SELECT hostname, sysdatabases.name , sysprocesses.status, last\_batch from sysprocesses, sysdatabases where sysprocesses.dbid = sysdatabases.dbid and nt\_username = '**SP Service Account**' and (hostname='**WFE1**' or hostname='**WFE2**') and sysprocesses.dbid = **10** order by last\_batch desc
(replace the bolded values with those appropriate for your environment)
We haven't tried this since the upgrade to MOSS though. | [
-0.1677848845720291,
0.05000011995434761,
0.613232433795929,
-0.09004547446966171,
0.12880657613277435,
0.39311471581459045,
0.2680895924568176,
-0.10935986042022705,
-0.22343112528324127,
-0.8851984739303589,
-0.21985289454460144,
0.6938841342926025,
-0.3893063962459564,
-0.08823841065168... | |
I've been trying to understand how Ruby blocks work, and to do that I've been trying to implement them in C.
One easy way to implement closures is to pass a `void*` to the enclosing stack to the closure/function but Ruby blocks also seem to handle returns and break statements from the scope that uses the block.
```
loop do
break i if (i >= 4000)
i *= 2
end
```
I think one of the closures proposals for Java works like this also.
So, how would you implement Ruby-blocks/Java-closures in C?
The concept of closures requires the concept of contexts. C's context is based on | [
0.3309744596481323,
0.3565787672996521,
-0.06656616926193237,
-0.12444037199020386,
-0.1737491637468338,
-0.0902596190571785,
0.17262093722820282,
-0.16718904674053192,
-0.2966786324977875,
-0.3719957172870636,
-0.15432676672935486,
0.4261173605918884,
-0.403003454208374,
0.090124331414699... | |
the stack and the registers of the CPU, so to create a block/closure, you need to be able to manipulate the stack pointer in a correct (and reentrant) way, and store/restore registers as needed.
The way this is done by interpreters or virtual machines is to have a `context` structure or something similar, and not use the stack and registers directly. This structure keeps track of a stack and optionally some registers, if you're designing a register based VM. At least, that's the simplest way to do it (though slightly less performant than actually mapping things correctly). | [
0.004512069281190634,
0.061595477163791656,
0.1938856542110443,
0.2939815819263458,
-0.016745205968618393,
0.11401479691267014,
0.155903622508049,
-0.15985947847366333,
-0.21962901949882507,
-0.471181184053421,
-0.23187018930912018,
0.45756763219833374,
-0.2601010799407959,
-0.214590430259... | |
I'm just designing the schema for a database table which will hold details of email attachments - their size in bytes, filename and content-type (i.e. "image/jpg", "audio/mp3", etc).
Does anybody know the maximum length that I can expect a content-type to be?
I hope I havn't misread, but it looks like the length is max 127/127 or **255 total**.
[RFC 4288](http://www.ietf.org/rfc/rfc4288.txt?number=4288) has a reference in 4.2 (page 6):
```
Type and subtype names MUST conform to the following ABNF:
type-name = reg-name
subtype-name = reg-name
reg-name = 1*127reg-name-chars
reg-name-chars = ALPHA / DIGIT / "!" / | [
-0.007614232134073973,
0.31726598739624023,
0.5604928731918335,
-0.16329795122146606,
-0.16611382365226746,
-0.13385529816150665,
0.03637899458408356,
-0.23183751106262207,
-0.34632304310798645,
-0.46214619278907776,
-0.2264580875635147,
0.3791488707065582,
-0.199499249458313,
0.0561914816... | |
"#" / "$" / "&" / "." /
"+" / "-" / "^" / "_"
```
It is not clear to me if the +suffix can add past the 127, but it appears not. | [
0.015463026240468025,
0.281604528427124,
0.5133318305015564,
-0.21715089678764343,
-0.3456575274467468,
0.23895058035850525,
0.09864480793476105,
-0.14368972182273865,
-0.2930714190006256,
-0.24774768948554993,
-0.21681800484657288,
0.4495956599712372,
-0.030255038291215897,
-0.00090803665... | |
I want to be able to capture the exception that is thrown when a user requests a non-existent controller and re-direct it to a 404 page. How can I do this?
For example, the user requests `http://www.nosite.com/paeges/1` (*should be* `/pages/`). How do I make it so they get re-directed to the 404 rather than the exception screen?
Take a look at [this page](http://richarddingwall.name/2008/08/09/three-common-aspnet-mvc-url-routing-issues/) for routing your 404-errors to a specified page. | [
0.32854393124580383,
-0.18153499066829681,
0.3319990932941437,
0.24663880467414856,
0.0965433269739151,
-0.2174386978149414,
0.052100084722042084,
-0.2538185119628906,
-0.3444165885448456,
-0.6737588047981262,
0.22384606301784515,
0.3226020932197571,
-0.14001627266407013,
0.327537029981613... | |
The RFC for a Java class is set of all methods that can be invoked in response to a message to an object of the class or by some method in the class.
RFC = M + R where
M = Number of methods in the class.
R = Total number of other methods directly invoked from the M.
Thinking C is the .class and J is the .java file of which we need to calculate RFC.
```
class J{
a(){}
b(){}
c(){
e1.e();
e1.f();
e1.g();
}
h(){
i.k();
i.j();
}
m(){} | [
0.25238823890686035,
0.24573004245758057,
0.3203907907009125,
-0.2518089711666107,
-0.24290171265602112,
0.009894073009490967,
0.1522853672504425,
-0.45204249024391174,
-0.14572061598300934,
-0.38626185059547424,
-0.29788005352020264,
0.3032546937465668,
-0.6796523332595825,
0.070358164608... | |
n(){
i.o();
i.p();
i.p();
i.p();
}
}
```
here M=6
and R=9 (Don't worry about call inside a loop. It's considered as a single call)
Calculating M is easy. Load C using classloader and use reflection to get the count of methods.
Calculating R is not direct. We need to count the number of method calls from the class. First level only.
For calculating R I must use regex. Usually format would be (calls without using . are not counted)
```
[variable_name].[method_name]([zero or more parameters]);
```
or
```
[variable_name].[method_name]([zero or more parameters])
```
with out semicolon when call return is directly becomes parameter to | [
-0.26008227467536926,
-0.11885257065296173,
0.4208592176437378,
-0.15862970054149628,
-0.050520919263362885,
0.3018241226673126,
0.11885769665241241,
-0.8049057722091675,
-0.13455751538276672,
-0.19811509549617767,
-0.05268324539065361,
0.707622766494751,
-0.3623615503311157,
0.05796494334... | |
another method.
or
```
[variable_name].[method_name]([zero or more parameters]).method2();
```
this becomes two method calls
What other patterns of the method call can you think of? Is there any other way other than using RegEx that can be used to calculate R.
---
**UPDATE:**
[@McDowell](https://stackoverflow.com/questions/19952/rfc-calculation-in-java-need-help-with-algorithm#19983 "@McDowell")
Looks like using BCEL I can simplify the whole process. Let me try it.
You could use the [Byte Code Engineering Library](http://jakarta.apache.org/bcel/index.html) with binaries. You can use a [DescendingVisitor](http://jakarta.apache.org/bcel/apidocs/org/apache/bcel/classfile/DescendingVisitor.html) to visit a class' members and references. I've used it to [find class dependencies](http://illegalargumentexception.blogspot.com/2008/04/java-finding-binary-class-dependencies.html).
Alternatively, you could reuse some model of the source files. I'm pretty sure the Java editor in the [Eclipse JDT](http://www.eclipse.org/jdt/) is | [
0.006292079575359821,
-0.10035886615514755,
0.08094793558120728,
0.05979739874601364,
-0.24669639766216278,
-0.17373768985271454,
-0.1368778645992279,
-0.2794514000415802,
-0.3843041658401489,
-0.5157028436660767,
0.34051504731178284,
0.2787216305732727,
-0.25774720311164856,
0.03039364702... | |
backed by some form of model. | [
0.2658384144306183,
0.14113301038742065,
0.2175232619047165,
0.4016575813293457,
0.0952310711145401,
-0.021410325542092323,
-0.3564527928829193,
-0.042882926762104034,
-0.006588457152247429,
-0.11376171559095383,
-0.051374953240156174,
0.5012578368186951,
0.18964257836341858,
-0.2580431103... | |
Of course I am aware of Ajax, but the problem with Ajax is that the browser should poll the server frequently to find whether there is new data. This increases server load.
Is there any better method (even using Ajax) other than polling the server frequently?
Yes, what you're looking for is COMET <http://en.wikipedia.org/wiki/Comet_(programming)>. Other good Google terms to search for are AJAX-push and reverse-ajax. | [
0.04026956856250763,
-0.11778952926397324,
0.10652836412191391,
0.33053797483444214,
-0.48534876108169556,
-0.19126354157924652,
0.07171185314655304,
0.322812557220459,
-0.07586847990751266,
-0.49969491362571716,
0.15717898309230804,
0.13649293780326843,
-0.11521563678979874,
-0.0278194062... | |
We're seeing some pernicious, but rare, deadlock conditions in the Stack Overflow SQL Server 2005 database.
I attached the profiler, set up a trace profile using [this excellent article on troubleshooting deadlocks](http://www.simple-talk.com/sql/learn-sql-server/how-to-track-down-deadlocks-using-sql-server-2005-profiler/), and captured a bunch of examples. The weird thing is that **the deadlocking write is *always* the same**:
```
UPDATE [dbo].[Posts]
SET [AnswerCount] = @p1, [LastActivityDate] = @p2, [LastActivityUserId] = @p3
WHERE [Id] = @p0
```
The other deadlocking statement varies, but it's usually some kind of trivial, simple **read** of the posts table. This one always gets killed in the deadlock. Here's an example
```
SELECT
[t0].[Id], [t0].[PostTypeId], [t0].[Score], [t0].[Views], [t0].[AnswerCount],
[t0].[AcceptedAnswerId], [t0].[IsLocked], [t0].[IsLockedEdit], [t0].[ParentId],
[t0].[CurrentRevisionId], [t0].[FirstRevisionId], | [
-0.10701146721839905,
-0.018228907138109207,
0.3605426549911499,
0.09592334926128387,
-0.08537312597036362,
-0.019104203209280968,
0.17172721028327942,
-0.3279323875904083,
-0.1975170373916626,
-0.34178173542022705,
0.12971574068069458,
0.4288517236709595,
-0.32457610964775085,
0.020981995... | |
[t0].[LockedReason],
[t0].[LastActivityDate], [t0].[LastActivityUserId]
FROM [dbo].[Posts] AS [t0]
WHERE [t0].[ParentId] = @p0
```
To be perfectly clear, we are not seeing write / write deadlocks, but read / write.
We have a mixture of LINQ and parameterized SQL queries at the moment. We have added `with (nolock)` to all the SQL queries. This may have helped some. We also had a single (very) poorly-written badge query that I fixed yesterday, which was taking upwards of 20 seconds to run every time, and was running every minute on top of that. I was hoping this was the source of some of the locking problems!
Unfortunately, I got another deadlock | [
0.2733735144138336,
-0.10025801509618759,
0.5521667003631592,
-0.02757878229022026,
-0.078990139067173,
-0.13581958413124084,
0.29861560463905334,
0.06141776964068413,
-0.31431812047958374,
-0.42570579051971436,
-0.1651325672864914,
0.3359500467777252,
-0.24240045249462128,
0.1867698580026... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.