instruction stringlengths 0 30k ⌀ |
|---|
Getting mail from GMail into Java application using IMAP |
|java|gmail|imap| |
I want to access messages in GMail from a Java application using JavaMail and IMAP. Why am I getting a SocketTimeoutException?
Here is my code:
Properties props = System.getProperties();
props.setProperty("mail.imap.host", "imap.gmail.com");
props.setProperty("mail.imap.port", "993");
props.set... |
The ASP.NET MVC Framework would give you a much more familiar separation. Because there is no viewstate, etc in the MVC Framework you won't have to worry about JavaScript being dumped into your pages. The only JavaScript calls you see will be ones that you manually add.
You can, for the most part, separate HTML / CS... |
Just add a reference to wmp.dll (\windows\system32\wmp.dll)
using WMPLib;
And then you can instantiate a media player
var Player = new WindowsMediaPlayer();
// Load a playlist or file and then get the title
var title = Player.controls.currentItem.name;
See [Creating the Windows Media Play... |
Will's suggestion of using .p4ignore only seems to work with the Websphere Studio (P4WSAD) plugin. I just tried it on my local windows box and any files and directories that I listed were _not_ ignored.
Raven's suggestion of modifying your client spec is the correct way under Perforce. Proper organization of your... |
YXJuLnphcnQ, that's the way I did it too. It's the most obvious.
But the fact is, that if you write an algorithm, that just shuffles all the cards in the collection one position to the right every time you call sort() it would pass the test, even though the output is not random. |
The reason why you can't cast from one to the other is that this is evil.
Lets say you create an array of object[5..9] and you pass it to a function F as an object[].
How would the function knows that this is a 5..9 ? What you chould do however, is a class that is a constrained collection that mimics the behaviou... |
The reason why you can't cast from one to the other is that this is evil.
Lets say you create an array of object[5..9] and you pass it to a function F as an object[].
How would the function knows that this is a 5..9 ? F is expecting a general array but it's getting a constrained one. You could say it's possible f... |
MySQL: According to the MySQL website, `COUNT(*)` is faster for single table queries when using MyISAM:
[http://dev.mysql.com/doc/refman/5.0/en/group-by-functions.html#function_count][1]
I'm guessing with a having clause with a count in it may change things.
[1]: http://dev.mysql.com/doc/refman/5.0/en/grou... |
When Testing your MVC-based UI, how much of the test setup do you make common? |
|unit-testing|user-interface|model-view-controller|tdd|mvp| |
I'm trying to test a simple WebForms (asp.net) based UI, and follow the MVP pattern to allow my UI to be more testable.
As I follow the TDD methodology for backend algorithms, I find that there are some unit test refactorings that happen in the spirit of the DRY principle (Don't Repeat Yourself). As I try to apply ... |
I am not sure what you constitute as cheap, but the Peter Blum ASP.NET controls are a good buy.
[peterblum.com][1]
[1]: http://www.peterblum.com/Home.aspx |
One of the best pieces of advice I ever got for doing demos is to just plain record them in advance and play back the video, narrating live. Then the unexpected stuff happens in private and you get as many stabs at it as you need.
You still usually need some environment to use as a reference for questions, but for t... |
I assume you're using the defragger that comes with Windows. Some commercial ones like DiskKeeper can move some of these files (usually system files). You can try their trial versions. |
Virtual Serial Port for Linux |
|linux|testing|hardware|serial-port|virtual-serial-port| |
I need to test a serial port application on Linux, however, my test machine only has one serial port.
**Is there a way to add a virtual serial port to Linux and test my application by emulating a device through a shell or script?**
Note: I cannot remap the port, it hard coded on ttys2 and I need to test the app... |
This usually means that the file is in use by some process. If you're defragmenting, you'll likely see this with a lot of system files. If the file should legitimately be movable and is stuck (it's being held by a process that runs at startup but shouldn't be, for example), the most useful way of resolving the problem ... |
The Threading example from Eli will run the thread, but not do any of the work after that line.
I'm going to look into the processing module and the subprocess module. I think the com method I'm running needs to be in another process, not just in another thread. |
Start with what we CS folks call "discrete math". Calculus and linear algebra can come in quite handy too because they get your foot in the door to a lot of application domains. Once you've mastered those three, go for probability theory. Those 4 will get you to competency in 95% (I made that up) of application doma... |
In addition to what others have said, Flash is constrained in the "rectangle" and cannot be added to a normal html page in an un-obtrusive manner.
@[Gulzar](52145) I think when more browsers will support the video tag like mozilla 3.1 does we'll see even more adoption of ajax/js over flash. |
There was a book that was recommended...the title was something like Concrete Mathematics. It was recommended in a few questions. |
My math background is really poor (Geologist by training), but I took a [discrete math][1] class in high school and I use the concepts every day as a programmer. It is probably the most valuable class I took in all of my education as it relates to my current profession.
[1]: http://en.wikipedia.org/wiki/Discret... |
Unmovable Files on Windows XP |
|windows|filesystems| |
When I defragment my XP machine I notice that there is a block of "Unmovable Files". Is there a file attribute I can use to make my own files unmovable?
Thanks,
Terry |
When I defragment my XP machine I notice that there is a block of "Unmovable Files". Is there a file attribute I can use to make my own files unmovable?
Just to clarify, I want a way to programmatically tell Windows that a file that I create should be unmovable. Is this possible, and if so, how can I do it?
Thank... |
I suppose you really want some kind of factory instead of the static initializer.
Some mix of a singleton and an abstract factory would probably be able to get you the same functionality as today, and with good testability, but that would add quite a lot of boiler-plate code, so it might be better to just try to ref... |
You have to connect to GMail using SSL only. Setting the following properties will force that for you.
<pre><code lang="java">
props.setProperty("mail.imap.socketFactory.class", "javax.net.ssl.SSLSocketFactory");
props.setProperty("mail.imap.socketFactory.fallback", "false");
</code></pre>
|
Web in a desktop application: Good web browser controls? |
|browser|controls|desktop-application| |
I've been utlising a "web browser control" in desktop based applications (in my case Windows Forms .NET) for a number of years. I mostly use it to create a familiar flow-based user interface that also allows a seamless transition to the internet where required.
I'm really tired of the IE browser control because of ... |
Hmm - I probably should have been a bit more specific.
I'm not so much looking for advice for myself - I'm writing a static code analysis tool (the current commercial offerings just aren't good enough for what I want), and I'm looking for ideas for plugins to highlight possible errors in the code.
Several people ... |
hmm..Interestingly
1. [Mozilla][1] seems to provide ActiveX control
2. [K-Melon][2] is another Gecko based browser control
[1]: http://www.iol.ie/~locka/mozilla/control.htm
[2]: http://kmeleon.sourceforge.net/ |
In JavaMail, you can use `imaps` as the URL scheme to use IMAP over SSL. (See `SSLNOTES.txt` in your JavaMail documentation for more details.) For example, `imaps://username%40gmail.com@imap.gmail.com/INBOX`.
Similarly, use `smtps` to send emails via Gmail. e.g., `smtps://username%40gmail.com@smtp.gmail.com/`. |
In JavaMail, you can use `imaps` as the URL scheme to use IMAP over SSL. (See `SSLNOTES.txt` in your JavaMail distribution for more details.) For example, `imaps://username%40gmail.com@imap.gmail.com/INBOX`.
Similarly, use `smtps` to send emails via Gmail. e.g., `smtps://username%40gmail.com@smtp.gmail.com/`. Again,... |
.Net arrays with lower bound > 0 |
|.net|arrays| |
Although perhaps a bizare thing to want to do, I need to create an Array in .Net with a lower bound > 0. This at first seems to be possible, using:
Array.CreateInstance(typeof(Object), New Integer[] {2}, New Integer[] {9})
Produces the desired results (an array of objects with a lower bound set to 9). However... |
Although perhaps a bizare thing to want to do, I need to create an Array in .Net with a lower bound > 0. This at first seems to be possible, using:
Array.CreateInstance(typeof(Object), new int[] {2}, new int[] {9});
Produces the desired results (an array of objects with a lower bound set to 9). However the cr... |
Although perhaps a bizare thing to want to do, I need to create an Array in .Net with a lower bound > 0. This at first seems to be possible, using:
Array.CreateInstance(typeof(Object), new int[] {2}, new int[] {9});
Produces the desired results (an array of objects with a lower bound set to 9). However the cr... |
Although perhaps a bizare thing to want to do, I need to create an Array in .Net with a lower bound > 0. This at first seems to be possible, using:
Array.CreateInstance(typeof(Object), new int[] {2}, new int[] {9});
Produces the desired results (an array of objects with a lower bound set to 9). However the cr... |
this is just a random shot, but are you getting blocked because of the order of authorization for Admin? Maybe you should try switching your deny all and your all Admin.
Just in case it's getting overwritten by the deny.
(I had code samples in here but they weren't showing up. |
That url string looks like it's invalid. Sure it's not supposed to be 'http://path'? Or are the server & port blank? |
bug in linq Contains statement - is there a fix or workaround? |
|linq| |
I found a bug in the Contains statement in Linq (not sure if it is really in Linq or Linq to SQL) and want to know if anyone else has seen this and if there is a fix or workaround.
If the querysource you do the contains with has more than 10 items in it, it does not pass the items correctly to the SQL query. It is h... |
|.net|linq| |
I found a bug in the Contains statement in Linq (not sure if it is really in Linq or Linq to SQL) and want to know if anyone else has seen this and if there is a fix or workaround.
If the querysource you do the contains with has more than 10 items in it, it does not pass the items correctly to the SQL query. It is h... |
It all depends on the throughput needs of your application. If you absolutely need the lowest latency possible, then it would make sense to optimize the routes. Aside from hugely scalable software, I would argue that this is rarely needed and you can just connect everything in a generic fashion. |
You can [Publish Web site][1]..If you want to automate your deployment, you need to use some [script][2].
[1]: http://msdn.microsoft.com/en-us/library/1y1404zt(VS.80).aspx
[2]: http://www.codeproject.com/KB/install/DeploySite.aspx |
Alt-Up Arrow moves the current selection up a line, Alt-Down Arrow moves it down. I also use Alt-Shift-Up/Down Arrow all the time. Ctrl-K and Ctrl-Shift-K is quite handy, finding next/previous occurrence of the current selection (or the last Find, if nothing is selected). |
Build --> Publish <website name>
A dialog box will appear that will guide you through the process. |
How can I do a line continuation of code in Python? |
|python|syntax| |
I have a long line of code that I want to break up among multiple lines. What do I use and what is the syntax? |
I have a long line of code that I want to break up among multiple lines. What do I use and what is the syntax?
For example, adding a bunch of strings:
e = 'a' + 'b' + 'c' + 'd'
have it like this:
e = 'a' + 'b'
+ 'c' + 'd' |
Also take a look at [SQLite for Windows CE][1]. There are also .NET bindings available to use it from the Compact Framework.
[1]: http://sqlite-wince.sourceforge.net/ |
How do I implement a HTML cache for a PHP site? |
|php|html|caching| |
What is the best way of implementing a cache for a PHP site? Obviously, there are some things that shouldn't be cached (for example search queries), but I want to find a good solution that will make sure that I avoid the 'digg effect'.
I know there is WP-Cache for WordPress, but I'm writing a custom solution that is... |
What is the best way of implementing a cache for a PHP site? Obviously, there are some things that shouldn't be cached (for example search queries), but I want to find a good solution that will make sure that I avoid the 'digg effect'.
I know there is WP-Cache for WordPress, but I'm writing a custom solution that is... |
To elaborate on the selected answer, observe this line
const matrix& getMatrix() const
This is great, you don't have to worry about pointers and casting. You're returning a _reference_ to the underlying matrix object. IMHO references are one of the best features of C++, which I miss when coding in straight C.... |
There is also a nice [C++ Style Guide][1] used internally by Google, which includes most of the rules mentioned here.
[1]: http://google-styleguide.googlecode.com/svn/trunk/cppguide.xml
|
I don't run vista, but virtualbox should do most of the setup for you - all you need to do is assign an IP address, subnet mask, and (optionally) a default gateway to your guest OS, and it should just work.
Don't bother with any of the advanced network settings in the options for the VM - they're useful in some situ... |
You could write your test code in Groovy and easily mock the static method using metaprogramming.
Math.metaClass.'static'.max = { int a, int b ->
a + b
}
Math.max 1, 2
If you can't use Groovy, you will really need to refactoring the code (maybe to inject something like a initializator).
... |
I recommend python as it's not only a sexy language, but also very widely used and easy to integrate with C++ through [Boost.Python][1].
But as [Thomi][2] said, there's lot to explore in C++ and with the help of Boost libraries it's becoming really easy to develop in.
[1]: http://www.boost.org/doc/libs/1_36_0/l... |
How about **closures** in javascript (equivalent of anonymous methods in C# v2.0+). You can create a function that creates a function or "expression".
Example of **closures**:
//Takes a function that filters numbers and calls the function on
//it to build up a list of numbers that satisfy the function.
... |
What is the best way to position a div in css? |
|asp.net|css|layout| |
I'm trying to place this menu:
`<div class="left-menu" style="left: 123px; top: 355px">
`
` <ul>
`
` <li> Categories </li>
`
` <li> Weapons </li>
`
` <li> Armor </li>
`
` <li> Manuals </li>
`
` <li> Sustenance </li>
`
` <li> Test </li>
... |
I had this in my bookmarks but have NOT tested it in anyway. Just a pointer in the right direction. It's nothing official and will require a bit of digging, but you should get a fairly simple wrapper (which will still use PInvoke under the hood - but you won't see it) around Windows Media Player.
Hope that helps. |
I had this [http://forums.msdn.microsoft.com/en-US/clr/thread/dbd43d7e-f3a6-4087-be06-df17e76b635d][1] in my bookmarks but have NOT tested it in anyway. Just a pointer in the right direction. It's nothing official and will require a bit of digging, but you should get a fairly simple wrapper (which will still use PInvok... |
Ok I have found the answer myself after several dead ends. In the end I fixed this unintentionally while fixing another issue. Basically we had just turned on the automatic execution of unit tests for our builds. The test would run sucessfully but then immediately the build would bomb out with a message saying it was u... |
@[Dentharg][1]: your "include one to include all sub-parts" is a common pattern. Like anything, it has its advantages (easy to get the things you want) and its disadvantages (the many includes can pollute namespaces and you have no control over them). Your pattern looks like this:
- lib/
some_ruby_fil... |
You could use the find command
$found = find -type d -name "myDirectory"
if [ -n $found]
# found is not empty
fi |
You could use the find command
found=`find -type d -name "myDirectory"`
if [ -n "$found"]
then
# found is not empty
fi |
<p>It depends on your non-functional requirements. Assuming the NICs are running at the same rate, keeping the database traffic away from the front-end traffic can only be a good thing from a bandwidth perspective - if bandwidth is an issue.</p>
<p>Far more significant is that security is improved by keeping the front... |
@ [Grundlefleck](http://stackoverflow.com/questions/59838/how-to-check-if-a-directory-exists-in-a-bash-shell-script#59839)
Note the **-d** test can produce some surprising results:
$ ln -s tmp/ t
$ if [ -d t ]; then rmdir t; fi
rmdir: directory "t": Path component not a directory
File under: "Whe... |
I have used J# as an easy interim step to port a java library into C#. It made for a good way to port code I don't plan to maintain from Java to .Net. However, all new development is being done in C#. |
If you are showing code that was prepared for you then make sure you can get it to work. I know this is an obvious one but I was just at a conference where 4 out of 5 speakers had code issues. Telling me it is 'cool' or even 'really cool' when it doesn't work is a tough sell. |
Declare it like this
<bean id="doubleValue" class="java.lang.Double">
<constructor-arg index="0" value="3.7"/>
</bean>
And use like this
<bean id="someOtherBean" ...>
<property name="value" ref="doubleValue"/>
</bean>
|
Using the shared switch could give increased latency, especially if the switch is busy. Also, you may be able to hook up a faster dedicated network channel (e.g. gigabit ethernet, if your switch is 100Mbit). Whether any of this is worth doing or not depends on your application though.
You may also want to use a dedi... |
What's the difference between the inner workings of Java's JVM and .NET's CLR? |
|c#|.net|java|jvm|clr| |
What's the difference between the inner workings of Java's JVM and .NET's CLR?
Perhaps a starting point would be, are they basically the same thing in their respective environments (Java > JVM > Machine code) (C# > CLR > IL). |
I don't think it has any purpose. But because RegEx is almost impossible to understand/decompose, people rarely point out errors. That is probably why no one else pointed it out.
Edit: Why am I downvoted for **not** being wrong? |
Probably better not to run vista in a VM. Especially if you want the Aero UI turned on. VMs aren't very good with advanced graphics, so you'll probably want to run XP, or Vista in classic mode. |
I would use a singleton if it needed to store any state, and static classes otherwise. There's no point in instantiating something, even a single instance, unless it needs to store something. |
Not really, it should run just fine. Your dev environment will just be a little bit slower...but in my experience, it's not really all that bad. I wouldn't want it as my main machine, but it's perfectly usable. |
[SimpSim][1] is definitely worth a look. It's Windows only, but the feature set is pretty decent:
- Main memory and register display
- Built-in editor with syntax highlighting
- Run, step, and break functions
[1]: http://www.anne-gert.nl/projects/simpsim/ |
XP Pro is definitely better, unless you have a really beefy Mac.
Regarding your other question, no there are no pitfalls, other than performance. I prefer to use a real PC to do actual coding, using VMs for testing. Clearly, that's not an option for you within OSX. However, you do have the option of Boot Camp if the... |
I can't tell you any specific experiences since I don't have a Mac, but I did want to point out that there was an awesome episode of the DeepFriedBytes podcast that discussed this very topic. It made me want to give it a try. They discuss the pros and cons of going this route - well worth the listen IMO if this is some... |
I'm developing .NET apps in a Vista VM under VMWare Fusion.
Obviously you need a lot of memory, but other than not having Aero, I haven't run into any problems yet. |
I don't think Kibbee advice is correct. VMware Fusion (for the mac) currently supports up to DirectX9. The Vista integration is very good. If you have any trouble, you can natively boot into your Virtual Machine (If you have set it up as a BootCamp partition on the mac).
I don't see any trouble with this setup, alth... |
@[Dentharg][1]: your "include one to include all sub-parts" is a common pattern. Like anything, it has its advantages (easy to get the things you want) and its disadvantages (the many includes can pollute namespaces and you have no control over them). Your pattern looks like this:
- src/
some_ruby_fil... |
I agree with @PabloG - it's been over a decade since I worked with FoxPro (Dos & Windows) but even back in FPW2.6 you could determine where your app was running 'from', set absolute or relative search paths and even bundle your resources straight into the "compiled" (heh) exe. All of our resources lived in a specific s... |
You could always consider compiling your Ruby to JVM byte-code (via [JRuby][1]) or .NET byte-code (via [IronRuby][2]) to distribute to people who have those virtual machines and don't want to install a Ruby runtime.
You might want to check out [Shoes][3] for building desktop applications in Ruby. Rails really is tu... |