« Previous12Next »
RSS Feed

Code dump

#  Oct 27, 2009 at 2:37 AM
Join Date:
Oct 27, 2007
Post Count:
2357
 
X.Static 79392
Loading...
Specialty: Soldier
Steam ID: jaypatrick
Clan: {TF2F}
SponsorSquigMember
 
Coding is art, so I'll start it off w/ this:

static void Process(int count)
        {
            for (int i = 1; i < count; i += 2)
            {
                int iSquared = (i * i);

                if (((iSquared) - 1) % 8 == 0)
                {
                    int result = ((iSquared - 1) / 8);
                    Console.WriteLine(i + "^2 = " + iSquared + " - 1 = " + ((iSquared) - 1) + " / 8 = " + result);
                }
                else
                {
                    Console.WriteLine("false");
                }
            }
            Console.ReadLine();
        }

I started a bit of a ruckus with these few lines, discussion:

  • Here (my initial post on my weblog)
  • Here (Math major, now works for Microsoft)
  • Here (more in depth explanation)
#  Oct 28, 2009 at 7:18 PM
Join Date:
Nov 30, 2007
Post Count:
7361
 
GManNickG 80805
Loading...
Specialty: Spy
Steam ID: gman_nick
Clan: {TF2F} Community
King SpySquigMember
 
This is a replacement for boost::lexical_cast, for when you can't use boost. (C++)

template <typename T>
T lexical_cast
(const std::string& s)
{
    std
::stringstream ss(s);

    T result
;
   
if ((ss >> result).fail() || !(ss >> std::ws).eof())
   
{
       
throw std::bad_cast();
   
}

   
return result;
}
#  Oct 28, 2009 at 7:46 PM
Join Date:
Mar 29, 2008
Post Count:
1518
 
DMX 83901
Loading...
Specialty: Scout
Steam ID: Hairless_Wookie
GamerTag: PSN:TF2F_DMX2
Clan: (TF2F) PS3
 
Its surprising to see code that has even been as far even as decided to use even go want to do look more like.
#  Oct 28, 2009 at 8:13 PM
Join Date:
Oct 31, 2007
Post Count:
966
 
SpaceBoy2000 79651
Loading...
Specialty: Medic
Steam ID: kwogger
LAN 08 Badge
 
I saw this elegant piece of code at DevDays Toronto (no, I'm not smart enough to come up with code like this). It's in C/C++, and it's replacement for strcpy:

while(*p++=*q++);

Unfortunately, due to strong type casting and bounding checks, it doesn't quite work for Java. The closest you can get is this:

while((p[i++]=q[j++])!=0);

...which is nowhere as elegant, and the lack of null terminated Strings in Java means it's pretty pointless. Oh well, you really shouldn't be using strcpy anyways, but this is still pretty elegant.
#  Oct 28, 2009 at 8:40 PM
Join Date:
Apr 03, 2008
Post Count:
2320
 
Steam ID: Twilight Mage
 

Could somebody please post some instructions for how to use X.Static's code?
I like playing around with Triangular numbers from time to time.
I find them useful in designing some types of games as well.

I did try sticking it in a bat file but that didn't seem to work, as whenever I opened it it would only flash on the screen for a moment before disappearing.

#  Oct 28, 2009 at 8:48 PM
Join Date:
Oct 27, 2007
Post Count:
2357
 
X.Static 79392
Loading...
Specialty: Soldier
Steam ID: jaypatrick
Clan: {TF2F}
SponsorSquigMember
 
It needs to be compiled into an executable, which I might be nice enough to do for you :-).
#  Oct 28, 2009 at 8:48 PM
Join Date:
Nov 30, 2007
Post Count:
7361
 
GManNickG 80805
Loading...
Specialty: Spy
Steam ID: gman_nick
Clan: {TF2F} Community
King SpySquigMember
 
Statics code is in C#, you can download the Express version of Visual Studio.

And kwogger, there in't really a choice in C, you have to use strcpy (which is usually just implemented by your code).
#  Oct 28, 2009 at 9:01 PM
Join Date:
Oct 27, 2007
Post Count:
2357
 
X.Static 79392
Loading...
Specialty: Soldier
Steam ID: jaypatrick
Clan: {TF2F}
SponsorSquigMember
 
Anyone doing anything w/ F#? That's my next language I'm gonna tackle, it has a really promising premise behind it, plus it's based of ocaml which I always had a strange fascination with. I actually just like functional programming in general, mutable typing drives me crazy some times.
#  Oct 28, 2009 at 9:03 PM
Join Date:
Nov 30, 2007
Post Count:
7361
 
GManNickG 80805
Loading...
Specialty: Spy
Steam ID: gman_nick
Clan: {TF2F} Community
King SpySquigMember
 
Someone I played TF2 with once suggested Clojure, which is functional. F# looks too meh.
#  Oct 28, 2009 at 9:04 PM
Join Date:
Oct 27, 2007
Post Count:
2357
 
X.Static 79392
Loading...
Specialty: Soldier
Steam ID: jaypatrick
Clan: {TF2F}
SponsorSquigMember
 
Don't forget if you're a college student, MS wants to get you addicted to their shit from the very start: Dreamspark. Sponsored by MS, lotsa free MS programming software.
« Previous12Next »

Copyright 2007-2008 All Rights Reserved

Team Fortress 2


2 Guys 1 Kill: {TF2F} FlyingPenguin - (102 kill assists)
Captures Blocked: Nimbli Bimbli - (26 captures blocked)
Dominator: {TF2F} Bitch Nasty - (25 dominations)
Flags Captured: Corporal Clegg - (11 flags captured)
Flags Defended: MechaEdd - (12 flags defended)
Physician Assisted Homicide: {TF2F}SME®BUI©K - (271 medic kill assists)
Points Captured: {TF2F}SME®BUI©K - (30 points captured)
Revenger: Count_Flakula - (10 revenges)
Spy Power: Chro - (19 objects killed as spy)
Ubercharger: {TF2F}SME®BUI©K - (89 ubercharges)
Axe Man: {TF2F} Ninja Dude - (18 kills with fireaxe)
Axtinguished: {TF2F} BOOSH Rizzilio - (81 kills with axtinguisher)
Batter Up!: soup! - (16 kills with bat)
Biggest Prick: Sam - ClutchKill.com - (8 kills with syringegun)
Blood Sucker: {TF2F}SME®BUI©K - (30 kills with blutsauger)
Broke Backburner: {TF2F} FlyingPenguin - (223 kills with backburner)
Can You Dig It?: {TF2F}.TüRb!NE. - (3 kills with shovel)
Doctor's Certificate: Maero - (16 kills with bonesaw)
Drunken Brawler: [???] Deviruchi - (4 kills with bottle)
Epic Defender: {TF2F} Spy - (9 kills with wrench)
Fire Spitter: {TF2F}blistering - (100 kills with flamethrower)
Flare Gunner: {TF2F} FlyingPenguin - (12 kills with flare gun)
Grenade Spammer: GeneralSheep - (47 kills with pipe)
Grey Matter: STar - (168 snipings as sniper)
Hadouken Master: Xandier - (1 kills with pyro taunt)
Hot Potato: {TF2F} BOOSH Rizzilio - (4 kills with rocket deflection)
I <3 Sasha: {TF2F} Bitch Nasty - (181 kills with minigun)
Knife Maniac: {TF2F} Dartagnan - (109 knifings)
Last Resort: [Ba-El] BoC - (26 kills with smg)
Manslayer: [FRGT] Klare - (10 kills with machete)
Master Fister: Maero - (3 kills with fists)
Peashooter Marksman: Corporal Clegg - (48 kills with scout pistol)
Pickle Squad Award: [NH]Pitt - (18 pickles man handled)
Rocket Scientist: [TF2F]Lancer - (217 kills with rocket)
Scatter Shot: Corporal Clegg - (147 kills with scattergun)
Sentrygun Master: Numenor - (142 kills with sentrygun)
Spam Blocker: {TF2F} BOOSH Rizzilio - (1 kills with pipe deflection)
Spy Checker: {TF2F} Fanlaen - (5 kills with pistol)
Sticky Explosion: {TF2F}Album - (105 kills with pipe remote)
Ubersawer: Psycholord - (27 kills with ubersaw)
Stats Refreshed 6/24/2008 5:00:03 AM CST
AddThis Social Bookmark Button
Fortcast Podcast
Donate
Welcome, you are not logged in.
Login or Register
Team Fortress 2 Fort Team Fortress 2 Fort