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
JawnV6
Jul 4, 2004

So hot ...

artificialj posted:

Cool, thanks, I'll look into that one.

I understand why you're providing a solution but honestly gaming the vote on a conservative echo chamber poll will, at best, feed into a persecution complex.

Adbot
ADBOT LOVES YOU

tef
May 30, 2004

-> some l-system crap ->
install a proxy that slows down access to those websites until she gets bored & frustrated of loading them

Apocadall
Mar 25, 2010

Aren't you the guitarist for the feed dogs?

How long does it take to be able to write code without constantly looking stuff up to make sure I'm doing it right? I've gotten to the point where I know where I need to put stuff and what does what inside the code but when it comes to actually implementing it all into something my brain just cuts out on me. I'm using Python, and am having fun with it regardless of said brain killing difficulties.

Mobius
Sep 26, 2000

Apocadall posted:

How long does it take to be able to write code without constantly looking stuff up to make sure I'm doing it right? I've gotten to the point where I know where I need to put stuff and what does what inside the code but when it comes to actually implementing it all into something my brain just cuts out on me. I'm using Python, and am having fun with it regardless of said brain killing difficulties.

What kind of "stuff"? Basic syntax? Library APIs? Basic syntax should come naturally pretty quickly -- probably within a couple of projects. As for APIs... You'll be looking those up for the rest of your life.

MrMoo
Sep 14, 2000

A question regarding bijection, a few database-free image hosting configurations like the belated Waffles use an extended base path, e.g. base64, base62, or base36, with minor modification for URL encoding. This produces a long URL, 22 characters if using MD5 checksums of the file contents for example:

https://wi.somethingawful.com/bf/bfeda567b2173dcc96f2f6b0efba56fba6c6bb93.jpg

Many of the popular sites now use shortened identifiers similar to URL shorteners, e.g.

http://i.imgur.com/dgsJW.jpg

Which would appear to be a base62 ID allowing up to a billion resources with five digits, bijection is used to randomize the number space to prevent idle snooping I guess.

Now the dumb question, is the basic psuedo-random number generator (PRNG) also a bijection function? Does reducing the size of the finite field affect the bijection status if not to a round number in the native base?

code:
f(x) = (x * 1103515245 + 12345) % (62 * 62 * 62 * 62 * 62)

MrMoo fucked around with this message at 19:44 on May 14, 2011

Apocadall
Mar 25, 2010

Aren't you the guitarist for the feed dogs?

Mobius posted:

What kind of "stuff"? Basic syntax? Library APIs? Basic syntax should come naturally pretty quickly -- probably within a couple of projects. As for APIs... You'll be looking those up for the rest of your life.

To give an example, I downloaded a nifty little open source game called Singularity and it's written in Python. I can look through the code and tell exactly what everything is doing, but when it comes to me sitting and writing something on my own I have trouble thinking about it.

raminasi
Jan 25, 2005

a last drink with no ice

Apocadall posted:

To give an example, I downloaded a nifty little open source game called Singularity and it's written in Python. I can look through the code and tell exactly what everything is doing, but when it comes to me sitting and writing something on my own I have trouble thinking about it.

You're just going to have to try and do it wrong a lot. The only way to become a good programmer is to be a bad one first.

Apocadall
Mar 25, 2010

Aren't you the guitarist for the feed dogs?

GrumpyDoctor posted:

You're just going to have to try and do it wrong a lot. The only way to become a good programmer is to be a bad one first.

Well you know what they say, you learn more from failure then success.

spiritual bypass
Feb 19, 2008

Grimey Drawer

Apocadall posted:

How long does it take to be able to write code without constantly looking stuff up

Never. You will always have the documentation open. Sure, you'll memorize the functions you use the most, but for many languages it's just not practical to know the name and arguments of every useful function.

polyfractal
Dec 20, 2004

Unwind my riddle.
I've been importing a bunch of XML files into a MySQL database. Due to a quirk in my import script that I didn't catch until 20,000 files had already been imported, I have an annoying situation I'm not sure of the best way to fix. The table schema is simple:

code:
"keyword" - primary, varchar
"occurrences" - int
The quirk is that some of the keywords became mangled with pound signs, so what should be a single entry looks like this instead:

code:
[exampleKeyword] => 10
[#,exampleKeyword] => 15
[#,&#,exampleKeyword] => 2
I need to merge all these variations into the correct "exampleKeyword" entry. What would be the best way to accomplish this? My current thought is to drop the primary on the table, programmatically rename all the mangled outliers, update original entry with all duplicates then drop the extraneous duplicates.

Is there a better way to accomplish this?

Thermopyle
Jul 1, 2003

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

Not having dealt with this before, what are the tradeoffs of storing binary files in a database (I'm thinking about MySQL, but haven't actually settled on anything yet) versus storing paths to filesystem locations?

The project I'm thinking about would probably have files up to maybe 10MB, if that makes any difference.

Ireland Sucks
May 16, 2004

Blegh i've gotten in over my head with some c++ thing so it's time to ask the internet

class definitions
code:
//the base class
class objWeapon: NSObject {
public:
	objWeapon(b2World *world,CCLayer *layer, b2Vec2 pos, NSString *file,  b2PolygonShape weaponBox;);
	//other poo poo
};

//one of many derived classes
class weapFork: public objWeapon{
	weapFork(b2World *world, CCLayer *layer, b2Vec2 pos);
};
class implementations
code:
//constructor for the base object where most of the building happens
objWeapon::objWeapon(b2World *world, CCLayer *layer, b2Vec2 pos, NSString* file, b2PolygonShape weaponBox){
	//irrelevant code
	
}

//derived class constructor
//I'm trying to make a few weapon specific things here before passing them to the base class constructor
weapFork::weapFork(b2World *world, CCLayer *layer, b2Vec2 pos)
	:objWeapon(world, layer, pos, @"forkarm2.png", weaponBox)	//<--- weaponBox is not in scope compiler error
{
        b2PolygonShape weaponBox;
	b2Vec2 vers[4];
	vers[0].Set(-0.6f, -0.5f);
	vers[1].Set(1.0f, -0.9f);
	vers[2].Set(1.0f, -0.6f);
	vers[3].Set(-0.6f, -0.4f);
	weaponBox.Set(vers, 3);		
}
I'm trying to create a bunch of different 'weapon' classes with their own image filepaths and shapes, all descended from a base weapon object (objWeapon). The problem I have is that I am trying to set up the weaponBox object in the weapFork constructor which is dumb and I am dumb because the objWeapon constructor is being called first. Where would be a good place to set the weaponBox object up?

I could give up and just put a massive switch statement in the base class constructor or something but I prefer to waste lots of time trying to make nice code without the knowledge to do so. Thanks!

nielsm
Jun 1, 2009



Make a protected function in the base class to set that box, or let all your objects start out in an uninitialised state and then have an Init function that can be called whenever.

rjmccall
Sep 7, 2007

no worries friend
Fun Shoe
The easiest solution is to have a separate function build and return a temporary box which you can then pass down to the base constructor:

code:
class weakFork {
  ...
 private:
  static b2PolygonShape makeDefaultWeaponBox() {
    b2PolygonShape weaponBox;
    b2Vec2 vers[4];
    vers[0].Set(-0.6f, -0.5f);
    vers[1].Set(1.0f, -0.9f);
    vers[2].Set(1.0f, -0.6f);
    vers[3].Set(-0.6f, -0.4f);
    weaponBox.Set(vers, 3);		
    return weaponBox;
  }
};

weapFork::weapFork(b2World *world, CCLayer *layer, b2Vec2 pos)
	: objWeapon(world, layer, pos, @"forkarm2.png", makeDefaultWeaponBox())
This does not, in fact, cause the weapon box to be copied any more than usual.

Ireland Sucks
May 16, 2004

That worked flawlessly, thanks guys

kimbo305
Jun 9, 2007

actually, yeah, I am a little mad
Everywhere, lots of posters use the convention name at domain to show their emails. I'm sure in the early days, it would have thwarted some bot crawling for addresses, but surely all of the possible "easy" variants people use are incorporated into bots now?
My question is, is there a point? I get that people who do "my posting name" or such might make it not worth it to parse, but the specific name at domain format seems useless.

Shy
Mar 20, 2010

kimbo305 posted:

Everywhere, lots of posters use the convention name at domain to show their emails. I'm sure in the early days, it would have thwarted some bot crawling for addresses, but surely all of the possible "easy" variants people use are incorporated into bots now?
My question is, is there a point? I get that people who do "my posting name" or such might make it not worth it to parse, but the specific name at domain format seems useless.

It still would be much harder for a bot to parse email addresses with various combinations of replaced symbols. Not saying that such bots don't exist but they would probably get a lot of noise data.

Shy fucked around with this message at 13:41 on Oct 23, 2018

kimbo305
Jun 9, 2007

actually, yeah, I am a little mad

Shy posted:

It still would be much harder for a bot to parse email addresses with various combinations of replaced symbols. Not saying that such bots don't exist (I don't know) but they would probably get a lot of noise data.

If it were me doing it, I'd probably just have the last group try to match against a huge pile of well-known/used domains. gmail|hotmail|etc. That would filter legit addresses out but probably be more accurate.

ShardPhoenix
Jun 15, 2001

Pickle: Inspected.

kimbo305 posted:

Everywhere, lots of posters use the convention name at domain to show their emails. I'm sure in the early days, it would have thwarted some bot crawling for addresses, but surely all of the possible "easy" variants people use are incorporated into bots now?
My question is, is there a point? I get that people who do "my posting name" or such might make it not worth it to parse, but the specific name at domain format seems useless.
I find spam filters are pretty effective these days anyway. I don't think trying to hide your email address if worth the inconvenience to the people who you actually want to email you, though I suppose for a lot of people it's just habit.

pokeyman
Nov 26, 2006

That elephant ate my entire platoon.

ShardPhoenix posted:

I find spam filters are pretty effective these days anyway. I don't think trying to hide your email address if worth the inconvenience to the people who you actually want to email you, though I suppose for a lot of people it's just habit.

I like when the "obfuscated" email address is an unobfuscated mailto link.

And I agree, you're not avoiding much spam by using words instead of punctuation. If it's that important to you, make it an image.

rolleyes
Nov 16, 2006

Sometimes you have to roll the hard... two?
I agree that spam filtering has come a long way - Gmail's spam filter is pretty outstanding to the point that I can't remember any false positives and very rarely (like once or twice a month) get a false negative, which is dealt with by hitting the "Report Spam" button. I have noticed a slight uptick in false negatives in the last month, which I'm attributing to the fact that I have a PSN account. Sony! :argh:

kimbo305
Jun 9, 2007

actually, yeah, I am a little mad
Right -- I've never had issues with spam in Gmail, but my work's corporate email provider has a garbage filter, and I imagine there's still plenty of non-Gmail users who are getting flooded with spam. I was just curious if it was well established or not that formatting emails was actually defeating bots.

rolleyes
Nov 16, 2006

Sometimes you have to roll the hard... two?

kimbo305 posted:

Right -- I've never had issues with spam in Gmail, but my work's corporate email provider has a garbage filter, and I imagine there's still plenty of non-Gmail users who are getting flooded with spam. I was just curious if it was well established or not that formatting emails was actually defeating bots.

At this point I doubt it, a few regexps and substitution rules defeat most of the standard formats. As has already been mentioned it all depends on how much noise (invalid email addresses) the spammer is willing to tolerate, but as the financial penalty for sending to an invalid email address is all but non-existent due to the low cost of spamming you'd have to have a really low SNR to make it not worth trying to beat the obfuscation.

Scaevolus
Apr 16, 2007

kimbo305 posted:

Everywhere, lots of posters use the convention name at domain to show their emails. I'm sure in the early days, it would have thwarted some bot crawling for addresses, but surely all of the possible "easy" variants people use are incorporated into bots now?
My question is, is there a point? I get that people who do "my posting name" or such might make it not worth it to parse, but the specific name at domain format seems useless.
Someone actually did quantitative testing of different methods a few years ago. "foo AT blah DOT com" nets 250x less spam than plaintext, so it's not completely worthless.

Jonnty
Aug 2, 2007

The enemy has become a flaming star!

Scaevolus posted:

Someone actually did quantitative testing of different methods a few years ago. "foo AT blah DOT com" nets 250x less spam than plaintext, so it's not completely worthless.

It's the usual relative security thing: as long as there's enough people who don't obfuscate, there's no point in trying to do complicated, failure-prone parsing when you could just nab the easy ones.

Rick Rickshaw
Feb 21, 2007

I am not disappointed I lost the PGA Championship. Nope, I am not.
I'm using regex to parse out some information about files based on their filenames and/or the folders they're contained in. I'm not very experienced in regex, so I can't figure out this surely simple problem.

I'm attempting to parse out year data, but I don't want it picking up on the 1080 that appears in 1080p.

My regex pattern: "[1,2][9,0][0-9][0-9]". I believe I could change it so that it ignores strings with an 8 in the 3rd position (I may have even got this working), though then I'll fail to match on 1980-1989. Any words of wisdom, regex gurus? It does not need to be efficient or elegant - just work.

In case there is any confusion, the logic I'm looking for is (MATCH ON "[1-2][9,0][0-9][0-9]" BUT NOT "1080")

Rick Rickshaw fucked around with this message at 13:26 on May 19, 2011

nielsm
Jun 1, 2009



Unless you are using a rather non-standard regex engine, you don't use commas in [] groups, just: [12][90][0-9][0-9]

As for not matching specifically "1080p", if you know it is always in that form and never only "1080", you can add a negated class: [12][90][0-9][0-9][^p] Just be aware that you're then catching one character too much.
If your regex engine also does irregular expressions, specifically forward assertions, you could use an assertion that the year must not be followed by a 'p'.
Another thing you might be able to do: (19|20)[0-9][0-9] Just be careful about capture groups, if you use those, you should probably use a grouping operator that doesn't capture if you have that available.

shrughes
Oct 11, 2008

(call/cc call/cc)

Rick Rickshaw posted:

I'm using regex

FFS please tell us what kind of regex.

Rick Rickshaw
Feb 21, 2007

I am not disappointed I lost the PGA Championship. Nope, I am not.

nielsm posted:

Unless you are using a rather non-standard regex engine, you don't use commas in [] groups, just: [12][90][0-9][0-9]

As for not matching specifically "1080p", if you know it is always in that form and never only "1080", you can add a negated class: [12][90][0-9][0-9][^p] Just be aware that you're then catching one character too much.
If your regex engine also does irregular expressions, specifically forward assertions, you could use an assertion that the year must not be followed by a 'p'.
Another thing you might be able to do: (19|20)[0-9][0-9] Just be careful about capture groups, if you use those, you should probably use a grouping operator that doesn't capture if you have that available.

Negating the "p" was an option I unfortunately already explored. It's not ideal, since the characters I'm trying to match on could be at the end of the string, plus the annoyance of capturing whatever character followed the year. Obviously a minor one, but when there should be a better option it becomes amplified.

However, (19|20)[0-9][0-9] works like a charm. Thanks a lot!

Modern Pragmatist
Aug 20, 2008

Rick Rickshaw posted:

Negating the "p" was an option I unfortunately already explored. It's not ideal, since the characters I'm trying to match on could be at the end of the string, plus the annoyance of capturing whatever character followed the year. Obviously a minor one, but when there should be a better option it becomes amplified.

However, (19|20)[0-9][0-9] works like a charm. Thanks a lot!

It doesn't matter if they are at the end of a string. Your assertion is basically saying that the date isn't followed by "p". Also, the lookahead assertion doesn't include the next character (if there is one) in the result.

Try this:
code:
[0-9]{4}(?!p)

Rick Rickshaw
Feb 21, 2007

I am not disappointed I lost the PGA Championship. Nope, I am not.

Modern Pragmatist posted:

It doesn't matter if they are at the end of a string. Your assertion is basically saying that the date isn't followed by "p". Also, the lookahead assertion doesn't include the next character (if there is one) in the result.

Try this:
code:
[0-9]{4}(?!p)

There we go. Your syntax for the exclusion of "p" is what I wanted. The syntax I tried (posted above by nielsm) would grab the 5th character. This solution has the added bonus of working up until the year 10,000.

edit: However, I may not use it as it will fail in the event that 1080 is not suffixed by p. I guess I'll have to add another condition if I live to the year 2100.

Rick Rickshaw fucked around with this message at 15:48 on May 19, 2011

double sulk
Jul 2, 2010

This is a general question: why is it that just about every single programming book is absolutely terrible at teaching a respective language? I got a book on C# by O'Reilly, and it goes from having you make the usual Hello World program to using various class/constructor things within 30 pages, also using commands such as get/set without literally explaining what they are, how they work, and what they do.

It also uses examples in a horrendously confusing way, telling you how you could theoretically do one thing, only to say "well, while it can work, this is actually the wrong way to do it, so here's the right way," only leading to more confusion because it starts talking about a completely different variable type or something with which you can achieve the goal.

Am I just really stupid and not meant for programming (at least in terms of languages which are not solely intended for web use), or are these books just awful? Is there any reasonable way to learn the stuff without being confused by poor writers? I'm in a C++ course right now and wanted to supplement it with C# because it/.NET is supposedly a desirable skill to have right now, but when the books are terrible, it's kind of hard to learn anything. I'm not even completely unfamiliar with programming itself, and tried to learn Java when I was much, much younger (I think the age was the biggest difficulty here), but I feel like an idiot.

rolleyes
Nov 16, 2006

Sometimes you have to roll the hard... two?
Many books make the assumption that you know the concepts already and just want to learn the particulars of a given language. In your case it sounds like, taking C#, you want this which a friend has had great success with.

It really does start from absolute basics but the advantage to that is you can skip those parts if you feel you can. You might find the reviews useful to gauge if it's right for you, although I'd ignore the 1 star one from someone of uncertain intelligence who seemed to be expecting a C# book to teach him ASP.NET.

rolleyes fucked around with this message at 01:13 on May 23, 2011

tef
May 30, 2004

-> some l-system crap ->

Sulk posted:

This is a general question: why is it that just about every single programming book is absolutely terrible at teaching a respective language?

object orientation :v:

(no, really)

They try to teach how to structure programs before people understand the foundations.

You may enjoy http://www.htdp.org/2003-09-26/Book/ how to design programs. Once you have a more consistent grasp of programming concepts, it becomes much easier to pick up new languages.

spiritual bypass
Feb 19, 2008

Grimey Drawer
I don't understand why CS courses don't start out with C. It's got everything you need and very little you don't: all the usual datatypes, pointers, arrays, conditionals, and looping, all implemented in a pretty straightforward way. None of it is very difficult, but it's all completely necessary if you're going to get very far in programming.

nielsm
Jun 1, 2009



rt4 posted:

I don't understand why CS courses don't start out with C. It's got everything you need and very little you don't: all the usual datatypes, pointers, arrays, conditionals, and looping, all implemented in a pretty straightforward way. None of it is very difficult, but it's all completely necessary if you're going to get very far in programming.

Already covered earlier:
C requires you to think about memory management and program organisation from the beginning, and requires much more boilerplate (#include <stdio.h> int main() {semicolons}, then get past the compiler) than many other languages. It removes focus from the task at hand: Instructing the computer how to solve a problem.
You can teach the students how to deal with the realities of the machine later.

E: Wait was that in the "coding horrors" thread? Maybe it was.

nielsm fucked around with this message at 14:44 on May 23, 2011

ToxicFrog
Apr 26, 2008


^^ Yeah, that was in the coding horrors thread. I wouldn't be surprised if the discussion has happened in this thread as well, though.

C is good to know and makes a good second language, but it has enough up-front complexity that teaching it as a first language means that learning the specifics of the language gets in the way of learning the concepts of programming.

Zombywuf
Mar 29, 2008

tef posted:

object orientation :v:

(no, really)

They try to teach how to structure programs before people understand the foundations.

You may enjoy http://www.htdp.org/2003-09-26/Book/ how to design programs. Once you have a more consistent grasp of programming concepts, it becomes much easier to pick up new languages.

I'd go further and blame the Design Patterns book. It doesn't contain a single pattern and seriously misleads people into a cookie cutter cargo cult programming.

tef
May 30, 2004

-> some l-system crap ->

rt4 posted:

I don't understand why CS courses don't start out with C. It's got everything you need

Because people have a hard time explaining pointers and stack vs heap. And null terminated strings. And Include files. Other people find data structures useful: Lists, Sets, Dictionaries,

Adbot
ADBOT LOVES YOU

Zombywuf
Mar 29, 2008

tef posted:

Because people have a hard time explaining pointers and stack vs heap. And null terminated strings. And Include files. Other people find data structures useful: Lists, Sets, Dictionaries,

I still say that introducing data structures before having a solid grounding in flow control is a bad idea.

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