instruction stringlengths 0 30k ⌀ |
|---|
I'm looking for an LDAP libracy in C or C++ that allows me to specify a list of LDAP hostnames instead of a single hostname. The library should then use the first one it can connect to in case one or more of the servers is/are down. I'm sure it'd be easy to wrap an existing library to create this, but why reinvent the ... |
For C++, there's [Boost.Date_Time][1].
[1]: http://www.boost.org/doc/libs/1_36_0/doc/html/date_time.html |
Falling through `switch`-`case`s can be achieved by having no code in a `case` (see `case 0`), or using the special `goto case` (see `case 1`) or `goto default` (see `case 2`) forms:
switch (/*...*/) {
case 0: // shares the exact same code as case 1
case 1:
// do something
... |
How can I know why one of my vxWorks task is pended? |
|vxworks| |
In vxWorks, I can issue the "i" command in the shell, and I get the list of tasks in my system along with some information like the following example:
<pre>
NAME ENTRY TID PRI STATUS PC SP ERRNO DELAY
---------- ------------ -------- --- ---------- -------- -------- ------- ----... |
In bash this is easy, just tie them together with &&:
command1 && command2 && command3
You can also use the nested if construct:
if command1
then
if command2
then
do_something
else
exit
fi
el... |
What style do you use for creating an "class" in JavaScript? |
|javascript| |
I'm curious as to whether people prefer to use prototype based "class" methods, or whether they use closures, eg.
function Vector(x, y, x) {
this.x = x;
this.y = y;
this.z = z;
return this;
}
Vector.prototype.length = function () { return Math.sqrt(this.x * this.x ... |
What style do you use for creating an "class" in JavaScript? |
There are a few ways to get class-like behaviour in javascript, the most common seem to be prototype based like this:
function Vector(x, y, x) {
this.x = x;
this.y = y;
this.z = z;
return this;
}
Vector.prototype.length = function () { return Math.sqrt(this.x * thi... |
It may help to double-check the timezone rules your OS is using.
/usr/bin/zdump -v /etc/localtime | less
This file should contain your daylight savings rules, like this one for the year 2080:
/etc/localtime Sun Mar 31 01:00:00 2080 UTC = Sun Mar 31 02:00:00 2080 BST isdst=1 gmtoff=3600
You can comp... |
The result of a DCT is a transformation of the original source into the frequency domain. The top left entry stores the "amplitude" the "base" frequency and frequency increases both along the horizontal and vertical axes. The outcome of the DCT is usually a collection of amplitudes at the more usual lower frequencies (... |
Both cases will execute the function, the only real difference is what the return value of the expression may be, and what the value of "this" will be inside the function.
Basically behaviour of
new expression
Is effectively equivalent to
var tempObject = {};
var result = expression.call(tempOb... |
You should look into using the MAC address on the network card (if it exists). Those are guaranteed to be unique. |
You should look into using the MAC address on the network card (if it exists). Those are usually unique but can be fabricated. I've used software that generates its license file based on your network adapter MAC address, so it's considered a fairly reliable way to distinguish between computers. |
When you use a dynamic text field, you have two options - either you embed (part of) the font into your SWF, or you use device fonts. If you embed, then the actual character shapes will be built into your SWF; if you don't, then you're including only the font's *name* - and if the OS doesn't have any fonts of that name... |
I like the Modified Preorder Tree Traversal Algorithm:
[http://dev.mysql.com/tech-resources/articles/hierarchical-data.html][1]
[1]: http://dev.mysql.com/tech-resources/articles/hierarchical-data.html
This technique makes it very easy to query the tree. |
What you probably want is a hex editor. The [PSPad](http://www.pspad.com/) text editor has a pretty good hex-editing mode. |
If you've set:
config.time_zone = 'UTC'
In your environment.rb (it's there by default), then times will automagically get converted into UTC when ActiveRecord stores them.
Then if you set Time.zone (in a before_filter on application.rb is the usual place) to the user's Time Zone, all the times will be auto... |
I use frhed and vim (with its convert to hex mode but that can be slow for big files). |
Do you mean something that detects a set of known fileformats and knows how to display them? Otherwise, hex editor (for example [PSPad][1] contains one) is the best thing that you can wish for. It's just bits which can mean anything.
[1]: http://www.pspad.com/ |
I use [HHD's free HexEditor][1], it's Free!
[1]: http://www.hhdsoftware.com/Family/hex-editor.html |
In 2008 I don't bother with Encapsulate Field. I use the new syntax for properties:
public string SomeString { get; set; }
|
How do I enumerate the properties of a javascript object? |
|javascript|properties| |
I actually want to list all the defined variables and their values, but I've learned that defining a variable actually creates a property of the window object. |
I need an algorithm for rendering soft paint brush strokes. |
|algorithm|lines|paint|soft|brush| |
I have an array of mouse points, a stroke width, and a softness. I can draw soft circles and soft lines. Which algorithm should I use for drawing my array of points? I want crossed lines to look nice as well as end points. |
Printing members of an array in PHP is a little tricky, especially when you're using a variable (as opposed to a literal) as your key. Instead of:
echo "$_GET[$field]";
try:
echo "${_GET[$field]}";
The other possibility is a malformed query; it would help if you posted the query string you're testin... |
EDIT: When I completed your test, here was the final URL:
http://hofstrateach.org/Roberto/process.php?keys=Grade1&keys=Nathan&keys=North%20America&keys=5&keys=3&keys=no&keys=foo&keys=blat&keys=0%3A0%3A24
This is probably a malformed URL. When you pass duplicate keys in a query, PHP makes them an array. The above ... |
EDIT: When I completed your test, here was the final URL:
http://hofstrateach.org/Roberto/process.php?keys=Grade1&keys=Nathan&keys=North%20America&keys=5&keys=3&keys=no&keys=foo&keys=blat&keys=0%3A0%3A24
This is probably a malformed URL. When you pass duplicate keys in a query, PHP makes them an array. The above ... |
How do you keep a personal wiki (TiddlyWiki) current and in sync in multiple locations? |
|project-management|wiki|development-environment|notetaking| |
If one were to use TiddlyWiki as a personal database for notes and code snippets, how would you go about keeping it in sync between multiple machines. Would a svn/cvs etc work. How would you handle merges? |
How do I create a folder in VB if it doesn't exist? |
Use jQuery to select the UL, clone it, and insert it after the previous UL. Something like:
$("ul#listname").clone().attr("id","listname2").after()
This would insert a copy of your list after the previous one. If the original list is styled with a float:left, they should appear side by side.
Then you can delete ... |
I've done this with jQuery - it's cross-platform and a minimum of code.
Select the UL, clone it, and insert it after the previous UL. Something like:
$("ul#listname").clone().attr("id","listname2").after()
This will insert a copy of your list after the previous one. If the original list is styled with a float:le... |
I've done this with jQuery - it's cross-platform and a minimum of code.
Select the UL, clone it, and insert it after the previous UL. Something like:
$("ul#listname").clone().attr("id","listname2").after()
This will insert a copy of your list after the previous one. If the original list is styled with a fl... |
I've done this with jQuery - it's cross-platform and a minimum of code.
Select the UL, clone it, and insert it after the previous UL. Something like:
$("ul#listname").clone().attr("id","listname2").after()
This will insert a copy of your list after the previous one. If the original list is styled with a fl... |
Variables not declared with var are global in scope.
Functions introduce a scope, but note that if blocks and other blocks do not introduce a scope.
I could also see much information about this by Googling Javascript scope. That's really what I would recommend.
http://www.digital-web.com/articles/scope_in_javascr... |
Try [HxD][1]:
> HxD is a carefully designed and fast
> hex editor which, additionally to raw
> disk editing and modifying of main
> memory (RAM), handles files of any
> size.
>
> The easy to use interface offers
> features such as searching and
> replacing, exporting,
> checksums/digests, insertion of byte... |
lex/flex and yacc/bison provide easy-to-use, well-understood lexer- and parser-generators, and I'd really recommend doing something like that as opposed to doing it procedurally in e.g. Perl. Regular expressions are powerful stuff for ripping apart strings with relatively-, but not totally-fixed structure. With any r... |
What tools do you use for Automated Builds / Automated Deployments? Why? |
|automation|automated-build|automated-deploy| |
What tools do you use for Automated Builds / Automated Deployments? Why?
What tools do you recommend? |
What tools do you use for Automated Builds / Automated Deployments? Why?
What tools do you recommend?
**EDIT:** By tools I mean scripting languages and the applications.
For instance, we use CC.NET and MSBuild where I work. I am starting to prefer Nant for build/deploy scripts. I also want to take a look at Cr... |
|build-automation|deployment|discussion| |
What tools do you use for Automated Builds / Automated Deployments? Why?
What tools do you recommend? |
How do you mock params when testing a Rails model's setter? |
|ruby-on-rails|unit-testing|testing|testing-strategies| |
Given the code from the [Complex Form part III][1] how would you go about testing the virtual attribute?
def new_task_attributes=(task_attributes)
task_attributes.each do |attributes|
tasks.build(attributes)
end
end
I am currently trying to test it like this:
d... |
According to [Effective Java][1], chapter 4, page 73, 2nd edition:
"There are many good reasons for this: Immutable classes are easier to design, implement, and use than mutable classes. They are less prone to error and are more secure.
[...]
"**Immutable objects are simple.** An immutable object can be in exa... |
It turns out that I was missing two things:
- My custom content type neeeded to be
added to the workflow task list
- I needed to add an empty FieldRefs element to my content type definition; without it, the content type wasn't inheriting any workflow task fields. |
How to design a rule engine? |
|rule-engine|c#|sql-server| |
I'm supposed to create a rule engine in C#. Any leads on how I can proceed?. It's a minimalistic rule engine, and would use SQL server as the back end. Do we have any general blueprint or design patterns that generally apply to rule engines? Any directions would be helpful.
Thanks. |
|c#|sql-server|rule-engine| |
I'm supposed to create a simple rule engine in C#. Any leads on how I can proceed?. It's a minimalistic rule engine, and would use SQL server as the back end. Do we have any general blueprint or design patterns that generally apply to rule engines? What kind of .Net technologies can I use to design one? Any directions ... |
Optimizing for low bandwidth |
|optimization|networking|web-applications| |
I am charged with designing a web application that displays very large geographical data. And one of the requirements is that it should be optimized so the PC still on dial-ups common in the suburbs of my country could use it as well.
Now I am permitted to use Flash and/or Silverlight if that will help with the limi... |
SQL Server 2k5 memory consumption? |
|sql-server|performance| |
I have a development vm which is running sql server as well as some other apps for my stack, and I found that the other apps are performing awfully. after doing some digging, SQL Server was hogging the memory. After quick web search I discovered that by default, it will consume as much memory as it can in order to ca... |
I have a development vm which is running sql server as well as some other apps for my stack, and I found that the other apps are performing awfully. After doing some digging, SQL Server was hogging the memory. After a quick web search I discovered that by default, it will consume as much memory as it can in order to ... |
I have a development vm which is running sql server as well as some other apps for my stack, and I found that the other apps are performing awfully. After doing some digging, SQL Server was hogging the memory. After a quick web search I discovered that by default, it will consume as much memory as it can in order to ... |
|deployment|discussion|build-automation| |
Are these sites trustworthy enough? After all they have **your** intellectual property on file. You don't want them to use it themselves or give it to your competitors. |
I would feel comfortable targeting HTML4 and CSS2, with the basic content structured with screenreaders in mind as a baseline experience for most websites. The key is to keep in mind a layout that is functional for text-based browsers and screenreaders and use that as the basis for the enhanced page. |
So "Progressive Enhancement" is just another term for "Graceful Degradation"?
In which case, it's the way all websites <em>should</em> be done.
Web Apps should be built in HTML (4 or later), semantically and against the standards.
All CSS should be optional - content & forms should work without it, but look ... |
If you are using [Selenium IDE][1] to generates code, then you just get a list of every action that selenium will executes. To me, Selenium IDE is a good way to start or do a fast "try and see" test. But, when you think about maintainability and more readable code, you must write your own code.
A good way to achieve... |
Both cases will execute the function, the only real difference is what the return value of the expression may be, and what the value of "this" will be inside the function.
Basically behaviour of
new expression
Is effectively equivalent to
var tempObject = {};
var result = expression.call(tempOb... |
How do I add SSL to a .net application that uses httplistener - it will *not* be running on IIS |
|ssl|authentication|encryption|.net| |
I am using the .net HttpListener class, but I'm won't be running on IIS and am not using ASP.net. This [web site][1] describes what code to actual use to implement SSL with asp.net and [this site][2] describes how to set up the certificates (although I'm not sure if it works only for IIS or not).
When I the class... |
|.net|authentication|encryption|ssl| |
**Original Question**
I am using the .net HttpListener class, but I'm won't be running on IIS and am not using ASP.net. This [web site][1] describes what code to actual use to implement SSL with asp.net and [this site][2] describes how to set up the certificates (although I'm not sure if it works only for IIS or not)... |
Try [xlsgen][1], supports Java (but can only run under Windows).
[1]: http://xlsgen.arstdesign.com/ |
I've never come across another way of doing it other than outputFormat. It is unfortunately quite verbose.
The only other thing I can suggest is creating the message in a backing bean and then outputting that rather than messageFormat.
In my case I have Spring's MessageSource integrated with JSF (using [MessageSo... |
In SQL Server 2008, they finally got around to addressing this classic problem by adding a new "table" datatype. Apparently, that lets you pass in an array of values, which can be used in a sub-select to accomplish the same as an IN statement.
If you're using SQL Server 2008, then you might look into that. |
Since you are using images anyway, why not generate an image representing the whole layout on the fly? You can use something like [GD][1] or [ImageMagick][2] to do the trick.
[1]: http://www.boutell.com/gd/
[2]: http://www.imagemagick.org/script/index.php |
Thread safety and performance. If a string cannot be modified it is safe and quick to pass a reference around among multiple threads. If strings were mutable, you would always have to copy all of the bytes of the string to a new instance, or provide synchronization. A typical application will read a string 100 times fo... |
Thread safety and performance. If a string cannot be modified it is safe and quick to pass a reference around among multiple threads. If strings were mutable, you would always have to copy all of the bytes of the string to a new instance, or provide synchronization. A typical application will read a string 100 times fo... |
Immutability is good. See Effective Java. If you had to copy a String every time you passed it around, then that would be a lot of error-prone code. You also have confusion as to which modifications affect which references. In the same way that Integer has to be immutable to behave like int, Strings have to behave as i... |
Debugging Eclipse Application Problem: Launches repeatedly |
|eclipse|debugging| |
I'm having a problem debugging an Eclipse Application from Eclipse. When I launch the Debug Configuration, the Eclipse Application starts up and then stops repeatedly. It shows the splash screen and then disappears. This is the farthest it gets before restarting:
MyDebugConfiguration [Eclipse Application]
... |
Having been a longtime classic asp programmer, and now an ASP.NET dev, I would take the time and architect it properly in the 2.0 framework (3.5 if you want/need the features).
My last job we had a large handful of very badly build classic asp apps that we were rebuilding, and the "nuke and pave" approach was the mo... |
These are my favorite shortcuts:
apple+t: Start typing name of a file to open it
ctrl+w: Select word
apple+r: Run the ruby or php-script that is open
apple+alt+m: Define a new macro
apple+shift+m: Run the macro
click the alt-button: Switch to vertical selection mode
apple+alt+a: Edi... |
Any formatting of this type is fine. People will argue with you black and blue over this because it is something easy to understand. People like to talk about things they understand instead of dealing with bigger problems such as good design and solving hard problems with new algorithms. I tend to prefer no brackets fo... |
The [pickle](http://docs.python.org/lib/module-pickle.html) module is pretty awesome |
From ["Virtual Functions in C++"][1]
------------------------------------
Whenever a program has a virtual function declared, a v - table is constructed for the class. The v-table consists of addresses to the virtual functions for classes that contain one or more virtual functions. The object of the class containin... |
How are virtual functions implemented at a deep level?
----------------------------------------
From ["Virtual Functions in C++"][1]
Whenever a program has a virtual function declared, a v - table is constructed for the class. The v-table consists of addresses to the virtual functions for classes that contain on... |
How are virtual functions implemented at a deep level?
----------------------------------------
From ["Virtual Functions in C++"][1]
Whenever a program has a virtual function declared, a v - table is constructed for the class. The v-table consists of addresses to the virtual functions for classes that contain on... |
How are virtual functions implemented at a deep level?
----------------------------------------
From ["Virtual Functions in C++"][1]
Whenever a program has a virtual function declared, a v - table is constructed for the class. The v-table consists of addresses to the virtual functions for classes that contain on... |
How are virtual functions implemented at a deep level?
----------------------------------------
From ["Virtual Functions in C++"][1]
Whenever a program has a virtual function declared, a v - table is constructed for the class. The v-table consists of addresses to the virtual functions for classes that contain on... |
How are virtual functions implemented at a deep level?
----------------------------------------
From ["Virtual Functions in C++"][1]
Whenever a program has a virtual function declared, a v - table is constructed for the class. The v-table consists of addresses to the virtual functions for classes that contain on... |