Paste Today's Line Of Code

  • (12 Pages)
  • +
  • 1
  • 2
  • 3
  • Last »

175 Replies - 15523 Views - Last Post: 18 June 2011 - 07:42 PM

#1 skyhawk133  Icon User is offline

  • Head DIC Head
  • member icon

Reputation: 1875
  • View blog
  • Posts: 20,283
  • Joined: 17-March 01

Paste Today's Line Of Code

Post icon  Posted 18 April 2011 - 08:06 AM

*
POPULAR

I wouldn't normally post a "game" like this in the Corner Cube, but wanted to get a thread about what you're doing that you can stop by any day and update. Kind of like the "Song Of The Day" thread in the caffeine lounge, this is "Today's Line Of Code".

For instance, today is the 18th, so open up whatever file you're working on and copy/paste the 18th line of code and tell us what you're working on.

Mine:
		$sql_result = $memcache->get($key);



I'm working on Dream.In.Code's layout a bit and line 18 is caching the results from our dynamic templates on to our memcache server that handles around 800 queries/second.

Your turn, paste today's line from whatever file you have open in your IDE and tell us a little about what you're working on.

Is This A Good Question/Topic? 5
  • +

Replies To: Paste Today's Line Of Code

#2 Kilorn  Icon User is offline

  • XNArchitect
  • member icon



Reputation: 1356
  • View blog
  • Posts: 3,528
  • Joined: 03-May 10

Re: Paste Today's Line Of Code

Posted 18 April 2011 - 08:17 AM

I've opened 3 projects that I've done a little work on over the past week, and believe it or not, line 18 was blank on all three of them. So I will leave you with the blank area between this line and my signature.

This post has been edited by Kilorn: 18 April 2011 - 08:17 AM

Was This Post Helpful? 4
  • +
  • -

#3 m-e-g-a-z  Icon User is offline

  • Winning
  • member icon


Reputation: 496
  • View blog
  • Posts: 1,453
  • Joined: 19-October 09

Re: Paste Today's Line Of Code

Posted 18 April 2011 - 08:32 AM

Here we go..

return properties.getProperty("oauth.consumerSecret");

I'm working on a Twitter App with some funky AI that analyses how much a person tweets each day, what they tweet about and general statistical data. The line of code retrieves values from a properties file authorizing the application with the consumer token.
Was This Post Helpful? 0
  • +
  • -

#4 lordofduct  Icon User is offline

  • I'm a cheeseburger
  • member icon


Reputation: 2533
  • View blog
  • Posts: 4,633
  • Joined: 24-September 10

Re: Paste Today's Line Of Code

Posted 18 April 2011 - 08:34 AM

Well I don't know the legality of copying out lines of code from my normal day job, so I won't be doing that.

My personal stuff I wrote at home though, that's not a big deal. It is mine after all.

And for both jobs I don't know what would constitute the 'file' I'm working on today seeing as I could easily be working on a ton of different files at any given point.

So I'll take a line of relevant code from the resulting 'level' of my game that references a good deal of what I worked on in the last 24 hours.

TileMapData tmd = Services.Load<TileMapData>(@"Content/Maps/Example", this.ContentManagerName);
_tileMap = TileMap.FromTileMapData(tmd, new TileFactory(VisualTheme.Limestone, this.ContentManagerName));



So I'm writing a level editor that allows me to 'paint' a tile map for a level. It's a redactive map that you cut away paths that can be taken. Then the program will 'resolve' the paths and guess what tiles should be in the remaining spots based on the shape of the paths. Like this:

Spoiler

I needed to write a few things for this.

1) Level Editor
2) Importer and Processor for the XNA pipeline
3) Factory for creating the 3d models that the map represents (the colours in the bitmap)
4) Factory for creating the physics meshes for each tile.

Those two lines of code load a created map data that has been processed through the pipeline. It then builds a TileMap from is then displayed on screen... like so:

Spoiler

This post has been edited by lordofduct: 18 April 2011 - 08:43 AM

Was This Post Helpful? 0
  • +
  • -

#5 Kilorn  Icon User is offline

  • XNArchitect
  • member icon



Reputation: 1356
  • View blog
  • Posts: 3,528
  • Joined: 03-May 10

Re: Paste Today's Line Of Code

Posted 18 April 2011 - 08:35 AM

Does the twitter app often tell people that nobody cares what you're eating for breakfast?
Was This Post Helpful? 0
  • +
  • -

#6 Raynes  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 611
  • View blog
  • Posts: 2,815
  • Joined: 05-January 09

Re: Paste Today's Line Of Code

Posted 18 April 2011 - 08:37 AM

(check-form form state-tester)


This is the 18th line of code from http://try-clojure.org. It's the primary project I've been working on lately. The line of code in question checks a form (code you enter into the repl) for stateful things so that it can sandbox them appropriately.
Was This Post Helpful? 0
  • +
  • -

#7 m-e-g-a-z  Icon User is offline

  • Winning
  • member icon


Reputation: 496
  • View blog
  • Posts: 1,453
  • Joined: 19-October 09

Re: Paste Today's Line Of Code

Posted 18 April 2011 - 08:57 AM

View PostKilorn, on 18 April 2011 - 04:35 PM, said:

Does the twitter app often tell people that nobody cares what you're eating for breakfast?


I hope i make it advanced as that :P
Was This Post Helpful? 0
  • +
  • -

#8 xclite  Icon User is offline

  • LIKE A BOSS
  • member icon


Reputation: 905
  • View blog
  • Posts: 3,170
  • Joined: 12-May 09

Re: Paste Today's Line Of Code

Posted 18 April 2011 - 08:59 AM

filter([Element | List], Limit) when Element =< Limit ->
[Element | filter(List, Limit)];

Yay learning Erlang exercises.
Was This Post Helpful? 0
  • +
  • -

#9 Creecher  Icon User is offline

  • I don't care
  • member icon

Reputation: 561
  • View blog
  • Posts: 2,049
  • Joined: 06-March 10

Re: Paste Today's Line Of Code

Posted 18 April 2011 - 09:04 AM

 if(isset($_POST['Submit'])) 



I'm making an image upload script in PHP for my Web Dev teacher. Yay :D
Was This Post Helpful? 0
  • +
  • -

#10 NickDMax  Icon User is offline

  • Can grep dead trees!
  • member icon

Reputation: 2250
  • View blog
  • Posts: 9,245
  • Joined: 18-February 07

Re: Paste Today's Line Of Code

Posted 18 April 2011 - 09:06 AM

Currently open in my editor:
         if (diff < 0) { 
                digitalWrite(triggerPin, HIGH);
                delay(del);
                digitalWrite(triggerPin, LOW);
         }


This is actually from this weekend. I was working on a high speed photography trigger using my Arduino microcontroller. This bit of code (granted more than one line) looked at a difference in sensor readings and then triggered the camera. The camera syncs on the falling edge of the signal so as soon as the triggerPin goes LOW the camera snaps a picture.
Was This Post Helpful? 0
  • +
  • -

#11 diego_pmc  Icon User is offline

  • D.I.C Addict

Reputation: 81
  • View blog
  • Posts: 565
  • Joined: 13-May 09

Re: Paste Today's Line Of Code

Posted 18 April 2011 - 09:15 AM

position_.x += speed_ * timePassed * std::cos(directionRadians_);



That's a line of code I wrote yesterday. It's from the Entity::update() function in a 2D game. Atm I trying to figure out a neat way for the Entity to interact with its EntityController and its EntityRepresentation. I'd like the representation and the controller to interact with the entity in a somewhat symmetrical manner (and obviously in a very simple and clear way).
Was This Post Helpful? 0
  • +
  • -

#12 BenignDesign  Icon User is online

  • holy shitin shishkebobs
  • member icon




Reputation: 6092
  • View blog
  • Posts: 10,527
  • Joined: 28-September 07

Re: Paste Today's Line Of Code

Posted 18 April 2011 - 09:57 AM

$parent=$L1_result['asimm_id'];


Working on a new site for a "wholly owned entity" of my employer. :)
Was This Post Helpful? 0
  • +
  • -

#13 Nikhil_07n  Icon User is offline

  • The cheese stands alone..
  • member icon

Reputation: 49
  • View blog
  • Posts: 2,489
  • Joined: 09-January 09

Re: Paste Today's Line Of Code

Posted 18 April 2011 - 10:10 AM

DataColumn dc_3 = new DataColumn("Number", typeof(int));


Exploring System.Data in C#.
Was This Post Helpful? 0
  • +
  • -

#14 hookiethe1  Icon User is offline

  • D.I.C Lover

Reputation: 416
  • View blog
  • Posts: 1,335
  • Joined: 28-September 10

Re: Paste Today's Line Of Code

Posted 18 April 2011 - 10:19 AM

private string[] StateArray = new string[64];


This is part of a semester long group project that requires writing a chess game for PvP over the net. It doesn't need to be able to play a game itself, but it does need to enforce the rules, which is a nice exercise in logic because chess has so many special cases. I use the array to represent the game state, each one is 3 characters that tells the handler function what piece is in the square and what color it is.

(I don't even have the option of pasting code I've written for work, I've done nothing but integration testing for months now and it's really starting to crush my spirit, but I guess that's what interns are for)

This post has been edited by hookiethe1: 18 April 2011 - 10:20 AM

Was This Post Helpful? 0
  • +
  • -

#15 mcampos  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 18-April 11

Re: Paste Today's Line Of Code

Posted 18 April 2011 - 10:24 AM

This is from my Flash homework that is due today.

user_txtbox.text = userScore.toString();

Was This Post Helpful? 0
  • +
  • -

  • (12 Pages)
  • +
  • 1
  • 2
  • 3
  • Last »