Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Post
  • Reply
ToxicFrog
Apr 26, 2008


nielsm posted:

It might be that someone is thoroughly confused about how computers work and they just meant to write that the data must be written as binary. (Although it would be a good idea to specify endianness too.)
"It appears as hexadecimal when I inspect it with my hex editor."

That would be my own immediate assumption too. A lot of people think that "binary data" and "hexadecimal representation of binary data" are the same thing and use "binary", "raw" and "hex" interchangeably.

Adbot
ADBOT LOVES YOU

pokeyman
Nov 26, 2006

That elephant ate my entire platoon.
Maybe I'm missing something but isn't the only difference between the three the filter you're using to look at the data?

And I'm assuming that "raw" in this case means "I opened a binary in Notepad".

ToxicFrog
Apr 26, 2008


pokeyman posted:

Maybe I'm missing something but isn't the only difference between the three the filter you're using to look at the data?

Well, if someone says "I want the data in hexadecimal", what they have implied is that they want a hex dump of the data (eg, as you might get from od -tx1 -An), but what they might actually mean is that they want the original binary file (which they think of as "hex" because they only ever look at it in a hex editor).

TasteMyHouse
Dec 21, 2006
I have a Beagleboard, running Angstrom Linux, which it boots off a microSD card. The SD card, by default, has 2 partitions. The first partition is FAT32 and contains the bootloader, the boot environment script, etc. The second partition is ext4 and contains the Linux filesystem.

The board can be mounted as a USB mass storage device from windows, so I want there to be a large FAT32 partition, so both Linux and Windows will have something to they can read and write to. So far, I've not been very successful in partitioning the card properly -- I can't get there to be a large FAT32 partition without also making the Linux partition unbootable.

There's some particular requirements on how the Linux and boot partitions are laid out. the Angstrom distribution provides a script for formatting the SD card that works perfectly, but I can't grok it thoroughly enough to be able to edit it to add my 3rd partition.

Can anyone help me out with understanding this shell script -----> http://www.angstrom-distribution.org/demo/beagleboard/mkcard.txt ?

pokeyman
Nov 26, 2006

That elephant ate my entire platoon.
Any Octave folk here? (Matlab probably works too.) Is there no way to call a function with arguments formed by destructuring a matrix into its columns?

For example, hypot takes a variable number of arguments and calculates the squared sums between the columns. So if I wanted to find the distance between two sets of points, I might do

code:
X1 = [bunch of 2-dimensional points];
X2 = [same number of 2D points];
diffs = X1 - X2;
distances = hypot(diffs(:, 1), diffs(:, 2));
Can I generalize this somehow, by calling hypot with however many columns I might have? e.g. in Python I might do

code:
distances = hypot(*diffs);

Strong Sauce
Jul 2, 2003

You know I am not really your father.





I would like to know if there is a good heuristic to this problem since I'm not sure if this is a NP-complete type of problem.

I have a word or phrase that I'd like to draw in an area wxh in size by maximizing the amount of space used and using as large of a font-size as possible. We can assume the height remains constant given a specific font-size but that the font is not fixed-width so the width of the word will have to be requested each time you try a new set of linebreaks for the phrase.

I assume this is some type of packing problem with different combinations of line breaks representing the "goods" I'm trying to pack into the container. The only problem is that I'm not trying to pack in as much as possible, just the one using the most amount of space in the area/container.

Anyone have any ideas about how to approach this problem?

shrughes
Oct 11, 2008

(call/cc call/cc)

Strong Sauce posted:

I have a word or phrase that I'd like to draw in an area wxh in size by maximizing the amount of space used and using as large of a font-size as possible. We can assume the height remains constant given a specific font-size but that the font is not fixed-width so the width of the word will have to be requested each time you try a new set of linebreaks for the phrase.

For any font size you can see if the phrase will fit in the box very easily (using greedy word wrapping). Then binary search to find the largest font size (up to your limitations of precision) for which the phrase will fit in the box.

Vaginal Engineer
Jan 23, 2007

pokeyman posted:

Any Octave folk here?

There's a mathematical programming languages thread over in SAL. Might want to try there too.

Strong Sauce
Jul 2, 2003

You know I am not really your father.





shrughes posted:

For any font size you can see if the phrase will fit in the box very easily (using greedy word wrapping). Then binary search to find the largest font size (up to your limitations of precision) for which the phrase will fit in the box.

Thanks. Since I want the font as large as possible, would it be better to just do a regular binary search or just sort from largest font to smallest font and then use a one-sided binary search to get the result?

shrughes
Oct 11, 2008

(call/cc call/cc)

Strong Sauce posted:

Thanks. Since I want the font as large as possible, would it be better to just do a regular binary search or just sort from largest font to smallest font and then use a one-sided binary search to get the result?

That depends on how big your largest font is. There's actually a maximum font size? There are only discrete font sizes??

I would use one-sided binary search from 0 up. That is, I think you'd first try font size X, for example, let X = pi = 3.141592. If the phrase fits, double the size to 2X. Keep doubling it until you get something that doesn't fit. (Make sure the phrase is not the empty string or otherwise empty.) Then you have an interval [2^k * X, 2^(k+1) * X) which contains the maximum possible font size. Binary search into that. It's not what I would call a "regular binary search" since you're binary searching over real numbers, and it's just a question of how precise a result you want.

The truth is that this algorithm is tremendously naive, you could do a lot better -- still using greedy word wrapping -- take any word-wrapped shape that fits and scale up its font size until it fits exactly (either in the width dimension or height). This way you never have to produce the same word wrapping more than once. After you get sufficiently precise, you can prove your solution the most optimal by showing that either increasing the font size will overflow the height because the lines are too wide, or increasing the font size by epsilon will cause an extra line to be needed, if you're maxing out the available width. Greedily wrapping a line with font size "x" is the same algorithm as wrapping a line with font size "x+epsilon" for arbitrarily small epsilon, except that if the width of your line (calculated using font size x) equals the width of your rectangle, that's considered non-fitting. So you could binary search until the lower bound meets this condition.

shrughes fucked around with this message at 04:23 on Dec 5, 2011

Plorkyeran
Mar 22, 2007

To Escape The Shackles Of The Old Forums, We Must Reject The Tribal Negativity He Endorsed
There's a fairly obvious maximum font size of "the largest that will fit in the vertical space", which is trivially calculatable.

Modern Pragmatist
Aug 20, 2008

pokeyman posted:

Any Octave folk here? (Matlab probably works too.) Is there no way to call a function with arguments formed by destructuring a matrix into its columns?

For example, hypot takes a variable number of arguments and calculates the squared sums between the columns. So if I wanted to find the distance between two sets of points, I might do

code:
X1 = [bunch of 2-dimensional points];
X2 = [same number of 2D points];
diffs = X1 - X2;
distances = hypot(diffs(:, 1), diffs(:, 2));
Can I generalize this somehow, by calling hypot with however many columns I might have? e.g. in Python I might do

code:
distances = hypot(*diffs);

Sadly, doing this can get kinda messy. You can use a cell array as the inputs and when you index the cell array with {:} it expands the elements, therefore passing multiple elements to the function
code:
X1 = [bunch of 2-dimensional points];
X2 = [same number of 2D points];
diffs = X1 - X2;
inputs = mat2cell(diffs,size(diffs,1),ones(1,size(diffs,2)));
distances = hypot(inputs{:});
I think that if you want to make things both readable and generalized, you're better off trying to do it another way. For example:
code:
X1 = [bunch of 2-dimensional points];
X2 = [same number of 2D points];
distances = sqrt(sum((X1 - X2).^2,2))

pokeyman
Nov 26, 2006

That elephant ate my entire platoon.
Christ that is ugly. And yeah, I figured out how to do what I wanted to do in my example easily enough. I was just curious about that (lack of a) language feature, as it was the first thing I thought to do and I couldn't make it work. Thanks!

Flaggy
Jul 6, 2007

Grandpa Cthulu needs his napping chair



Grimey Drawer
What program/website do people use to make the banner ads on here. I would like to make one but not a programmer. Any recommendations? Didn't know where else to ask, figured this would be a good place. Thanks.

ToxicFrog
Apr 26, 2008


Flaggy posted:

What program/website do people use to make the banner ads on here. I would like to make one but not a programmer. Any recommendations? Didn't know where else to ask, figured this would be a good place. Thanks.

"Any image editing program", basically. GIMP and Photoshop are likely to be popular choices, but there are a shitload.

the talent deficit
Dec 20, 2003

self-deprecation is a very british trait, and problems can arise when the british attempt to do so with a foreign culture





If I want to release a library for non-commercial use only, what are my options? I thought the Sleepycat license was what I wanted, but upon reading, it turns out I'm wrong.

ShoulderDaemon
Oct 9, 2003
support goon fund
Taco Defender

the talent deficit posted:

If I want to release a library for non-commercial use only, what are my options? I thought the Sleepycat license was what I wanted, but upon reading, it turns out I'm wrong.

Creative Commons Non-Commercial is probably your best bet, although it's not a software-specific license. Note that the open source community won't touch it, either, so you are likely to have very few users. A fairly significant portion of the open source community feels very strongly that software should not have licenses that restrict use in any way whatsoever.

the talent deficit
Dec 20, 2003

self-deprecation is a very british trait, and problems can arise when the british attempt to do so with a foreign culture





ShoulderDaemon posted:

Creative Commons Non-Commercial is probably your best bet, although it's not a software-specific license. Note that the open source community won't touch it, either, so you are likely to have very few users. A fairly significant portion of the open source community feels very strongly that software should not have licenses that restrict use in any way whatsoever.

I've seen a few libraries licensed under CC-NC, but nothing with enough of a profile that I was confident it's actually sensible for software.

We already have hundreds of commercial users of our SDK who pay for the right to use it. We want to release a free version (that isn't crippled) as cheap advertising. We're not really concerned with open source idealists, more just increased openness and exposure without hindering our ability to operate as a for profit business.

Plorkyeran
Mar 22, 2007

To Escape The Shackles Of The Old Forums, We Must Reject The Tribal Negativity He Endorsed
If your SDK is for something run on the client and not a server, the GPL will probably work fine.

Non-commercial licenses aren't very popular for libraries as once you eliminate open source and commercial uses, you're mostly just left with toys.

Suspicious Dish
Sep 24, 2011

2020 is the year of linux on the desktop, bro
Fun Shoe

the talent deficit posted:

I've seen a few libraries licensed under CC-NC, but nothing with enough of a profile that I was confident it's actually sensible for software.

We already have hundreds of commercial users of our SDK who pay for the right to use it. We want to release a free version (that isn't crippled) as cheap advertising. We're not really concerned with open source idealists, more just increased openness and exposure without hindering our ability to operate as a for profit business.

Do not use CC-NC. CC licenses are not designed for software. I'm happy with the MPL or GPL as a compromise. The MPL says that any modifications to the source code must be open-source. The GPL says that any derivatives to the source code must be open-source.

To have an explicit license that says that you don't allow the use of your software in commercial use isn't really aligned with the goals of open source. In fact, read the Open Source Definition, especially clause 6. Any license that you would publish that prohibits use in commercial environment would be classified as "not Open Source" by OSI.

Mr. Crow
May 22, 2008

Snap City mayor for life
Doesn't GPL require you to open up your software source code to any and all? Honestly you probably should ask a lawyer, in an official capacity or otherwise if its for a company.

Suspicious Dish
Sep 24, 2011

2020 is the year of linux on the desktop, bro
Fun Shoe

Mr. Crow posted:

Doesn't GPL require you to open up your software source code to any and all? Honestly you probably should ask a lawyer, in an official capacity or otherwise if its for a company.

Not sure what you mean by that. If you license a program under the GPL, any distributed binary must have freely available source code as well as the means to build it. This means that if you ship source code that relies on a proprietary build system, the code is not GPL compliant.

Additionally, any derivatives of the code must be licensed under GPL as well. This is the "viral" aspect of copyleft. What constitutes a derivative is quite loose: The FSF says that including any GPL code is enough to make it a derivative. The courts, in US, at least, have had a saner definition of "derivative". IANAL. Talk to your legal team.

EDIT: Oh, and this wonderful blog post from a coworker arrived in my RSS reader today: http://blog.verbum.org/2011/12/06/the-gpl-and-distributing-binaries/

Suspicious Dish fucked around with this message at 23:16 on Dec 6, 2011

mobby_6kl
Aug 9, 2009

by Fluffdaddy
Is it possible to stick some javascript into HTML emails to be used in Outlook? Clearly having JS at all isn't a very good security-wise, but if this is supported, I'd gladly exploit this to make a report that will be sent out more palatable...

Suspicious Dish
Sep 24, 2011

2020 is the year of linux on the desktop, bro
Fun Shoe

mobby_6kl posted:

Is it possible to stick some javascript into HTML emails to be used in Outlook? Clearly having JS at all isn't a very good security-wise, but if this is supported, I'd gladly exploit this to make a report that will be sent out more palatable...

I think that JavaScript and VBScript and all that have all been explicitly disallowed inside of Outlook. I remember there being a certain exploit that was possible when you used a specific "type" attribute on the script tag, but I believe it was fixed a long time ago.

Why not just link to a web page containing whatever interactive charts you need?

Dave Stieb
Apr 15, 2010
Can anyone recommend me a good book or resource on raycasting? I've just been doing some basic 3d rendering stuff for a university paper (a pretty simple 3D rendering pipeline with just triangular polygons) and was hoping to delve a little deeper.

piratepilates
Mar 28, 2004

So I will learn to live with it. Because I can live with it. I can live with it.



Lord_Of_Pancake posted:

Can anyone recommend me a good book or resource on raycasting? I've just been doing some basic 3d rendering stuff for a university paper (a pretty simple 3D rendering pipeline with just triangular polygons) and was hoping to delve a little deeper.

This is about 1200 pages of everything to do with raycasting, raytracing, path tracing and everything else you can shake a stick at. with diagrams, pictures, equations and code for everything.

Dave Stieb
Apr 15, 2010

Thanks, I'll check that out.

raminasi
Jan 25, 2005

a last drink with no ice
I have a collection that includes points, lines, and planes (in 3-dimensional space). If I want to do neighbor queries on points (nearest neighbor, nearest k neighbors, whatever) I can use a k-d tree. Is there any technique for if I want to include the lines and the planes in the queries as well? i.e. "find me all the points, lines, and planes within an epsilon of this given point"

72o
Dec 14, 2007

I have little to no programming experience, outside of having briefly looked at a few starter Visual C tutorials (and trying to keep up). My goal is to create a specific tool for work, a simple text template database tool designed for easy retrieval of these via categorised lists, including text strings retrieved via simple macros (for instance, typing .asd would bring up a sentence). Other similar tools we have are updated automatically every time they are run via our network and is of course something I'd want, but I really don't know what goes into making that work.

Would anyone be so kind to steer me in the right direction to start working on something like this? Are there any starter project packages out there that can be modified without having years of know-how? As I mentioned I have a vague familiarity with Visual C, but I don't have a clue whether this is ideal - of course I'd want to use any skills I learn from this to make more tools in the future and probably stick to one language, but I'd take all the advice I can get.

TasteMyHouse
Dec 21, 2006

72o posted:

I have little to no programming experience, outside of having briefly looked at a few starter Visual C tutorials (and trying to keep up). My goal is to create a specific tool for work, a simple text template database tool designed for easy retrieval of these via categorised lists, including text strings retrieved via simple macros (for instance, typing .asd would bring up a sentence). Other similar tools we have are updated automatically every time they are run via our network and is of course something I'd want, but I really don't know what goes into making that work.

Would anyone be so kind to steer me in the right direction to start working on something like this? Are there any starter project packages out there that can be modified without having years of know-how? As I mentioned I have a vague familiarity with Visual C, but I don't have a clue whether this is ideal - of course I'd want to use any skills I learn from this to make more tools in the future and probably stick to one language, but I'd take all the advice I can get.

What do you want to use these sentences for? in what context? My first thought is for you to customize Vim or Emacs, or maybe zsh?

Where do you want to type '.asd' and where do you want the sentence to be brought up, for what purpose?

C is a terrible language for text processing stuff like this. Python, Ruby, Perl, or some similar language would be better, but I wanna understand the problem you're trying to solve better first

Hammerite
Mar 9, 2007

And you don't remember what I said here, either, but it was pompous and stupid.
Jade Ear Joe

GrumpyDoctor posted:

I have a collection that includes points, lines, and planes (in 3-dimensional space). If I want to do neighbor queries on points (nearest neighbor, nearest k neighbors, whatever) I can use a k-d tree. Is there any technique for if I want to include the lines and the planes in the queries as well? i.e. "find me all the points, lines, and planes within an epsilon of this given point"

If you have a point p and a line l then there is a unique point p2 on l that is closest to p. You could just calculate the distance between p and p2, which is then the same as the distance between p and l. The analogous statement also holds for a point and a plane.

In the case where you have a point p and a plane q you calculate the normal l to q passing through p; the point p2 is the intersection of l with q.

In the case where you have a point p and a line l, you express the line in terms of a parameter (t, say), and then express the square-distance s from p to a point on l in terms of t. Then you find the minimum value of ds/dt and calculate its square root to get the distance from p to l (you can also calculate the point p2 at this point, but you don't actually need to).

If this is too inefficient an approach or otherwise impractical then don't mind me, I'm a programming novice.

Suspicious Dish
Sep 24, 2011

2020 is the year of linux on the desktop, bro
Fun Shoe

72o posted:

I have little to no programming experience, outside of having briefly looked at a few starter Visual C tutorials (and trying to keep up). My goal is to create a specific tool for work, a simple text template database tool designed for easy retrieval of these via categorised lists, including text strings retrieved via simple macros (for instance, typing .asd would bring up a sentence). Other similar tools we have are updated automatically every time they are run via our network and is of course something I'd want, but I really don't know what goes into making that work.

That's a very broad goal. Do you want to be able to type .asd in any text widget on the system and have something expanded for you? Just one specific application? A new application where you type those letters? Are you on Windows? OS X? Linux?

Here we go:

If the answer is "a new application" with any OS, just implement the logic in the application itself. I still don't recommend using C, though

Windows:
  • all applications - you use the Win32 APIs to hook into keypresses and do something there.
  • one specific application - the above, but you make sure that the process names match to what you want
  • a new application - The above information, but don't learn C. C# would be the best thing choice.

OS X: I have no idea.

Linux:
  • all applications - a mess of giant things. I recommend hooking into IBus and writing your own input method.
  • one specific application - the above, but make sure that the process names match to what you want.
  • a new application - The above information, but don't learn C. I recommend learning Python and GTK+. (use PyGObject with GObject-Introspection, not PyGTK+), or Python and Qt (use PySide, not PyQt)

ultrafilter
Aug 23, 2007

It's okay if you have any questions.


Hammerite posted:

If you have a point p and a line l then there is a unique point p2 on l that is closest to p. You could just calculate the distance between p and p2, which is then the same as the distance between p and l. The analogous statement also holds for a point and a plane.

In the case where you have a point p and a plane q you calculate the normal l to q passing through p; the point p2 is the intersection of l with q.

In the case where you have a point p and a line l, you express the line in terms of a parameter (t, say), and then express the square-distance s from p to a point on l in terms of t. Then you find the minimum value of ds/dt and calculate its square root to get the distance from p to l (you can also calculate the point p2 at this point, but you don't actually need to).

If this is too inefficient an approach or otherwise impractical then don't mind me, I'm a programming novice.

As long as you're not constrained by memory, this is the right way to go. What you're talking about is a projection, and it's easy to compute by matrix multiplication.

72o
Dec 14, 2007

TasteMyHouse posted:

Suspicious Dish posted:


- Do you want to be able to type .asd in any text widget on the system and have something expanded for you?
- What do you want to use these sentences for? in what context?
- Just one specific application?

The macros I want to use for other chat applications, and making general notes on a various items in other applications for whatever I did, etc.

The templates are pre-written responses in a searchable list for e-mail responses and such, copied to the clipboard. Further on I'd want to make combinable templates, to prevent having to remove and add paragraphs in an e-mail template manually, for instance. As a general example, ticking boxes for what information will be in the template and copied to the clipboard.

- Are you on Windows? OS X? Linux?

Windows.


I have seen colleagues use AutoHotkey for simple applications, but not something I'd want any user to have to use for this. Is C# the best option, then?

Only registered members can see post attachments!

Thermopyle
Jul 1, 2003

...the stupid are cocksure while the intelligent are full of doubt. —Bertrand Russell

72o posted:

- Do you want to be able to type .asd in any text widget on the system and have something expanded for you?
- What do you want to use these sentences for? in what context?
- Just one specific application?

The macros I want to use for other chat applications, and making general notes on a various items in other applications for whatever I did, etc.

The templates are pre-written responses in a searchable list for e-mail responses and such, copied to the clipboard. Further on I'd want to make combinable templates, to prevent having to remove and add paragraphs in an e-mail template manually, for instance. As a general example, ticking boxes for what information will be in the template and copied to the clipboard.

- Are you on Windows? OS X? Linux?

Windows.


I have seen colleagues use AutoHotkey for simple applications, but not something I'd want any user to have to use for this. Is C# the best option, then?



Personally, I'd use AutoIT. It's pretty much perfect for these sorts of things. It's like AHK, but easier to use. You can make fine looking and easy to use applications with either of those languages if you put in the work.

72o
Dec 14, 2007

Thermopyle posted:

Personally, I'd use AutoIT. It's pretty much perfect for these sorts of things. It's like AHK, but easier to use. You can make fine looking and easy to use applications with either of those languages if you put in the work.

That looks pretty interesting, I'll have a look. Thanks, and thanks you other two.

raminasi
Jan 25, 2005

a last drink with no ice

Hammerite posted:

If you have a point p and a line l then there is a unique point p2 on l that is closest to p. You could just calculate the distance between p and p2, which is then the same as the distance between p and l. The analogous statement also holds for a point and a plane.

In the case where you have a point p and a plane q you calculate the normal l to q passing through p; the point p2 is the intersection of l with q.

In the case where you have a point p and a line l, you express the line in terms of a parameter (t, say), and then express the square-distance s from p to a point on l in terms of t. Then you find the minimum value of ds/dt and calculate its square root to get the distance from p to l (you can also calculate the point p2 at this point, but you don't actually need to).

If this is too inefficient an approach or otherwise impractical then don't mind me, I'm a programming novice.

ultrafilter posted:

As long as you're not constrained by memory, this is the right way to go. What you're talking about is a projection, and it's easy to compute by matrix multiplication.

I wasn't clear. I know how to do this; I need to know how to do it more efficiently than a brute-force check against every line or plane in the search space.

nielsm
Jun 1, 2009



GrumpyDoctor posted:

I wasn't clear. I know how to do this; I need to know how to do it more efficiently than a brute-force check against every line or plane in the search space.

Have you looked into BSP? Or maybe an octree.
I don't know if they are really applicable to your problem... not really an expert on 3D geometry.

ultrafilter
Aug 23, 2007

It's okay if you have any questions.


GrumpyDoctor posted:

I wasn't clear. I know how to do this; I need to know how to do it more efficiently than a brute-force check against every line or plane in the search space.

The idea is that for each point/line pair, you store the projection of that point onto the line. Then you can just query it like any other point.

Adbot
ADBOT LOVES YOU

raminasi
Jan 25, 2005

a last drink with no ice

nielsm posted:

Have you looked into BSP? Or maybe an octree.
I don't know if they are really applicable to your problem... not really an expert on 3D geometry.

Yeah, there's a bunch of cool stuff for doing this sort of thing with finite entities (segments, bounded surfaces), but I'm trying to find something analogous for infinite ones (lines and planes).

ultrafilter posted:

The idea is that for each point/line pair, you store the projection of that point onto the line. Then you can just query it like any other point.

Oh, I see. However, I don't think this will save me any time, because each query is only done once. I mean, now I only have to construct the projection of each point to each line/plane one time, but I'm already only doing it once.

raminasi fucked around with this message at 01:01 on Dec 8, 2011

  • 1
  • 2
  • 3
  • 4
  • 5
  • Post
  • Reply