instruction stringlengths 0 30k ⌀ |
|---|
|version-control| |
I know there are at least 10 different ways to structure project in version control. I'm curious what some methods being used are and which ones work for you. I've worked with SVN, TFS, and currently/unfortunately VSS. I've seen version control implemented very poorly and just OK, but never great.
Just to get the ball rolling, here is a review of things I've seen.
This example is SVN-based, but applies to most VCS's.
1. branch the individual projects that are part of site
/division/web/projectName/vb/src/[trunk|branches|tags]
2. branch the whole site, in the case I've seen, the whole site except for core components was branched.
/division/[trunk|branches|tags]/web/projectName/vb/src/
3. Use main-line a default, only branch when necessary for **huge** changes. |
One of the most comprehensive solutions is Cognos. |
One of the most comprehensive solutions is Cognos.
Dislike: You wouldn't believe how many CDs it ships in... its huge. |
Hobby or Serious project, [![alt text][1]](http://svn1clicksetup.tigris.org/files/documents/3106/33794/Svn1ClickSetup-1.3.3.exe) gives you all you need with ease :)
[1]: http://svn1clicksetup.tigris.org/images/svn1click.png |
SVN with SmartSVN or tortoiseSVN ? not really all that lightweight, but good practice for the big bad world. |
You can also type command '-i' while less is running. It toggles case sensivity for searches. |
[Double Brace Initialization][1] took me by surprise a few months ago when I first discovered it, never heard of it before.
[ThreadLocals][2] are typically not so widely known as a way to store per-thread state.
Since JDK 1.5 Java has had extremely well implemented and robust concurrency tools beyond just locks, they live in [java.util.concurrent][3] and a specifically interesting example is the [java.util.concurrent.atomic][4] subpackage that contains thread-safe primitives that implement the [compare-and-swap][5] operation and can map to actual native hardware-supported versions of these operations.
[1]: http://www.c2.com/cgi/wiki?DoubleBraceInitialization
[2]: http://java.sun.com/javase/6/docs/api/java/lang/ThreadLocal.html
[3]: http://java.sun.com/javase/6/docs/api/java/util/concurrent/package-summary.html
[4]: http://java.sun.com/javase/6/docs/api/java/util/concurrent/atomic/package-summary.html
[5]: http://www.ibm.com/developerworks/java/library/j-jtp11234/ |
See this MSDN Forum Post: [Creating a new Table in SQL Server from ADO.net DataTable][1].
Here the poster seems to be trying to do the same thing as you, and provides code that generates a Create Table statement using the schema contained in a DataTable.
Assuming this works as it should, you could then take that code, and submit it to the database through SqlCommand.ExecuteNonQuery() in order to create your table.
[1]: http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=373468&SiteID=1#1003715 |
The [GZipStream][1] class might be what you want.
[1]: http://msdn.microsoft.com/en-us/library/system.io.compression.gzipstream.aspx |
How do I use T-SQL Group By |
|sql| |
I know I need to have (although I don't know why) an Order By clause on the end of a SQL query that uses any aggregate functions like count, sum, avg, etc:
select count(userID), userName from users group by userName
When else would GROUP BY be useful, and what are the performance ramifications? |
Counting the number of times tags are used might be a google example:
Select TagName,Count(*) As TimesUsed From Tags Group By TagName Order TimesUsed
If your simply wanting a distinct value of tags, I would prefer to use the distant statement.
Select Distinct TagName From Tags Order By TagName Asc |
GROUP BY also helps when you want to generate a report that will average or sum a bunch of data. You can GROUP By the Department ID and the SUM all the sales revenue or AVG the count of sales for each month. |
Group By forces the entire set to be populated before records are returned (since it is an implicit sort).
For that reason (and many others), never use a Group By in a subquery. |
If you are on Mac OSX, I found <a href = "http://www.versionsapp.com/">Versions</a> to be an incredible (free) GUI front-end to SVN. |
@superjoe30
I use SVN for all of my personal projects. I started off with running svn on my home machine but eventually migrated over to Dreamhost. Their hosting packages that include Subversion are pretty reasonable. |
>[superjoe30 writes](http://stackoverflow.com/questions/2658/#2674):
>>Related question (perhaps answers can be edited to answer this question as well):
>>
>>What about using source control on your own computer, if you're the sole programmer? Is >>this good practice? Are there related tips or tricks?
I use SVN for all of my personal projects. I started off with running svn on my home machine but eventually migrated over to Dreamhost. Their hosting packages that include Subversion are pretty reasonable. |
<http://www.csszengarden.com/>
The images are not Creative Commons, but the CSS is. |
<pre>
CREATE TABLE #tmpSizeChar (
table_name sysname ,
row_count int,
reserved_size varchar(50),
data_size varchar(50),
index_size varchar(50),
unused_size varchar(50))
CREATE TABLE #tmpSizeInt (
table_name sysname ,
row_count int,
reserved_size_KB int,
data_size_KB int,
index_size_KB int,
unused_size_KB int)
SET NOCOUNT ON
INSERT #tmpSizeChar
EXEC sp_msforeachtable 'sp_spaceused ''?'''
INSERT INTO #tmpSizeInt (
table_name,
row_count,
reserved_size_KB,
data_size_KB,
index_size_KB,
unused_size_KB
)
SELECT [table_name],
row_count,
CAST(SUBSTRING(reserved_size, 0, PATINDEX('% %', reserved_size)) AS int)reserved_size,
CAST(SUBSTRING(data_size, 0, PATINDEX('% %', data_size)) AS int)data_size,
CAST(SUBSTRING(index_size, 0, PATINDEX('% %', index_size)) AS int)index_size,
CAST(SUBSTRING(unused_size, 0, PATINDEX('% %', unused_size)) AS int)unused_size
FROM #tmpSizeChar
/*
DROP TABLE #tmpSizeChar
DROP TABLE #tmpSizeInt
*/
SELECT * FROM #tmpSizeInt
ORDER BY reserved_size_KB DESC
</pre> |
You can mark variables as "[silent][1]" like this:
$!variable
If $variable is null, nothing will be rendered. If it is not null, its value will render as it normally would.
[1]: http://velocity.apache.org/engine/releases/velocity-1.5/vtl-reference-guide.html |
I kind of like perfmon my self. It comes with windows out of the box, and has support for a whole lot of different measurements.
|
Extensions are, in general, a way for graphics card vendors to add new functionality to OpenGL without having to wait until the next revision of the OpenGL spec. There are different types of extensions:
1. Vendor extension - only one vendor provides a certain type of functionality.
- Example: `NV_vertex_program`
2. Multivendor extension - multiple vendors have gotten together and agreed on the functionality.
- Example: `EXT_vertex_program`
3. ARB extension - the OpenGL Architecture Review Board has blessed the extension. You have a reasonable expectation that this type of extension will be around for a while.
- Example: `ARB_vertex_program`
Extensions don't have to go through all of these steps. Sometimes an extension is only ever implemented by one vendor, before hardware designs go a different way and the extension is abandoned. Other times, an extension might make it as far as ARB status before everyone decides there's a better way. (The `ARB_vertex_program` approach, for instance, was set aside in favor of the high-level shading language approach of `ARB_vertex_shader` when it came time to roll shaders into the core OpenGL spec.) Even ARB extensions don't last forever; I wouldn't write something today requiring `ARB_matrix_palette`, for instance.
All of that having been said, it's a very good idea to keep up to date on extensions, in particular the latest ARB and EXT extensions. In the past it has been true that some of the 'fast paths' through the hardware were only accessible via extensions. Likewise, if you want to know what all functionality a piece of hardware can do, there's no better place to look than in a vendor-specific extension.
If you're just getting started in OpenGL, I'd recommend investigating:
- `ARB_vertex_buffer_object` (vertices)
- `ARB_vertex_shader` / `ARB_fragment_shader` / `ARB_shader_objects` / GLSL spec (shaders)
More advanced:
- `ARB/EXT_framebuffer_object` (off-screen rendering)
This is all functionality that's been rolled into core, but it can be good to see it in isolation so you can get a better feel for where its boundaries lie. (The core OpenGL spec seamlessly mixes the old with the new, so this can be pretty important if you want to stay on the fast path, and avoid the legacy and sometimes implemented in software paths.)
Whatever you do, make sure you have appropriate checks for the extensions you decide to use, and fallbacks where necessary. Even though your card may have a given extension, there's no guarantee that the extension will be present on another vendor's card, or even on another operating system with the same card. |
On my Vista system typing S won't launch an lnk file unless I have the environment variable PATHEXT set with .lnk in the list. When I do S will work in cmd.exe and I have to do .\S in powershell. |
On my Vista system typing S won't launch a lnk file unless I have the environment variable PATHEXT set with .lnk in the list. When I do. S will work in cmd.exe and I have to do .\S in powershell. |
Why not use LINQ:
System.Collections.Generic.Dictionary<string, int> myDict = new Dictionary<string, int>();
myDict.Add("one", 1);
myDict.Add("four", 4);
myDict.Add("two", 2);
myDict.Add("three", 3);
var sortedDict = (from entry in myDict orderby entry.Value ascending select entry); |
Why not use LINQ:
System.Collections.Generic.Dictionary<string, int> myDict = new Dictionary<string, int>();
myDict.Add("one", 1);
myDict.Add("four", 4);
myDict.Add("two", 2);
myDict.Add("three", 3);
var sortedDict = (from entry in myDict orderby entry.Value ascending select entry);
This would also allow for great flexibility in that you can select the top 10, 20 10% etc. Or if you are using your word frequency index for type-ahead, you could also include StartsWith clause as well. |
Do you mean that from a set of N colors, you need to pick M colors, where M < N, such that M is the *best* representation of the N colors in the M space?
As a better example, reduce a true-color (24 bit color space) to a 8-bit mapped color space (GIF?).
There are quantization algorithms for this, like the [Adaptive Spatial Subdivision](http://www.imagemagick.org/www/quantize.html) algorithm used by ImageMagic.
These algorithms usually don't just pick existing colors from the source space but creates new colors in the target space that most closely resemble the source colors. As a simplified example, if you have 3 colors in the original image where two are red (with different intensity or bluish tints etc.) and the third is blue, and need to reduce to two colors, the target image could have a red color that is some kind of average of the original two red + the blue color from the original image.
If you need something else then I didn't understand your question :) |
You can try [SuperCopier](http://sourceforge.net/projects/supercopier/), it replaces the standard Windows copy mechanism while loaded.
It can retry failed files at the end, resume a canceled copy (even a copy canceled by Windows), accepts "All" for every answers. You can even answer the annoying questions (file already exists, error copying file) before they occur. |
You can split them in to RGB HEX format so that you can compare the R with R's of a different color, same with the G and B.
Same format as HTML
XX XX XX
RR GG BB
00 00 00 = black
ff ff ff = white
ff 00 00 = red
00 ff 00 = green
00 00 ff = blue
So the only thing you would need to decide is how close you want the colors and what is an acceptable difference for the segments to be considered different. |
How about good old Command-Line Xcopy? With S: being the source and T: the target:
xcopy /K /R /E /I /S /C /H /Y s:\*.* t:\
(German-speakers can easily memorize the command line arguments, hence I always use xcopy) |
How about good old Command-Line Xcopy? With S: being the source and T: the target:
xcopy /K /R /E /I /S /C /H /G /X /Y s:\*.* t:\
> /K Copies attributes. Normal Xcopy will reset read-only attributes.
>
> /R Overwrites read-only files.
>
> /E Copies directories and subdirectories, including empty ones.
>
> /I If destination does not exist and copying more than one file, assumes that destination must be a directory.
>
> /S Copies directories and subdirectories except empty ones.
>
> /C Continues copying even if errors occur.
>
> /H Copies hidden and system files also.
>
> /Y Suppresses prompting to confirm you want to overwrite an existing destination file.
>
> /G Allows the copying of encrypted files to destination that does not support encryption.
>
> /X Copies file audit settings (implies /O).
(Edit: Added /G and /X which are new since a few years) |
@theprise
If I were wanting to use an incrementing loop instead of an instantiated list (problems with memory for massive numbers...), what would be a good way to do that without building the list? |
@theprise
If I were wanting to use an incrementing loop instead of an instantiated list (problems with memory for massive numbers...), what would be a good way to do that without building the list?
It doesn't seem like it would be cheaper to do a divisibility check for the given integer (X % 3) than just the check for the normal number (N % X). |
I am not sure why would you say that unit tests are going be removed once refactoring is completed. Actually your unit-test suite should run after main build (you can create a separate "tests" build, that just runs the unit tests after the main product is built). Then you will immediately see if changes in one piece break the tests in other subsystem. Note it's a bit different than running tests during build (as some may advocate) - some limited testing is useful during build, but usually it's unproductive to "crash" the build just because some unit test happens to fail.
If you are writing Java (chances are), check out http://www.easymock.org/ - may be useful for reducing coupling for the test purposes. |
I recommend you should either add the `<br/>` line breaks or maybe use line-break entity - `
` |
I don't see what's wrong with <Line> tags.
Apparently, the visualization of the data is important to you, important enough to keep it in your data (via line breaks in your first example). Fine. Then really keep it, don't rely on "magic" to keep it for you. Keep every bit of data you'll need later on and can't deduce perfectly from the saved portion of the data, keep it even if it's visualization data (line breaks and other formatting). Your user (end user of another developer) took the time to format that data to his liking - either tell him (API doc / text near the input) that you don't intend on keeping it, or - just keep it. |
I'm not in a position to modify the permissions on folders (especially outside of the virtual directory home folder), and don't already have an App_Data folder, so am a bit hesitant to go with that.
So for the moment I'm going with the CommonApplicationData Folder.
- On Vista/Server 2008 this is C:\ProgramData\
- On XP/Server 2003 this is C:\Documents and Settings\All Users\Application Data\ |
If you're using .NET 3.5 have a look at the Enumerable.Cast<TResult> method. It's an extension method so you can call it directly on the List<string>.
List<string> sl = new List<string>();
IEnumerable<object> ol;
ol = sl.Cast<object>();
It's not exactly what you asked for but should do the trick. |
If you're using .NET 3.5 have a look at the Enumerable.Cast<TResult> method. It's an extension method so you can call it directly on the List<string>.
List<string> sl = new List<string>();
IEnumerable<object> ol;
ol = sl.Cast<object>();
It's not exactly what you asked for but should do the trick.
Edit: As noted by Zooba, you can then call ol.ToList() to get a List<object)> |
> I'm not in a position to modify the permissions on folders (especially outside of the virtual directory home folder), and don't already have an App_Data folder, so am a bit hesitant to go with that.
If you have a website, you clearly have a folder somewhere. Can you not add a (non-web-facing) subfolder? It seems like that would be a more appropriate place to put your logs than dumping them into a global, shared folder. |
I would **strongly** advise against putting unrelated data in a given
Git repository. The overhead of creating new repositories is quite
low, and that is a *feature* that makes it possible to keep
different lineages completely separate.
Fighting that idea means ending up with unnecessarily tangled history,
which renders administration more difficult and--more
importantly--"archeology" tools less useful because of the resulting
dilution. Also, as you mentioned, Git assumes that the "unit of
cloning" is the repository, and practically has to do so because of
its distributed nature.
A solution is to keep every project/package/etc. as its own *bare*
repository (i.e., without working tree) under a blessed hierarchy,
like:
/repos/a.git
/repos/b.git
/repos/c.git
Once a few conventions have been established, it becomes trivial to
apply administrative operations (backup, packing, web publishing) to
the complete hierarchy, which serves a role not entirely dissimilar to
"monolithic" SVN repositories. Working with these repositories also
becomes somewhat similar to SVN workflows, with the addition that one
*can* use local commits and branches:
svn checkout --> git clone
svn update --> git pull
svn commit --> git push
(Cf. [this
post](http://beta.stackoverflow.com/questions/6009/how-do-you-deal-with-configuration-files-in-source-control#36767)
of mine for an example where local, throw-away commits & branches can
be very useful).
The easiest way to make an existing `~/dev/foo` in such a bare
repository is probably:
$ cd ~/dev
$ git clone --bare foo /repos/foo.git
$ mv foo foo.old
$ git clone /repos/foo.git
which is mostly equivalent to a `svn import`--but does not throw the
existing, "local" history away.
Note: *submodules* are a mechanism to include shared *related*
lineages, so I wouldn't consider them an appropriate to solve your
problem.
|
I would **strongly** advise against putting unrelated data in a given
Git repository. The overhead of creating new repositories is quite
low, and that is a *feature* that makes it possible to keep
different lineages completely separate.
Fighting that idea means ending up with unnecessarily tangled history,
which renders administration more difficult and--more
importantly--"archeology" tools less useful because of the resulting
dilution. Also, as you mentioned, Git assumes that the "unit of
cloning" is the repository, and practically has to do so because of
its distributed nature.
A solution is to keep every project/package/etc. as its own *bare*
repository (i.e., without working tree) under a blessed hierarchy,
like:
/repos/a.git
/repos/b.git
/repos/c.git
Once a few conventions have been established, it becomes trivial to
apply administrative operations (backup, packing, web publishing) to
the complete hierarchy, which serves a role not entirely dissimilar to
"monolithic" SVN repositories. Working with these repositories also
becomes somewhat similar to SVN workflows, with the addition that one
*can* use local commits and branches:
svn checkout --> git clone
svn update --> git pull
svn commit --> git push
You can have multiple remotes in each working clone, for the ease of
synchronizing between the multiple parties:
$ cd ~/dev
$ git clone /repos/foo.git # or the one from github, ...
$ cd foo
$ git remote add github ...
$ git remote add memorystick ...
You can then fetch/pull from each of the "sources", work and commit
locally, and then push ("backup") to each of these remotes when you
are ready with something like (note how that pushes the *same* commits
and history to each of the remotes!):
$ for remote in origin github memorystick; do git push; done
The easiest way to turn an existing working repository `~/dev/foo`
into such a bare repository is probably:
$ cd ~/dev
$ git clone --bare foo /repos/foo.git
$ mv foo foo.old
$ git clone /repos/foo.git
which is mostly equivalent to a `svn import`--but does not throw the
existing, "local" history away.
Note: *submodules* are a mechanism to include shared *related*
lineages, so I indeed wouldn't consider them an appropriate tool for
the problem you are trying to solve.
|
Just use the [HttpWebRequest][1] class in the System.Net namespace to request the file and download it. Then use [GZipStream][2] class in the System.IO.Compression namespace to extract the contents to the location you specify. They provide examples.
[1]: http://msdn.microsoft.com/en-us/library/system.net.httpwebrequest.aspx
[2]: http://msdn.microsoft.com/en-us/library/system.io.compression.gzipstream.aspx |
I use [VisualSVN Server][1] (free) and [Tortoise SVN][2] (free) for school, work, hobbies, everything. If you want Visual Studio integration, you can use [Visual SVN][3] ($49) or [AnkhSVN][4] (free).
[1]: http://www.visualsvn.com/server
[2]: http://tortoisesvn.tigris.org
[3]: http://www.visualsvn.com/visualsvn
[4]: http://ankhsvn.open.collab.net |
Pick your flavour of distributed version control. I like Mercurial, other folks swear by Git and Bazaar. There's no need to make a fake server to put a directory under version control, which, IMO, makes it very ideal for small projects.
I'm not sure if any of these have Visual Studio plugins, though. |
A nice abstraction on top of Jsch is Apache [commons-vfs][1] which offers a virtual filesystem API that makes accessing and writing SFTP files almost transparent. Worked well for us.
[1]: http://commons.apache.org/vfs/ |
You can use WebClient in System.Net to download:
WebClient Client = new WebClient ();
Client.DownloadFile("http://data.dot.state.mn.us/dds/det_sample.xml.gz", " C:\mygzipfile.gz");
then use [#ziplib][1] to extract
Edit: or GZipStream... forgot about that one
[1]: http://sharpdevelop.net/OpenSource/SharpZipLib/Default.aspx |
Try the [SharpZipLib][1], a C# based library for compressing and uncompressing files using gzip/zip.
Sample usage can be found on this [blog post][2]:
using ICSharpCode.SharpZipLib.Zip;
FastZip fz = new FastZip();
fz.ExtractZip(zipFile, targetDirectory,"");
[1]: http://www.icsharpcode.net/OpenSource/SharpZipLib/
[2]: http://preview.tinyurl.com/6x9uer |
Here is a post I wrote last year that shows how to decompress a gzip file using C# and the built-in GZipStream class.
<http://blogs.msdn.com/miah/archive/2007/09/05/zipping-files.aspx>
As for downloading it, you can use the standard [WebRequest](http://msdn.microsoft.com/en-us/library/system.net.webrequest.aspx) or [WebClient](http://msdn.microsoft.com/en-us/library/system.net.webclient.aspx) classes in .NET.
|
Kyle has the right approach in asking about the interaction. There is no "correct" answer without knowing what the usage patterns are likely to be.
Any architectural decision -- especially at this level -- is a trade-off.
You must ask yourself:
- What kind of messages need to be passed between the systems?
- What types of data need to be shared?
- Is there an important requirement to support complex model objects or will primitives + arrays do?
- what is the volume of the data?
- How frequently will the interactions occur?
- What is the acceptable communication latency?
Until you have an understanding of the answers, or potential answers, to those questions, it will be difficult to choose an implementation architecture. Once we know which factors are important, it will be far easier to choose the more suitable implementation candidates that reflect the requirements of the running system. |
Honestly it depends on what fits in to your environment better. If you are using a lot of Non-Microsoft tools, nunit, ccnet, ncover. You will probably find better support with nant. Alternatively if you are using MSTest, TFSBuild, you will probably find MSBuild a better environment. I would learn both and use which every fits more smoothly with your environment. |
Well, as a first point of call, I'd say of the common metrics HSV (Hue, Saturation and Value) or HSL are better representative of how humans perceive colour than say RGB or CYMK. See [HSL, HSV on Wikipedia][1].
I suppose naively I would plot the points in the HSL space for the two colours and calculate the magnitude of the difference vector. However this would mean that bright yellow and bright green would be considered just as different as green to dark green. But then many consider red and pink two different colours.
Moreover, difference vectors in the same direction in this parameter space are not equal. For instance, the human eye picks up green much better than other colours. A shift in hue from green by the same amount as a shift from red may seem greater. Also a shift in saturation from a small amount to zero is the difference between grey and pink, elsewhere the shift would be the difference between two shades of red.
From a programmers point of view, you would need to plot the difference vectors but modified by a proportionality matrix that would adjust the lengths accordingly in various regions of the HSL space - this would be fairly arbitrary and would be based on various colour theory ideas but be tweaked fairly arbitrarily depending on what you wanted to apply this to.
Even better, you could see if anyone has already done such a thing online...
[1]: http://en.wikipedia.org/wiki/HSL_and_HSV |
This also sounds to me like some kind of *resistance graph* where you try to map out the path of least resistance. If you inverse the requirements, path of maximum resistance, it could perhaps be used to produce a set that from the start produces maximum difference as you go, and towards the end starts to go back to values closer to the others.
For instance, here's one way to perhaps do what you want.
1. Calculate the distance (ref [your other post](http://stackoverflow.com/questions/1313/followup-finding-an-accurate-distance-between-colors)) from each color to all other colors
2. Sum the distances for each color, this gives you an indication for *how far away this color is from all other colors in total*
3. Order the list by distance, going down
This would, it seems, produce a list that starts with the color that is farthest away from all other colors, and then go down, colors towards the end of the list would be closer to other colors in general.
Hmm, ok, upon reading your reply to mine I think I didn't understand what you need and I don't think the above description fits it either. |
This also sounds to me like some kind of *resistance graph* where you try to map out the path of least resistance. If you inverse the requirements, path of maximum resistance, it could perhaps be used to produce a set that from the start produces maximum difference as you go, and towards the end starts to go back to values closer to the others.
For instance, here's one way to perhaps do what you want.
1. Calculate the distance (ref [your other post](http://stackoverflow.com/questions/1313/followup-finding-an-accurate-distance-between-colors)) from each color to all other colors
2. Sum the distances for each color, this gives you an indication for *how far away this color is from all other colors in total*
3. Order the list by distance, going down
This would, it seems, produce a list that starts with the color that is farthest away from all other colors, and then go down, colors towards the end of the list would be closer to other colors in general.
Edit: Reading your reply to my first post, about the spatial subdivision, would not exactly fit the above description, since colors close to other colors would fall to the bottom of the list, but let's say you have a cluster of colors somewhere, at least one of the colors from that cluster would be located near the start of the list, and it would be the one that generally was farthest away from all other colors in total. If that makes sense. |
I would **strongly** advise against putting unrelated data in a given
Git repository. The overhead of creating new repositories is quite
low, and that is a *feature* that makes it possible to keep
different lineages completely separate.
Fighting that idea means ending up with unnecessarily tangled history,
which renders administration more difficult and--more
importantly--"archeology" tools less useful because of the resulting
dilution. Also, as you mentioned, Git assumes that the "unit of
cloning" is the repository, and practically has to do so because of
its distributed nature.
One solution is to keep every project/package/etc. as its own *bare*
repository (i.e., without working tree) under a blessed hierarchy,
like:
/repos/a.git
/repos/b.git
/repos/c.git
Once a few conventions have been established, it becomes trivial to
apply administrative operations (backup, packing, web publishing) to
the complete hierarchy, which serves a role not entirely dissimilar to
"monolithic" SVN repositories. Working with these repositories also
becomes somewhat similar to SVN workflows, with the addition that one
*can* use local commits and branches:
svn checkout --> git clone
svn update --> git pull
svn commit --> git push
You can have multiple remotes in each working clone, for the ease of
synchronizing between the multiple parties:
$ cd ~/dev
$ git clone /repos/foo.git # or the one from github, ...
$ cd foo
$ git remote add github ...
$ git remote add memorystick ...
You can then fetch/pull from each of the "sources", work and commit
locally, and then push ("backup") to each of these remotes when you
are ready with something like (note how that pushes the *same* commits
and history to each of the remotes!):
$ for remote in origin github memorystick; do git push $remote; done
The easiest way to turn an existing working repository `~/dev/foo`
into such a bare repository is probably:
$ cd ~/dev
$ git clone --bare foo /repos/foo.git
$ mv foo foo.old
$ git clone /repos/foo.git
which is mostly equivalent to a `svn import`--but does not throw the
existing, "local" history away.
Note: *submodules* are a mechanism to include shared *related*
lineages, so I indeed wouldn't consider them an appropriate tool for
the problem you are trying to solve.
|
I'm not sure if I completely understand this, but:
70966 / 70 seconds = 1013.8
So dividing the "value" by 1013.8 should get the duration, approximately...
Edit: Yes, Ben is right, you should divide by 1000. I got 1013.8 because the 70 seconds was rounded down from 70.966 seconds to 70. |
> Is what I'm trying to do possible? If so, what am I doing wrong?
It's certainly possible. What's wrong is that `HTMLDecorator.__init__()` doesn't accept parameters.
Here's a simple example:
def decorator (func):
def new_func ():
return "new_func %s" % func ()
return new_func
@decorator
def a ():
return "a"
def b ():
return "b"
print a() # new_func a
print decorator (b)() # new_func b |
To expand on what [Ben][1] said, it looks like they are milliseconds, and the display value is rounded slightly, possibly to the nearest 100 milliseconds and then 'cropped' to seconds. This would explain why 30533 is 30s and 70966 is 70s.
[1]: http://stackoverflow.com/questions/37483/calculate-video-duration#37485 |
Your almost looking at it the wrong way, no 3party tool that is not aware of your application methods/naming/data/domain is going to going to be able to perfectly protect you.
Something like SQL injection prevention is something that has to be in the code, and best written by the people that wrote the SQL, because they are the ones that will know what should/shouldnt be in those fields (unless your project has very good docs)
Your right, this all has been done before. You dont quite have to reinvent the wheel, but you do have to carve a new one because of a differences in everyone's axle diameters.
This is not a drop-in and run problem, you really do have to be familiar with what exactly SQL injection is before you can prevent it. It is a sneaky problem, so it takes equally sneaky protections.
These 2 links taught me far more then the basics on the subject to get started, and helped me better phrase my future lookups on specific questions that weren't answered.
* <http://en.wikipedia.org/wiki/SQL_injection>
* <http://www.unixwiz.net/techtips/sql-injection.html>
And while this one isnt quite a 100% finder, it will "show you the light" on existing problem in your existing code, but like with webstandards, dont stop coding once you pass this test.
* <http://www.securitycompass.com/exploitme.shtml> |
Xcopy keeps the Date Modified, only the Date Created and Date Accessed will change.
(tested on XP Pro, try it on a small folder to check if you're using Vista as I did not test it under Vista) |
Xcopy keeps the Date Modified, only the Date Created and Date Accessed will change.
(tested on XP Pro, try it on a small folder to check if you're using Vista as I did not test it under Vista)
Edit: You MAY want to redirect the Output though:
xcopy /K /R ....... s:\*.* t:\ >c:\xcopy.log 2>&1
That way, if files fail to copy you can check the log (i.e. System Volume Information will generate an error, but that folder does not matter anyway for what you're trying to do) |
The CC.Net interface is generated via an XSL transform on your XML files put together as specified in the ccnet.config file for your projects. The XSL is already written for things like FxCop - check your server's CC xsl directory for examples - shouldn't be too hard to write your own to add in the info - just remember to add the XML output from your tests into the main log. |
If you've already got a bunch of custom tasks you use with nAnt, stick with it - you don't gain much with MSBuild. That said, there doesn't seem to be anything that nAnt can do that MSBuild can't at its core. Both can call external tools, both can run .Net-based custom tasks, and both have a bunch of community tasks out there.
We're using MSBuild here for the same reason you are - it's the default build system for VS now, and we didn't have any nAnt-specific stuff to worry about.
The [MSBuildCommunityTasks][1] are a good third-party task base to start with, and covers most of the custom stuff I ever did in nAnt, including VSS and Subversion support.
[1]: http://msbuildtasks.tigris.org/ |
On windows, curses works out of the box, ncurses doesn't, and for a progress bar curses should be sufficient. So, use curses instead of ncurses.
Also, both curses and ncurses are wafer-thin wrappers around the c library - that means you don't really need Ruby-specific tutorials.
However, on the [site for the PickAxe](http://www.pragprog.com/titles/ruby/source_code) you can download all the code examples for the book. The file "ex1423.rb" contains a curses demo which plays Pong - that should give you plenty of material to get you going. |
Sanitising user input using Python |
|python|xss| |
What's the best way to sanitise user input for a Python-based web app? Is there a single function to remove HTML chars and any other necessary characters combinations to ensure that an XSS or SQL injection attack isn't possible?
|
Lightweight source control |
|sourcecontrol| |
I am looking for a lightweight source control system for use on "hobby" projects with only one person (myself) working on the project. Does anyone have any suggestions? |
|version-control| |
|sourcecontrol| |
I am looking for a lightweight source control system for use on "hobby" projects with only one person (myself) working on the project. Does anyone have any suggestions? Ideally it should interface with Visual Studio to either naively or through another plug-in, outside of that, anything that works would be nice to be replace Gmail as source control.
|
|version-control| |
I am looking for a lightweight source control system for use on "hobby" projects with only one person (myself) working on the project. Does anyone have any suggestions? Ideally it should interface with Visual Studio either naively or through another plug-in, outside of that, anything that works would be nice to be replace Gmail as source control.
|
How do you download and extract a gzipped file with C#? |
|c#|gzip| |
I need to periodically download, extract and save the contents of http://data.dot.state.mn.us/dds/det_sample.xml.gz to disk. Anyone have experience downloading gzipped files with C#? |
|c#|.net|gzip| |
**break** causes the program counter to jump out of the scope of the innermost loop
for(i = 0; i < 10; i++)
{
if(i == 2)
break;
}
Works like this
for(i = 0; i < 10; i++)
{
if(i == 2)
goto BREAK;
}
BREAK:;
**continue** jumps to the end of the loop. In a for loop, continue jumps to the increment expression.
for(i = 0; i < 10; i++)
{
if(i == 2)
continue;
printf("%d", i);
}
Works like this
for(i = 0; i < 10; i++)
{
if(i == 2)
goto CONTINUE;
printf("%d", i);
CONTINUE:;
}
|
If you have access to SQL Server, then SourceGear's Vault is free for a single user. If you want to go even further, Axosoft's OnTime issue tracking is also free for single user use. I use both at home (for free) and we also use both (licensed) at our company. Both integrate into Visual Studio, and OnTime also supports Vault integration. |
It's a simple matter of division:
- 70966 / 70 seconds (1:10 minutes) = 1013.8
- 30533 / 30 = 1017.76
- 7007 / 7 = 1001
Looks like the numbers are nothing but milliseconds. 70966 displays as 1:10 minutes because it shaves of the millisecond part (last 3 digits). |
Asserts in C/C++ only run in debug builds. So this won't happen at runtime. In general asserts should mark things that if they happen indicate a bug, and generally show assumptions in your code etc.
If you want to have code that checks for errors at runtime (in release) you should probably use exceptions rather than asserts as these are what they are designed to do. Your answer basically wraps an exception thrower in assert syntax. While this will work, there is no particular advantage to this that I can see over just throwing the exception in the first place. |
@shrughes.blogspot.com:
I don't know about removing all but two - I've been sketching out various runs of the algorithm and assuming that parallel runs may remove an edge more than once I can't find a situation where I'm left without a spanning tree. Whether or not it's minimal I don't know. |
How about parsing the HTML data and extracting the data with the help of the parser ?
I'd try something like the author described in chapter 8.3 in the Dive Into Python [(link)][1] book
[1]: http://diveintopython.org/ |
Yes, as a matter of fact there is. You will need to write a custom assert function yourself, as C++'s `assert()` is exactly C's `assert()`, with the `abort()` "feature" bundled in. Fortunately, this is surprisingly straightforward.
_Assert.hh_
template <typename X, typename A>
inline void Assert(A assertion)
{
if( !assertion ) throw X();
}
The above function will throw an exception if a predicate doesn't hold. You will then have the chance to catch the exception. If you don't catch the exception, `terminate()` will be called, which will end the program similarly to `abort()`.
You may wonder what about optimizing away the assertion when we're building for production. In this case, you can define constants that will signify that you're building for production and then refer to the constant when you `Assert()`.
_debug.hh_
#ifdef NDEBUG
const bool CHECK_WRONG = false;
#else
const bool CHECK_WRONG = true;
#endif
_main.cc_
#include<iostream>
struct Wrong { };
int main()
{
try {
Assert<Wrong>(!CHECK_WRONG || 2 + 2 == 5);
std::cout << "I can go to sleep now.\n";
}
catch( Wrong e ) {
std::cerr << "Someone is wrong on the internet!\n";
}
return 0;
}
If `CHECK_WRONG` is a constant then the call to `Assert()` will be compiled away in production, even if the assertion is not a constant expression. There is a slight disadvantage in that by referring to `CHECK_WRONG` we type a little more. But in exchange we gain an advantage in that we can classify various groups of assertions and enable and disable each of them as we see fit. So, for example we could define a group of assertions that we want enabled even in production code, and then define a group of assertions that we only want to see in development builds.
For more details on this technique see Bjarne Stroustrup's The C++ Programming Language 3e, section 24.3.7.2. |
Get a keyboard launcher program like [Launchy][1]
[1]: http://www.launchy.net/ |
How do I get the current location of an iframe? |
|asp.net|javascript|dom|iframe| |
I have built a basic data entry application allowing users to browse external content in iframe and enter data quickly from the same page. One of the data variables is the URL.
Ideally I would like to be able to load the iframes current url into a textbox with javascript. I realize now that this is not going to happen due to security issues.
Has anyone done anything on the server side? or know of any .Net browser in browser controls. The ultimate goal is to just give the user an easy method of extracting the url of the page they are viewing in the iframe It doesn't necessarily HAVE to be an iframe, a browser in the browser would be ideal.
Thanks,
Adam
|
[AutoHotkey][1] is a reasonably god program for implementing windows key shortcuts. You might instead define WIN + G to be "open browser to google" which gives you a better response time (don't have to wait for start menu to popup, etc)
There are macro programs that change the macros used based on the window that's in focus. I've never needed that much control, but you might want to look into that.
-Adam
[1]: http://www.autohotkey.com/ |
How can I avoid global state? |
|testing|state|global| |
So, I was reading the Google testing blog, and it says that global state is bad and makes it hard to write tests. I believe it--my code is difficult to test right now. So how do I avoid global state?
The biggest things I use global state (as I understand it) for is managing key pieces of information between our development, acceptance, and production environments. For example, I have a static class named "Globals" with a static member called "DBConnectionString." When the application loads, it determines which connection string to load, and populates Globals.DBConnectionString. I load file paths, server names, and other information in the Globals class.
Some of my functions rely on the global variables. So, when I test my functions, I have to remember to set certain globals first or else the tests will fail. I'd like to avoid this.
Is there a good way to manage state information? (Or am I understanding global state incorrectly?)
thanks,
Jim
|
I use a lot the "intellisense" snippets in Visual Studio. You can include your own snippets and press double tab when they appear in the list. That's definitely a time saver. |
Not that performance usually matters with 99% of the times you need to do this, but if you had to do this in a loop several million times I would highly suggest that you use .Equals or == because as soon as it finds a character that doesn't match it throws the whole thing out as false, but if you use the CompareTo it will have to figure out which character is less than the other, leading to slightly worse performance time.
If your app will be running in different countries, I'd recommend that you take a look at the CultureInfo implications and possibly use .Equals. Since I only really write apps for the US (and don't care if it doesn't work properly by someone), I always just use ==. |
Get the current logged in OS user in Adobe Air |
|apache-flex|air| |