Open Side Menu Go to the Top
Register
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** ** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD **

06-25-2011 , 09:18 AM
That's weird, it defiantly will sync from my iMac to iPad.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
06-25-2011 , 09:36 AM
Quote:
Originally Posted by TheIrishThug
Dear god man! Step 1, don't make it all one big statement. Step 2, comment the **** out of it. Step 3, ask people that are smarter than you how to do it better.

I have never used LINQ, so I can't actually give you a better way to do it.
I did ask on SO that's basically the only way I know to do it. If you know how to do it better in SQL let me know! I can't think of many other ways to do it without fetching/traversing tons of records.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
06-25-2011 , 09:46 AM
Quote:
Originally Posted by Gullanian
I did ask on SO that's basically the only way I know to do it. If you know how to do it better in SQL let me know! I can't think of many other ways to do it without fetching/traversing tons of records.
Do it in two queries (You may need to play with which query uses the ASC & which uses the DESC)

Code:
SELECT * FROM table WHERE tag < 'Tutorial' ORDER BY tag DESC LIMIT 5
SELECT * FROM table WHERE tag > 'Tutorial' ORDER BY tag DESC LIMIT 5
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
06-25-2011 , 10:11 AM
@Zurvan, that's pretty much what I did to, the Union() just joins them together. The other bit in the query is just filtering out any synonym tags. It looks pretty ugly that's why I posted it!
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
06-25-2011 , 12:53 PM
Found the iPad issue apparently. iTunes seems to want you to enable it first for the iPad individually. Hadn't noticed that. Hooray.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
06-26-2011 , 10:41 AM
Is there a way to use the ternary operator to choose between two operators?

Example:

Code:
BOOL greaterThan = true;

int x = 5;
int y = 10;

if(x (greaterThan? > : <) y)
{
    // if(greaterThan && x > y || !greaterThan && x < y)
}
edit: apparently if(greaterThan? x > y : x < y) works but I like my way better

edit2: maybe not
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
06-26-2011 , 11:08 AM
niggler,

i already have no idea what you're trying to do; introducing the ternary operator is unlikely to make things better.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
06-26-2011 , 11:16 AM
That's some confusing logic, what is it you are trying to achieve? Even if it works, I would favour longer easier to read code
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
06-26-2011 , 11:16 AM
Your idea will not work. The ternary format is
Code:
expression ? statement : statement
Just an operator is not a valid statement, so it is a syntax error.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
06-26-2011 , 11:48 AM
Quote:
Originally Posted by greg nice
code formatting q

i find myself using a lot of if's that end up cascading:

Code:
if (expr1) {
   if (expr2) {
      if (expr3) {
         do_something
      }
   }
}
should i be doing it like this?

Code:
if ((expr1) && (expr2) && (expr3)) {
   do_something
}
but the expressions are usually long, so
Code:
if ( (expr1) 
  && (expr2) 
  && (expr3)) 
{
   do_something
}
yeah case 1 is grotesque, case 2 and 3 are ok.

better to refactor the condition into a function that describes it:

Code:
function myConditionHolds() {
  return ((expr1) && (expr2) && (expr3));  //or break into multiple lines
}

//now you can do
if (myConditionHolds()) {
  //do something
}
NOTE: myConditionHolds() should be named something succinctly describing the conditions as a whole, eg, "allTestsPass()" or whatever
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
06-26-2011 , 02:07 PM
Quote:
Originally Posted by gaming_mouse
better to refactor the condition into a function that describes it:

...

NOTE: myConditionHolds() should be named something succinctly describing the conditions as a whole, eg, "allTestsPass()" or whatever
This is definitely a good suggestion, but I think some people overuse it. Sometimes its just easier to see the three conditional expressions in one place instead of looking at a method called:

Code:
if tests_are_initialized_and_db_connection_exists_and_no_failures_so_far(tests, db_connection, test_status):
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
06-26-2011 , 02:40 PM
Hey, anyone know enough about making C extensions in ruby to know what's going on here?

http://stackoverflow.com/questions/6...ross-instances

Last edited by redCashion; 06-26-2011 at 02:47 PM.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
06-26-2011 , 03:06 PM
Quote:
Originally Posted by redCashion
Hey, anyone know enough about making C extensions in ruby to know what's going on here?

http://stackoverflow.com/questions/6...ross-instances
Yeah, he's using global variables... which unsurprisingly have global scope.

If he wanted variables to be class scoped, then he needed them stored with the class.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
06-26-2011 , 03:30 PM
Quote:
Originally Posted by jjshabado
This is definitely a good suggestion, but I think some people overuse it. Sometimes its just easier to see the three conditional expressions in one place instead of looking at a method called:

Code:
if tests_are_initialized_and_db_connection_exists_and_no_failures_so_far(tests, db_connection, test_status):
Yeah, I think the art of good refactoring is finding the balance between clarity and over-explanation. In this particular case, you'd need to find the one word or two that captures all three things -- otherwise you gain nothing.

In general, you are trying to find the most compact expression possible that still retains the essential meaning. There are guidelines for this but no rules. It is a human and not a technical task: You need to understand how other minds (in this case, the minds of fellow programmers) process information. And it is difficult for the same reason that writing clear, succinct prose is difficult.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
06-26-2011 , 06:33 PM
Quote:
Originally Posted by Neil S
Yeah, he's using global variables... which unsurprisingly have global scope.

If he wanted variables to be class scoped, then he needed them stored with the class.
Hey Neil, that was actually me asking the question. I haven't used C in 10 years and I'm apparently really rusty. I got things to work by using all ruby variables like:

Code:
VALUE TestClass;
VALUE SCOPE;

VALUE set(self, val);
VALUE get();

VALUE set(VALUE self, VALUE val) {
	rb_iv_set(self, "test_var", val);
	return Qnil;
}

VALUE get(VALUE self) {
	return rb_iv_get(self, "test_var");
}

void Init_scope() 
{
	SCOPE = rb_define_module("SCOPE");
	TestClass = rb_define_class_under(SCOPE, "TestClass", rb_cObject);
	
	rb_define_method(TestClass, "set=", set, 1);
	rb_define_method(TestClass, "get", get, 0);

	rb_define_variable("@test_var", 0);
}
But I still don't see how to make a variable have scope that only applies to a class if I write all the code without the ruby helpers. If I declare a C variable in the init method, the other functions don't have access to it. And if I declare it externally it is global. What is the obvious thing that I am missing?
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
06-26-2011 , 06:47 PM
Ah it's you. Good thing I didn't say anything mean eh?

You have to use ruby helpers. Exactly. Ruby can't manage any pure C variables you create, so you can't expect any pure C variables you use to work properly in the context of the ruby runtime.

What you'll sometimes see in extensions is an entire struct shoved into a class as an opaque instance variable. Programming Ruby documents that.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
07-01-2011 , 05:08 AM
didn't realize I had Google+ the whole time, who needs an invite!? I think we can learn a lot about the functionality and future implications of Google+ , just PM me your email

Last edited by freedom18; 07-01-2011 at 05:21 AM.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
07-01-2011 , 01:46 PM
Quote:
Originally Posted by freedom18
didn't realize I had Google+ the whole time, who needs an invite!? I think we can learn a lot about the functionality and future implications of Google+ , just PM me your email
Awesome. PM Sent. I know invitation activations have been temporarily frozen but it'll be nice when they open back up.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
07-06-2011 , 02:48 AM


Brogramming.

Last edited by anononon; 07-06-2011 at 03:12 AM. Reason: if that's not clear, that is me
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
07-06-2011 , 04:18 AM
brogramming loooooool
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
07-06-2011 , 06:12 AM
coors light...what a wuss.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
07-06-2011 , 06:55 AM
Brogramming explains a lot of PHP I see out there.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
07-06-2011 , 02:14 PM
A joke I think programmers will appreciate.

Quote:
Originally Posted by Reddit Post
A woman in a hot air balloon realized she was lost.

She reduced altitude and spotted a man below. She descended a bit more and shouted: 'Excuse me, can you help me? I promised a friend I would meet him an hour ago but I don't know where I am..'

The man below replied, 'You're in a hot air balloon hovering approximately 30 feet above the ground. You're between 40 and 41 degrees north latitude and between 59 and 60 degrees west longitude.'

'You must be an Engineer,' said the balloonist.

'I am,' replied the man, 'how did you know?'

'Well,' answered the balloonist, 'everything you have told me is probably technically correct, but I've no idea what to make of your information and the fact is, I'm still lost. Frankly, you've not been much help at all. If anything, you've delayed my trip by your talk.'

The man below responded, 'You must be in Management.'

'I am,' replied the balloonist, 'but how did you know?'

'Well,' said the man, 'you don't know where you are or where you're going. You have risen to where you are, due to a large quantity of hot air. You made a promise, which you've no idea how to keep, and you expect people beneath you to solve your problems. The fact is you are in exactly the same position you were in before we met, but now, somehow, it's my f**king fault.'

Credit Link: http://www.reddit.com/r/funny/commen...he_balloonist/
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
07-06-2011 , 02:33 PM
lol

This (the woman's) behaviour is also common amongst sales people

Last edited by iggster; 07-06-2011 at 02:43 PM. Reason: hi!
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
07-06-2011 , 02:34 PM
loll!

Last edited by _dave_; 07-06-2011 at 02:35 PM. Reason: both that and brogrammers
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote

      
m