Skip to content

Instantly share code, notes, and snippets.

View holtwick's full-sized avatar
👁️‍🗨️
On a mission for privacy

Dirk Holtwick holtwick

👁️‍🗨️
On a mission for privacy
View GitHub Profile
import httplib
import time
import oauth
import urllib
from google.appengine.api import memcache
from django.utils import simplejson as json
from google.appengine.api import users
from google.appengine.ext import webapp
from google.appengine.ext.webapp import template
from google.appengine.ext.webapp.util import run_wsgi_app
- (void)test:(id)some second:(id)sec {
// Inspired by http://stackoverflow.com/questions/1797964/how-to-pass-all-arguments-of-a-method-into-nslog/1799472#1799472
{
// Find argument stack and skip first arguments
void *stack = &self;
stack += sizeof(self);
stack += sizeof(_cmd);
@veritech
veritech / NSManagedObjectContext+blocks.m
Created May 9, 2011 04:21
NSMangedObjectContext async fetch requests
#import <Foundation/Foundation.h>
typedef void (^NSManagedObjectContextFetchCompleteBlock)(NSArray* results);
typedef void (^NSManagedObjectContextFetchFailBlock)(NSError *error);
@interface NSManagedObjectContext (NSManagedObjectContext_blocks)
-(void)executeFetchRequestInBackground:(NSFetchRequest*) aRequest
onComplete:(NSManagedObjectContextFetchCompleteBlock) completeBlock
# These are my notes from the PragProg book on CoffeeScript of things that either
# aren't in the main CS language reference or I didn't pick them up there. I wrote
# them down before I forgot, and put it here for others but mainly as a reference for
# myself.
# assign arguments in constructor to properties of the same name:
class Thingie
constructor: (@name, @url) ->
# is the same as:
@steipete
steipete / gist:1175357
Created August 27, 2011 12:54
Easy [fade] animation for UIImageView.image
- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
selected_ = selected;
if (animated) {
CATransition *transition = [CATransition animation];
transition.duration = 0.25f;
transition.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
transition.type = kCATransitionFade;
[self.selectionImageView.layer addAnimation:transition forKey:nil];
}
@rodbegbie
rodbegbie / facebook.py
Created September 3, 2011 00:15
Hacked version of "official" (but now unsupported) Facebook Python SDK to support OAuth 2.0
#!/usr/bin/env python
#
# Copyright 2010 Facebook
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
- (void)animateImageView:(UIImageView *)imageView newImage:(UIImage *)image {
// build animation block
CATransition *transition = [CATransition animation];
transition.duration = 0.25f;
transition.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
transition.type = kCATransitionFade;
[imageView.layer addAnimation:transition forKey:@"image"];
// set new image
imageView.image = image;
@indragiek
indragiek / gist:1397046
Created November 27, 2011 05:50
NSWindow -isFullscreen
@interface NSWindow (Fullscreen)
- (BOOL)isFullscreen;
@end
@implementation NSWindow (Fullscreen)
- (BOOL)isFullscreen
{
return ([self styleMask] & NSFullScreenWindowMask) == NSFullScreenWindowMask;
}
@end
@indragiek
indragiek / NSWindow+Fade.h
Created November 27, 2011 05:55
NSWindow+Fade - Animator proxy based NSWindow fading
@interface NSWindow (Fade)
- (IBAction)fadeIn:(id)sender;
- (IBAction)fadeOut:(id)sender;
@end
@steipete
steipete / DrawInsetBeveledRoundedRect.m
Created December 17, 2011 10:00
DrawInsetBeveledRoundedRect
void DrawInsetBeveledRoundedRect( CGContextRef context, CGRect rect, CGFloat radius, UIColor *fillColor )
{
//contract the bounds of the rectangle in to account for the stroke
CGRect drawRect = CGRectInset(rect, 1.0f, 1.0f);
//contract the height by 1 to account for the white bevel at the bottom
drawRect.size.height -= 1.0f;
//Save the current state so we don't persist anything beyond this operation
CGContextSaveGState(context);