Jump to content

  • Log In with Google      Sign In   
  • Create Account


Member Since 22 Jul 2001
Offline Last Active Jun 14 2016 08:20 AM

#5216833 File upload server

Posted by Zao on 16 March 2015 - 06:26 AM

In the distributed storage software we use, clients authenticate with client certificates over TLS HTTP with the head nodes, which may either proxy the data to the storage pools or redirect the client to issue its PUT to the storage pools over unauthenticated HTTP.


The mechanism of redirect-on-PUT requires that the client _must_ issue a "expect 100 continue" on its initial request. This is so that the server will have the ability to decide on if to accept the data directly (by responding with a 100 continue), or redirect/reject/whatever with 30x/40x.


Our storage uses dynamically opened ports on the storage nodes and have a GUID as query parameter to figure out where to put stuff, but it's in no way secure. In your case, you'd either have to delegate credentials to the clients as part of the URLs, or make your S3 world-writable and pray.

#5157898 will make help me?

Posted by Zao on 03 June 2014 - 12:23 PM

In some projects, includes are required to be relative to the top of the hierarchy. This allows you to have a single include directory, typically with an absolute path, and simply include headers by their full path relative that location.




In which foo.cc would include files in a manner like:


#include <boost/thread/thread.hpp>

#include <my/awesome/graphics/buffer.hpp>

#include <my/awesome/network/buffer.hpp>


By retaining the path information in the include directive you gain location independence and the ability to distinguish between several headers with the same filename.

#5144051 [C++] Is there an easy way to mimic printf()'s behavior?

Posted by Zao on 03 April 2014 - 04:27 AM

Perhaps this would work:

	char str[255];


The core problem with using a C-style printf is that you have to either guess at the length of the resulting string or use one of the "safe" sized variants of printf and attempt with larger and larger buffers until the resulting string fits.


This is more pretty_fatal_stack_smash than pretty_fatal_message_format.

#5043398 Inline assembly

Posted by Zao on 15 March 2013 - 09:10 AM

If you want to do runtime x86 and x86_64 code generation properly (and yes, there's use cases for it), I would recommend using Xbyak. Nice little C++ DSL to generate machine code at runtime, complete with labels, jumping to them and all sorts of nice stuff.

#5009579 Understanding an algorithm solution

Posted by Zao on 11 December 2012 - 05:11 PM

Let's state in plain text what the outer shell of the algorithm does:
For each offset i in the string - take successively larger substrings of even length from that offset, until the end of the string is reached.
i is the left index of the substring, inclusive.
j is the right index of the substring, inclusive. j+1 is the right index of the string, exclusive

We cannot immediately use j in our expressions, as we want to both find out if a substring is even and the substring(off,n) function takes an absolute count n of characters.

We can set up an equation to find the length from i and j, looking for "what number must we add to i to get the index of one character to the right of j":
i + len = j + 1
len = j + 1 - i
len = j - 1 + 1

#4998978 Industry's look on tattoos etc.

Posted by Zao on 08 November 2012 - 01:01 PM

It will most likely make you less desirable for some people and/or studios, compared to an unadorned human. Get the wrong interviewer and you might be racking up some negative points due to their personal opinions and ideals, even subconciously.

In general though, this industry tends to be quite used to strange-looking misfits. Just look at the people in an average art department and you'll see lots of strange stuff.

#4903913 Normalization Approximation in 30 operations

Posted by Zao on 18 January 2012 - 02:18 AM

Although if new things are never tried, nothing is ever advanced.

Trying arbitrary permutations of things without a decent mathematical foundation is not only unproductive, but counter-productive as you cannot really reason about the behavior and properties of the "approximation" you have produced.

This reflects in your confused statements (now some edited away) about just simply applying scaling factors and misuse of terms.

Things like the Carmack sqrt approximation have a foundation in mathematics and architecture (Newton-Rhapson iterations and IEEE754 vs. integer interaction), while your approach just substitutes a function with something with completely different properties and proclaim it to be The Next Best Things without a proper analysis of it.

Heck, a simple mesh plot of your function would have revealed the massive oscillations and regions of infinite results.

#4903651 Normalization Approximation in 30 operations

Posted by Zao on 17 January 2012 - 09:37 AM

Could you please "normalize" the two vectors <1,0,0> and <-1,1,0> for me?

#4771754 c++ private inheritance question

Posted by Zao on 09 February 2011 - 12:05 AM

Long story short, name lookup rules do not care about access. Only after a name is found is the access considered, and then it's too late to do anything about that the name is unusable. If you want to refer to the type, either qualify it explicitly or consider using protected inheritance (which I believe will be sufficient to provide access to the typename).

One interesting thing about this kind of lookup is that MSVC10 will allow your use of a private base in a class template, but Intel 12.0 will not. If you want to be portable, you should therefore qualify typenames that occur in a base.

#4767076 Moving Camera - What should be changed - Viewmatrix or Worldmatrix?

Posted by Zao on 30 January 2011 - 10:44 AM

With the usual three matrices of world/view/projection, the view matrix is used to orientate and place the camera relative to the world, while the world matrix is used to orientate and place objects in the world. It's all just convention though, the math turns out the same way.

I would personally go with modifying the view matrix as you typically have one world matrix per object, but only a few view matrices in total. The imprecision that KulSeran outlines can be worth having in mind, but for game worlds of reasonable scale, it's generally not a problem.

#4762927 Can I create Templated Projects that start up with the files I need?

Posted by Zao on 22 January 2011 - 06:14 AM

An alternative to a template project would be to make a Property Sheet, which is a collection of project settings which when added to a project augments or overrides the base settings for the project.
I have property sheets for the most diverse of things, from things like adding include directories, library directories and libraries for third party libraries to things like changing the runtime library variant, changing the output directory, adding common sets of preprocessor definitions, etc.

Near the Solution Explorer pane, you have a Property Manager view where you can modify and add property sheet files to a project.

#4762276 Struggling with maps in C++

Posted by Zao on 21 January 2011 - 02:28 AM

As some may have hinted to above, the default comparator for a std::map is std::less<Key>, which defaults to operator <, which for pointers just compares addresses.
As mentioned, string literals may be folded together in static storage, ending up comparing equal by coincidence.

The proper solution here if you really must use char const* as your key is to provide a comparator to your std::map, which would do a string comparison with strcmp or a similar function.
Of course, by using raw pointers you run into ownership issues, as you have no way of properly handling the memory the pointers point to. Changing the key type to std::string would most probably be a Good Thing.

Note that operator [] on a std::map default-constructs a value if the key could not be found and inserts it into the container. If you do not desire that behavior, use the find(key) member function which returns an iterator to a key-value pair if the key was found, or the end() iterator if it was not found.

#560549 Distributing modified third party headers

Posted by Zao on 28 January 2010 - 12:30 PM

I am developing a library which will be distributed as sources under a sane free license, probably MIT. The problem I face is that I depend on third party headers I have modified. The headers are not redistributable at all but are available in pristine form from their owner. As my library requires those headers to build, how legal would the following alternatives be:
  1. Bundle the modified headers?
  2. Bundle a set of patches the user must apply to the pristine headers?
  3. Bundle a custom script to process pristine headers the user provides?
Alternative one feels like the safest of the above, as the only connection to the headers is that it's designed to mangle them into the form I require. Would alternative two be considered derivative work somehow, as the patches will contain part of the text of the pristine headers to establish context for applying the patch? Alternative three I assume will be right out, as I'm not even allowed to redistribute pristine headers. The headers in question are the C headers for DirectX, whose license explicitly says which headers may be redistributed (these are not among them).