instruction stringlengths 0 30k ⌀ |
|---|
What are the correct pixel dimensions for an apple-touch-icon? |
|iphone|favicon|apple-touch-icon| |
I'm not sure what the correct size should be.
Many sites seem to repeat that the apple-touch-icon should be 57x57 pixels but site a broken link as their source.
[Hanselman][1]'s and [playgroundblues][2]'s comments suggest different sizes including 163x163 and 60x60.
Apple's own [apple.com icon][3] is 129x129!
See my related question:
[How do I give my web sites an icon for iPhone?][4]
[1]: http://www.hanselman.com/blog/MakeYourWebsiteMobileAndIPhoneFriendlyAddHomeScreenIPhoneIconsAndAdjustTheViewPort.aspx
[2]: http://playgroundblues.com/posts/2008/jan/15/iphone-bookmark-iconage/
[3]: http://www.apple.com/apple-touch-icon.png
[4]: http://stackoverflow.com/questions/1505/how-do-i-give-my-web-sites-an-icon-for-iphone |
I don't think there is a "correct size". Since the iPhone really is running OSX, the icon rendering system is pretty robust. As long as you give it a high-quality image with the right aspect ratio and a resolution at least as high as the actual output will be, the OS will downscale very cleanly. My site uses a 158x158 and the icon looks pixel-perfect on the iPhone screen. |
Best way to copy a database in SQL Server 2005/8? |
|sql-server| |
I always create a new empty database and then do a backup and restore of the existing database into it, but is this really the best way? As it seems very error prone and over complicated to me. |
In all honesty, a combination of print and print_r() to print out the variables. I know that many prefer to use other more advanced methods but I find this the easiest to use.
I will say that I didn't fully appreciate this until I did some Microprocessor programming at Uni and was not able to use even this. |
The best way I can think of would be to use **Cygwin** over an **OpenSSH** connection.
Here's a document that explains how to do just that:
<http://www.ucl.ac.uk/cert/openssh_rdp_vnc.pdf> |
Depends on how much detail you want it to have, it needs to have the aspect ratio of 1:1 (basically - it needs to be square)
I would go with the Apple's own 129*129 |
I would check both IP and User Agent to see if they change
if ($_SESSION['user_agent'] != $_SERVER['HTTP_USER_AGENT']
|| $_SESSION['user_ip'] != $_SERVER['REMOTE_ADDR'])
{
//Something fishy is going on here?
} |
Some info on Tapestry: I'm familiar with Tapestry 4 and find it to be a great framework. The two biggest problems it has are 1) the mental model is rather different from those of other frameworks, so if you're familiar with one of them, you may have to "unlearn what you have learned;" 2) backwards compatibility breakage has been a problem.
To his credit, Mr. Ship does seem to be addressing the latter point in Tapestry 5. The biggest example is in the page classes: in previous incarnations, page classes descended from a base class provided by Tapestry; incompatible API changes in this class were the cause of a large number of backward compatibility in an upgrade in this class would cause your app to break. In Tapestry 5, pages are POJOs which are enhanced at runtime with the "magic Tapestry fairy dust" via annotations. So as long as the contract for the annotations is maintained, changes to Tapestry won't affect your page classes.
As for the "unlearning" part, I've found that Tapestry's model is actually quite straightforward and sensible. So yes, there's a bit of a learning curve due to having to get past any preconceived notions of how things ought to work, but I've found it's very much worth it. And it's *way* better than Struts. |
Some info on Tapestry: I'm familiar with Tapestry 4 and find it to be a great framework. The two biggest problems it has are 1) the mental model is rather different from those of other frameworks, so if you're familiar with one of them, you may have to "unlearn what you have learned;" 2) backwards compatibility breakage has been a problem.
To his credit, Mr. Ship does seem to be addressing the latter point in Tapestry 5. The biggest example is in the page classes: in previous incarnations, page classes descended from a base class provided by Tapestry; incompatible API changes in this class were the cause of a large number of backward compatibility problems. In Tapestry 5, pages are POJOs which are enhanced at runtime with the "magic Tapestry fairy dust" via annotations. So as long as the contract for the annotations is maintained, changes to Tapestry won't affect your page classes.
As for the "unlearning" part, I've found that Tapestry's model is actually quite straightforward and sensible. So yes, there's a bit of a learning curve due to having to get past any preconceived notions of how things ought to work, but I've found it's very much worth it. And it's *way* better than Struts. |
How do I prevent replay attacks? |
|asp.net|encryption|hacking| |
This is related to [another question I asked](/questions/43324/can-i-put-an-aspnet-session-id-in-a-hidden-form-field). In summary, I have a special case of a URL where, when a form is POSTed to it, I can't rely on cookies for authentication or to maintain the user's session, but I somehow need to know who they are, and I need to know they're logged in!
I think I came up with a solution to my problem, but it needs fleshing out. Here's what I'm thinking. I create a hidden form field called "username", and place within it the user's username, encrypted. Then, when the form POSTs, even though I don't receive any cookies from the browser, I know they're logged in because I can decrypt the hidden form field and get the username.
The major security flaw I can see is replay attacks. How do I prevent someone from getting ahold of that encrypted string, and POSTing as that user? I know I can use SSL to make it harder to steal that string, and maybe I can rotate the encryption key on a regular basis to limit the amount of time that the string is good for, but I'd really like to find a bulletproof solution. Anybody have any ideas? Does the ASP.Net ViewState prevent replay? If so, how do they do it? |
The 3.5 SP1 update has support for browser history and back button in ASP.NET ajax now. |
Giant NodeManagerLogs from hibernate in weblogic |
|weblogic|logging| |
One of our weblogic 8.1s has suddenly started logging giant amounts of logs and filling the disk.
The logs giving us hassel resides in
mydrive:\bea\weblogic81\common\nodemanager\NodeManagerLogs\generatedManagedServer1\managedserveroutput.log
I cant find any debug settings set anywhere.
Ive looked in the Remote Start classpath and Arguments for the managed server.
Can anyone point me in the direction to gain control over this logfile?
|
One of our weblogic 8.1s has suddenly started logging giant amounts of logs and filling the disk.
The logs giving us hassel resides in
mydrive:\bea\weblogic81\common\nodemanager\NodeManagerLogs\generatedManagedServer1\managedserveroutput.log
and the entries in the logfile is just the samekinds of entrires repeated again and again. Stuff like
19:21:24,470 DEBUG [StdRowLockSemaphore] Lock 'TRIGGER_ACCESS' returned by: LLL-SCHEDULER_QuartzSchedulerThread
19:21:31,923 DEBUG [StdRowLockSemaphore] Lock 'STATE_ACCESS' is deLLLred by: QuartzScheduler_LLL-SCHEDULER-NACDLLLF011219763113220_ClusterManager
19:21:31,923 DEBUG [StdRowLockSemaphore] Lock 'STATE_ACCESS' is being obtained: QuartzScheduler_LLL-SCHEDULER-NACDLLLF011219763113220_ClusterManager
19:21:31,923 DEBUG [StdRowLockSemaphore] Lock 'STATE_ACCESS' given to: QuartzScheduler_LLL-SCHEDULER-NACDLLLF011219763113220_ClusterManager
19:21:31,923 DEBUG [StdRowLockSemaphore] Lock 'TRIGGER_ACCESS' is deLLLred by: QuartzScheduler_LLL-SCHEDULER-NACDLLLF011219763113220_ClusterManager
...
19:17:46,798 DEBUG [CascadingAction] cascading to saveOrUpdate: mypackage.config.common.Share
19:17:46,798 DEBUG [DefaultSaveOrUpdateEventListener] reassociated uninitialized proxy
19:17:46,798 DEBUG [Cascade] done processing cascade ACTION_SAVE_UPDATE for: mypackage.config.common.FileLocation
19:17:46,798 DEBUG [Cascade] processing cascade ACTION_SAVE_UPDATE for: mypackage.config.common.FileLocation
19:17:46,798 DEBUG [CascadingAction] cascading to saveOrUpdate: mypackage.config.common.Share
19:17:46,798 DEBUG [DefaultSaveOrUpdateEventListener] reassociated uninitialized proxy
and so on.
I cant find any debug settings set anywhere.
Ive looked in the Remote Start classpath and Arguments for the managed server.
Can anyone point me in the direction to gain control over this logfile?
|
|logging|hibernate|weblogic| |
Dig in and find out? Stick a debugger on that bastard!
I can see at least the following possibilities:
1. the logging system hangs;
3. the thread exited just fine but the service is still running because some other part has a logic error.
And maybe, but almost certainly not, the following:
* Sleep() hangs.
But in any case, attaching a debugger will show you whether the thread is still there and whether it really has hung. |
You could enumerate all the network adapters, get their IP addresses and compare the part covered by the subnet mask with the sender's address.
Like:
foreach( adapter in EnumAllNetworkAdapters() )
{
adapterSubnet = adapter.subnetmask & adapter.ipaddress;
senderSubnet = adapter.subnetmask & senderAddr;
if( adapterSubnet == senderSubnet )
{
return adapter.ipaddress;
}
} |
I'm confused...
The images from ASP would be compressed on the server side--not client side.
I'm sure your web server is not running on Windows CE, so I don't think your concern is warranted. |
I'm confused...
The images from ASP would be compressed on the server side--not client side.
I'm sure your web server is not running on Windows CE, so I don't think your concern is warranted.
**EDIT:** Seems as though you can run a web server on Windows CE: [http://www.microsoft.com/windows/embedded/products/windowsce/default.mspx][1]. I'll keep my thoughts to myself from now on. :-x
[1]: http://www.microsoft.com/windows/embedded/products/windowsce/default.mspx |
How to find a Java Memory Leak |
|java|memory| |
How do you find a memory leak in Java (using for example JHat)? I have tried to load the heap dump up in JHat to take a basic look. However I do not understand how I am supposed to be able to find the root reference ([ref][1]) or whatever it is called. Basically I can tell that there are several hundred meg of hash table entries ([java.util.HashMap$Entry or something like that), but maps are used all over the place... Is there some way to search for large maps, or perhaps finding general roots of large object trees?
[1]: http://stackoverflow.com/questions/104/anatomy-of-a-memory-leak |
|java|memory|jhat| |
How do you find a memory leak in Java (using for example JHat)? I have tried to load the heap dump up in JHat to take a basic look. However I do not understand how I am supposed to be able to find the root reference ([ref][1]) or whatever it is called. Basically I can tell that there are several hundred meg of hash table entries ([java.util.HashMap$Entry or something like that), but maps are used all over the place... Is there some way to search for large maps, or perhaps finding general roots of large object trees?
[Edit]
Ok, I've read the answers so far but lets just say I am a cheap bastard (meaning I am more interested in learning how to use JHat than to pay for JProfiler). Also JHat is always available since it is part of the JDK. Unless of course there is no way with JHat but brute force, but I can't believe that can be the case.
[1]: http://stackoverflow.com/questions/104/anatomy-of-a-memory-leak |
How do you find a memory leak in Java (using for example JHat)? I have tried to load the heap dump up in JHat to take a basic look. However I do not understand how I am supposed to be able to find the root reference ([ref][1]) or whatever it is called. Basically I can tell that there are several hundred meg of hash table entries ([java.util.HashMap$Entry or something like that), but maps are used all over the place... Is there some way to search for large maps, or perhaps finding general roots of large object trees?
[Edit]
Ok, I've read the answers so far but lets just say I am a cheap bastard (meaning I am more interested in learning how to use JHat than to pay for JProfiler). Also JHat is always available since it is part of the JDK. Unless of course there is no way with JHat but brute force, but I can't believe that can be the case.
Also, I do not think I will be able to actually modify (adding logging of *all* map sizes) and run it for long enough for me to notice the leak.
[1]: http://stackoverflow.com/questions/104/anatomy-of-a-memory-leak |
Here's another good resource from MSDN: [Data Binding Overview][1].
[1]: http://msdn.microsoft.com/en-us/library/ms752347.aspx |
Instead of J#, I would rather prefer IKVM (http://www.ikvm.net/) to convert my JARs to .NET assemblies as well as access Java APIs in C#. |
@jatan
> Thanks for you answer. It makes sense. Can you please explain me MathContext in the context of BigDecimal#round method.
There's nothing special about `BigDecimal.round()` *vs.* any other `BigDecimal` method. In all cases, the `MathContext` specifies the number of significant digits and the rounding technique. Basically, there are two parts of every [`MathContext`](http://java.sun.com/j2se/1.5.0/docs/api/java/math/MathContext.html). There's a precision, and there's also a [`RoundingMode`](http://java.sun.com/j2se/1.5.0/docs/api/java/math/RoundingMode.html).
The precision again specifies the number of significant digits. So if you specify `123` as a number, and ask for 2 significant digits, you're going to get `120`. It might be clearer if you think in terms of scientific notation.
`123` would be `1.23e2` in scientific notation. If you only keep 2 significant digits, then you get `1.2e2`, or `120`. By reducing the number of significant digits, we reduce the precision with which we can specify a number.
The `RoundingMode` part specifies how we should handle the loss of precision. To reuse the example, if you use `123` as the number, and ask for 2 significant digits, you've reduced your precision. With a `RoundingMode` of `HALF_UP` (the default mode), `123` will become `120`. With a `RoundingMode` of `CEILING`, you'll get `130`.
For example:
System.out.println(new BigDecimal("123.4",
new MathContext(4,RoundingMode.HALF_UP)));
System.out.println(new BigDecimal("123.4",
new MathContext(2,RoundingMode.HALF_UP)));
System.out.println(new BigDecimal("123.4",
new MathContext(2,RoundingMode.CEILING)));
System.out.println(new BigDecimal("123.4",
new MathContext(1,RoundingMode.CEILING)));
Outputs:
123.4
1.2E+2
1.3E+2
2E+2
You can see that both the precision and the rounding mode affect the output. |
There are no standards for REST other than HTTP. There are established REST services out there. I suggest you take a peak at them and get a feel for how they work.
For example, we borrowed a lot of ideas from Amazon's S3 REST service when developing our own. But we opted not to use the more advanced security model based on request signatures. The simpler approach is HTTP Basic auth over SSL. You have to decide what works best in your situation.
Also, I highly recommend the book [RESTful Web Services][1] from O'reilly. It explains the core concepts and does provide some best practices. You can generally take the model they provide and map it to your own application.
[1]: http://oreilly.com/catalog/9780596529260/ |
Of Memory Management, Heap Corruption, and C++ |
|c++|memory|heap|stack| |
So, I need some help. I am working on a project in C++. However, I think I have somehow managed to corrupt my heap. This is based off the fact that I added a `std::string` to a class and assigning it a value from another `std::string`:
std::string hello = "Hello, world.\n";
/* exampleString = "Hello, world.\n" would work fine. */
exampleString = hello;
crashes on my system with a stack dump. So basically I need to **stop** and go through all my code and memory management stuff and find out where I've screwed up. The codebase is still small (about 1000 lines), so this is easily do-able.
Still, I'm over my head with this kind of stuff, so I thought I'd throw it out there. I'm on a Linux system, and have poked around with `valgrind`, and while not knowing completely what I'm doing, it did report that the `std::string`'s destructor was an invalid free. I have to admit to getting the term 'Heap Corruption' from a Google search; any general purpose articles on this sort of stuff would be appreciated as well.
(In before `rm -rf ProjectDir`, do again in C# :D) |
I don't think there such a feature out of the box.
However, you could write a RS plugin that does this. But this would be another question... |
If your only objective is to stop FxCop from yelling at you, then you have found the best practice.
The best practice for signing your assemblies is something that is completely dependent on your objectives and needs. We would need more information like your intended deployment:
* For personal use
* For use on corporate network PC's as a client application
* Running on a web server
* Running in SQL Server
* Downloaded over the internet
* Sold on a CD in shrink wrap
* Uploaded straight into a cybernetic brain
* Etc.
Generally you use code signing to verify that the Assemblies came from a specific trusted source and have not been modified. ***So each with the same key is fine.*** Now how that trust and identity is determined is another story. |
If your only objective is to stop FxCop from yelling at you, then you have found the best practice.
The best practice for signing your assemblies is something that is completely dependent on your objectives and needs. We would need more information like your intended deployment:
* For personal use
* For use on corporate network PC's as a client application
* Running on a web server
* Running in SQL Server
* Downloaded over the internet
* Sold on a CD in shrink wrap
* Uploaded straight into a cybernetic brain
* Etc.
Generally you use code signing to verify that the Assemblies came from a specific trusted source and have not been modified. ***So each with the same key is fine.*** Now how that trust and identity is determined is another story.
**UPDATE:** How this benefits your end users when you are deploying over the web is if you have obtained a [software signing certificate from a certificate authority][1]. Then when then download your assemblies they can verify they came from *Domenic's Software Emporium*, and they haven't been modified or corrupted along the way. You will also want to sign the installer when it is downloaded. This prevents the warning that some browsers display that it has been obtained from an unknown source.
Note, you will pay for a software signing certificate. What you get is they become the trusted 3rd party who verifies you are who you say you are. This works because of a web of trust that traces its way back to a root certificate that is installed in their operating system. There are a few certificate authorities to choose from, but you will want to make sure they are supported by the root certificates on the target operating system.
[1]: http://www.thawte.com/code-signing/index.html?click=main-nav-products-codesigning |
Who else is involved in the database? Are you the only person making schema changes (creating new objects, releasing new stored procedures, permissioning new users)?
- Make sure that the number of users doing anything that could impact performance is reduced to as close to zero as possible, ideally including you.
- Make sure that you're testing your backups - ideally run a DEV box that is recreating the production environment periodically, 1. a DEV box is a good idea, 2. a backup is only useful if you can restore from it.
- Create groups for the various apps that connect to your database, so when a new user comes along you don't guess what permissions they need, just add them to the group, meanwhile permission the database objects to only the groups that need them
- Use indices, primary keys, foreign keys, constraints, stats and whatever other tools your database supports. Normalise.
- Optimise the most common code against your box - bad stored procedures/data access code will kill you.
|
This is related to [another question I asked](http://beta.stackoverfow.com/questions/43324/can-i-put-an-aspnet-session-id-in-a-hidden-form-field). In summary, I have a special case of a URL where, when a form is POSTed to it, I can't rely on cookies for authentication or to maintain the user's session, but I somehow need to know who they are, and I need to know they're logged in!
I think I came up with a solution to my problem, but it needs fleshing out. Here's what I'm thinking. I create a hidden form field called "username", and place within it the user's username, encrypted. Then, when the form POSTs, even though I don't receive any cookies from the browser, I know they're logged in because I can decrypt the hidden form field and get the username.
The major security flaw I can see is replay attacks. How do I prevent someone from getting ahold of that encrypted string, and POSTing as that user? I know I can use SSL to make it harder to steal that string, and maybe I can rotate the encryption key on a regular basis to limit the amount of time that the string is good for, but I'd really like to find a bulletproof solution. Anybody have any ideas? Does the ASP.Net ViewState prevent replay? If so, how do they do it?
**Edit**: I'm hoping for a solution that doesn't require anything stored in a database. Application state would be okay, except that it won't survive an IIS restart or work at all in a web farm or garden scenario. I'm accepting Chris's answer, for now, because I'm not convinced it's even possible to secure this without a database. But if someone comes up with an answer that does not involve the database, I'll accept it! |
This is related to [another question I asked](http://stackoverflow.com/questions/43324/can-i-put-an-aspnet-session-id-in-a-hidden-form-field). In summary, I have a special case of a URL where, when a form is POSTed to it, I can't rely on cookies for authentication or to maintain the user's session, but I somehow need to know who they are, and I need to know they're logged in!
I think I came up with a solution to my problem, but it needs fleshing out. Here's what I'm thinking. I create a hidden form field called "username", and place within it the user's username, encrypted. Then, when the form POSTs, even though I don't receive any cookies from the browser, I know they're logged in because I can decrypt the hidden form field and get the username.
The major security flaw I can see is replay attacks. How do I prevent someone from getting ahold of that encrypted string, and POSTing as that user? I know I can use SSL to make it harder to steal that string, and maybe I can rotate the encryption key on a regular basis to limit the amount of time that the string is good for, but I'd really like to find a bulletproof solution. Anybody have any ideas? Does the ASP.Net ViewState prevent replay? If so, how do they do it?
**Edit**: I'm hoping for a solution that doesn't require anything stored in a database. Application state would be okay, except that it won't survive an IIS restart or work at all in a web farm or garden scenario. I'm accepting Chris's answer, for now, because I'm not convinced it's even possible to secure this without a database. But if someone comes up with an answer that does not involve the database, I'll accept it! |
I think always, always, always add logging when there is an exception, including the message and full stack trace. Beyond that, I think it's pretty subjective to whether or not you use the logs often or not...
I often try to only add logging in critical places where what I am logging should very rarely hit, otherwise you get the problem like he mentioned of logs that grow way too big... this is why logging error cases is the ideal thing to always log (and it's great to be able to see when these error cases are actually being hit so you can inspect the problem further).
Other good things to log are if you have assertions, and your assertions fail, then log it... such as, this query should be under 10 results, if it is bigger there may be a problem, so log it. Of course, if a log statement ends up filling the logs, it is probably a hint to either put it to some sort of "debug" level, or to adjust or remove the log statement. If the logs grow too big, you will often end up ignoring them. |
You could enumerate all the network adapters, get their IP addresses and compare the part covered by the subnet mask with the sender's address.
Like:
IPAddress FindLocalIPAddressOfIncomingPacket( senderAddr )
{
foreach( adapter in EnumAllNetworkAdapters() )
{
adapterSubnet = adapter.subnetmask & adapter.ipaddress;
senderSubnet = adapter.subnetmask & senderAddr;
if( adapterSubnet == senderSubnet )
{
return adapter.ipaddress;
}
}
} |
Anthony Cramp's answer looked good to me. As he mentions the DCT transforms the data into the frequency domain. The DCT is heavily used in video compression as the human visual system is must less sensitive to high frequency changes, therefore zeroing out the higher frequency values results in a smaller file, with little effect on a human's perception of the video quality.
In terms of using the DCT to compare images, I guess the only real benefit is if you cut away the higher frequency data and therefore have a smaller set of data to search/match. Something like Harr wavelets may give better image matching results. |
At the place where I work, we decided to move from SVN to Bazaar (after evaluating git and mercurial). Bazaar was easy to start off, with simple commands (not like the 140 commands that git has)
The advantages that we see is the ability to create local branches and work on it without disturbing the main version. Also being able to work without network access, doing diffs is faster.
One command in bzr which I like is the shelve extension. If you start working on two logically different pieces of code in a single file and want to commit only one piece, you can use the shelve extension to literally shelve the other changes later. In Git you can do the same with playing around in the index(staging area) but bzr has a better UI for it.
Most of the people were reluctant to move over as they have to type in two commands to commit and push (bzr ci + bzr push). Also it was difficult for them to understand the concept of branches and merging (no one uses branches or merges them in svn).
Once you understand that, it will increase the developer's productivity. Till everyone understands that, there will be inconsistent behaviour among everyone.
|
vmware-cmd causes "perl.exe - Ordinal Not Found" error |
|vmware| |
My automated script for staring and stopping VMWare Server virtual machines has stopped working. vmware-cmd has started raising the error:
"The ordinal 3288 could not be located in the dynamic link library LIBEAY32.dll."
I am not aware of any specific change or update when this started happening.
I have found a bunch of other people reporting this problem (or very similar) but no solution.
Do you know what caused this? and/or how to fix this? |
@Sergio and @Rowan
Yes, we're **not** talking about loading and transforming data into the database (like a SSIS tool would do). That's solved using out integration platform. |
@Sergio and @Rowan
Yes, we're **not** talking about loading and transforming data into the database (like a SSIS tool would do). That's solved using our integration platform. |
In **ZFC**, either the axiom of foundation [as mentioned] or the axiom (scheme) of comprehension will prohibit this. The first, for obvious reasons; the second, since it basically says that for given *z* and first-order property *P*, you can construct { *x* ∈ *z* : *P*(*x*) }, but to generate the Russell set, you would need *z* = *V* (the class of all sets), which is not a set (i.e. cannot be generated from any of the given axioms).
In New Foundations (**NF**), "*x* ∉ *x*" is not a stratified formula, and so again we cannot define the Russell set. Somewhat amusingly, however, *V* *is* a set in **NF**.
In von Neumann--Bernays--Gödel set theory (**NBG**), the class *R* = { *x* : *x* is a set and *x* ∉ *x* } is definable. We then ask whether *R* ∈ *R*; if so, then also *R* ∉ *R*, giving a contradiction. Thus we must have *R* ∉ *R*. But there is no contradiction here, since for any given class *A*, *A* ∉ *R* implies either *A* ∈ *A* or *A* is a proper class. Since *R* ∉ *R*, we must simply have that *R* is a proper class.
Of course, the class *R* = { *x* : *x* ∉ *x* }, without the restriction, is simply not definable in **NBG**.
Also of note is that the above procedure is formally constructable as a proof in **NBG**, whereas in **ZFC** one has to resort to meta-reasoning. |
I haven't used the AuthorizeAttribute that comes in Preview 4 yet. I rolled my own, because I have been using the MVC framework since the first CTP. I took a quick look at the attribute in reflector and it is doing what I mentioned above internally, except they use the hex equivalent of 401. I will need to look further up the call, to see where the exception is caught, because more than likely that is where they are doing the redirect. This is the functionality you will need to override. I am not sure if you can do it yet, but I will post back when I find it and give you a work around, unless Haacked sees this and posts it himself. |
According to the [`Timer`](http://java.sun.com/javase/6/docs/api/java/util/Timer.html) documentation, in Java 1.5 onwards, you should prefer the [`ScheduledThreadPoolExecutor`]( http://java.sun.com/javase/6/docs/api/java/util/concurrent/ScheduledThreadPoolExecutor.html) instead. (You may like to create this executor using [`Executors`](http://java.sun.com/javase/6/docs/api/java/util/concurrent/Executors.html)`.newSingleThreadScheduledExecutor()` for ease of use; it creates something much like a `Timer`.)
The cool thing is, when you schedule a task (by calling `schedule()`), it returns a [`ScheduledFuture`](http://java.sun.com/javase/6/docs/api/java/util/concurrent/ScheduledFuture.html) object. You can use this to cancel the scheduled task. You're then free to submit a new task with a different triggering time. |
According to the [`Timer`](http://java.sun.com/javase/6/docs/api/java/util/Timer.html) documentation, in Java 1.5 onwards, you should prefer the [`ScheduledThreadPoolExecutor`]( http://java.sun.com/javase/6/docs/api/java/util/concurrent/ScheduledThreadPoolExecutor.html) instead. (You may like to create this executor using [`Executors`](http://java.sun.com/javase/6/docs/api/java/util/concurrent/Executors.html)`.newSingleThreadScheduledExecutor()` for ease of use; it creates something much like a `Timer`.)
The cool thing is, when you schedule a task (by calling `schedule()`), it returns a [`ScheduledFuture`](http://java.sun.com/javase/6/docs/api/java/util/concurrent/ScheduledFuture.html) object. You can use this to cancel the scheduled task. You're then free to submit a new task with a different triggering time.
ETA: The `Timer` documentation linked to doesn't say anything about `ScheduledThreadPoolExecutor`, however the [OpenJDK](http://openjdk.java.net/) version had this to say:
> Java 5.0 introduced the `java.util.concurrent` package and
> one of the concurrency utilities therein is the
> `ScheduledThreadPoolExecutor` which is a thread pool for repeatedly
> executing tasks at a given rate or delay. It is effectively a more
> versatile replacement for the `Timer`/`TimerTask`
> combination, as it allows multiple service threads, accepts various
> time units, and doesn't require subclassing `TimerTask` (just
> implement `Runnable`). Configuring
> `ScheduledThreadPoolExecutor` with one thread makes it equivalent to
> `Timer`. |
I suggest [TeamCity][1]. :)
[1]: http://www.jetbrains.com/teamcity/ |
I would probably rely on an issue tracking system for this purpose, and make sure to tag each change that needed to be brought forward into the trunk code. You can then ensure that check-in comments for each change reference the relevant issue, and are clear in expressing the intent of the code change so that it can be easily understood when trying to re-implement in the trunk. |
From [Wikipedia][1]
> At the time when octal originally
> became widely used in computing,
> systems such as the IBM mainframes
> employed 24-bit (or 36-bit) words.
> Octal was an ideal abbreviation of
> binary for these machines because
> eight (or twelve) digits could
> concisely display an entire machine
> word (each octal digit covering three
> binary digits). It also cut costs by
> allowing Nixie tubes, seven-segment
> displays, and calculators to be used
> for the operator consoles; where
> binary displays were too complex to
> use, decimal displays needed complex
> hardware to convert radixes, and
> hexadecimal displays needed to display
> letters.
>
> All modern computing
> platforms, however, use 16-, 32-, or
> 64-bit words, with eight bits making
> up a byte. On such systems three octal
> digits would be required, with the
> most significant octal digit
> inelegantly representing only two
> binary digits (and in a series the
> same octal digit would represent one
> binary digit from the next byte).
> Hence hexadecimal is more commonly
> used in programming languages today,
> since a hexadecimal digit covers four
> binary digits and all modern computing
> platforms have machine words that are
> evenly divisible by four. Some
> platforms with a power-of-two word
> size still have instruction subwords
> that are more easily understood if
> displayed in octal; this includes the
> PDP-11. The modern-day ubiquitous x86
> architecture belongs to this category
> as well, but octal is almost never
> used on this platform.
-Adam
[1]: http://en.wikipedia.org/wiki/Octal |
The article [here][1] (Day-to-day with Subversion) mentions that one method is to constantly update version 2 with data from the version 1.1 build. In the article, the guy says to do this every day.
The part you'll want to read is titled "Waiter, There's a Bug in my Trunk!". It's about halfway though the article.
[1]: http://weblogs.asp.net/bsimser/archive/2008/05/06/day-to-day-with-subversion.aspx |
I recently had to write network protocol code that accesses 3-bit fields. Octal comes in handy when you want to debug that.
Just for effect, can you tell me what the 3-bit fields of this are?
0x492492
On the other hand, this same number in octal:
022222222
Now, finally, in binary (in groups of 3):
010 010 010 010 010 010 010 010
|
What do you want to do with the data? Store it? Pass it around? Display it? These questions should drive your search for an appropriate technology. Simply asking how you should format your data is like asking what language you should program in, without specifying what you want to accomplish.
For most data tasks, well Dr. Codd has the cure: http://en.wikipedia.org/wiki/Edgar_F._Codd. Databases should be able to do just about anything you have in mind.
If you're passing it around, I advocate plain text. When you roll your own binary format your data goes away when your parser goes away.
With plain text, the deeper question is where to put the metadata. Should it be external to the data file, or internal ("self-describing").
For example, XML is plain text, but so is source code. With a source file, there is a specification that goes in to great detail as to the syntax and semantics, while XML is *supposed* to be self-describing. The problem is that it isn't. Furthermore it evolved right out of document presentation and markup, but is now being abused for all sorts of data serialization, transfer, and storage. |
|c++|memory|stack|heap| |
So, I need some help. I am working on a project in C++. However, I think I have somehow managed to corrupt my heap. This is based off the fact that I added a `std::string` to a class and assigning it a value from another `std::string`:
std::string hello = "Hello, world.\n";
/* exampleString = "Hello, world.\n" would work fine. */
exampleString = hello;
crashes on my system with a stack dump. So basically I need to **stop** and go through all my code and memory management stuff and find out where I've screwed up. The codebase is still small (about 1000 lines), so this is easily do-able.
Still, I'm over my head with this kind of stuff, so I thought I'd throw it out there. I'm on a Linux system, and have poked around with `valgrind`, and while not knowing completely what I'm doing, it did report that the `std::string`'s destructor was an invalid free. I have to admit to getting the term 'Heap Corruption' from a Google search; any general purpose articles on this sort of stuff would be appreciated as well.
(In before `rm -rf ProjectDir`, do again in C# :D)
EDIT:
I haven't made it clear, but what I'm asking for are ways an advice of diagnosing these sort of memory problems. I know the std::string stuff is right, so it's something I've done (or a bug, but there's Not A Problem With Select). I'm sure I could chuck the code I've written up and you very smart folks would see the problem in no time, but I want to add this kind of code analysis to my 'toolbox', as it were. |
Why don't you use Microsoft ATL's regex library? Kenny Kerr has written a [short article][1] on that recently. Hope it helps.
[1]: http://weblogs.asp.net/kennykerr/archive/2008/07/18/visual-c-in-short-regular-expressions.aspx |
The code was simply an example of where my program was failing (it was allocated on the stack, Jim). I'm not actually looking for 'what have I done wrong', but rather 'how do I diagnose what I've done wrong'. Teach a man to fish and all that. Though looking at the question, I haven't made that clear enough. Thank goodness for the edit function. :') |
The code was simply an example of where my program was failing (it was allocated on the stack, Jim). I'm not actually looking for 'what have I done wrong', but rather 'how do I diagnose what I've done wrong'. Teach a man to fish and all that. Though looking at the question, I haven't made that clear enough. Thank goodness for the edit function. :')
Also, I actually fixed the std::string problem. How? By replacing it with a vector, compiling, then replacing the string again. It _was_ consistently crashing there, and that fixed even though it...couldn't. There's something nasty there, and I'm not sure what. I did want to check the one time I manually allocate memory on the heap, though:
this->map = new Area*[largestY + 1];
for (int i = 0; i < largestY + 1; i++) {
this->map[i] = new Area[largestX + 1];
}
and deleting it:
for (int i = 0; i < largestY + 1; i++) {
delete [] this->map[i];
}
delete [] this->map;
I haven't allocated a 2d array with C++ before. It seems to work. |
Oh, if you want to know how to debug the problem, that's simple. First, get a dead chicken. Then, [start shaking it](http://c2.com/cgi/wiki?VoodooChickenCoding).
Seriously, I haven't found a consistent way to track these kinds of bugs down. Because there's so many potential problems, there's not a simple checklist to go through. However, I would recommend the following:
1. Get comfortable in a debugger.
2. Start tromping around in the debugger to see if you can find anything that looks fishy. Check especially to see what's happening during the `exampleString = hello;` line.
3. Check to make sure it's actually crashing on the `exampleString = hello;` line, and not when exiting some enclosing block (which could cause destructors to fire).
4. Check any pointer magic you might be doing. Pointer arithmetic, casting, etc.
5. Check all of your allocations and deallocations to make sure they are matched (no double-deallocations).
6. Make sure you aren't returning any references or pointers to objects on the stack.
There are lots of other things to try, too. I'm sure some other people will chime in with ideas as well. |
DOS filename escaping for use with *nix commands |
|dos|scripting|shell| |
Earlier today I wanted to escape a DOS filename so I could use it with sed. I had a DOS batch file something like this:
set FILENAME=%~f1
sed 's/Some Pattern/%FILENAME%/' inputfile
(Note: %~f1 - expands %1 to a Fully qualified path name - C:\utils\MyFile.txt)
I found that the backslashes in %FILENAME% were just escaping the next letter.
How can I double them up so that they are escaped?
(I have cygwin installed so feel free to use any other *nix commands) |
I want to escape a DOS filename so I can use it with sed. I have a DOS batch file something like this:
set FILENAME=%~f1
sed 's/Some Pattern/%FILENAME%/' inputfile
(Note: %~f1 - expands %1 to a Fully qualified path name - C:\utils\MyFile.txt)
I found that the backslashes in %FILENAME% are just escaping the next letter.
How can I double them up so that they are escaped?
(I have cygwin installed so feel free to use any other *nix commands) |
|scripting|dos|shell| |
I want to escape a DOS filename so I can use it with sed. I have a DOS batch file something like this:
set FILENAME=%~f1
sed 's/Some Pattern/%FILENAME%/' inputfile
(Note: %~f1 - expands %1 to a Fully qualified path name - C:\utils\MyFile.txt)
I found that the backslashes in %FILENAME% are just escaping the next letter.
How can I double them up so that they are escaped?
(I have cygwin installed so feel free to use any other *nix commands)
<h1>Solution</h1>
Combining Jeremy and Alexandru Nedelcu's suggestions, and using | for the delimiter in the sed command I have
set FILENAME=%~f1
cygpath "s|Some Pattern|%FILENAME%|" >sedcmd.tmp
sed -f sedcmd.tmp inputfile
del /q sedcmd.tmp |
Because you've already made a typedef for the struct (because you used the 's1' version), you should write:
foo test;
rather than
struct foo test;
That will work in both C and C++
|
mysql software: any suggestions to oversee my mysql replication server? |
|mysql| |
I've had a tough time setting up my replication server. Is there any program (OS X, Win, Linux or php no problem) that lets me monitor and resolve replication issues? (btw, for those -uhm- following, ive been on this issue [here][1], [here][2], [here][3] and [here][4]. Either i'm going about this the wrong way or i must be immensely thick)
My production database is several megs in size and growing. Every time the database replication stops and the databases inevitably begin to slide out of sync i cringe. My last resync from dump took almost 4 hours roundtrip!
As always, even after sync, I run into this kind of show-stopping error":
Error 'Duplicate entry '252440' for key 1' on query.
I would love it if there was some way to closely monitor whats going on and perhaps let the software deal with it. I'm even all ears for service companies which may help me monitor my data better. Or an alternate way to mirror altogether.
**Edit**: going through my previous questions i found [this][5] which helps tremendously. I'm still all ears on the monitoring solution.
cheers,
/mp
[1]: http://stackoverflow.com/questions/8166/mysql-replication-if-i-dont-specify-any-databases-will-logbin-log-everything
[2]: http://stackoverflow.com/questions/3798/full-complete-mysql-db-replication-ideas-what-do-people-do
[3]: http://stackoverflow.com/questions/8365/mysql-administrator-backups-compatibility-mode-what-exactly-is-this-doing
[4]: http://stackoverflow.com/questions/30660/mysql-binary-log-replication-can-it-be-set-to-ignore-errors
[5]: http://stackoverflow.com/questions/30660/mysql-binary-log-replication-can-it-be-set-to-ignore-errors#30889 |
Try this:
http://www.freedownloadscenter.com/Programming/Delphi_Tools_and_Components/PowerPoint_ActiveX.html
This is an ActiveX component that embeds powerpoint into an OCX.
Since you are using just IE6/7 you can embed this component into the HTML.
|
I'm assuming you are using GNU ls?
try
\ls
It will unalias the usual ls (ls --color=auto).
|
ls -U
will do the ls without sorting. |
Keith's approach seems nice. I put together a more naive approach using lists. This has error checking so hopefully should pick up most problems:-
public List<int> parsePageNumbers(string input) {
if (string.IsNullOrEmpty(input))
throw new InvalidOperationException("Input string is empty.");
var pageNos = input.Split(',');
var ret = new List<int>();
foreach(string pageString in pageNos) {
if (pageString.Contains("-")) {
parsePageRange(ret, pageString);
} else {
ret.Add(parsePageNumber(pageString));
}
}
ret.Sort();
return ret.Distinct().ToList();
}
private int parsePageNumber(string pageString) {
int ret;
if (!int.TryParse(pageString, out ret)) {
throw new InvalidOperationException(
string.Format("Page number '{0}' is not valid.", pageString));
}
return ret;
}
private void parsePageRange(List<int> pageNumbers, string pageNo) {
var pageRange = pageNo.Split('-');
if (pageRange.Length != 2)
throw new InvalidOperationException(
string.Format("Page range '{0}' is not valid.", pageNo));
int startPage = parsePageNumber(pageRange[0]),
endPage = parsePageNumber(pageRange[1]);
if (startPage > endPage) {
throw new InvalidOperationException(
string.Format("Page number {0} is greater than page number {1}" +
" in page range '{2}'", startPage, endPage, pageNo));
}
pageNumbers.AddRange(Enumerable.Range(startPage, endPage - startPage + 1));
} |
By default, the entities will use all fields for checking concurrency when making edits. That's what's throwing the InvalidOperationException.
This can be setting the Update Check property for all fields to Never. This must be done on all fields to attach the entity as modified. If this is done, an additional call to context.SubmitChanges() will save the data.
Alternatively, if you know the original values, you can attach and then make the updates, but all values that are being checked must match the original values.
LinqEntity item = new LinqEntity(){ Id = 1, Name = "OldName", Surname = "OldSurname"};
context.LinqEntities.Attach(item);
item.Name = "John";
item.Surname = "Doe";
context.SubmitChanges();
|
Technically, you don't need a Mac. Applications in OS X just require a [specific folder structure][1] and an [XML file][2]. However, the Mac has a really nice tool called [Jar Bundler][3]. In addition to setting up the bundle directories and XML file, it creates a C executable that launches your java application via JNI. This is nice because the process name matches the application name.
I believe that you could have someone generate an application bundle for you once, and then check in the files to your project. At build time, all you would need to do is copy your jar files to the appropriate locations and maybe update the XML file.
[1]: http://developer.apple.com/documentation/CoreFoundation/Conceptual/CFBundles/Concepts/BundleAnatomy.html#//apple_ref/doc/uid/20001119
[2]: http://developer.apple.com/documentation/MacOSX/Conceptual/BPRuntimeConfig/Articles/ConfigFiles.html#//apple_ref/doc/uid/20002091-CJBJIEDH
[3]: http://developer.apple.com/documentation/Java/Conceptual/Jar_Bundler/Introduction/chapter_1_section_1.html |
Any document that proves switching will lower costs. Failing that, multi-colored graphs and charts. Maybe a power-point presentation. |
The best argument would have to be the reason why you want them to switch to subversion. :)
I know absolutely nothing about VSS, but the phrase "if it ain't broken don't fix it" comes to mind. You have to show your managers that VSS is broken and needs fixing. Even better if you can show management how it would save them money. |
The only place I come across octal literals these days is when dealing with the permission bits on files in Linux, which are normally represented as 3 octal digits, where each digit represents the permissions for the file owner, group and other users respectively.
e.g. 0755 (also just 755 with most command line tools) means the file owner has full permissions (read, write, execute), and the group and other users just have read and execute permissions.
Representing these bits in octal makes it easier to figure out what permissions are set. You can tell at a glance what 0755 means, but not 493 or 0x1ed. |
VSS totally relies on the clients to manage the database. If a client drops connection in the middle of a write over the network at just the wrong time, your file is trashed on the server. Not just the tip, but all the history. Hope you have a good backup. I've been through it. It's bad news.
VSS usage over VPN or other remote connections is abysmal. It's using SMB to transfer the data, and you have to retrieve the file and all of its deltas just to get the tip. Nasty.
I've seen VSS start to act up at 1GB of data. Database errors, etc. MS (somewhere in a FAQ or KB) says that 2GB is really the max safe limit. There are no good management tools (the clients run the asylum), so you don't really get any warning about this.
*Anything* with a server process to provide some level of transactions and integrity control is a superior solution.
|
How different are the host names?
These hosts can share cookies.
- mail.xyz.com
- www.xyz.com
- logon.xyz.com
But there can not.
- abc.com
- xyz.com
- www.tre.com
In the former case you can bang out a cookie based solution. Think GUID and a database session table.
|
Tom's article is very old. It only discusses the DATE type. If you use TIMESTAMP types then date arithmetic is built into PL/SQL.
[http://www.akadia.com/services/ora_date_time.html][1]
DECLARE
ts_a timestamp;
ts_b timestamp;
diff interval day to second;
BEGIN
ts_a := systimestamp;
ts_b := systimestamp-1/24;
diff := ts_a - ts_b;
dbms_output.put_line(diff);
END;
+00 01:00:00.462000
or
DECLARE
ts_b timestamp;
ts_a timestamp;
date_part interval day to second;
BEGIN
ts_a := systimestamp;
date_part := to_dsinterval('0 01:23:45.678');
ts_b := ts_a + date_part;
dbms_output.put_line(ts_b);
END;
04-SEP-08 05.00.38.108000 PM
[1]: http://www.akadia.com/services/ora_date_time.html |
Looks like it can't be done from `bash`
If you using `zsh` then
ls **/*.rb
will produce the correct result.
Otherwise you can hijack the `ruby` interpreter (and probably those of other languages)
ruby -e "puts Dir.glob('**/*.rb')"
Thanks to Chris and Gaius for your answers. |
If you use [WinMerge](http://winmerge.org/) it has added support for merging Word and Excel binary files. |
Make sure you bind the DefaultView to the Controls Datasource, after you set the Sort property, and not the table:
myCombo.DataSource = this.typedDataSet.Tables["Table1"].DefaultView;
myCombo.DisplayMember = "ColumnB";
myCombo.ValueMember = "ColumnA"; |
How to submit a form when the return key is pressed? |
|javascript|html| |
Can someone please tell me how to submit an HTML form when the return key is pressed and if there are no buttons in the form?
The submit button is not there. I am using a custom div instead of that.
|
Why don't you just apply the div submit styles to a submit button? I'm sure there's a javascript for this but that would be easier. |
Here is how I do it with jQuery
j(".textBoxClass").keypress(function(e)
{
// if the key pressed is the enter key
if (e.which == 13)
{
// do work
}
});
Other javascript wouldnt be too different. the catch is checking for keypress argument of "13", which is the enter key |