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
Scaevolus
Apr 16, 2007

Dijkstracula posted:

I don't know the name of such a thing, but why on earth would you want to use that instead of a bit field? Suddenly extracting values becomes Hard-With-A-Capitol-H rather than a simple mask and shift.

Not to mention that you can only store half as many bits in a byte-- 2*3*5*7 = 210 < 256, but 1+2+4+8+16+32+64+128 = 255 < 256. It gets worse the more primes you add.

Adbot
ADBOT LOVES YOU

tef
May 30, 2004

-> some l-system crap ->

quadreb posted:

If you make the prime numbers large enough, you could have a new crypto algorithm to play with.

A good hint: Look at euler's totient function

I propose calling it a bozo enum

nbv4
Aug 21, 2002

by Duchess Gummybuns

Dijkstracula posted:

I don't know the name of such a thing, but why on earth would you want to use that instead of a bit field? Suddenly extracting values becomes Hard-With-A-Capitol-H rather than a simple mask and shift.

Instead of creating a table in my database with a bunch of boolean columns, I can store all the information in one bigint. This way if I want to add a new boolean, instead of creating a new column in my table, I can just factor in a new prime. The only problem is that it would probably overflow the integer after so many primes...

The method I remember reading about may have used addition, because I remember it being used with like 40 different booleans.

nbv4 fucked around with this message at 21:07 on Aug 1, 2009

Avenging Dentist
Oct 1, 2005

oh my god is that a circular saw that does not go in my mouth aaaaagh

nbv4 posted:

Instead of creating a table in my database with a bunch of boolean columns, I can store all the information in one bigint. This way if I want to add a new boolean, instead of creating a new column in my table, I can just factor in a new prime. The only problem is that it would probably overflow the integer after so many primes...

The method I remember reading about may have used addition, because I remember it being used with like 40 different booleans.

Do you know what a bit field is?

Dijkstracula
Mar 18, 2003

You can't spell 'vector field' without me, Professor!

nbv4 posted:

Instead of creating a table in my database with a bunch of boolean columns, I can store all the information in one bigint. This way if I want to add a new boolean, instead of creating a new column in my table, I can just factor in a new prime. The only problem is that it would probably overflow the integer after so many primes...
:psyduck: I'm astonished that this is your solution to this problem. I mean, I hate to perpetuate a sense of elitism in CoC and everything, but I strongly recommend you look at properties of the binary number system before implementing this idea.

nbv4 posted:

The method I remember reading about may have used addition, because I remember it being used with like 40 different booleans.
Go and read the fundamental theorem of arithmetic and tell me if you think a sum of primes works the same was as a product of primes (hint: 2,3,5 are prime. if 2+3 = 5, what does this mean about the uniqueness of a decomposition of a sum of primes?). Also, you remember it wrong.


edit: or, I'm easily trolled? :confused:

Dijkstracula fucked around with this message at 21:26 on Aug 1, 2009

cronio
Feb 15, 2002
Drifter
Someone was reading the coding horrors thread as a programming guide!

http://forums.somethingawful.com/showthread.php?threadid=2803713&userid=0&perpage=40&pagenumber=10

pokeyman
Nov 26, 2006

That elephant ate my entire platoon.
I thought that sounded really familiar.

For what it's worth, it sounds as stupid the second time.

Spug
Dec 10, 2006

Then turn not pale, beloved snail, but come and join the dance.
How do I push some text to the bottom of a page in LaTeX? Some dynamic vertical filler box or something?

Tux Racer
Dec 24, 2005
Can anyone point me to a good resource that explains the differences between different video formats (specifically vob/mpeg-2 and divx/xvid)? I want to create a program that will merge many different video files together, but I don't know where to start.

jupo
Jun 12, 2007

Time flies like an arrow, fruit flies like a banana.
Look into ffmpeg - you'll definitely end up using it.

Tux Racer
Dec 24, 2005
Thanks for the help, but since it is under the gpl, I won't use it. I am looking for information about the formats or maybe video conversion techniques. I can't seem to find much information on the topic.

Avenging Dentist
Oct 1, 2005

oh my god is that a circular saw that does not go in my mouth aaaaagh

mykuhl posted:

Thanks for the help, but since it is under the gpl, I won't use it. I am looking for information about the formats or maybe video conversion techniques. I can't seem to find much information on the topic.

LGPL (unless you're using libpostproc or libswscale).

Tux Racer
Dec 24, 2005
Oh ok I see now. Still some literature on the subject would be nice.

litghost
May 26, 2004
Builder

Spug posted:

How do I push some text to the bottom of a page in LaTeX? Some dynamic vertical filler box or something?

I have a terrible solution that may work for you! Beware that floats may migrate!

code:

\documentclass[a4paper]{report}

\usepackage{float}
\newfloat{bottom}{b}{bot}[part]

\begin{document}


\begin{center}
This text is at the top!
\end{center}
\begin{bottom}
\begin{center}
This text is at the bottom!
\end{center}
\end{bottom}

\newpage
\ 
\begin{bottom}
\begin{center}
This text is at the bottom of an otherwise blank page!
\end{center}
\end{bottom}

\end{document}

HiredGoon
Dec 30, 2005
Anyone? :(

HiredGoon posted:

Hey guys,

I'm sure this is a deathly simple question, but I really appreciate the advice!


I'm building a website on a Tumblr platform, and the last piece of the puzzle for me is truncating longer posts. Tumblr doesn't really allow you to add a 'jump' or a 'break' or a 'read more' kind of thing (as far as I have looked) and I wanted to find a way to include longer, wordier posts without disrupting the rest of the content. I figure CSS is the best way to do this.

I've found this code for truncating posts after a set amount of characters, but it's not doing anything after I paste it into the custom CSS:

code:
<script type="text/javascript">
function truncate() {
  var len = 10;
  var p = document.getElementById('truncateMe');
  if (p) {
    var trunc = p.innerHTML;
    if (trunc.length > len) {

     
      trunc = trunc.substring(0, len);
      trunc = trunc.replace(/w+$/, '');

     
      trunc += '<a href="#" ' +
        'onclick="this.parentNode.innerHTML=' +
        'unescape(''+escape(p.innerHTML)+'');return false;">' +
        '<span style="font-size: 10px;">[ more ... ]</span></a>';
      p.innerHTML = trunc;
    }
  }
}


function addLoadEvent(func) {
  var oldonload = window.onload;
  if (typeof window.onload != 'function') {
    window.onload = func;
  } else {
    window.onload = function() {
      if (oldonload) {
        oldonload();
      }
      func();
    }
  }
}

addLoadEvent(function() {
  truncate();
});
</script>
I also found this guide to adding a 'read more' thing – http://groups.google.com/group/blogger-help-howdoi/browse_frm/thread/fae3eb826955e5a5 – is it Tumblr compatible?


Thanks in advance for any help!

Avenging Dentist
Oct 1, 2005

oh my god is that a circular saw that does not go in my mouth aaaaagh

HiredGoon posted:

Anyone? :(

Well the first thing is: that's not CSS, so I can't fathom why you are putting it into a custom CSS field.

BigRedDot
Mar 6, 2008

litghost posted:

I have a terrible solution that may work for you! Beware that floats may migrate!
Wouldn't \vspace suffice for this?

HiredGoon
Dec 30, 2005

Avenging Dentist posted:

Well the first thing is: that's not CSS, so I can't fathom why you are putting it into a custom CSS field.

Ah. Well, what I have found is:

<style>
<MainOrArchivePage>
span.fullpost {display:none;}
</MainOrArchivePage>
<ItemPage>
span.fullpost {display:inline;}
</ItemPage>
</style>

<MainOrArchivePage><br />
<a href="<$BlogItemPermalinkURL$>">...</a>
</MainOrArchivePage>

Now, I've posted that into the site's code, and it works all fine in inserting the "..." at the end of the post and linking to the individual post. Now, I should be able to use the:

<span class="fullpost">

</span>

Command to truncate my posts at will, but I can't seem to get that part of it to work. Any suggestions?

litghost
May 26, 2004
Builder

BigRedDot posted:

Wouldn't \vspace suffice for this?

What would the input to vspace be? How do you know how much space to add to get the bottom of the page? It is a function of the text on the page and how much text you want to add to the bottom of the page. So no, vspace would not suffice.

BigRedDot
Mar 6, 2008

litghost posted:

What would the input to vspace be? How do you know how much space to add to get the bottom of the page?
Trial and error? It's really not that difficult...

quote:

It is a function of the text on the page and how much text you want to add to the bottom of the page. So no, vspace would not suffice.
*shrug* I assumed he said "dynamically" because he wanted something that worked auto-magically once, not because he was really generating different dynamic content multiple instances.

ShoulderDaemon
Oct 9, 2003
support goon fund
Taco Defender

BigRedDot posted:

Trial and error? It's really not that difficult...

code:
\documentclass{article}

\begin{document}

blah

\vfill

foo

\newpage

quux

\end{document}
TeX is not as dumb as you make it out to be.

litghost
May 26, 2004
Builder

ShoulderDaemon posted:

code:
\documentclass{article}

\begin{document}

blah

\vfill

foo

\newpage

quux

\end{document}
TeX is not as dumb as you make it out to be.

Haha, I tried that but it didn't work, because I was trying it on a blank page. I didn't think or know of of an explicit space (\ ) until I started messing with the float stuff. Ex:


code:
\documentclass{article}

\begin{document}

\vfill

% This will be at the top of the page
foo

\end{document}
code:
\documentclass{article}

\begin{document}

\ 
\vfill

% This will be at the bottom of the page
foo

\end{document}

litghost fucked around with this message at 07:09 on Aug 4, 2009

BigRedDot
Mar 6, 2008

ShoulderDaemon posted:

TeX is not as dumb as you make it out to be.
I didn't happen to remember \vfill, but I don't think TeX is dumb. I have typeset literally several thousand pages with it.

tef
May 30, 2004

-> some l-system crap ->
What's a good way to sort RGB values into a pleasing list?

fankey
Aug 31, 2001

tef posted:

What's a good way to sort RGB values into a pleasing list?
I'd convert to another color space like HSV and then sort on H. Although since most ( every? ) color space has 3 dimensions sorting in a linear list can be hard. But if all your values have similar S and V then sorting on H will probably work.

tef
May 30, 2004

-> some l-system crap ->

fankey posted:

I'd convert to another color space like HSV and then sort on H. Although since most ( every? ) color space has 3 dimensions sorting in a linear list can be hard. But if all your values have similar S and V then sorting on H will probably work.

HSV does give a much more pleasing result than RGB.

I'm tempted by this approach though: http://portal.acm.org/citation.cfm?doid=76359.76361

Xae
Jan 19, 2005

How can I sed or AWK a file so that it replaces every 100th instance of a comma with comma{newline}?

Avenging Dentist
Oct 1, 2005

oh my god is that a circular saw that does not go in my mouth aaaaagh

Xae posted:

How can I sed or AWK a file so that it replaces every 100th instance of a comma with comma{newline}?

Though I can't fathom why you'd voluntarily use sed/awk instead of perl,
code:
sed 's/\(\([^,]*,\)\{99\}[^,]*\),/\1,\n/g'

Lonely Wolf
Jan 20, 2003

Will hawk false idols for heaps and heaps of dough.
Perl is the mindkiller. Perl is the silent death.

Xae
Jan 19, 2005

Avenging Dentist posted:

Though I can't fathom why you'd voluntarily use sed/awk instead of perl,
code:
sed 's/\(\([^,]*,\)\{99\}[^,]*\),/\1,\n/g'

I'm running this through Cygwin. I don't know if it even support perl.

Avenging Dentist
Oct 1, 2005

oh my god is that a circular saw that does not go in my mouth aaaaagh

Xae posted:

I'm running this through Cygwin. I don't know if it even support perl.

According to their website, Perl is a standard package in Cygwin.

Ulta
Oct 3, 2006

Snail on my head ready to go.
I've got a question about regular expressions.

I've got a web app written in C# Asp. There's a textbox users may provide a some input, most likely to be a file location, either on a file share, the Internet, or on disk. This input is later exported to Excell, in code I do not have access to. These locations are inserted as hyperlinks in the excell document. Excell takes it upon itself to validate these links. Most anything is fine, for example "Pizza", "Foo Bar", and "In my filing cabinent" all are fine. However, enter something like "\\my.com pany" (notice the space), when you go to open the file later, you get a greatly descriptive
message from Excel saying, and I quote, "Error"

To head this off at the pass, Ive put a regular expression validator on the input textbox. Writing the part saying no spaces is simple enough

^(\\\\)[^ ]*((\/).*)*$

how do I say if it doesn't start with \\ or [url]http://[/url] I don't care what is in the textbox?

(Spaces after the first / are apparently cool with Excell)

Jethro
Jun 1, 2000

I was raised on the dairy, Bitch!

Ulta posted:

I've got a question about regular expressions.

I've got a web app written in C# Asp. There's a textbox users may provide a some input, most likely to be a file location, either on a file share, the Internet, or on disk. This input is later exported to Excell, in code I do not have access to. These locations are inserted as hyperlinks in the excell document. Excell takes it upon itself to validate these links. Most anything is fine, for example "Pizza", "Foo Bar", and "In my filing cabinent" all are fine. However, enter something like "\\my.com pany" (notice the space), when you go to open the file later, you get a greatly descriptive
message from Excel saying, and I quote, "Error"

To head this off at the pass, Ive put a regular expression validator on the input textbox. Writing the part saying no spaces is simple enough

^(\\\\)[^ ]*((\/).*)*$

how do I say if it doesn't start with \\ or [url]http://[/url] I don't care what is in the textbox?

(Spaces after the first / are apparently cool with Excell)
Since .NET regex lets you use any arbitrary regex in a lookbehind:
code:
^([^ ]|(?<!^(\\\\|[url]http://[/url])[^ \\/]*) )*$
This uses negative lookbehind to say that spaces are okay as long as they aren't preceded by ^(\\\\|[url]http://[/url])[^ \\/]*

EscapeHere
Jan 16, 2005
So this one is freaking me out.

I have this line of code for checking a registry entry:

code:
if(!RegQueryValueEx(hKey, _T("rememberDetails"), NULL, &dwType, (LPBYTE)&dwVal, &dwSize))
{
/* some code here */
}
Assuming the application has been installed correctly, RegQueryValueEx will pretty much always return 0. Tested and confirmed on Windows 95, 98, ME, XP, Vista, 7 Beta 1. Cool, that does what it is meant to.

On Windows 7 RC1 and RTM however, for some reason it returns a non-zero result, even though the registry entry is there. At first I figured something has changed in the library between Windows 7 Beta and Windows 7 RC1, but I can't find anything.

And now the really freaky bit. Simply putting these two lines above fixes the problem:

code:
char msg[CHAR_BUFFER_SIZE];
sprintf_s(msg, CHAR_BUFFER_SIZE, "Blah blah, test, test");
What do those two lines have to do with RegQueryValueEx? Absolutely nothing as far as I can tell, but amazingly you put those two lines in and suddenly RegQueryValueEx starts returning 0, as it should. Remove them and it goes back to returning errors.

This is only in Windows 7 RC1 and beyond.

So, anybody have any clue what is going on here?

Vanadium
Jan 8, 2005

EscapeHere posted:

So, anybody have any clue what is going on here?

You are invoking undefined behaviour in a way that is not immediately obvious from the lines of code you posted.

Avenging Dentist
Oct 1, 2005

oh my god is that a circular saw that does not go in my mouth aaaaagh

Vanadium posted:

You are invoking undefined behaviour in a way that is not immediately obvious from the lines of code you posted.

I would guess that's he's blowing out of the stack somewhere, and adding another stack variable is saving his rear end.

floWenoL
Oct 23, 2002

Avenging Dentist posted:

I would guess that's he's blowing out of the stack somewhere, and adding another stack variable is saving his rear end.

I don't know why, but your statement sounds really gay. :pwn:

Mustach
Mar 2, 2003

In this long line, there's been some real strange genes. You've got 'em all, with some extras thrown in.
Probably because he's gay.

EscapeHere
Jan 16, 2005

Avenging Dentist posted:

I would guess that's he's blowing out of the stack somewhere, and adding another stack variable is saving his rear end.

Thanks. Any ideas on how I might go about debugging this given it works fine with Debug, but not Release?

Adbot
ADBOT LOVES YOU

4VAlien
Jun 19, 2008

EscapeHere posted:

Thanks. Any ideas on how I might go about debugging this given it works fine with Debug, but not Release?

Check all your array boundaries to make sure you are not referencing outside of arrays (most likely cause). Debug mode gives different machine code so the stack does not look the same and you're not breaking it then. Also, what is the meaning of the non zero return code, it might actually mean something.

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