instruction stringlengths 0 30k ⌀ |
|---|
|boo|closures| |
|closures|boo| |
I've run into a strange syntax in [Boo Language Guide][1] :
setter = { value | a = value }
What does the | operator mean?
[1]: http://boo.codehaus.org/Closures |
C# console program can't send fax when run as a scheduled task |
|c#|console|fax| |
I have a console program written in C# that I am using to send faxes. When I step through the program in Visual Studio it works fine. When I double click on the program in Windows Explorer it works fine. When I setup a Windows scheduled task to run the program it fails with this in the event log.
EventType cl... |
shouldn't this:
{{ user.item }}
be this?
{{ item }}
there is no user object in the context within that loop....? |
MSDN [says][1] that IPAddress.Address property (which returns numeric representation of IP address) is obsolete and you should use [GetAddressBytes][2] method.
You can convert IP address to numeric value using following code:
var ipAddress = IPAddress.Parse("some.ip.address");
var ipBytes = ipAddress.Get... |
MSDN [says][1] that IPAddress.Address property (which returns numeric representation of IP address) is obsolete and you should use [GetAddressBytes][2] method.
You can convert IP address to numeric value using following code:
var ipAddress = IPAddress.Parse("some.ip.address");
var ipBytes = ipAddress.Get... |
I think you would need to consider leap years. I didn't do the math, but I think during a leap year, with a hard code of 28 days for feb, a comparison of noon on 2/29 and noon on 3/1 would result in the same duplicate time stamp as before. Although it looks like you didn't implement it like that. They way you implem... |
I'd go with your original idea. If you are concerned that the queue might get too large implement a buffer-zone for it (i.e. If is gets above 100 lines the stop reading the file and if it gets below 20 then start reading again. You'd need to do some testing to find the optimal barriers). Make it so that any of the thre... |
The interesting thing here is how you can do it in the least amount of drops possible. Going to the 50th floor and dropping the first would be disastrous if the breaking floor is the 49th, resulting in us having to do 50 drops. We should drop the first marble at floor n, where n is the max amount of drops required. If ... |
The interesting thing here is how you can do it in the least amount of drops possible. Going to the 50th floor and dropping the first would be disastrous if the breaking floor is the 49th, resulting in us having to do 50 drops. We should drop the first marble at floor n, where n is the max amount of drops required. If ... |
Log4j has been around for a long time, and it works very well. I have no scientific study to back it, but based on what I've seen at a large number of clients, it is easily the logging framework that I see used more than any other. It has been around for a long time, and not been replaced by the Next Big Logging Fram... |
Yaws uses old config file |
|yaws| |
I'm developing a web app on Yaws 1.65 (installed through apt) running on Debian etch on a VPS with UML. Whenever I do /etc/init.d/yaws restart or a stop/start, it initializes according to an old version of the config file (/etc/yaws/yaws.conf).
I know this because I changed the docroot from the default to another d... |
I'm developing a web app on Yaws 1.65 (installed through apt) running on Debian etch on a VPS with UML. Whenever I do /etc/init.d/yaws restart or a stop/start, it initializes according to an old version of the config file (/etc/yaws/yaws.conf).
I know this because I changed the docroot from the default to another d... |
Generally a unit test is intended to exercise the public interface of a class or unit, private methods therefore are implementation detail that you would not expect to test explicitly. |
If you have several options that follow this layout, why not create a user control? The user control will contain the CheckBox, a NumericUpDown, a ComboBox and a label for the "after loading". You can override OnFontChanged to adjust the location of the controls based on the rendering of the text with the given font.... |
My solution to this, that I hope can be bettered, is to use Oracle to explicitly convert the TIMESTAMP into a string:
cursor.execute("SELECT TO_CHAR(WhenAdded, 'YYYY-MM-DD HH:MI:SSAM') FROM Log")
This works, but isn't portable. I'd like to use the same Python script against a SQL Server database, so an Oracle... |
Use sessions to ensure that any Ajax posts are done in an authenticated context. Think of your Ajax code as just another client to your server, it becomes easier to tackle authentication issues that way. |
What is your static memory manager actually doing? Unless it is doing something unsafe (P/Invoke, unsafe code), the behaviour you are seeing is a bug in your program, and not due to the behaviour of the CLR.
Secondly, what do you mean by 'pointer', with respect to links between structures? Do you literally mean an u... |
Any request that the AJAX calls in your pages can make can also be made by someone outside of the application. If done right, you will not be able to tell if they were made as part of an AJAX call from your webapp or by hand/other means.
There are two scenarios I can think of which you might be talking about when y... |
@buyutec
Instead of
list.RemoveAll(item => ShouldIRemoveThis(item));
you can use:
list.RemoveAll(ShouldIRemoveThis);
The lambda has the same signature as the method, so they are equivalent so you can just pass the method directly. |
In IIS, check the settings on the application pool that SSRS is running in. On the properties pane->Performance tab you can set the amount of time the worker process needs to be idle for before it shuts down. You can also disable this entirely. |
Your example just compiles to a compiler-named private inner class (with field firedCount and a compiler-named method). Each call to PotentialMemoryLeaker creates a new instance of the closure class to which where foo keeps a reference by way of a delegate to the single method.
If you don't reference the whole objec... |
* Apache Axis can generate proxy code from WSDL <http://ws.apache.org/axis/java/user-guide.html#UsingWSDLWithAxis>
* NetBeans with the RESTful Web Services plug-in can generate code for you. Instructions for an example client for the eBay shopping web service are at <http://ebay.custhelp.com/cgi-bin/ebay.cfg/php/endu... |
If you want to specify both a limit for number of items to remove and a condition to select the items to remove, you can use this approach:
int limit = 30; // Suppose you want to remove 30 items at most
list.RemoveAll(item => ShouldIRemoveThis(item) && limit-- > 0); |
The database is often running as a service under an account with no network access. If this is the case, then you wouldn't be able to restore directly over the network. Either the backup needs to be copied to the local machine or the database service needs to run as a user with the proper network access. |
It refers to the [lambda calculus](http://en.wikipedia.org/wiki/Lambda_calculus) which is a formal system that just has lambda expressions, which represents a function that takes a function for its sole argument and returns a function. All functions in the lambda calculus are of that type.
Lisp used the lambda conce... |
You can think of it as an anonymous function - here's some more info: [Wikipedia - Anonymous Function][1]
[1]: http://en.wikipedia.org/wiki/Anonymous_function |
> Note that a responsible web developer
> does not use fonts that are only
> available on Windows (and especially
> ones that are only available on
> Vista), nor do they use a technology
> that isn't supported by at least the
> majority of browsers.
There's nothing wrong or incorrect about using Windows/Vista-... |
My experience is with Java, not C#, so apologies if these solutions don't apply.
The immediate solution I can think up off the top of my head would be to have an executor that runs 3 threads (using [`Executors`](http://java.sun.com/javase/6/docs/api/java/util/concurrent/Executors.html)`.newFixedThreadPool`, say). Fo... |
My experience is with Java, not C#, so apologies if these solutions don't apply.
The immediate solution I can think up off the top of my head would be to have an executor that runs 3 threads (using [`Executors`](http://java.sun.com/javase/6/docs/api/java/util/concurrent/Executors.html)`.newFixedThreadPool`, say). Fo... |
If you use javascript to hide the buttons, you open a security hole in the application. A malicious user could either disable javascript or apply some of their own to get around your security.
I suggest using PHP to chose to either render the buttons or not. I do this in .NET quite often.
You should be able to c... |
showing a message box from a bash script in linux |
|linux|bash|scripting|ubuntu|gtk| |
I'm writing a few little bash scripts under Ubuntu linux. I want to be able to run them from the GUI without needing a terminal window to enter any input or view any output.
So far the only input required is a password for sudo - and gksudo handles that fine.
But I haven't found an easy way to show a message box ye... |
You can't do it without any static variables, however if you are willing to tolerate one, you can use [Boost.Thread](http://www.boost.org/doc/html/thread.html) for this purpose. Read the "one-time initialisation" section for more info.
Then in your singleton accessor function, use `boost::call_once` to construct the... |
Development of shaders in XNA (which obviously uses DirectX) requires knowledge of [HLSL][1] or shader assembly. I'd recommend getting familiar with the former before diving into the latter.
Before writing any shaders, it's a good idea to get solid understanding of the shader pipeline, and attempt to get your mind a... |
You've got a few issues here that don't relate well to each other.
At the basic database level you can track changes by having a separate table that gets an entry added to it via triggers on INSERT/UPDATE/DELETE statements. Thats the general way of tracking changes to a database table.
The other thing you want is... |
A trace log in a separate table (with an ID column, possibly with timestamps)?
Are you going to want to undo the changes as well - perhaps pre-create the undo statement (a DELETE for every INSERT, an (un-) UPDATE for every normal UPDATE) and save that in the trace? |
The problem is your action does two things, violating the Single Responsibility Principle.
If your Create action redirects to the List action when it's done creating the item, then this problem disappears. |
In general, if your application is structured into layers, have the data access tier call a stored procedure on your database server to write a log of the database changes.
In languages that support such a thing [aspect-oriented programming][1] can be a good technique to use for this kind of application. Auditing da... |
While a fast forward cursor does have some optimizations in Sql Server 2005, it is *not* true that they are anywhere close to a set based query in terms of performance. There are very few situations where cursor logic cannot be replaced by a set-based query. Cursors will always be inherently slower, due in part to th... |
I don't know much about development at that level, but... it seems like it would be a good idea to separate into multiple solutions. You could have a final "pre-ship" step that consolidates them all into a single .dll if you/your customers really insist.
Compare, e.g., to the .NET Framework where we have lots of dif... |
> Note that a responsible web developer
> does not use fonts that are only
> available on Windows (and especially
> ones that are only available on
> Vista), nor do they use a technology
> that isn't supported by at least the
> majority of browsers.
There's nothing wrong or incorrect about using Windows/Vista-... |
The PRE tag can be a valid solution, depending on your needs. However, if you are trying to use the 2 space rule in sentences throughout your site, you'll soon find that the other characters the PRE tag preserves are the line feed/carriage returns (or lack of) will muck up any styling you try to do.
In general, I... |
A lambda is a type of function, defined inline. Along with a lambda you alsu usually have some kind of variable type that can hold a reference to a function, lambda or otherwise.
For instance, here's a C# piece of code that doesn't use a lambda:
public Int32 Add(Int32 a, Int32 b)
{
return a + b;... |
With both queries, it looks like you are trying to insert into #temp. #temp is located on one of the databases (for arguments sake, databaseA). So when you try to insert into #temp from databaseB, it reports that it does not exist.
Try changing it from *Into **#temp** From* to *Into **databaseA.dbo.#temp** From* in ... |
With both queries, it looks like you are trying to insert into #temp. #temp is located on one of the databases (for arguments sake, databaseA). So when you try to insert into #temp from databaseB, it reports that it does not exist.
Try changing it from *Into **#temp** From* to *Into **databaseA.dbo.#temp** From* in ... |
As of PHP 5.1.0 you can use [*date_default_timezone_set()*][1] function to set the default timezone used by all date/time functions in a script.
For MySql (quoted from [MySQL Server Time Zone Support][2] page)
> Before MySQL 4.1.3, the server operates only in the system time zone set at startup. Beginning with MyS... |
Has anybody used "props"?
You type "prop" and then press [TAB] twice, it generates useful code for your properties and can speed your typing.
I know this works in VS 2005 (I use it) but I don´t know in previous versions. |
In the tomcat/conf/server.xml there are several connectors configured.
each connector has an optional "address" attribute where you can specify a bind address for that connector.
<Connector
port="8080"
protocol="HTTP/1.1"
address="127.0.0.1"
connectionTimeout="20000"
... |
This is a good question, one that I will be subscribing too :)
I am still relatively new to web dev, and I too am looking at a lot of code that is largely untested.
For me, I keep the UI **as light as possible** (normally only a few lines of code) and test the crap out of everything else. At least I can then have... |
If this were me, I would define 2 namespaces:
Protocol
and
Protocol.Driver
Dividing the namespace like this separates your "library code" vs your "executable / test code."
I also create my namespaces to match the directory structure; it will give logic to your programs structure and codefiles. (may... |
I save all my dates as a bigint due to having had issues with the dateTime type before. I save the result of the time() PHP function into it, now they count as being in the same timezone :) |
We've been using it for a project here at work that needed to run on Linux but reuse some .NET libraries that we built in Managed C++. I've been very surprised at how well it has worked out. Our main executable is being written in C# and we can just reference our Managed C++ binaries with no issue. The only differen... |
Check that you set correct working directory for your task |
Is the scheduled task running on the same computer you're developing on, or is it on a dedicated olp server? It's quite common for paths to change when you change environments, so is the path to the document you're trying to send the same? |
I can't explain it - but I have a few ideas.
Most of the times, when a program works fine testing it, and doesn't when scheduling it - security is the case. In the context of which user is your program scheduled? Maybe that user isn't granted enough access.
Is the resource your programm is trying to access a netw... |
The 'standard' way to do this with rails is to run a "pack" of Mongrel instances (ie: 4 copies of the rails application) and then use apache or nginx or some other piece of software to sit in front of them and act as a load balancer.
This is probably how it's done with other ruby frameworks such as merb etc, but I ... |
As other's have mentioned we use CCNET here, which we don't usually work on a nightly build, but instead go with a Continuous Integration strategy (every check-in).
I would advise doing the same, whether it be by yourself or within a team, because you can very easily set up unit testing to run on every checkin as we... |
I would store the referring URL using the [ViewState][1]. Storing this outside the scope of the page (i.e. in the Session state or cookie) may be overkill.
The example below validates that the page was called internally (i.e. not requested directly) and bounces back to the referring page after the user submits their... |
PostgreSQL's [UPDATE][1] statement has the RETURNING clause that will return a result set like a SELECT statement:
UPDATE mytable
SET views = 5
WHERE id = 16
RETURNING id, views, othercolumn;
I'm pretty sure this is not standard though. I don't know if any other databases implement it.
... |
PostgreSQL's [UPDATE][1] statement has the RETURNING clause that will return a result set like a SELECT statement:
UPDATE mytable
SET views = 5
WHERE id = 16
RETURNING id, views, othercolumn;
I'm pretty sure this is not standard though. I don't know if any other databases implement it.
Ed... |
You do it the exact same way. Put a string in as the first statement in the module. |
NT authentication login |
|authentication|ntlm| |
I have a site I am working on, on this site users can login to get more private information. My client has another site elseware that uses nt authentication for accessing it. What they want to do is have a button on the site I am working on under the private area that will send them to the ntauthenticated site, but not... |
It would help if you listed the RDBMS you are using
SQL Server has the OUTPUT statement
Example
USE AdventureWorks;
GO
DECLARE @MyTestVar table (
OldScrapReasonID int NOT NULL,
NewScrapReasonID int NOT NULL,
WorkOrderID int NOT NULL,
ProductID int NOT NULL,
... |
I like the second one purely because any avoidance of magic strings/numbers in code is a good thing. IMO if you need to reference a number or string literal in code more than once, it should be a constant. In most cases even if it's only used once it should be in a constant |
@Mendelt Siebenga: You can only call GetType on the value property if the variable is not set to null; otherwise, you'll get an exception.
What you want to do is use the "GetValueOrDefault" property and call GetType on that, since you are guaranteed it will not be null. Example:
Dim i As Nullable(Of Integer) ... |
[ActiveRecord][1] seems to be the state of the art at the moment. I can't recommend any good PHP frameworks for that though. I tried [Propel][2] which, while nice, is not easy to set up (especially on a host that you can't install anything on).
Ultimately, I rolled my own ORM/ActiveRecord framework, which is not too... |
Good Starting Places for SQL Server Alerts/Notifications? |
|sql-server|ssis|etl|notifications|alert| |
Just recently started having issues with a SQL Server Agent Job that contains a SSIS package to extract production data and summarize it into a separate reporting database.
I *think* that some of the Alerts/Notifications settings I tried playing with caused the problem as the job had been running to completion unat... |
ARMV4i (Windows Mobile 6) Native Code disassembler |
|windows-mobile|arm|disassembly| |
Does anyone know of a disassembler for ARMV4i compiled executables and dlls?
I've got a plugin DLL I'm writing and it has a very rare data abort (<5% of the time) that I have narrowed down to a specific function (via dumpbin and the memory address output by the data abort) however it's a fairly large function and I wo... |
I don't entirely understand your question.
Are you saying that files you check out on one machine seems to be unaccessible on another of your machines? I'd say that would be entirely by design, as now you have a file that has local modifications done on one machine, which may or may not be available on your other ma... |
Are you sure you have no ImageMagick on server?
I guest you use PHP (question is tagged with PHP). Hosting company which I use has no ImageMagick extension turned on according to phpinfo().
But when I asked them about they said *here is the list of ImageMagick programs available from PHP code*. So simply -- there... |
My basic rule in Django is: if you could conceivably need the functionality from somewhere other than the view itself, it doesn't belong in the view function.
I'd also recommend downloading some of the plethora of apps on [Django Pluggables][1] and seeing how they do it.
[1]: http://djangoplugables.com/ |
It is a function that has no name. For e.g. in c# you can use
numberCollection.GetMatchingItems<int>(number => number > 5);
to return the numbers that are greater than 5.
number => number > 5
is the lambda part here. It represents a function which takes a parameter (number) and returns a boolean val... |
This question was not about optimizing the algorithm - but thanks anyway ;-)
At the time I wrote it, I considered the labeled continue as a readable solution.
I asked SO a [question][1] about the convention (having the label in all caps or not) for labels in Java.
Basically every answer told me "do not use th... |
I like the explanation of Lambdas in this article: [The Evolution Of LINQ And Its Impact On The Design Of C#][1]. It made a lot of sense to me as it shows a real world for Lambdas and builds it out as a practical example.
Their quick explanation: Lambdas are a way to treat code (functions) as data.
[1]: http:... |
I've done this in the past.
Either do it manually, (build a nice gui that helps the user do it quickly) or have it automated and check against a recent address database (you have to buy that) and manually handle errors.
Manual handling will take about 10 seconds each, meaning you can do 3600/10 = 360 per hour, s... |
One method I've seen quite often is to have audit tables. Then you can show just what's changed, what's changed and what it changed from, or whatever you heart desires :) Then you could write up a trigger to do the actual logging. Not too painful if done properly...
No matter how you do it, though, it kind of depe... |
Retrieving an Oracle timestamp using Python's Win32 ODBC module |
|python|oracle-database| |
Given an Oracle table created using the following:
CREATE TABLE Log(WhenAdded TIMESTAMP(6) WITH TIME ZONE);
Using the Python ODBC module from its Win32 extensions (from the win32all package), I tried the following:
import dbi, odbc
connection = odbc.odbc("Driver=Oracle in OraHome92;Dbq=SERVE... |
Given an Oracle table created using the following:
CREATE TABLE Log(WhenAdded TIMESTAMP(6) WITH TIME ZONE);
Using the Python ODBC module from its [Win32 extensions][1] (from the win32all package), I tried the following:
import dbi, odbc
connection = odbc.odbc("Driver=Oracle in OraHome92;Dbq=... |
@Domenic: indeed, it would be a good thing... However, a whole team's been at it for some time now, and until they succeed we are stuck with a single .dll and something quite monolithic :-( |
Is SOAP now a legacy technology? |
|soap|rpc| |
Ok so I found the [xmessage][1] command, which is sort of good enough.
If anyone knows of something better - ie. uses GTK widgets and so on, please post :)
[1]: http://www.linuxmanpages.com/man1/xmessage.1x.php |
Here's a little Tcl script that will do what you want. The Wish interpreter should be installed by default on Ubuntu.
#!/usr/bin/wish
pack [label .msg -text [lindex $argv 0]]
pack [entry .ent]
bind .ent <KeyPress-Return> { puts [.ent get]; destroy . }
focus .ent
Call it like this:
... |
This will eliminate bottlenecks of having a single thread do the reading:
open file
for each thread n=0,1,2,3:
seek to file offset 1/n*filesize
scan to next complete line
process all lines in your part of the file |
While this question has already been answered, I think there are some other points to mention:
- If you want lazy-instantiation of the singleton while using a pointer to a dynamically allocated instance, you'll have to make sure you clean it up at the right point.
- You could use Matt's solution, but you'd need... |