Skip to content

Instantly share code, notes, and snippets.

//Override UICollectionViewFlowLayout class
@interface FixedHeaderLayout : UICollectionViewFlowLayout
@end
@implementation FixedHeaderLayout
//Override shouldInvalidateLayoutForBoundsChange to require a layout update when we scroll
- (BOOL) shouldInvalidateLayoutForBoundsChange:(CGRect)newBounds {
return YES;
}
#!/bin/sh
until [ -z $1 ]; do
unix2dos $1 2>/dev/null
iconv -f UTF-8 -t GBK $1 -o /tmp/unix2doc.tmp 2>/dev/null
if [ $? -eq 0 ]; then
mv /tmp/unix2doc.tmp $1
echo "linux2win: converting file $1 to WIN format ..."
else
/* a clever way to implement string multiplication in JavaScript */
String.prototype.times = function(n) {
return Array.prototype.join.call({length:n+1}, this);
};
"js".times(5) // => "jsjsjsjsjs"
#include <stdlib.h>
#include <stdio.h>
#include <setjmp.h>
jmp_buf __exception_context;
#define try if(!setjmp(__exception_context))
#define catch else
#define throw_exception longjmp(__exception_context, 1)