Author Topic: Coders, unite!  (Read 5833 times)

0 Members and 1 Guest are viewing this topic.

Offline Captain Jack Harkness

  • Petter, Brony, and All-Around Cartoon Addict
  • The Beast
  • *****
  • Posts: 2868
  • Gender: Male
  • Or as a friend calls him, Captain Jack Hotness!
Re: Coders, unite!
« Reply #15 on: April 04, 2013, 01:05:02 am »
So I learned a few cool things.  Apparently the memory watch in Visual Studio can evaluate complex statements.  Also, I now know how to run a VBScript from a Perl Script.  Being able to integrate two different languages and have one invoke the other feels freaking epic.
My friend's blog.  Check it out!

I blame/credit The Doctor with inspiring my name change.

Offline Captain Jack Harkness

  • Petter, Brony, and All-Around Cartoon Addict
  • The Beast
  • *****
  • Posts: 2868
  • Gender: Male
  • Or as a friend calls him, Captain Jack Hotness!
Re: Coders, unite!
« Reply #16 on: April 07, 2013, 05:47:52 pm »
In case you weren't aware, it's possible to substitute string patterns in Perl with a simple regular expression.

Code: [Select]
use strict;
use warnings;


my $test_string = 'test%20string%20fuck%20yeah%20bitches';
$test_string =~ s/%20/ /g;
print $test_string;

Let me explain.  The =~ indicates a regular expression.  The s stands for substitution.  The %20 is what you want to replace, the ' ' (Space) is what you want as the replacement, and the g is for global.  Having a global switch just means that you'll replace all instances, as opposed to just the first.

Note that on letters, they'll be case sensitive unless you denote it with an i at the very end next to the g.
My friend's blog.  Check it out!

I blame/credit The Doctor with inspiring my name change.

Offline Joey

  • Bishop
  • ***
  • Posts: 151
Re: Coders, unite!
« Reply #17 on: April 07, 2013, 05:56:58 pm »
I fucking love regular expressions! Everyone in my classes seems to hate them, I cannot for the life of me understand why. :scratch:
"A human is a system for converting dust billions of years ago into dust billions of years from now via a roundabout process which involves checking email a lot." - XKCD

Offline Captain Jack Harkness

  • Petter, Brony, and All-Around Cartoon Addict
  • The Beast
  • *****
  • Posts: 2868
  • Gender: Male
  • Or as a friend calls him, Captain Jack Hotness!
Re: Coders, unite!
« Reply #18 on: April 07, 2013, 06:01:19 pm »
I fucking love regular expressions! Everyone in my classes seems to hate them, I cannot for the life of me understand why. :scratch:

They're simple and powerful indeed.  Also, even VBScript supports them, albeit in a rather unusual way.  You have to create a regular expression object and set the properties and all that jazz.
My friend's blog.  Check it out!

I blame/credit The Doctor with inspiring my name change.

Distind

  • Guest
Re: Coders, unite!
« Reply #19 on: April 08, 2013, 02:37:55 pm »
I fucking love regular expressions! Everyone in my classes seems to hate them, I cannot for the life of me understand why. :scratch:
Wait till you need to read someone else's.

I hate the things because of the damned syntax, I understand the concepts just fine, but the syntax is just miserable.

Offline Captain Jack Harkness

  • Petter, Brony, and All-Around Cartoon Addict
  • The Beast
  • *****
  • Posts: 2868
  • Gender: Male
  • Or as a friend calls him, Captain Jack Hotness!
Re: Coders, unite!
« Reply #20 on: April 18, 2013, 04:07:06 am »
So I just noticed something cool.  As long as the logic's not too complex, you can use a ternary statement to replace a switch statement in Perl.  I mean, you COULD use the Switch statement, but you'd have to have the Switch.pm module on the machine running the script.  If you were to instead use a ternary operator, you could do the logic with nothing more than Perl's native language methods.

(click to show/hide)

I could see such logic working particularly well for a menu system.

Edit:  Shit, why hardcode a value for selection?  You can shift and pass it through the command line when testing out the script running it.  Doing so made me realize that you can test for multiple conditions with the right syntax.

(click to show/hide)

Yeah, this works pretty slickly.  In fact, I can show you some sample tests from my machine.

(click to show/hide)

So you can take this logic one step further and do multiple variable assignment with your ternary statement.

(click to show/hide)

When you run this, you get the following results:

(click to show/hide)

I'm not quite sure how far you can take this thinking in other languages because I haven't tested it.  However, I now know that it works in Perl, and that's awesome.
« Last Edit: April 18, 2013, 05:26:36 am by B-Man »
My friend's blog.  Check it out!

I blame/credit The Doctor with inspiring my name change.

Distind

  • Guest
Re: Coders, unite!
« Reply #21 on: April 18, 2013, 06:33:12 am »
Perl is a natural language for hacking the crap out of, just beware of efficiency concerns should you ever use this in a place where that would be critical.

Offline Yla

  • The Beast
  • *****
  • Posts: 809
  • Gender: Male
Re: Coders, unite!
« Reply #22 on: April 18, 2013, 06:50:22 am »
That said, I've stopped trying to anticipate what people around here want a while ago, I've found it makes things smoother.
For I was an hungred, and ye told me to pull myself up by my bootstraps: I was thirsty, and ye demanded payment for the privilege of thine urine: I was a stranger, and ye deported me: naked, and ye arrested me for indecency.

Offline Sigmaleph

  • Ungodlike
  • Administrator
  • The Beast
  • *****
  • Posts: 3615
    • sigmaleph on tumblr
Re: Coders, unite!
« Reply #23 on: April 18, 2013, 05:53:23 pm »
I mostly do some simple mathy stuff for school on Matlab. Nothing more complicated than Gauss-Jordan elimination, so far.
Σא

Offline Captain Jack Harkness

  • Petter, Brony, and All-Around Cartoon Addict
  • The Beast
  • *****
  • Posts: 2868
  • Gender: Male
  • Or as a friend calls him, Captain Jack Hotness!
Re: Coders, unite!
« Reply #24 on: April 18, 2013, 07:52:20 pm »
@B-Man:

If you've gone this far, you've gone too far. :-p

I see the bug.

(click to show/hide)
My friend's blog.  Check it out!

I blame/credit The Doctor with inspiring my name change.

Offline Yla

  • The Beast
  • *****
  • Posts: 809
  • Gender: Male
Re: Coders, unite!
« Reply #25 on: April 19, 2013, 06:25:58 pm »
There are two conceptually bigger problems with that example. One, it uses 26 checks for a single character, when you can do it more easily with 2. (easily as in, it's faster to code and you don't invite typos, in addition to the performance gain). Second, there's almost certainly a library function for that, so you don't need to code it at all. Always use the appropriate tool.
(That blog, btw, is an enjoyable read and quite informative in showing what not to do.)

I used Matlab during my internship. The language is quite nice, although I despaired at the fact that array indices started counting at 1. :o :o My brain was full of fuck until I got accustomed to the new way of thinking. :D

I'll now be working with generated code for my thesis. Vector intrinsics have a very unwieldy syntax, and working with a rather large block of code that uses them almost exclusively would be a bitch otherwise. (The first draft I wrote by hand using only copy&paste. It was a monotonous, error-prone affair and, oh, it didn't work either)
« Last Edit: April 19, 2013, 06:33:33 pm by Yla »
That said, I've stopped trying to anticipate what people around here want a while ago, I've found it makes things smoother.
For I was an hungred, and ye told me to pull myself up by my bootstraps: I was thirsty, and ye demanded payment for the privilege of thine urine: I was a stranger, and ye deported me: naked, and ye arrested me for indecency.

Offline Sleepy

  • Fuck Yes Sunshine In a Bag
  • The Beast
  • *****
  • Posts: 4598
  • Gender: Female
  • Danger zone
Re: Coders, unite!
« Reply #26 on: April 19, 2013, 07:46:50 pm »
I used Matlab during my internship. The language is quite nice, although I despaired at the fact that array indices started counting at 1. :o :o My brain was full of fuck until I got accustomed to the new way of thinking. :D

I've used R a decent amount, and its indices also start at 1. It's quite maddening, especially since I'm in three comp sci courses right now that use several different languages.
Guys, this is getting creepy. Can we talk about cannibalism instead?

If a clown eats salmon on Tuesday, how much does a triangle weigh on Jupiter? Ask Mr. Wiggins for 10% off of your next dry cleaning bill. -Hades

Offline RavynousHunter

  • Master Thief
  • The Beast
  • *****
  • Posts: 8108
  • Gender: Male
  • A man of no consequence.
    • My Twitter
Re: Coders, unite!
« Reply #27 on: April 21, 2013, 01:35:30 am »
I'm thinking of creating my own mod for Minecraft, while following Pahimar's most excellent Let's Mod series.  Having played with a few of the FTB packs (Mindcrack, Beta, Direwolf20, and Ultimate), I've noticed that steam doesn't get a lot of love.  Yeah, Railcraft has boilers and steam, but using them for anything is painfully inefficient, not to mention a fair bit inelegant with all but the snazziest of setups.

So, my solution?  A steampunk-themed mod inspired by Thief!  I wanna use something kinda resembling how real-life steam works, you have the boilers which have to have water and such to keep running, with steam lines and such, BUT...you need to keep an eye on your pressure levels, which will be conveniently handled by gauges (steampunk isn't steampunk without gauges!) that you can place on steam lines or boilers to give you a visual indication of the pressure (in PSI) in a given steam system.  Steam system being defined as either a boiler or a network of contiguous pipes and any machines to which they're connected.

What would happen if you overpressurize a system, with no emergency release (also craftable, attaches to either a boiler or steam pipe)?  Depends on what you're talkin about, but in general, things explode.  A standard iron boiler would likely end up with roughly the power of half a block of dynamite, whereas an industrial-grade boiler would explode with the force of 4 blocks of dynamite, and the other grades and types will scale between the two.  If its pipes that are overpressurized, a random pipe on the system will be chosen, and it'll blow up, but while it won't do any structural damage (this may change, depending on pipe grade), any living things nearby will take a pretty large hit from the boiling-hot steam and shrapnel.

But!  Its not all steam, after all, Thief isn't all technology.  There's some magic, as well, and I've always been fond of well-done magitech.  One thing I plan on making is steam golems.  They're similar to iron golems, but require more in the way of resources, have a bit less health, but will hit much harder.  Now that I think about it...I wonder how cool it'd be to have a golem that would be able to build a building off blueprints.  Just mark a chest (or other inventory) for them to draw from, give them a blueprint to work with, and they'll set to building!  Hell, maybe work in something to where you can have more than one working on the same building project, as a team...

Anywho, whaddya think?
« Last Edit: April 21, 2013, 01:37:17 am by RavynousHunter »
Quote from: Bra'tac
Life for the sake of life means nothing.

Offline Dan

  • Apprentice
  • **
  • Posts: 99
  • Gender: Male
Re: Coders, unite!
« Reply #28 on: April 21, 2013, 11:17:59 am »
I used Matlab during my internship. The language is quite nice, although I despaired at the fact that array indices started counting at 1. :o :o My brain was full of fuck until I got accustomed to the new way of thinking. :D

I've used R a decent amount, and its indices also start at 1. It's quite maddening, especially since I'm in three comp sci courses right now that use several different languages.
Fortran also uses one-based arrays. I find it convenient that the number of array elements is equal to the array's upper bound.

In Basic of course you can define your own lower bound. The default is zero, but some dialects let you change that.

Offline Sleepy

  • Fuck Yes Sunshine In a Bag
  • The Beast
  • *****
  • Posts: 4598
  • Gender: Female
  • Danger zone
Re: Coders, unite!
« Reply #29 on: April 21, 2013, 11:26:28 am »
I used Matlab during my internship. The language is quite nice, although I despaired at the fact that array indices started counting at 1. :o :o My brain was full of fuck until I got accustomed to the new way of thinking. :D

I've used R a decent amount, and its indices also start at 1. It's quite maddening, especially since I'm in three comp sci courses right now that use several different languages.
Fortran also uses one-based arrays. I find it convenient that the number of array elements is equal to the array's upper bound.

In Basic of course you can define your own lower bound. The default is zero, but some dialects let you change that.

It was admittedly handy since we used R for a lot of statistical analysis and simulations, so we didn't have to second-guess ourselves when using and plotting array elements.

For my object-oriented programming class, we're currently making Facebook. It's quite fun, I must say, and I can't wait to see how it turns out. The worst part is the persistence layer, because we're manually saving files to disk, then manually repopulating the system at bootstrap time. We've been fooling around with CSS templates since we want our page to look pretty, but they're cranky for some reason.
Guys, this is getting creepy. Can we talk about cannibalism instead?

If a clown eats salmon on Tuesday, how much does a triangle weigh on Jupiter? Ask Mr. Wiggins for 10% off of your next dry cleaning bill. -Hades