sdfgeoff
(sdfgeoff)
January 16, 2013, 10:38pm
1
In a few categories:
Repetitiveness:
'KList2':[str(keyS['slideForwards'])+'
'+str(keyS['slideBackwards'])+'
'+str(keyS['slideLeft'])+'
'+str(keyS['slideRight'])+'
'+str(keyS['slideUp'])+'
'+str(keyS['slideDown'])+'
'+str(keyS['afterburner'])+'
'+str(keyS['tiltUp'])+'
'+str(keyS['tiltDown'])+'
'+str(keyS['bankLeft'])+'
'+str(keyS['bankRight'])+'
'+str(keyS['panLeft'])+'
'+str(keyS['panRight']),
(It’s an entry in a dictionary that contains references to another dictionary for a keymapper)
Unreadibility:
joyS[dictElement[:-1]][int(dictElement[-1:])] = str(joyS[dictElement[:-1]][int(dictElement[-1:])])+key
(joyS is a dictionary of settings, dictElement is a string like ‘roll1’ that indicates an item in the dictionary, and a position in that item. It then appends a single character onto the end from the user’s keyboard.)
ideasman42
(ideasman42)
January 17, 2013, 2:52am
2
By Far, blender institute renderfarm :), (though I cant claim full responsibility).
http://projects.blender.org/scm/viewvc.php/trunk/py/scripts/tools/bi_farm/new_master.py?view=markup&root=bf-extensions&sortdir=down
With Some python experience - you can see the horror of it.
… not my code originally but I worked on making it easier to follow (no kidding, since I had to fix bugs in it!).
/* grow an array by a specified number of items */
#define BLI_array_grow_items(arr, num) ( \
(((void *)(arr) == NULL) && \
((void *)(_##arr##_static) != NULL) && \
/* dont add _##arr##_count below because it must be zero */ \
(_bli_array_totalsize_static(arr) >= _##arr##_count + num)) ? \
/* we have an empty array and a static var big enough */ \
((arr = (void *)_##arr##_static), (_##arr##_count += (num))) \
: \
/* use existing static array or allocate */ \
(LIKELY(BLI_array_totalsize(arr) >= _##arr##_count + num) ? \
(_##arr##_count += num) : /* UNLIKELY --> realloc */ \
( \
(void) (_##arr##_tmp = MEM_callocN( \
sizeof(*arr) * (num < _##arr##_count ? \
(_##arr##_count * 2 + 2) : \
(_##arr##_count + num)), \
#arr " " __FILE__ ":" STRINGIFY(__LINE__) \
) \
), \
(void) (arr && memcpy(_##arr##_tmp, \
arr, \
sizeof(*arr) * _##arr##_count) \
), \
(void) (arr && ((void *)(arr) != (void *)_##arr##_static ? \
(MEM_freeN(arr), arr) : \
arr) \
), \
(void) (arr = _##arr##_tmp \
), \
(_##arr##_count += num) \
)) \
)
/* returns length of array */
#define BLI_array_grow_one(arr) BLI_array_grow_items(arr, 1)
/* appends an item to the array. */
#define BLI_array_append(arr, item) ( \
(void) BLI_array_grow_one(arr), \
(void) (arr[_##arr##_count - 1] = item) \
)
/* appends an item to the array and returns a pointer to the item in the array.
* item is not a pointer, but actual data value.*/
#define BLI_array_append_r(arr, item) ( \
(void) BLI_array_grow_one(arr), \
(void) (arr[_##arr##_count - 1] = item), \
(&arr[_##arr##_count - 1]) \
)
For full test: https://svn.blender.org/svnroot/bf-blender/trunk/blender/source/blender/blenlib/BLI_array.h
… sadly that is blender code :S
Sackadoo
(fastload64)
January 17, 2013, 9:07am
3
Not code, but pseudo-code:
DWIM (do what I mean)
Atom
(Atom)
January 17, 2013, 9:10am
4
According to Laurie Anderson…
x=x
place57
(place57)
January 17, 2013, 10:10am
5
No code to post, only a story.
Back when windows first came out and everyone was getting used to using a mouse. I had a boss in Japan that was a real jerk. So I wrote a small mouse driver that would switch the left and right mouse buttons after he clicked his left mouse button 20 times. It would swap the mouse buttons for 5 clicks, then switch them back again, waiting for another 20 clicks…
Everyone in the office knew I did this, but it was so enjoyable to watch him get pissed off at the computer that no one said a word…
Moral of the story: Don’t f#$% with someone that knows how to write drivers for your computer…