instruction stringlengths 0 30k ⌀ |
|---|
sizeof( f.x = 1)
returns 1 as its answer. The sizeof(1) is presumably the size of an integer on the platform you are compiling on, probably either 4 or 8 bytes. |
[SQLite][1] is exactly what you're after. It's a C library for accessing a file based relational database. The referred site has full visual studio support (System.Data.SQLite).
[1]: http://sqlite.phxsoftware.com/ |
No, you must be thinking of the == operator, which yields a "boolean" expression of type int in C and indeed bool in C++.
I think the expression will convert the value 1 to the correspondin bitfield type and assign it to the bitfield. The result should also be a bitfield type because there are no hidden promotions o... |
How do you add a JavaScript widget to a Wordpress.com hosted blog? |
|javascript|wordpress|widget| |
I've got a [site][1] that provides blog-friendly widgets via JavaScript. These work fine in most circumstances, including self-hosted Wordpress blogs. With blogs hosted at Wordpress.com, however, JavaScript isn't allowed in sidebar text modules. Has anyone seen a workaround for this limitation?
[1]: http://noteb... |
Reading from a ZipInputStream into a ByteArrayOutputStream |
|java|inputstream|outputstream| |
I am trying to read a single file from a java.util.zip.ZipInputStream, and copy it into a java.io.ByteArrayOutputStream (so that I can then create a java.io.ByteArrayInputStream and hand that to a 3rd party library that will end up closing the stream, and I don't want my ZipInputStream getting closed).
I'm probably ... |
I am trying to read a single file from a java.util.zip.ZipInputStream, and copy it into a java.io.ByteArrayOutputStream (so that I can then create a java.io.ByteArrayInputStream and hand that to a 3rd party library that will end up closing the stream, and I don't want my ZipInputStream getting closed).
I'm probably ... |
I am trying to read a single file from a java.util.zip.ZipInputStream, and copy it into a java.io.ByteArrayOutputStream (so that I can then create a java.io.ByteArrayInputStream and hand that to a 3rd party library that will end up closing the stream, and I don't want my ZipInputStream getting closed).
I'm probably ... |
It just needs the generic type specifier on the function:
namespace System.Web.Mvc
{
public static class ViewPageExtensions
{
public static string GetDefaultPageTitle<Type>(this ViewPage<Type> v)
{
return "";
}
}
}
Ed... |
|macos|iphone|cocoa|xcode|apple| |
What do you think is complex about DVCS like GIT? It's simpler in some ways: no client/server, no repo in one place with working dir in another place, user management is not built-in (use ssh if you need it). As Jim Puls said, you can use DVCS like non-distributed if you want. I use GIT for one-man projects, even on... |
If you want a single file that is portable to all platforms and which contain structured data, consider using sqlite. You'll get a full featured ACID compliant database that exists on disk as a single file.
There are libraries you can link against to directly access the file, and there is a command line tool you can... |
In short, not really.
In the old days when machines were slower the answer was yes; but having a modern processor rip through even a 60MB registry is not a problem.
Typically, the real reason a modern machine starts running slow is due to everything from malware to virus scanners: Mcafee, Norton's, etc are prim... |
In short, not really.
In the old days when machines were slower the answer was yes; but having a modern processor rip through even a 60MB registry is not a problem.
Typically, the real reason a modern machine starts running slow is due to everything from malware to virus scanners: Mcafee, Norton's, etc are prim... |
To generalize it a bit (perhaps incorrectly...), which of these situations would you prefer:
1. To find yourself on an island with no boat or bridge in site. Of course, you could talk to the villager in town and he would tell you the magical word to make a bridge appear...but you had no idea that magic existed.
2... |
I have had the exact same problem about a year ago, and after much googling and research, my headers (from Java code) look for IE6 & PDFs like this:
response.setHeader("Content-Type", "application/pdf "; name=" + file.getName());
response.setContentType("application/pdf");
response.setHeade... |
I have had the exact same problem about a year ago, and after much googling and research, my headers (from Java code) look for IE6 & PDFs like this:
response.setHeader("Content-Type", "application/pdf "; name=" + file.getName());
response.setContentType("application/pdf");
response.setHeade... |
I have had the exact same problem about a year ago, and after much googling and research, my headers (from Java code) look for IE6 & PDFs like this:
response.setHeader("Content-Type", "application/pdf "; name=" + file.getName());
response.setContentType("application/pdf");
response.setHeade... |
I'm not a totally expert in team system but I found the recent dotnetrocks show on team server to be really interesting:
[http://www.dotnetrocks.com/default.aspx?showNum=373][1]
I think it might hold some information that could be of use to you.
[1]: http://www.dotnetrocks.com/default.aspx?showNum=373 |
That depends at least in part on the programming language you intend to teach her. That said, you might want to take a look at [Eclipse][1]. Though it started primarily as a Java IDE, it's been extended via plugins to support many others (including C/C++, Flex, Haskell, and ColdFusion, to name a few), and can fairly ea... |
I'd recommend <a href="http://www.scintilla.org/SciTE.html">SciTE</a>, as it's both available for *nix and Windows and free (as in beer). It supports pretty much anything you'd expect from a decent editor and, if she goes on to use it, quite customizable. It also isn't too complex, so it should be easy for her to get g... |
There are definitely merits to both choices; however, since your domain is an educational experience I think a C/C++ solution would most benefit the students. Graphical programming will always be an option but simply does not provide the functionality in an elegant manner that would make it more efficient to use than ... |
I would chose YAML if the documents needed to be edited or created by humans. Just a thought. |
[**T**oolset for **Ora**cle (TOra)][1] is a free, Open Source Database Tool very similar in scope (and look and feel) to [Quest's TOAD][2]
Compared to the [freeware edition of TOAD][2], TOra allows multiple connections to different database instances at the same time, and has no concurrent connection limit (so any n... |
Try the following:
perl -ne 'print unless m{^//#}' input.txt > output.txt
If you are using windows you need double quotes instead of single quotes.
You can do the same with grep
grep -v -e '^//#' input.txt > output.txt |
If you really want to use a built-in function, perhaps for robustness, you can try date_default_timezone_set('UTC'); $date = strtotime($hms,0); and use any of the date formatting functions (date(), strftime(), etc) to format the time in any way you wish. Or you can use the output of strptime($hms,'%T'). Either may be o... |
scriptResourceHandler |
|asp.net|ajax|asp.net-ajax| |
Does anyone know much about the Asp.Net webconfig element [<scriptResourceHandler>][1]?
I'm looking at it because I'm implementing an MS Ajax updatepanel in an existing site,
and after doing some looking around, on the web I'm not finding a lot of info about it.
And to avoid the flood of replies telling me how i... |
Does anyone know much about the Asp.Net webconfig element [<scriptResourceHandler>][1]?
I'm looking at it because I'm implementing an MS Ajax updatepanel in an existing site,
and after doing some looking around, on the web I'm not finding a lot of info about it.
And to avoid the flood of replies telling me how i... |
Emacs, switch active window |
|emacs| |
In Emacs, "C-x o" takes me to the next window.
What keyboard macro takes me to the previous window in Emacs? |
Use the web application descriptor:
Paste this in to your web.xml:
<login-config>
<auth-method>BASIC</auth-method>
</login-config>
<security-role>
<role-name>MySiteRole</role-name>
</security-role>
<security-constraint>
<display-name>ProtectEverything</display-name>... |
I've done something similar in Python. Basically, you need lots of sample data from various encodings, which are broken down by a sliding two-byte window and stored in a dictionary (hash), keyed on byte-pairs providing values of lists of encodings.
Given that dictionary (hash), you take your input text and:
- i... |
> *You can't detect the codepage*
This is clearly false. Every web browser has some kind of universal charset detector to deal with pages which have no indication what so every of an encoding. Firefox has one. You can download the code and see how it does it. see some documentation [here][1]. basically it is a heuri... |
We use rs.exe, once we developed the script we have not needed to touch it anymore, it just works.
Here is the source (I slightly modified it by hand to remove sensitive data without a chance to test it, hope I did not brake anything), it deploys reports and associated images from subdirectories for various language... |
That'd be "C-- C-x o"
In other words, "C-x o" with an argument of -1. You can specify how many windows to move by inserting a numeric argument between C-u and the command, as in "C-u 2 C-x o". ("C--" is a shortcut for "C-u - 1") |
I have used DirectX, FMOD and Wwise on a range of platforms in shipped games. I won't talk about DirectX here since other people will have plenty of feedback here ;-)
Here's what you need to consider:
* License, I put this first because this may make your decision for you. Have your lawyer go over them and mak... |
+1 to the Notepad++ suggestion - Anything I do that's not .Net-related I do in that. |
Mixing jsp and jsf |
|jsp|jsf| |
I will elaborate somewhat. Jsf is kind-of extremely painful for working with from designer's perspective, somewhat in the range of trying to draw a picture while having hands tied at your back, but it is good for chewing up forms and listing lots of data. So sites we are making in my company are jsf admin pages and jsp... |
I will elaborate somewhat. Jsf is kind-of extremely painful for working with from designer's perspective, somewhat in the range of trying to draw a picture while having hands tied at your back, but it is good for chewing up forms and listing lots of data. So sites we are making in my company are jsf admin pages and jsp... |
|java|jsp|jsf| |
I will elaborate somewhat. Jsf is kind-of extremely painful for working with from designer's perspective, somewhat in the range of trying to draw a picture while having hands tied at your back, but it is good for chewing up forms and listing lots of data. So sites we are making in my company are jsf admin pages and jsp... |
I can't think of anything especially optimized.
You can do something like this, which shouldn't be too hard:
//c# -- assuming your strings are in a List<string> named Names
int shortestLength = Names[0].Length, j;
char[] CommonCharacters;
char single;
for (int i = 1; i < Names.Count; i++)
... |
`pushd` and `popd` almost always come in handy |
I'm pretty sure Java's regex engine is greedy by default, meaning that <code>"\w+ +\w+ \*\\(.\*\\) \*\\{"</code> will never match since the <code>.\*</code> within the parenthesis will eat everything after the opening paren. I recommend you replace the <code>.*</code> with [^)], this way you it will select all non-clo... |
I'm pretty sure Java's regex engine is greedy by default, meaning that <code>"\w+ +\w+ \*\\(.\*\\) \*\\{"</code> will never match since the <code>.\*</code> within the parenthesis will eat everything after the opening paren. I recommend you replace the <code>.*</code> with [^)], this way you it will select all non-clo... |
The C++ compiler creates symbol names differently than the C compiler. So, if you are trying to make a call to a function that resides in a C file, compiled as C code, you need to tell the C++ linker that the symbol names that it is trying to resolve look different than it expects. |
The C++ compiler creates symbol names differently than the C compiler. So, if you are trying to make a call to a function that resides in a C file, compiled as C code, you need to tell the C++ compiler that the symbol names that it is trying to resolve look different than it defaults to; otherwise the link step will f... |
How do you create a weak reference to an object in Python? |
|python| |
How do you create a weak reference to an object in Python? |
|python|weak-references| |
http://www.pythonchallenge.com/
highly addictive, and a great way to learn python |
I believe that a different compiler ships with each version of Visual Studio. For example in the case of C# the 2.0 compiler shipped with Visual Studio 2005 and the C# 3.0 shipped with Visual Studio 2008. Depending upon which version of Visual Studio you use you end up with a different compiler.
Targeting a framew... |
You should also check that your categories table has a primary key on the CategoryName field. You original configuration should have thrown an error or message saying the update would violate the key. As it is it seems you can have 2 categories with the same name. |
Arrays are also available in bash:
fruits=(apple orange kiwifruit)
for fruit in ${fruits[@]}; do
echo $fruit
done
This has the advantage of not depending on the current value of `IFS`, unlike many of the other answers I've seen here so far. |
Arrays are also available in bash:
fruits=(apple orange kiwifruit)
for fruit in "${fruits[@]}"; do
echo "$fruit"
done
This has the advantage of not depending on the current value of `IFS`, unlike many of the other answers I've seen here so far. |
Now that the answer I like has been accepted as the correct answer, I'll now move into another topic: how to use `IFS` for personal gain. :-P
fruits="apple,orange,kiwifruit,dried mango"
(IFS=,
for fruit in $fruits; do
echo "$fruit"
done)
I've put the code in brackets so that the `IF... |
This is a bit of a guess, but try
Windows => Preferences => JavaScript => Include Path |
In a later essay in The Mythical Man Month, Brooks warns that he's found that if you do indeed plan to throw 1 away, you'll end up throwing 2 away!
I personally saw this happen in real life; we assigned a version 1 of the project as a quick throw-away to a mediocre programmer, because "we plan to throw it away later... |
The best method would be to take the code the sqlite3 db dump would do, excluding schema parts.
Example pseudo code:
SELECT 'INSERT INTO ' || tableName || ' VALUES( ' ||
{for each value} ' quote(' || value || ')' (+ commas until final)
|| ')' FROM 'tableName' ORDER BY rowid DESC
See: `src/... |
If you're interested in performance, I recommend that you write a test that measures performance.
Check the current time, run the method you're concerned about, then check the time again. Assert that the total time taken is less than some value.
The problem with check that methods are called in a certain order i... |
Are the cards exactly the same (both GeForce 8400GS), and only the memory size differ? Quite often with different memory sizes come slightly different clock rates (i.e. your card with more memory might use slower memory!).
So the first thing to check would be GPU core & memory clock rates, using something like [GPU-... |
I use them for searching for my stack (C#, ASP.NET, WinForms etc). I have them set up in Launchy as shortcuts.
I have posted some thoughts ideas on my [StackOverflow blog post][1] - feel free to comment on there if you like:
> **Search Support**
>
> The search functionality is improving.
> However, is it stil... |
You wouldn't use SOAP web services but rather 'native' REST web services, which are native in Rails. The book quoted by DEFusion above is actually about that: how to use a FLEX client as the front-end of a Rails application using REST (meaning XML).
The AMF protocol has primarily been built by Adobe as a binary prot... |
You wouldn't use SOAP web services but rather 'native' REST web services, which are native in Rails. The book quoted by DEFusion above is actually about that: how to use a FLEX client as the front-end of a Rails application using REST (meaning XML).
The AMF protocol has primarily been built by Adobe as a binary prot... |
Show the interface to a sample of users. Ask them to perform a typical task. Watch for their mistakes. Listen to their comments. Make changes and repeat. |
Thanks to Cameron's suggestion, I've found the correct syntax, which is:
Item[]
Which updates everything (all index values) bound to that indexed property. |
Only one answer, Wordpress. I have used it only a few times to customise but simply found that it can be done by editing the header and footer files along with the stylesheet.
What can be simpler.
I suggest you just give it a go before you look at others as you could deliberate for ages just to come back to it :... |
Prepared statements and parameter binding is always a good way to go.
PEAR::MDB2 supports prepared statements, for example:
$db = MDB2::factory( $dsn );
$types = array( 'integer', 'text' );
$sth = $db->prepare( "INSERT INTO table (ID,Text) (?,?)", $types );
if( PEAR::isError( $sth ) ) die... |
There is a partial function OnCreated, which can be used to initialise items:
partial void OnCreated()
{
Name = "";
}
This function will be called after a new item is constructed - maybe this is what you are looking for? |
The default constructor which is generated by the O/R-Designer, calls a partial function called OnCreate - so the best practise is not to override the default constructor, but instead implement the partial function OnCreated in MyDataClasses.cs to initialise items:
partial void OnCreated()
{
Name = "... |
The default constructor which is generated by the O/R-Designer, calls a partial function called OnCreate - so the best practice is not to override the default constructor, but instead implement the partial function OnCreated in MyDataClasses.cs to initialize items:
partial void OnCreated()
{
Name = "... |
See http://richnewman.wordpress.com/2007/04/15/a-beginner’s-guide-to-calling-a-net-library-from-excel/
or better still try out ExcelDNA ( http://groups.google.com/group/ExcelDna )
|
We've used merb_facebooker in one of our projects ([Rock the Vote][1]), and it worked out pretty well. Testing Facebook apps is quite annoying, as you don't have control of the middleware, so watch out for your expectations of the FB API and make sure you validate as much of them as possible early in the development st... |
I will elaborate somewhat. Jsf is kind-of extremely painful for working with from designer's perspective, somewhat in the range of trying to draw a picture while having hands tied at your back, but it is good for chewing up forms and listing lots of data. So sites we are making in my company are jsf admin pages and jsp... |
I would thoroughly recommend [Java Concurrency in Practice][1] by Brian Goetz, Tim Peierls, Joshua Bloch, and Joseph Bowbeer. It focusses solely on good concurrency coding, but includes excellent guidance on the new concurrency features in the Java 5 and 6 libraries.
Of course, it is no help at all on the other feat... |
I would thoroughly recommend [Java Concurrency in Practice][1] by Brian Goetz, Tim Peierls, Joshua Bloch, and Joseph Bowbeer. It focusses solely on good concurrency coding, but includes excellent guidance on the new concurrency features in the Java 5 and 6 libraries.
Of course, it is no help at all on the other feat... |
Delete all but the 4 newest directories |
|bash|shell| |
How would you do this in bash |
You want to do the [semantic analysis][1] of a text.
Word frequency analysis is one of the easiest ways to do the semantic analysis. Unfortunately (and obviously) it is the least accurate one. It can be improved by using special dictionaries (like for synonims or forms of a word), "stop-lists" with common words, oth... |
Before:
// Init Movie
m_ImageArray = new Image[K_NB_IMAGE];
Stream l_ImageStream = null;
Bitmap l_Bitmap = null;
// get a reference to the current assembly
Assembly l_Assembly = Assembly.GetExecutingAssembly();
// get a list of resource names from the manifest
... |
-D stands for _define_ (in gcc) at least, which lets you #define on the command line instead of a file somewhere. A common thing to see would be -DDEBUG or -DNDEBUG which respectively activate or disable debugging code. |
Mongrel hangs with 100% CPU / EBADF (Bad file descriptor) |
|ruby|rubyonrails|mongrel|rmagick| |
We have a server with 10 running mongrel_cluster instances with apache
in front of them, and every now and then one or some of them hang.
No activity is seen in the database (we're using activerecord sessions).
Mysql with innodb tables. show innodb status shows no locks. show
processlist shows nothing.
The serve... |
|ruby|ruby-on-rails|mongrel|rmagick| |
We have a server with 10 running mongrel_cluster instances with apache
in front of them, and every now and then one or some of them hang.
No activity is seen in the database (we're using activerecord sessions).
Mysql with innodb tables. show innodb status shows no locks. show
processlist shows nothing.
The serve... |
Iterate over each line in the file, and skip the line if it matches the pattern:
<pre>
my $fh = new FileHandle 'filename'
or die "Failed to open file - $!";
while (my $line = $fh->getline) {
next if $line =~ m{^//#};
print $line;
}
close $fh;
</pre>
This will print all lines from the file, e... |
The -D option set pre-processor variables, so in your case, all code that is in the specified "#ifdef / #endif" blocks will be compiled.
I.e.
#ifdef PACKET_LINK
/* whatever code here */
#endif
The CFLAGS is a variable used in the makefile which will be expanded to it's contents when the compiler ... |
You could sort the column into descending format and then just obtain the value from the nth row. |
Trying to get the size of a bitfield isn't legal, as you have seen. (<code>sizeof</code> returns the size in bytes, which wouldn't make much sense for a bitfield.)
<code>sizeof(f.x = 1)</code> will return the size of the type of the expression. Since C doesn't have a real "bitfield type", the expression (here: an as... |