instruction stringlengths 0 30k ⌀ |
|---|
I guess you can trying selling the idea of O/R mapping and mapper tools. The benefit of treating rows as objects is pretty powerful. |
I've seen a setup going through [Invision Power Board](http://www.invisionpower.com/community/board/), using [IpbWiki](http://www.ipbwiki.com/) and a Wordpress integration mod. Mind you, it's expensive and excessive. |
For the C-runtime go to the project settings, choose C/C++ then 'Code Generation'. Change the 'runtime library' setting to 'multithreaded' instead of 'multithreaded dll'.
If you are using any other libraries you may need to tell the linker to ignore the dynamically linked CRT explicitly. |
> <i>Remember to consider the possibility that they're onto something you've missed. Being part of a team means taking turns learning & teaching.</i>
Seconded. The whole idea that "enterprise development" is somehow distinct from (and usually the implication is 'more important than') normal development really irks me.
If there really is a benefit for using some technology, then you'll need to come up with a considered list of all the pros and cons that would occur if you switched.
Present this list to your co workers along with explanations and examples for each one.
You have to be realistic when creating this list. You can't just say "Saves us lots of time!!! WIN!!" without addressing the fact that sometimes it is going to take MORE time, will require X months to come up to speed on the new tech, etc. You have to show concrete examples where it will save time, and exactly how.
Likewise you can't just skirt over the cons as if they don't matter, your co-workers *will* call you on it.
If you don't do these things, or come across as just pushing what you personally like, nobody is going to take you seriously, and you'll just get a reputation for being the guy who's full of enthusiasm and energy but has no idea about anything.
BTW. Look out for this particular con. It will trump everything, unless you have a *lot* of strong cases for all your other stuff:
* Requires 12+ months work porting our existing code. You lose. |
I've had this same dependency problem and I also know that you can include the VS 8.0 DLLs (release only! not debug!---and your program has to be release, too) in a folder of the appropriate name, in the parent folder with your .exe:
<a href="http://msdn.microsoft.com/en-us/library/ms235291%28VS.80%29.aspx">How to: Deploy using XCopy (MSDN)</a>
With a different toolset (VC++ 6.0) it does work, since Windows 2000 and above have the correct DLLs installed.
Also note that things are guaranteed to go awry if you need to have C++ and C code in the same statically linked .exe because you will get linker conflicts that can only be resolved by ignoring the correct libXXX.lib and then linking dynamically (DLLs). |
I've had this same dependency problem and I also know that you can include the VS 8.0 DLLs (release only! not debug!---and your program has to be release, too) in a folder of the appropriate name, in the parent folder with your .exe:
<a href="http://msdn.microsoft.com/en-us/library/ms235291%28VS.80%29.aspx">How to: Deploy using XCopy (MSDN)</a>
Also note that things are guaranteed to go awry if you need to have C++ and C code in the same statically linked .exe because you will get linker conflicts that can only be resolved by ignoring the correct libXXX.lib and then linking dynamically (DLLs).
Lastly, with a different toolset (VC++ 6.0) things "just work", since Windows 2000 and above have the correct DLLs installed.
|
So if you have two arrays and they hold the same data just in different order then just do this:
A = B
I suspect that is not your situation so I think we need more info. |
In addition to the other answers, there's a nice powertoy for XP called "open command window here." It adds an option to your right-click context menu when you click inside a folder to open a command window using that directory as the starting path.
http://www.microsoft.com/windowsxp/Downloads/powertoys/Xppowertoys.mspx
|
<html>
<head>
<title>Font Detect please</title>
<script src="prototype.js" type="text/javascript"></script>
<script type="text/javascript">
$('Myanmar3').update('False');
$('Myanmar3').innerHTML;
</script>
</head>
<body>
<table border="1">
<tr><td>Font</td><td>Installed</td></tr>
<tr><td>Myanmar3</td><td id=Myanmar3>True</td></tr>
</table>
</body>
</html>
I have a simple code like that above and am trying to change the result True to false via Javascript using Prototype. What might I be doing wrong? |
<html>
<head>
<title>Font Detect please</title>
<script src="prototype.js" type="text/javascript"></script>
<script type="text/javascript">
$('Myanmar3').update('False');
$('Myanmar3').innerHTML;
</script>
</head>
<body>
<table border="1">
<tr><td>Font</td><td>Installed</td></tr>
<tr><td>Myanmar3</td><td id=Myanmar3>True</td></tr>
</table>
</body>
</html>
I have a simple code like that above and am trying to change the result True to false via Javascript using Prototype. What might I be doing wrong?
Edit: Got it. I didn't call it. :D |
I've found [UI Patterns][1] to be a useful reference for this sort of thing. It's arranged much like the classic GoF Design Patterns book, with each pattern description containing:
- The problem the pattern solves
- An example of the pattern in action
- Sample use cases for the pattern
- The solution to implement the pattern
- Rationale for the solution
[1]: http://ui-patterns.com/ |
"undefined handler" from prototype.js line 3877 |
|javascript|prototype|googlemaps|prototypejs| |
A very niche problem:
I sometimes (30% of the time) get an 'undefined handler' javascript error on line 3877 of the prototype.js library (version 1.6.0.2 from google: http://ajax.googleapis.com/ajax/libs/prototype/1.6.0.2/prototype.js).
Now on this page I have a Google Map and I use the Prototype Window library.
The problem occurs in IE7 and FF3.
This is the info FireBug gives:<br />
handler is undefined<br />
? in prototype.js@3871()prototype.js (line 3877)<br />
handler.call(element, event);<br />
I switched to a local version of prototypejs and added some debugging in the offending method (createWraper) but the debugging never appears before the error...
I googled around and found 1 other mention of the error on the same line, but no answer so I'm posting it here where maybe, some day someone will have an answer :). |
What is the best way to setup memcached on CentOS to work with Apache and PHP |
|php|linux|memcached| |
What is the simplest way to install memcached on CentOS for someone new to the world of Linux? What is the best way to enable it for Apache and PHP |
I've been doing a lot of work with this recently. I'm finding SQL2008's new features really make this easy. I can find all the points that are withing Xkm of a 100k record table in sub-second time...not too shabby.
The great circle (spherical assumption) method in my testing was about 2.5 miles off when compared to the vincenty formula (elipsoidal assumption, which is what the earth is).
The real trick is getting the lat and long..for that I'm using Google. |
You can't have two processes bound to the same port on the same IP address. You can add another IP address to the box and have each server listen on one.
Another option is to proxy pass one server to the other. With Apache, you could do something like:
NameVirtualHost *
<virtualhost *>
ServerName other.site.com
# assumes CherryPy listens on port 8080
ProxyPass / http://127.0.0.1:8080/
ProxyPassReverse / http://127.0.0.1:8080/
</Virtualhost>
That's a pretty quick example, but you can always check the [ProxyPass documentation][1]. Remember though, the application being proxyed to will get 127.0.0.1 in it's logs instead of the requester's IP address. Some web servers (apache does with [mod_rpaf][3]) can substitute the X-Forwarded-For header in place of the wrong IP address. Possibly CherryPy has this?
[1]: http://httpd.apache.org/docs/2.2/mod/mod_proxy.html
[3]: http://stderr.net/apache/rpaf/ |
TinyMCE only goes out of its way to disable spell-checking when you don't specify the `gecko_spellcheck` option (i verified this with their example code). Might want to double-check your `tinyMCE.init()` call - it should look something like this:
tinyMCE.init({
mode : "textareas",
theme : "simple",
gecko_spellcheck : true
});
|
Include a method:
void text(n){
builder.yield n
}
Most likely you (I) copied this code from somewhere that had a text method, but you didn't also copy the text method. Since MarkupBuilder accepts any name for the name of a tag and browsers ignore unknown markup, it just happened to work. |
Just an idea of something to try to see if it gives you more info: Try resizes the list object before the exception line and see if that also throws an exception. If not, try and resize the range object to the new size of the DataTable.
You say that this happens when the ListObject shrinks and grows. Does it also happen if the ListObject remains the same size? |
> With a foreach loop, a copy of the original array is made in memory to use inside.
> Foreach is nice, but has one important caveat: you can't modify the enumerable you're iterating.
Both of those won't be a problem if you pass by reference instead of value:
foreach ($array as &$value) {
I think this has been allowed since PHP 5. |
I'm having the exact same issue, and from the JetBrains site, it looks like they sort-of know about it but aren't admitting anything. Turning off solution-wide analysis does seem to help quite a bit. |
I've tried to write a string replace function in C, which works on a char * which has been allocated using malloc(). It's a little different in that it will find and replace strings, rather than characters in the starting string.
It's trivial to do if the search and replace strings are the same length (or the replace string is shorter than the search string), since I have enough space allocated. If I try to use realloc(), I get an error that tells me I am doing a double free - which I don't see how I am, since I am only using realloc().
Perhaps a little code will help:
void strrep(char *input, char *search, char *replace) {
int searchLen = strlen(search);
int replaceLen = strlen(replace);
int delta = replaceLen - searchLen;
char *find = input;
while (find = strstr(find, search)) {
if (delta > 0) {
realloc(input, strlen(input) + delta);
find = strstr(input, search);
}
memmove(find + replaceLen, find + searchLen, strlen(input) - (find - input));
memmove(find, replace, replaceLen);
}
}
The program works, until I try to realloc() in an instance where the replaced string will be longer than the initial string. (It still kind of works, it just spits out errors as well as the result).
If it helps, the calling code looks liks:
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
void strrep(char *input, char *search, char *replace);
int main(void) {
char *input = malloc(81);
while ((fgets(input, 81, stdin)) != NULL) {
strrep(input, "Noel", "Christmas");
}
}
[Edit: I'm not seeing any HTML-escaped chars.] |
I am currently "manually" doing it through a prebuild-exec Task, using my [cmdnetsvnrev][1] tool, but if someone knows a better ccnet-integrated way of doing it, i'd be happy to hear :-)
[1]: http://www.stum.de/various-tools/cmdtools/ |
This seems to work;
char *strrep(char *string, const char *search, const char *replace) {
char *p = strstr(string, search);
if (p) {
int occurrence = p - string;
int stringlength = strlen(string);
int searchlength = strlen(search);
int replacelength = strlen(replace);
if (replacelength > searchlength) {
string = (char *) realloc(string, strlen(string) + replacelength -
searchlength + 1);
}
if (replacelength != searchlength) {
memmove(string + occurrence + replacelength, string + occurrence +
searchlength, stringlength - occurrence - searchlength + 1);
}
strncpy(string + occurrence, replace, replacelength);
}
return string;
} |
This seems to work;
char *strrep(char *string, const char *search, const char *replace) {
char *p = strstr(string, search);
if (p) {
int occurrence = p - string;
int stringlength = strlen(string);
int searchlength = strlen(search);
int replacelength = strlen(replace);
if (replacelength > searchlength) {
string = (char *) realloc(string, strlen(string)
+ replacelength - searchlength + 1);
}
if (replacelength != searchlength) {
memmove(string + occurrence + replacelength,
string + occurrence + searchlength,
stringlength - occurrence - searchlength + 1);
}
strncpy(string + occurrence, replace, replacelength);
}
return string;
}
Sigh, is there anyway to post code without it sucking? |
|javascript|prototype|google-maps| |
Database Patterns |
|design-patterns|database-design| |
Does anyone know of papers/books/etc. that document patterns for databases? For example, one common rule of thumb is that every table should have a primary key and that the key should be [devoid of information content][1]. So I was wondering if anyone had written a book or published papers regarding design patterns for designing relational databases?
[1]: http://en.wikipedia.org/wiki/Surrogate_key |
In the example you gave (an array of numbers), there would be no point in re-ordering A, since you could just use B.
So, presumably these are arrays of objects which you want ordered by one of their properties.
Then, you will need a way to look up items in A based on the property in question (like a hashtable). Then you can iterate B (which is in the desired sequence), and operate on the corresponding element in A. |
Both array's contain the same values (or nearly so) but I need to force them to be in the same order. For example, in array A the value "3045" is in index position 4 and in array B it is in index position 1. I want to reorder B so that the index positions of like values are the same as A. |
Program for working with large CSV Files |
|data|csv| |
Are there any good programs for dealing with reading large CSV files? Some of the datafiles I deal with are in the 1 GB range. They have too many lines for Excel to even deal with. Using Access can be a little slow, as you have to actually import them into a database to work with them directly. Is there a program that can open large CSV files and give you a simple spreadsheet layout to help you easily and quickly scan through the data? |
Differences in string compare methods in C# |
|c#|string|comparison| |
Comparing string in C# is pretty simple. In fact there are several ways to do it. I have listed some in the block below. What I am curious about are the differences between them and when one should be used over the others? Should one be avoided at all costs? Are there more I haven't listed?
string testString = "Test";
string anotherString = "Another";
if (testString.CompareTo(anotherString) == 0) {}
if (testString.Equals(anotherString)) {}
if (testString == anotherStirng) {}
(Note: I am looking for equality in this example, not less than or greater than but feel free to comment on that as well)
|
As someone who is in the middle of switching between CVS and SVN (initially we switched all of our projects with cvs2svn and then decided that we would transition by only using svn on new projects), here are some of the problems we have had.
- Merging and branching are very different, and if you branch and merge frequently, unless you have SVN 1.5 running on your server have to know when you branched (this isn't very clear in the Tortoise SVN dialogs). Michael says the branching and merging is intuitive, I would argue that after using CVS for 10 years, it is not.
- If your are running the SVN server on Linux, it may be hard to get your SA to move to svn 1.5, as the default install 1.4.x.
- Merging conflicts is not nearly as easy or as clear (at least to me and my co-workers) in TortoiseSVN as it is in TortoiseCVS. The three pane approach takes some getting used to and the WinMerge (my preferred merge tool) doesn't do a three pane merge.
- Beware: many of the online tutorials and magazine articles I have read obviously don't branch and merge, you should set up your main repository as https://svn.yoursvnserver.com/repos/YourProject/Trunk and branches on https://svn.yoursvnserver.com/repos/YourProject/Branches/BranchX . You can clean up if you start your repos in the wrong place, but it leads to confusion.
|
If you are working on legacy code (e.g., apps ported from .NET 1.x to 2.0 or 3.5) then it would be a bad idea to depart from datasets. Why change something that already works?
If you are, however, creating a new apps, there a few things that you can cite:
- Appeal to experiencing *pain* in maintaining apps that stick with DataSets
- Cite performance benefits for your new approach
- Bait them with a good middle-ground. Move to .NET 3.5, and promote LINQ to SQL, for instance: while still sticking to data-driven architecture, is a huge, huge departure to string-indexed data sets, and enforces... voila! Custom collections -- in a manner that is hidden from them.
What is important is that whatever approach you use you remain consistent, and you are completely honest with the pros and cons of your approaches.
If all else fails (e.g., you have a development team that utterly refuses to budge from old practices and is skeptical of learning new things), this is a **very, very clear sign** that you've outgrown your team it's time to leave your company! |
Generally, if something is not deliberately conceived as public, I make it private.
If a situation arises where I need access to that private variable or method from a derived class, I change it from private to protected.
This hardly ever happens - I'm really not a fan at all of inheritance, as it isn't a particularly good way to model most situations. At any rate, carry on, no worries.
I'd say this is fine (and probably the best way to go about it) for the majority of developers.
**The simple fact of the matter is**, if some other developer comes along a year later and decides they need access to your private member variable, they are simply going to edit the code, change it to protected, and carry on with their business.
The only real exceptions to this are if you're in the business of shipping binary dll's in black-box form to third parties. This consists basically of Microsoft, those 'Custom DataGrid Control' vendors, and maybe a few other large apps that ship with extensibility libraries. Unless you're in that category, it's not worth expending the time/effort to worry about this kind of thing. |
One way would be to have the Erlang core of the application be a daemon that the Cocoa front-end communicates with over a Unix-domain socket using some simple protocol you devise.
The use of a Unix-domain socket means that the Erlang daemon could be launched on-demand by `launchd` and the Cocoa front-end could find the path to the socket to use via an environment variable. That makes the rendezvous between the app and the daemon trivial, and it also makes it straightforward to develop multiple front-ends (or possibly a framework that wraps communication with the daemon).
The Mac OS X `launchd` system is really cool this way. If you specify that a job should be launched on-demand via a secure Unix-domain socket, `launchd` will actually create the socket itself with appropriate permissions, and advertise its location via the environment variable named in the job's property list. The job, when started, will actually be passed a file descriptor to the socket by `launchd` when it does a simple check-in.
Ultimately this means that the entire process of the front-end opening the socket to communicate with the daemon, `launchd` launching the daemon, and the daemon responding to the communication can be secure, even if the front-end and the daemon run at different privilege levels.
|
Automatically check bounced emails via POP3 ? |
|.net|software|pop3|check|bouncedemail| |
Can anyone recommend software or even a .net library to develop software, that will check for bounced emails and the reason for the bounce? I get bounced emails into a pop3 account that I can read then...
I need it to keep my user database clean from invalid email addresses and want to automate this (mark user as invalid email).
Thanks |
See "[Authentication on Resin][1]"
The closest you'll come to .htaccess with apache is configuring for Basic auth using an XmlAuthenticator. You'll need to convert your htpasswd file into the XML format that resin uses.
Follow the "Quick Start" section and you'll get what you want.
[1]: http://www.caucho.com/resin-3.0/security/authentication.xtp |
I assume that you want this "pause" for debugging purposes, otherwise think about it, you'll always have some better tasks to do for your server than sleep ...
A suggestion: Maybe you could get CURRENT, add it a few seconds ( let mytimestamp ) then in a while loop select CURRENT while CURRENT <= mytimestamp . I've no informix setup around my desk to try it, so you'll have to figure the correct syntax. Again, do not put such a hack on a production server. You've been warned :D |
after you moved the DBs over to 2005 did you
update the stats with full scan?
rebuilt the indexes?
first try that and then check performance again |
Also a FYI, if you run compatibility level 90 then some things are not supported anymore like old style outer joins `(*= and =*)` |
It's pretty easy to do with a TcpClient. Open the server:
TcpClient tcpClient = new TcpClient();
tcpClient.Connect(POP3Server, POP3Port);
NetworkStream stream = tcpClient.GetStream();
Read the welcome message:
int read = stream.Read(inBuffer, 0, inBuffer.Length);
string response = Encoding.ASCII.GetString(inBuffer, 0, read);
if (response.IndexOf("+OK") != 0) throw new ...;
Write back to the server:
byte[] outBuffer = Encoding.ASCII.GetBytes("USER " + account + "\r\n");
stream.Write(outBuffer, 0, outBuffer.Length);
That sends the USER command. You need to login and then you can start grabbing messages - see the POP3 [RFC][1] for the full list of commands. If you're not looking to roll your own check out this [CodeProject article][2].
[1]: http://www.faqs.org/rfcs/rfc1939.html
[2]: http://www.codeproject.com/KB/IP/despop3client.aspx |
@lassevk
// 4. Outer double-for-loop to consider all possible positions
// for topleft corner.
for (int i=0; i < M; i++) {
for (int j=0; j < N; j++) {
// 2.1 With (i,j) as topleft, consider all possible bottom-right corners.
for (int a=i; a < M; a++) {
for (int b=j; b < N; b++) {
HAHA... O(m2 n2).. That's probably what I would have come up with.
I see they go on to develop optmizations... looks good, I'll have a read. |
have a look at the jqery javascript libary for animation (it is what is used on stackoverflow).
Unfortuntly with out flash silverlight or another plug in cross system videio support is limmited. |
I found this project on google code: http://code.google.com/p/svnrevisionlabeller/. This is CCNET plugin to generate the label in CCNET.
The DLL is tested with CCNET 1.3 but it works with CCNET 1.4 for me. I'm successfully using this plugin to label my build.
Now onto passing it to MSBuild... |
I found this project on google code: <http://code.google.com/p/svnrevisionlabeller/>. This is CCNET plugin to generate the label in CCNET.
The DLL is tested with CCNET 1.3 but it works with CCNET 1.4 for me. I'm successfully using this plugin to label my build.
Now onto passing it to MSBuild... |
If you prefer doing it on the MSBuild side over the CCNet config, looks like the MSBuild Community Tasks extension's ([http://msbuildtasks.tigris.org/][1]) SvnVersion task might do the trick.
[1]: http://msbuildtasks.tigris.org/ |
A dictionary may also contain overhead, depending on the actual implementation. A hashtable usually contain some prime number of available nodes to begin with, even though you might only use a couple of the nodes.
Judging by your example, "Property", would you be better of with a class approach for the final level and real properties? Or is the names of the properties changing a lot from node to node?
I'd say that what "efficient" means depends on a lot of things, like:
* speed of updates (insert, update, delete)
* speed of random access retrieval
* speed of sequential retrieval
* memory used
I think that you'll find that a data structure that is speedy will generally consume more memory than one that is slow. This isn't always the case, but most data structures seems to follow this.
A dictionary might be easy to use, and give you relatively uniformly fast access, it will most likely use more memory than, as you suggest, lists. Lists, however, generally tend to contain more overhead when you insert data into it, unless they preallocate X nodes, in which they will again use more memory.
My suggestion, in general, would be to just use the method that seems the most natural to you, and then do a "stress test" of the system, adding a substantial amount of data to it and see if it becomes a problem.
You might also consider adding a layer of abstraction to your system, so that you don't have to change the programming interface if you later on need to change the internal data structure. |
If you are doing "just extract and run", you are going to run in security issues. This is especially true if you are users are running Vista (or later). is there a reason why you wanted to avoid packaging your applications inside an installer? Using an installer would alleviate the "external source" problem. You would be able to use .chm files without any problems.
We use [InstallAware][1] to create our install packages. It's not cheap, but is very good. If cost is your concern, [WIX][2] is open source and pretty robust. WIX does have a learning curve, but it's easy to work with.
[1]: http://www.installaware.com
[2]: http://wix.sourceforge.net/ |
The GNU C library regular expressions facility (regcomp(), regexec() and friends) is broken. Use libetre instead; the function signatures match the ones provided by glibc.
http://laurikari.net/tre/ |
The trick to that is to use URL rewriting so that **name.domain.com** transparently maps to something like **domain.com/users/name** on your server. Once you start down that path, it's fairly trivial to implement. |
I am writing this on a Centrino 1.5GHz, 512MB RAM running [Ubuntu][1]. It's Debian based and is the first Linux distro I have tried that actually worked with my laptop on first install. Find more info [here][2].
[1]: http://www.ubuntu.com/
[2]: http://en.wikipedia.org/wiki/Ubuntu |
I suggest you should checkout the following three distros:
- [Damn Small Linux][1] - Very lightweight. Includes its own lightweight browser (Dillo), but you can install Firefox easily. The entire distro fits on a 50MB LiveCD.
- [Slackware][2] - Performance wise Slackware will probably perform the best out of the three, but I'd suggest running your own benchmarks with your hardware.
- [Debian][3]- Debian is extremely versatile. This is the only distro of the three I'd recommend for both a 32 bit 1GB RAM laptop and also a 4GB RAM 64 bit machine.
[1]: http://www.damnsmalllinux.org/
[2]: http://www.slackware.com/
[3]: http://www.debian.org/ |
You can't convince them otherwise. Pick a smaller challenge or move to a different organization. If your manager respects you see if you can do a project in the domain-driven style as a sort of technology trial. |
I'm in a similar situation to [Schroeder][1]; having a laptop with 512mb RAM is a PITA. I tried running Xubuntu but tbh I didn't find it that it was either useable or a great saver on RAM. So I switched to Ubuntu and it's worked out pretty well.
[1]: http://stackoverflow.com/questions/37396/linux-lightweight-distro-and-x-windows-for-development#37410 |
I would recommend [Xubuntu](http://www.xubuntu.org/). It's based on Ubuntu/Debian and optimized for small footprint with the Xfce desktop environment. |
I think you should focus on the performance. If you can create an application that shows the performance difference when using DataSets vs Custom Entities. Also, try to show them Domain Driven Design principles and how it fits with entity frameworks. |
Try using Gentoo, Most distros with X are targetted towards desktop user and by default includes a lot of other application you don't need and at the same time lacks a lot of the stuff you need. YOu could customize the install but usually a lot of useless stuff will get into the 'base' install anyway.
If you worried about compile time, you can specify portage(the getoo package management system) to fetch binaries when available instead of compiling. It allows you to get the flexibility of installing a system with only the stuff you want.
I used gentoo and never went back.
<http://www.gentoo.org/>
|
How do I find broken NMEA log sentences with grep? |
|grep|gps|nmea| |
My GPS logger occassionally leaves "unfinished" lines at the end of the log files. I think they're only at the end, but I want to check all lines just in case.
A sample complete sentence looks like:
$GPRMC,005727.000,A,3751.9418,S,14502.2569,E,0.00,339.17,210808,,,A*76
The line should start with a `$` sign, and end with an `*` and a two character hex checksum. I don't care if the checksum is correct, just that it's present. It also needs to ignore "ADVER" sentences which don't have the checksum and are at the start of every file.
The following Python code might work:
import re
from path import path
nmea = re.compile("^\$.+\*[0-9A-E]{2}$")
for log in path("gpslogs").files("*.log"):
for line in log.lines():
if not nmea.match(line) and not "ADVER" in line:
print "%s\n\t%s\n" % (log, line)
Is there a way to do that with `grep` or `awk` or something simple? I haven't really figured out how to get `grep` to do what I want.
Thanks. |
@Jared - a minor correction to your code example. The last line of the first code example should read:
dist = sqrt(dx*dx + dy*dy); |
You might have better success researching Bittorrent, I believe that the creator has written some papers, and it seems others are as well.
[BitTyrant][1]
[Bittorent.org, see the developers section][2]
[1]: http://bittyrant.cs.washington.edu/#papers
[2]: http://bittorrent.org/ |
I don't know what platform you are trying to use, but here is [a decent article on the subject for .NET][1].
[1]: http://msdn.microsoft.com/en-us/magazine/cc188685.aspx |
You can dot-source as described by others here, or you could also use the invocation character "&". This means that PS treats your string as something to execute rather than just text. This might be more important in a script though.
I'd add that you should pass any parameters OUTSIDE of the quotes (this one bit me before) note that the "-r" is not in the quoted string, only the exe.
& "C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\aspnet_regiis.exe" -r | out-null
|
For one, the shortcut is not "s" it is "s.lnk". E.g. you are not able to open a text file (say with notepad) by typing "t" when the name is "t.txt" :)
You can dot-source as described by others here, or you could also use the invocation character "&". This means that PS treats your string as something to execute rather than just text. This might be more important in a script though.
I'd add that you should pass any parameters OUTSIDE of the quotes (this one bit me before) note that the "-r" is not in the quoted string, only the exe.
& "C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\aspnet_regiis.exe" -r | out-null
|
For one, the shortcut is not "s" it is "s.lnk". E.g. you are not able to open a text file (say with notepad) by typing "t" when the name is "t.txt" :) [Technet says][1]
> The PATHEXT environment variable
> defines the list of file extensions
> checked by Windows NT when searching
> for an executable file. The default value of PATHEXT is .COM;.EXE;.BAT;.CMD
You can dot-source as described by others here, or you could also use the invocation character "&". This means that PS treats your string as something to execute rather than just text. This might be more important in a script though.
I'd add that you should pass any parameters OUTSIDE of the quotes (this one bit me before) note that the "-r" is not in the quoted string, only the exe.
& "C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\aspnet_regiis.exe" -r | out-null
[1]: http://technet.microsoft.com/en-us/library/cc723564.aspx#XSLTsection127121120120 |
When accessing the elements of an array, for clarity I would use a foreach whenever possible, and only use a for if you need the actual index values (for example, the same index in multiple arrays). This also minimizes the chance for typo mistakes since for loops make this all too easy. In general, PHP might not be the place be worrying too much about performance. And last but not least, for and foreach have (or should have; I'm not a PHP-er) the same Big-O time (O(n)) so you are looking possibly at a small amount more of memory usage or a slight constant or linear hit in time. |
I'm not sure how important it is to be unbreakable, but a simple solution might just be to append a text file to the end of the image. Something like "This image belongs to ...".
If you open the image in a viewer/browser, it looks like a normal jpeg, but if you open it in a text editor, the last line would be readable.
The same method allows you include an actual file into an image. ([hide a file inside of an image][1]) I've found that it's a bit hit-or-miss, but 7-zip files seem to work. You could hide all sorts of copywrite goodies inside the image.
Again, it's not unbreakable by any stretch of the imagination, but it's completely invisible to the naked eye.
[1]: http://www.online-tech-tips.com/computer-tips/hide-file-in-picture/ |
My shortcut in similar cases is to add a space at the start of Canada and two spaces at the start of United States. If displaying these as options in a SELECT tag, the spaces are not visible but the sorting still brings them to the front.
However, that may be a little hacky in some contexts. In Java the thing to do would be to extend StringComparator, override the compare() method making the US and Canada special cases, then sort the list (or array) passing in your new comparator as the sort algorithm.
However I would imagine it might be simpler to just find the relevant entries in the array, remove them from the array and add them again at the start. If you are in some kind of framework which will re-sort the array, then it might not work. But in most cases that will do just fine.
[edit] I see that you are using a hash and not an array - so it will depend on how you are doing the sorting. Could you simply put the US into the hash with a key of -2, Canada with -1 and then sort by ID instead? Not having used PHP in anger for 11 years, I don't recall whether it has built-in sorting in its hashes or if you are doing that at the application level. |
Enabled Brigded Network in Vmware Server |
|vmware|virtualization|vmware-server| |
I have the vmware server with this error, anyone knows how to fix it?![VMware Server Error][1]
[1]: http://soporte.cardinalsystems.com.ar/errorvmwareserver.jpg |
Firefox with a little elbow grease is your best bet. I've written [locked down extensions](http://webconverger.org/kiosk/) (one that's full screen and great for digital signage) as well as [Live CD](http://webconverger.com/) to ease deployment. |
Can you make just part of a regex case-insensitive? |
|regex| |
I've seen lots of examples of making an entire regular expression case-insensitive. What I'm wondering about is having just part of the expression be case-insensitive.
For example, let's say I have a string like this:
fooFOOfOoFoOBARBARbarbarbAr
What if I want to match all occurrences of "foo" regardless of case but I only want to match the upper-case "BAR"s?
The ideal solution would be something that works across regex flavors but I'm interested in hearing language-specific ones as well (Thanks [Espo]([@Espo](http://stackoverflow.com/questions/43632/can-you-make-just-part-of-a-regex-case-insensitive#43636)) |
The follow is SQL92 standard so should be supported by the majority of RDMBS that use SQL:
CREATE INDEX [index name] ON [table name] ( [column name] ) |
The following is SQL92 standard so should be supported by the majority of RDMBS that use SQL:
CREATE INDEX [index name] ON [table name] ( [column name] ) |
Viewstate invalid when using Safari |
|c#|.net|safari|viewstate| |
Hey guys, just had a bug submitted for a site I maintain which heavily uses the viewstate (not my code). However on certain pages when the viewstate is extra bloated Safari is throwhing the usual "Validation of viewstate MAC failed" error.
Any ideas?? Only happens in Safari, Firefox, IE, Opera all fine. |
I've been doing a little research into this and whilst I'm not entirely sure its the cause I believe it is because Safari is not returning the full result set (hence cropping it).
I have been in dicussion with another developer and found the following post on Channel 9 as well which recommends making use of the SQL State service to store the viewstate avoiding the postback issue and also page size.
[http://channel9.msdn.com/forums/TechOff/250549-ASPNET-ViewState-flawed-architecture/?CommentID=270477#263702][1]
Does this seem like the best solution?
[1]: http://channel9.msdn.com/forums/TechOff/250549-ASPNET-ViewState-flawed-architecture/?CommentID=270477#263702 |
Making a class-based structure would probably have more overhead than the dict-based structure, since in python classes actually use dicts when they are implemented. |
My first port of call would be to go through the elements on the page and see which controls:
1. Will still work when I switch ViewState off
2. Can be moved out of the page and into an AJAX call to be loaded when required
Failing that, and here's the disclaimer - I've never used this solution on a web-facing site - but in the past where I've wanted to eliminate massive ViewStates in limited-audience applications I have stored the ViewState in the Session.
It has worked for me because the hit to memory isn't significant for the number of users, but if you're running a fairly popular site I wouldn't recommend this approach. However, if the Session solution works for Safari you could always detect the user agent and fudge appropriately. |
> **Customizing csproj files to autogenerate AssemblyInfo.cs**
> <http://www.codeproject.com/KB/dotnet/Customizing_csproj_files.aspx>
>
> Every time we create a new C# project,
> Visual Studio puts there the
> AssemblyInfo.cs file for us. The file
> defines the assembly meta-data like
> its version, configuration, or
> producer.
Found the above technique to auto-gen AssemblyInfo.cs using MSBuild. Will post sample shortly. |
Don't worry about DNS. You should have there just static entry like:
A *.YOURDOMAIN.COM [IPADDRESS]
Ask your DNS provider to do it for you (if it's not done already) or do it by yourself if you have control over your DNS records. This will automatically point all your subdomains (current and future ones) into the same HTTP server.
Once it's done, you will need to parse HOST header in your web application on every single HTTP request to detect what client is accessing your server and display appropriate data. Let us know what HTTP server and language/framework you're using. |
See [Scott Hanselman's post on using DotNetOpenID][1] in ASP.NET. [Andrew Arnott's blog][2] is full of samples on using DotNetOpenID with ASP.NET, including ASP.NET MVC.
I recently hooked up DotNetOpenID for the Subtext 2.0 release. It went really smoothly - the code samples included with the DotNetOpenID download are pretty helpful. The one thing I'd recommend is that you just use the library and avoid the ASP.NET control. It uses table based layout (hardcoded) and is pretty difficult to restyle.
[1]: http://www.hanselman.com/blog/TheWeeklySourceCode25OpenIDEdition.aspx
[2]: http://blog.nerdbank.net/ |
For completeness sake: even though my company more or less standardizes on Eclipse we use Netbeans (6 and up) with its [included, free profiler][1] on a daily basis. It works better than the Eclipse TPTP plugin (last checked 3 months ago) and for us it removes any need for a commercial profiler such as JProfiler, which is excellent, but fast becoming unnecessary.
[1]: http://profiler.netbeans.org/ |
How to affordably release a Web App |