Skip to content

Instantly share code, notes, and snippets.

View Me1000's full-sized avatar

Randy Luecke Me1000

View GitHub Profile
// totally works!
[UIView animateWithDuration:0.5
delay:0
usingSpringWithDamping:.5
initialSpringVelocity:1
options:0
animations:^{
CGRect bounds = self.scrollview.bounds;
bounds.origin = CGPointZero;
self.scrollview.bounds = bounds;
@Me1000
Me1000 / gist:5439162
Last active December 16, 2015 13:08
// I'm a bad person
var loc = window.location.hash;
if (loc.length > 0)
{
loc = loc.substr(1);
if (typeof window[loc] === "function")
window[loc]();
}
Test 0:
Manual Time: 0.001s
Built In Time: 0s
Test 1:
Manual Time: 0s
Built In Time: 0s
Test 2:
Manual Time: 0.003s
Built In Time: 0s
Test 3:
@implementation Foo : Bar
{
id foo;
id x;
}
- (void)setFoo:(id)foo
{
var blah = foo;
foo = blah;
retainedSelf = self;
- (void)scrollViewDidScroll:(UIScrollView *)scrollView
{
const CGFloat threshHold = -60.0f;
const float minOpacity = 0.2;
CGFloat currentOffset = [scrollView contentOffset].x;
if (currentOffset < 0.0)
{
CGFloat currentProgress = currentOffset / threshHold;
[scrollView setAlpha:MAX(1.0 - (1.0 * currentProgress), minOpacity)];
@implementation VerticalLayoutView : CPView
{
double gapBetweenViews;
}
- (void)setGapBetweenViews:(double)aGap
{
gapBetweenViews = aGap;
}
NSString *localDateString = [NSDateFormatter dateFormatFromTemplate:@"MdY" options:0 locale:[NSLocale currentLocale]];
NSCharacterSet *validChars = [NSCharacterSet letterCharacterSet];
NSInteger i = 0;
NSMutableString *newString = [NSMutableString stringWithCapacity:5];
while (i < [localDateString length])
{
char charatcter = [localDateString characterAtIndex:i];
static NSString *appendChar = @"%c";
/**
Goal: have a properly localized date (month/day in the correct order), yet
have a custom date component separator.
Example as follows:
*/
NSLocale *usLocale = [[NSLocale alloc] initWithLocaleIdentifier:@"en_US"];
NSLocale *gbLocale = [[NSLocale alloc] initWithLocaleIdentifier:@"en_GB"];
NSLocale *deLocale = [[NSLocale alloc] initWithLocaleIdentifier:@"de_DE"];
echo "Hi, I'm Douglas Crockford. What do you want?";
while read question
do
what="$question"
if [ -z "${what}" ]; then
echo "Stop waisting my time."
exit
else