evan All American 27701 Posts user info edit post |
just because i have to tell someone about it.
WMI to a remote machine from PHP. this is part of a script that automatically installs the MS iSCSI initiator on a remote machine, provisions LUNs on a target via libzfs/libstmf, configures the remote machine to connect to the target portal and sets up the target to be persistent, and then initializes the new iSCSI disks/partitions them/formats the partitions. eventually going to clean this up and make it into a group of functions, but yeah.
fucking COM
$objWMI = new COM("WbemScripting.SWbemLocator");
// 0x3 = wbemImpersonationLevelImpersonate $objWMI->Security_->ImpersonationLevel = 3; // 0x6 = wbemAuthenticationLevelPkt $objWMI->Security_->AuthenticationLevel = 6;
try { $objServer = $objWMI->ConnectServer($_POST['machine'],"root\\CIMV2",$_POST['username'],$_POST['password']); $objRegistry = $objWMI->ConnectServer($_POST['machine'],"root\\default:StdRegProv",$_POST['username'],$_POST['password']); $objStdReg = $objRegistry->Get("StdRegProv"); } catch (Exception $theException) { //print_r($theException); die("couldn't make WMI connection: " . $theException->getMessage() . " (" . $theException->getCode() . ")"); }
$objDrives = $objServer->ExecQuery("SELECT * FROM Win32_DiskDrive"); $intNum = 0; $arrDrivesToInitialize = array(); foreach ($objDrives as $objDrive) { if (stripos($objDrive->Model,"COMSTAR") !== FALSE) { if ($objDrive->Partitions == 0) { echo "drive " . $intNum . " is a comstar volume that contains no partitions. it will be initialized."; $arrDrivesToInitialize[] = $intNum; } else { echo "drive " . $intNum . " is a comstar volume but already contains partitions. skipping."; } } else { echo "drive " . $intNum . " is not a comstar volume. skipping."; } $intNum++; }
if (count($arrDrivesToInitialize)) { $objVolumes = $objServer->ExecQuery("SELECT * FROM Win32_Volume WHERE DriveType = 3"); foreach ($objVolumes as $objVolume) { if (trim($objVolume->FileSystem) == "") { echo "formatting volume " . $objVolume->DriveLetter . " (" . $objVolume->DeviceID . ")"; $vtBoolTrue = new VARIANT(TRUE,VT_BOOL); $vtBoolFalse = new VARIANT(FALSE,VT_BOOL); $objVolume->Format("NTFS",$vtBoolTrue,4096,"iSCSI Volume",$vtBoolFalse); } else { echo "volume " . $objVolume->DriveLetter . " (" . $objVolume->DeviceID . ") is not blank. skipping."; } } } ]10/15/2010 8:09:18 PM |
Walter All American 7761 Posts user info edit post |
so basically, this is a self-masturbation thread? 10/15/2010 9:12:30 PM |
OmarBadu zidik 25071 Posts user info edit post |
i'm actually kind of hoping something patentable is posted 10/15/2010 9:26:11 PM |
YOMAMA Suspended 6218 Posts user info edit post |
Hello World'; ?>
Quote : | " Hello World'; ?> " |
[Edited on October 15, 2010 at 9:43 PM. Reason : .]10/15/2010 9:43:05 PM |
AlaskanGrown I'm Randy 4694 Posts user info edit post |
if ([code isCool]) { [code post]; } else { [code makeCooler]; }
- (void) post { [outStream print:code.description]; }
- (void) makeCooler { [code addIce]; } 10/15/2010 10:52:23 PM |
Stein All American 19842 Posts user info edit post |
Should've used Powershell.
[Edited on October 15, 2010 at 11:20 PM. Reason : Because it ownnnnnnnnnnnnnnnnnsss] 10/15/2010 11:20:12 PM |
lewisje All American 9196 Posts user info edit post |
After installing DD-WRT on my router, I modified some guy's script that auto-loads dnsmasq entries and a hosts file to send ad- and malware domains off to an instance of pixelserv so that the result would be a bit gentler on my router (link goes to that guy's implementation): http://hotfortech.wikispaces.com/How+to+remove+advertisements+with+pixelserv+on+DD-WRT
I altered the script so it would choose something other than MVPs, which is full of false positives: http://jansal.googlecode.com/svn/trunk/adblock/disable_ads.startup
I instead pointed it to a HOSTS file I made based off what SpywareBlaster adds to Restricted Sites; it's much smaller than the MVPs file (so it all fits on my router's flash memory) and free of false positives AFAIK.
I know I didn't make the code but I am proud of digging in there to change all references from MVPs to something else and to change the parameters of sed to deal with a redirection IP of 0.0.0.0 rather than 127.0.0.1 and to make this work with a router set to 192.168.0.0/8 instead of 192.168.1.0/8
[Edited on October 15, 2010 at 11:23 PM. Reason : dnsmasq and pixelserv pwn 10/15/2010 11:23:15 PM |
gs7 All American 2354 Posts user info edit post |
There is no way my company would allow me to post my work here. Just imagine that I am posting something REALLY cool ... because it is. 10/16/2010 12:28:36 AM |
lewisje All American 9196 Posts user info edit post |
post it on AnonIB
be sure to use 7 proxies 10/16/2010 12:43:04 AM |
spöokyjon ℵ 18617 Posts user info edit post |
if(b == true) { return true; } else if(b == false) { return false; } 10/16/2010 12:51:01 AM |
lewisje All American 9196 Posts user info edit post |
http://thedailywtf.com/Articles/Discovering-New-Math.aspx
10/16/2010 1:29:29 AM |
Fry The Stubby 7784 Posts user info edit post |
^^ screw returning b
wonder if i have any code that i am both proud of and able to share... depressing thought
[Edited on October 16, 2010 at 1:31 AM. Reason : omgz 4000 poasts] 10/16/2010 1:29:52 AM |
Kris All American 36908 Posts user info edit post |
I wish I could post it, but it's company code and it's across like 1,000 different files, but I uniquely priority threaded and typed certain javascript methods we use. I used some really cool tricks, but a bit too much to post here and I'm not even sure I'm legally allowed to. 10/16/2010 2:29:16 AM |
evan All American 27701 Posts user info edit post |
if it's javascript, where are you using it that you're not posting the source anyway? 10/16/2010 6:38:11 AM |
Kris All American 36908 Posts user info edit post |
Internally accessible pages. 10/16/2010 10:37:19 AM |
AlaskanGrown I'm Randy 4694 Posts user info edit post |
All my code is either Objective-C or Java. And none of it is super duper interesting unless you can see the end result. 10/16/2010 2:00:36 PM |
0EPII1 All American 42541 Posts user info edit post |
I wrote a genetic algorithm for function optimization in Java for an AI course in my junior year.
And then as a grad student I rewrote it in Matlab for a course called Soft Computing.
Unfortunately, I don't have any of them now, and that makes me sad. Because those were the best programs I ever wrote (simple for y'all, but something big for me).
Another awesome program I made in Java was a resurrection of the old school game from QBasic called Gorillas (2-player). Every time you started it, it generated a random skyline and there were 2 gorillas randomly placed on top of two of the skyscrapers. The 1st player had to enter the speed (m/s) and angle (degrees) for the his/her gorilla to throw the banana at, which followed projectile motion, to hit the other gorilla (which killed it and you scored a point). If you missed, it was the other player's turn. Anytime a gorilla got killed, a new skyline was generated automatically. You could also change the value of gravity before the start of the game, and the direction and speed of wind was indicated by an arrow and value (in m/s) in one corner. Of course, the wind had to be taken into account when entering the speed and angle for the banana.
The best was when your opponent's gorilla was placed behind a really tall building so you had to shoot the banana at like an angle of 85 degrees (sometimes 88 or 89) with extremely high speed... it went out of the screen (sometimes for half a minute to a minute or longer) and continued projectile motion and reentered the screen (hopefully) and hopefully hit the gorilla.
I really wish I still had that program cuz that was fucking baller, and I absolutely loved playing that game... I had become good enough to hit the gorilla on the first shot in a lot of cases. Or I wish I could at least get some modern version of the original game, if it exists.
Youtube video capture of the original QBasic Gorillas, for those who don't know... must see!
http://www.youtube.com/watch?v=ncykt-YJO1M from http://xspblog.com/2009/07/08/abandonware-gorilla-bas-pc/
OMFG I haven't heard that startup music for like 20 years... takes me so far back
Screenshot:
Nibbles (video at http://xspblog.com/2008/11/11/abandonware-nibblesbas-pc ) was another awesome game that came with QBasic and that I was really good at... gone are the days of simple but amazing games such as those, alas! 10/16/2010 5:29:28 PM |
EuroTitToss All American 4790 Posts user info edit post |
I wrote this fucking shit in vb in high school:
[Edited on October 16, 2010 at 6:06 PM. Reason : I haven't been super proud of anything lately. Trying to rectify that. ] 10/16/2010 5:34:22 PM |
qntmfred retired 40726 Posts user info edit post |
the last neat thing i did was something that analyzed this game and did real-time simulations to determine what the optimum input would be.
http://chainrxn.zwigglers.com/
[Edited on October 16, 2010 at 10:07 PM. Reason : that was over a year ago. which means i ain't done squat since ] 10/16/2010 10:03:34 PM |
AlaskanGrown I'm Randy 4694 Posts user info edit post |
^ Thats awesome. Good game btw. 10/16/2010 10:45:31 PM |
J33Pownr Veteran 356 Posts user info edit post |
^^ 13,801,500 points. Thats too fun. 10/17/2010 3:00:13 AM |
EuroTitToss All American 4790 Posts user info edit post |
^^^ that's pretty neat
oh, also I'm pretty proud of this captcha. not because it was especially difficult to write, but because I feel that it's fairly readable and somewhat challenging to break compared to most of the ones I see today.
10/17/2010 6:08:00 AM |
AstralEngine All American 3864 Posts user info edit post |
I have no idea what I'd need to type to pass that captcha... 10/17/2010 11:12:17 AM |
EuroTitToss All American 4790 Posts user info edit post |
In any order, you type the two words that are in a circle. Is it unreadable or is that too hard? 10/17/2010 12:03:58 PM |
lewisje All American 9196 Posts user info edit post |
the "any order" part makes it less ambiguous 10/17/2010 12:36:17 PM |
Lionheart I'm Eggscellent 12775 Posts user info edit post |
most of my impressive shit is finding stuff thats programmed lousy down fifteen layers of legacy code and fixing it.... Oh and the variables are all in German. 10/17/2010 12:44:43 PM |
synapse play so hard 60939 Posts user info edit post |
^^^ what about the other letters floating around? 10/17/2010 6:06:11 PM |
wdprice3 BinaryBuffonary 45912 Posts user info edit post |
import java.util.* ; import java.io.* ;
public class PokerModel { private FileReader fr ; private BufferedReader br ; private Card [ ] deck ; private Card [ ] hand ; private int deckPos ; private String score ; /** * A null constructor, which initializes all instance variables. * This includes the deck of cards and the initial hand. */ public PokerModel ( ) { deck = new Card [ 52 ] ; hand = new Card [ 5 ] ; deckPos = 0 ; score = "" ; // Local Variables int number = 0 ; int i = 0 ; String suit = "" ; String s = "" ; try { fr = new FileReader ( "deck.txt" ) ; br = new BufferedReader ( fr ) ; while ( ( s = br.readLine ( ) ) != null ) { StringTokenizer tokenizer = new StringTokenizer ( s ) ; number = Integer.parseInt ( tokenizer.nextToken ( ) ) ; suit = tokenizer.nextToken ( ) ; Card myCard = new Card ( number , suit ) ; deck [ i ] = myCard ; i ++ ; } for ( int j = 0 ; j < hand.length ; j ++ ) { hand [ j ] = deck [ j ] ; deckPos ++ ; } } catch ( IOException e ) { System.err.println ( "Error" ) ; System.exit ( 1 ) ; } } /** * Method which accepts an integer value 0,1,2,3, or 4 corresponding to * that card in the hand * * @param whichOne - The card position in the hand which was selected * @return hand - Returns the card that was selected */ public Card getCard ( int whichOne ) { return hand [ whichOne ] ; } /** * Method which receives an integer value 0, 1,2, 3, or 4 and replaces * that card in the hand of cards. The replacement card is the next * card in the deck. * * @param whichOne - The card position in the hand which was selected * @return hand - Returns the replacement card */ public Card replaceCard ( int whichOne ) { hand [ whichOne ] = deck [ deckPos++ ] ; return hand [ whichOne ]; } /** * Method that returns a String indicating the score for the * current hand: * * @return score - The score of the hand */ public String scoreHand ( ) { Arrays.sort (hand, 0, 5);
if ( ( hand [ 0 ].getSuit ( ).equals ( hand [ 1 ].getSuit ( ) ) ) && ( hand [ 1 ].getSuit ( ).equals ( hand [ 2 ].getSuit ( ) ) ) && ( hand [ 2 ].getSuit ( ).equals ( hand [ 3 ].getSuit ( ) ) ) && ( hand [ 3 ].getSuit ( ).equals ( hand [ 4 ].getSuit ( ) ) ) && ( ( hand [ 0 ].getValue ( ) == 1 ) && ( hand [ 1 ].getValue ( ) == 10 ) && ( hand [ 2 ].getValue ( ) == 11 ) && ( hand [ 3 ].getValue ( ) == 12 ) && ( hand [ 4 ].getValue ( ) == 13 ) ) ) { score = "Royal Flush" ; } else if ( ( hand [ 0 ].getSuit ( ).equals ( hand[ 1 ].getSuit ( ) ) ) && ( hand [ 1 ].getSuit ( ).equals ( hand[ 2 ].getSuit ( ) ) ) && ( hand [ 2 ].getSuit ( ).equals ( hand[ 3 ].getSuit ( ) ) ) && ( hand [ 3 ].getSuit ( ).equals ( hand[ 4 ].getSuit ( ) ) ) && ( ( hand [ 0 ].getValue ( ) == hand [ 1 ].getValue ( ) - 1 ) && ( hand [ 1 ].getValue ( ) == hand [ 2 ].getValue ( ) - 1 ) && ( hand [ 2 ].getValue ( ) == hand [ 3 ].getValue ( ) - 1 ) && ( hand [ 3 ].getValue ( ) == hand [ 4 ].getValue ( ) - 1 ) ) ) { score = "Straight Flush" ; } else if ( ( ( hand [ 0 ].getValue ( ) == hand [ 1 ].getValue ( ) ) && ( hand [ 1 ].getValue ( ) == hand [ 2 ].getValue ( ) ) && ( hand [ 2 ].getValue ( ) == hand [ 3 ].getValue ( ) ) ) || ( ( hand [ 0 ].getValue ( ) == hand [ 1 ].getValue ( ) ) && ( hand [ 1 ].getValue ( ) == hand [ 2 ].getValue ( ) ) && ( hand [ 2 ].getValue ( ) == hand [ 4 ].getValue ( ) ) ) || ( ( hand [ 0 ].getValue ( ) == hand [ 1 ].getValue ( ) ) && ( hand [ 1 ].getValue ( ) == hand [ 3 ].getValue ( ) ) && ( hand [ 3 ].getValue ( ) == hand [ 4 ].getValue ( ) ) ) || ( ( hand [ 0 ].getValue ( ) == hand [ 2 ].getValue ( ) ) && ( hand [ 2 ].getValue ( ) == hand [ 3 ].getValue ( ) ) && ( hand [ 3 ].getValue ( ) == hand [ 4 ].getValue ( ) ) ) || ( ( hand [ 1 ].getValue ( ) == hand [ 2 ].getValue ( ) ) && ( hand [ 2 ].getValue ( ) == hand [ 3 ].getValue ( ) ) && ( hand [ 3 ].getValue ( ) == hand [ 4 ].getValue ( ) ) ) ) { score = "Four of a Kind" ; } else if ( ( ( hand [ 0 ].getValue ( ) == hand [ 1 ].getValue ( ) ) && ( hand [ 1 ].getValue ( ) == hand [ 2 ].getValue ( ) ) && ( hand [ 3 ].getValue ( ) == hand [ 4 ].getValue ( ) ) ) || ( ( hand [ 0 ].getValue ( ) == hand [ 2 ].getValue ( ) ) && ( hand [ 2 ].getValue ( ) == hand [ 3 ].getValue ( ) ) && ( hand [ 1 ].getValue ( ) == hand [ 4 ].getValue ( ) ) ) || ( ( hand [ 0 ].getValue ( ) == hand [ 2 ].getValue ( ) ) && ( hand [ 2 ].getValue ( ) == hand [ 4 ].getValue ( ) ) && ( hand [ 1 ].getValue ( ) == hand [ 3 ].getValue ( ) ) ) || ( ( hand [ 0 ].getValue ( ) == hand [ 3 ].getValue ( ) ) && ( hand [ 3 ].getValue ( ) == hand [ 4 ].getValue ( ) ) && ( hand [ 1 ].getValue ( ) == hand [ 2 ].getValue ( ) ) ) || ( ( hand [ 0 ].getValue ( ) == hand [ 1 ].getValue ( ) ) && ( hand [ 1 ].getValue ( ) == hand [ 3 ].getValue ( ) ) && ( hand [ 2 ].getValue ( ) == hand [ 4 ].getValue ( ) ) ) || ( ( hand [ 0 ].getValue ( ) == hand [ 1 ].getValue ( ) ) && ( hand [ 1 ].getValue ( ) == hand [ 4 ].getValue ( ) ) && ( hand [ 2 ].getValue ( ) == hand [ 3 ].getValue ( ) ) ) || ( ( hand [ 1 ].getValue ( ) == hand [ 2 ].getValue ( ) ) && ( hand [ 2 ].getValue ( ) == hand [ 3 ].getValue ( ) ) && ( hand [ 0 ].getValue ( ) == hand [ 4 ].getValue ( ) ) ) || ( ( hand [ 1 ].getValue ( ) == hand [ 3 ].getValue ( ) ) && ( hand [ 3 ].getValue ( ) == hand [ 4 ].getValue ( ) ) && ( hand [ 0 ].getValue ( ) == hand [ 2 ].getValue ( ) ) ) || ( ( hand [ 1 ].getValue ( ) == hand [ 2 ].getValue ( ) ) && ( hand [ 2 ].getValue ( ) == hand [ 4 ].getValue ( ) ) && ( hand [ 0 ].getValue ( ) == hand [ 3 ].getValue ( ) ) ) || ( ( hand [ 2 ].getValue ( ) == hand [ 3 ].getValue ( ) ) && ( hand [ 3 ].getValue ( ) == hand [ 4 ].getValue ( ) ) && ( hand [ 0 ].getValue ( ) == hand [ 1 ].getValue ( ) ) ) ) { score = "Full House" ; } else if ( ( hand [ 0 ].getSuit ( ).equals ( hand[ 1 ].getSuit ( ) ) ) && ( hand [ 1 ].getSuit ( ).equals ( hand[ 2 ].getSuit ( ) ) ) && ( hand [ 2 ].getSuit ( ).equals ( hand[ 3 ].getSuit ( ) ) ) && ( hand [ 3 ].getSuit ( ).equals ( hand[ 4 ].getSuit ( ) ) ) ) {
score = "Flush" ; } else if ( ( ( hand [ 0 ].getValue ( ) == hand [ 1 ].getValue ( ) - 1 ) && ( hand [ 1 ].getValue ( ) == hand [ 2 ].getValue ( ) - 1 ) && ( hand [ 2 ].getValue ( ) == hand [ 3 ].getValue ( ) - 1 ) && ( hand [ 3 ].getValue ( ) == hand [ 4 ].getValue ( ) - 1 ) ) ) { score = "Straight" ; }
[Edited on October 17, 2010 at 6:28 PM. Reason : .]10/17/2010 6:27:37 PM |
wdprice3 BinaryBuffonary 45912 Posts user info edit post |
else if ( ( ( hand [ 0 ].getValue ( ) == hand [ 1 ].getValue ( ) + 10 ) && ( hand [ 1 ].getValue ( ) == hand [ 2 ].getValue ( ) - 1 ) && ( hand [ 2 ].getValue ( ) == hand [ 3 ].getValue ( ) - 1 ) && ( hand [ 3 ].getValue ( ) == hand [ 4 ].getValue ( ) - 1 ) ) ) { score = "Straight" ; } else if ( ( ( hand [ 0 ].getValue ( ) == hand [ 1 ].getValue ( ) ) && ( hand [ 2 ].getValue ( ) == hand [ 3 ].getValue ( ) ) ) || ( ( hand [ 0 ].getValue ( ) == hand [ 1 ].getValue ( ) ) && ( hand [ 2 ].getValue ( ) == hand [ 4 ].getValue ( ) ) ) || ( ( hand [ 0 ].getValue ( ) == hand [ 1 ].getValue ( ) ) && ( hand [ 3 ].getValue ( ) == hand [ 4 ].getValue ( ) ) ) || ( ( hand [ 1 ].getValue ( ) == hand [ 2 ].getValue ( ) ) && ( hand [ 0 ].getValue ( ) == hand [ 3 ].getValue ( ) ) ) || ( ( hand [ 1 ].getValue ( ) == hand [ 2 ].getValue ( ) ) && ( hand [ 0 ].getValue ( ) == hand [ 4 ].getValue ( ) ) ) || ( ( hand [ 1 ].getValue ( ) == hand [ 2 ].getValue ( ) ) && ( hand [ 3 ].getValue ( ) == hand [ 4 ].getValue ( ) ) ) || ( ( hand [ 2 ].getValue ( ) == hand [ 3 ].getValue ( ) ) && ( hand [ 0 ].getValue ( ) == hand [ 4 ].getValue ( ) ) ) || ( ( hand [ 2 ].getValue ( ) == hand [ 3 ].getValue ( ) ) && ( hand [ 1 ].getValue ( ) == hand [ 4 ].getValue ( ) ) ) || ( ( hand [ 3 ].getValue ( ) == hand [ 4 ].getValue ( ) ) && ( hand [ 0 ].getValue ( ) == hand [ 2 ].getValue ( ) ) ) ) { score = "Two Pair" ; } else if ( ( hand [ 0 ].getValue ( ) == hand [ 1 ].getValue ( ) ) || ( hand [ 0 ].getValue ( ) == hand [ 2 ].getValue ( ) ) || ( hand [ 0 ].getValue ( ) == hand [ 3 ].getValue ( ) ) || ( hand [ 0 ].getValue ( ) == hand [ 4 ].getValue ( ) ) || ( hand [ 1 ].getValue ( ) == hand [ 2 ].getValue ( ) ) || ( hand [ 1 ].getValue ( ) == hand [ 3 ].getValue ( ) ) || ( hand [ 1 ].getValue ( ) == hand [ 4 ].getValue ( ) ) || ( hand [ 2 ].getValue ( ) == hand [ 3 ].getValue ( ) ) || ( hand [ 2 ].getValue ( ) == hand [ 4 ].getValue ( ) ) || ( hand [ 3 ].getValue ( ) == hand [ 4 ].getValue ( ) ) ) { score = "One Pair" ; } else { score = "No Pair" ; } return score ; } /** * Method that returns the current hand of cards, one card per line. * * @return s - Returns the current hand */ public String toString ( ) { String str = "" ; for ( int i = 0 ; i < 5 ; i ++ ) { str += hand [ i ].toString ( ) + "\n" ; } return str ; } /** * Main of this class, used for testing the public methods. * * @param args - Command line arguments which we do not use */ public static void main ( String [ ] args ) { PokerModel model = new PokerModel () ; System.out.println ( "\tTEST1\t\n" ) ; System.out.println ( "Original Cards, using toString:\n" ) ; System.out.println ( model ) ; System.out.println ( model.scoreHand ( ) + "\n" ) ; System.out.println ( "Original Cards, using getCard: \n" ) ; for ( int i = 0 ; i < model.hand.length ; i ++ ) { System.out.println ( model.getCard ( i ) ) ; } System.out.println ( "\n" + model.scoreHand ( ) + "\n" ) ; System.out.println ( "Replaced Cards: \n" ) ; for ( int i = 0 ; i < model.hand.length ; i ++ ) { System.out.println ( model.replaceCard ( i ) ) ; } System.out.println ( "\n" + model.scoreHand ( ) + "\n" ) ; System.out.println ( "\tTEST2\t\n" ) ; System.out.println ( "Original Cards, using toString:\n" ) ; System.out.println ( model ) ; System.out.println ( model.scoreHand ( ) + "\n" ) ; System.out.println ( "Original Cards, using getCard: \n" ) ; for ( int i = 0 ; i < model.hand.length ; i ++ ) { System.out.println ( model.getCard ( i ) ) ; } System.out.println ( "\n" + model.scoreHand ( ) + "\n" ) ; System.out.println ( "Replaced Cards: \n" ) ; for ( int i = 0 ; i < model.hand.length ; i ++ ) { System.out.println ( model.replaceCard ( i ) ) ; } System.out.println ( "\n" + model.scoreHand ( ) + "\n" ) ; 10/17/2010 6:28:45 PM |
wdprice3 BinaryBuffonary 45912 Posts user info edit post |
System.out.println ( "\tTEST3\t\n" ) ; System.out.println ( "Original Cards, using toString:\n" ) ; System.out.println ( model ) ; System.out.println ( model.scoreHand ( ) + "\n" ) ; System.out.println ( "Original Cards, using getCard: \n" ) ; for ( int i = 0 ; i < model.hand.length ; i ++ ) { System.out.println ( model.getCard ( i ) ) ; } System.out.println ( "\n" + model.scoreHand ( ) + "\n" ) ; System.out.println ( "Replaced Cards: \n" ) ; for ( int i = 0 ; i < model.hand.length ; i ++ ) { System.out.println ( model.replaceCard ( i ) ) ; } System.out.println ( "\n" + model.scoreHand ( ) + "\n" ) ; System.out.println ( "\tTEST4\t\n" ) ; System.out.println ( "Original Cards, using toString:\n" ) ; System.out.println ( model ) ; System.out.println ( model.scoreHand ( ) + "\n" ) ; System.out.println ( "Original Cards, using getCard: \n" ) ; for ( int i = 0 ; i < model.hand.length ; i ++ ) { System.out.println ( model.getCard ( i ) ) ; } System.out.println ( "\n" + model.scoreHand ( ) + "\n" ) ; System.out.println ( "Replaced Cards: \n" ) ; for ( int i = 0 ; i < model.hand.length ; i ++ ) { System.out.println ( model.replaceCard ( i ) ) ; } System.out.println ( "\n" + model.scoreHand ( ) + "\n" ) ; System.out.println ( "\tTEST5\t\n" ) ; System.out.println ( "Original Cards, using toString:\n" ) ; System.out.println ( model ) ; System.out.println ( model.scoreHand ( ) + "\n" ) ; System.out.println ( "Original Cards, using getCard: \n" ) ; for ( int i = 0 ; i < model.hand.length ; i ++ ) { System.out.println ( model.getCard ( i ) ) ; } System.out.println ( "\n" + model.scoreHand ( ) + "\n" ) ; System.out.println ( "Replaced Cards: \n" ) ; for ( int i = 0 ; i < model.hand.length ; i ++ ) { System.out.println ( model.replaceCard ( i ) ) ; } System.out.println ( "\n" + model.scoreHand ( ) + "\n" ) ; System.out.println ( "\tTEST6\t\n" ) ; System.out.println ( "Original Cards, using toString:\n" ) ; System.out.println ( model ) ; System.out.println ( model.scoreHand ( ) + "\n" ) ; System.out.println ( "Original Cards, using getCard: \n" ) ; for ( int i = 0 ; i < model.hand.length ; i ++ ) { System.out.println ( model.getCard ( i ) ) ; } System.out.println ( "\n" + model.scoreHand ( ) + "\n" ) ; System.out.println ( "Replaced Cards: \n" ) ; for ( int i = 0 ; i < model.hand.length ; i ++ ) { System.out.println ( model.replaceCard ( i ) ) ; } System.out.println ( "\n" + model.scoreHand ( ) + "\n" ) ; System.out.println ( "\tTEST7\t\n" ) ; System.out.println ( "Original Cards, using toString:\n" ) ; System.out.println ( model ) ; System.out.println ( model.scoreHand ( ) + "\n" ) ; System.out.println ( "Original Cards, using getCard: \n" ) ; for ( int i = 0 ; i < model.hand.length ; i ++ ) { System.out.println ( model.getCard ( i ) ) ; } System.out.println ( "\n" + model.scoreHand ( ) + "\n") ; System.out.println ( "Replaced Cards: \n" ) ; for ( int i = 0 ; i < model.hand.length ; i ++ ) { System.out.println ( model.replaceCard ( i ) ) ; } System.out.println ( "\n" + model.scoreHand ( ) + "\n") ; System.out.println ( "\tTEST8\t\n" ) ; System.out.println ( "Original Cards, using toString:\n" ) ; System.out.println ( model ) ; System.out.println ( model.scoreHand ( ) + "\n" ) ; System.out.println ( "Original Cards, using getCard: \n" ) ; for ( int i = 0 ; i < model.hand.length ; i ++ ) { System.out.println ( model.getCard ( i ) ) ; } System.out.println ( "\n" + model.scoreHand ( ) + "\n" ) ; System.out.println ( "Replaced Cards: \n" ) ; for ( int i = 0 ; i < model.hand.length ; i ++ ) { System.out.println ( model.replaceCard ( i ) ) ; } System.out.println ( "\n" + model.scoreHand ( ) + "\n" ) ; System.out.println ( "\tTEST9\t\n" ) ; System.out.println ( "Original Cards, using toString:\n" ) ; System.out.println ( model ) ; System.out.println ( model.scoreHand ( ) + "\n" ) ; System.out.println ( "Original Cards, using getCard: \n" ) ; for ( int i = 0 ; i < model.hand.length ; i ++ ) { System.out.println ( model.getCard ( i ) ) ; } System.out.println ( "\n" + model.scoreHand ( ) + "\n" ) ; System.out.println ( "Replaced Cards: \n" ) ; for ( int i = 0 ; i < model.hand.length ; i ++ ) { System.out.println ( model.replaceCard ( i ) ) ; } System.out.println ( "\n" + model.scoreHand ( ) + "\n" ) ; } } 10/17/2010 6:29:07 PM |
Ernie All American 45943 Posts user info edit post |
^ CSC 116 folks aren't going to be happy about that 10/17/2010 6:32:41 PM |
EuroTitToss All American 4790 Posts user info edit post |
^^^they should be easy enough to ignore. I was just having a little fun there; I doubt they could do much to confuse a bot but who knows? if anyone is interested, I'd love to explain why I think it's relatively hard to break.
^^dear god
you could kill a horse with those if statements, ^haha
[Edited on October 17, 2010 at 6:34 PM. Reason : asdfasdf] 10/17/2010 6:33:56 PM |
wdprice3 BinaryBuffonary 45912 Posts user info edit post |
10/17/2010 6:46:30 PM |
zorthage 1+1=5 17148 Posts user info edit post |
Jesus christ those are some long methods
Why can't people make code readable? Nevermind constants
if (isRoyalFlush(hand)) { score = HandType.ROYALFLUSH; } else if (isStraightFlush(hand)) { score = HandType.STRAIGHTFLUSH; } else if (isFourOfAKind(hand)) { score = HandType.FOUROFAKIND; } else if (isFullHouse(hand)) { score = HandType.FULLHOUSE; } else if (isFlush(hand)) { score = HandType.FLUSH; } else if (isStraight(hand)) { score = HandType.STRAIGHT; } else if (isTwoPair(hand)) { score = HandType.TWOPAIR; } else if (isOnePair(hand)) { score = HandType.ONEPAIR; } else { score = HandType.NOTHING; }
10/17/2010 8:54:59 PM |
Kris All American 36908 Posts user info edit post |
Even better:
Hand hand = Hand.create(); hand.printScore();
make a Hand object then just make a each type of hand extend Hand makes it way easier to create new hands and such and reduces the cyclomatic complexity. 10/17/2010 9:21:08 PM |
ncstatetke All American 41128 Posts user info edit post |
63033
Florissant, MO 10/17/2010 10:15:57 PM |
zorthage 1+1=5 17148 Posts user info edit post |
Using objects? In CSC 116?
But I agree. Though that logic to determine what kind of hand it is would then just be in the object instead of the application. 10/17/2010 10:17:03 PM |
Potty Mouth Suspended 571 Posts user info edit post |
I don't know that I've ever been proud of code...once you solve the problem in your head, on paper, whatever, the code is just that solution in a different language. Nothing more.
Unless you're one of those types that bashes away at code until you stumble on the solution through trial and error. 10/17/2010 10:29:34 PM |
Kris All American 36908 Posts user info edit post |
It's a lot cleaner to have it there, not to mention the logic would be done at instantiation, so it won't be duplicated across the program 10/17/2010 11:07:42 PM |
FroshKiller All American 51911 Posts user info edit post |
zorthage said:
Quote : | "But I agree. Though that logic to determine what kind of hand it is would then just be in the object instead of the application." |
I think you are missing out on the fundamental strength of the object-oriented paradigm, dude.10/18/2010 8:14:03 AM |
wdprice3 BinaryBuffonary 45912 Posts user info edit post |
good lord. lot of opinions on a csc 116 assignment for someone just learning java. sheesh 10/18/2010 9:03:50 AM |
EuroTitToss All American 4790 Posts user info edit post |
QUICK, SOMEONE GENERATE A UML DIAGRAM FOR 52 CARD CLASSES. WE NEED 4 SUIT INTERFACES AND 13 ABSTRACT VALUE CLASSES. ON MY DESK BY TOMORROW MORNING. 10/18/2010 10:13:58 AM |
FroshKiller All American 51911 Posts user info edit post |
you are some kind of asshole if you think a card suit is anything but an enum though for real
talk about the classic example 10/18/2010 10:17:07 AM |
qntmfred retired 40726 Posts user info edit post |
that code needs a Reformat Document 10/18/2010 12:03:49 PM |
EmptyFriend All American 3686 Posts user info edit post |
i created a gui interface using visual basic, and used it to track an ip address. 10/18/2010 12:15:15 PM |
qntmfred retired 40726 Posts user info edit post |
^ iswydt 10/18/2010 12:50:15 PM |
qntmfred retired 40726 Posts user info edit post |
oh ok, here's something i'm proud of. no code to show off, but still pretty cool
back in the day, i used to manage college bookstores and every semester we would have to type in the entire course catalog by hand so we would know which courses hadn't had textbook requisitions submitted yet. obviously this took freaking forever, was prone to error, and was difficult to update after the course catalog was printed and courses were moved/dropped/added.
so i wrote a program to continuously scrape and monitor changes to the course catalogs at about 20 different universities. that was pretty fun by itself, but there wasn't a good way to import that data into our company's custom bookstore management program. we used SSH clients to telnet into an AIX server that ran a Textual User Interface application. incredibly, the ssh client (securecrt) has an automation api, so i wrote some javascript to read the course catalog dumps, and simulate the key presses necessary to type all the data into our program. it was pretty fun watching the expression on my regional director's face when i showed it to him the first time. and then, i took it a step further and made it so that when we acquired new stores, we could import the old store's data (including all textbook information) into our program, saving years of valuable textbook usage and sales history.
but then, i asked for a raise and they said no, so i left. i even offered to do it on a contractual basis for the low, low price of $25/hr and they still balked. -shrug- oh well] 10/18/2010 1:02:00 PM |
msb2ncsu All American 14033 Posts user info edit post |
Remote synchronization of statewide traffic signal data in an occasionally connected app (C++).
Employer dropped Oracle Light license, wouldn't trust any open-source code, and didn't want to purchase third-party sync software. It was my first real app out of college. The app as a whole was a beast, but I'm definitely most proud of the sync code and the entity generator I wrote to handle any schema changes. It still works today with near zero conflicts/collisions. 10/18/2010 1:02:35 PM |
shmorri2 All American 10003 Posts user info edit post |
Nothing special. Just references two predetermined memory locations and displays which value is greater.
0011000000000000 0101100100100000 0101000000100000 0001000000101111 0001000000101111 0001000000101111 0001000000101111 0001000000100101 1111000000100001 0010001111110100 0010010111110100 1001001001111111 0001001001100001 0001011010000001 0000011000000111 0001000000111101 1111000000100001 0001000000100100 1111000000100001 0001100100100001 0011100111101011 1111000000100101 0000010000001000 0001000000111011 1111000000100001 0001000000100110 1111000000100001 0101100100100000 1001100100111111 0011100111100010 1111000000100101 0001000000111100 1111000000100001 0001000000100101 1111000000100001 0011100111011100 1111000000100101
[Edited on November 2, 2010 at 11:27 PM. Reason : .a] 11/2/2010 11:26:57 PM |
aaronburro Sup, B 53065 Posts user info edit post |
kind of proud of some VB .NET code I wrote 3 years ago to automate pulling daily reports from access databases and merge them all into one PDF document. I'm only proud of it because I haven't touched that shit since until a guy was doing basically the same thing by hand the other day, and I was like "I can work on that for you..." And the framework I had written 3 years ago was sufficient to write the new app without any changes. 11/10/2010 8:43:25 PM |