Skip to content

Instantly share code, notes, and snippets.

View basecode's full-sized avatar

Tobi Reiss basecode

  • Adobe
  • Basel
View GitHub Profile
@basecode
basecode / gist:995230
Created May 27, 2011 13:20
Raphael.fn.canvas2dArc
var round = function(value) {
return Math.round(value*100)/100;
};
Raphael.fn.canvas2dArc = function(x, y, radius, aStartAngle, aEndAngle, anticlockwise) {
var startX, startY, endX, endY;
var fullCircle = 2 * Math.PI;
var startAngle = (anticlockwise || 0) ? aEndAngle : aStartAngle;
var endAngle = (anticlockwise || 0) ? Math.abs(fullCircle - aStartAngle) : aEndAngle;
@basecode
basecode / animStartTime.js
Created June 16, 2011 19:19
animationStartTime: shim layer with Date.now() fallback
window.animStartTime = (function(w) {
return w.animationStartTime ||
w.webkitAnimationStartTime ||
w.mozAnimationStartTime ||
w.oAnimationStartTime ||
w.msAnimationStartTime ||
+new Date();
})(window);
@basecode
basecode / detect_special_characters.py
Created December 22, 2011 11:15
'no-break space' detection plugin for Sublime Text 2
# encoding: utf-8
import sublime, sublime_plugin
class DetectSpecialCharacters(sublime_plugin.EventListener):
def on_load(self, view):
sublime.status_message("detect_special_characters is active")
def on_modified(self, view):
# find no-break space
special_characters = view.find_all(u"\u00A0")
@basecode
basecode / UIImage+ColorOverlayCategory.h
Created January 8, 2012 22:18
UIImage Category: Image with UIColor overlay (kCGBlendModeColor, ARC enabled)
// UIImage+ColorOverlayCategory.h
// Created by Tobias Reiss, @basecode on 1/8/12.
#import <UIKit/UIKit.h>
@interface UIImage (ColorOverlayCategory)
- (UIImage*)imageWithColorOverlay:(UIColor*)colorOverlay;
@end
@basecode
basecode / should-work.html
Created March 16, 2012 20:52
Webkit SVG Bugs: <use> + <filter>
<svg style="border:1px solid #000;" width="240" height="200">
<defs>
<symbol id="imageRef">
<image xlink:href="http://www.howtocleanstuff.net/wp-content/uploads/boat.jpg" width="100%" height="100%" />
</symbol>
<filter id="filterRef" height="10" width="10" x="-5" y="-5">
<feGaussianBlur stdDeviation="1"></feGaussianBlur>
</filter>
</defs>
<!-- reuse image reference and apply a blur filter //-->
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@basecode
basecode / AVAudioPlayer+SpriteCategory.h
Created July 1, 2012 19:32
An AVAudioPlayer Category for playing an Audio (mainly Audio-Sprite) File at a certain time for a certain duration. This Code is already in use in several iOS 5 Apps (that make use of ARC) published by MadameLeRenoir.
// AVAudioPlayer+SpriteCategory.h
// Copyright (C) 2012 Tobias Reiss (MIT License)
#import <AVFoundation/AVFoundation.h>
@interface AVAudioPlayer (SpriteCategory)
- (void) playAt:(NSTimeInterval)aStartTime duration:(NSTimeInterval)aDuration;
- (void) playAt:(NSTimeInterval)aStartTime duration:(NSTimeInterval)aDuration completion:(void (^)(void))completionBlock;
- (void) completionCleanup:(NSTimer*)aTimer;
@basecode
basecode / non-writable-factory-functions.js
Created July 17, 2012 20:18
non-writable factory functions
// class+constructor
var Lib = function() {
// instance variable
this.aVariable = 0;
// instance method
this.changeVariable = function(value) {
this.aVariable = value;
return this;
};
}
@basecode
basecode / NSArray+Additions.h
Created July 18, 2012 19:19
NSArray+Additions
// NSArray+Additions.h
// Copyright (c) 2012 Tobias Reiss (MIT License)
#import <Foundation/Foundation.h>
@interface NSArray (Additions)
+ (id)arrayWithObject:(id)object count:(NSUInteger)cnt;
@end
@basecode
basecode / UIImage+Additions.h
Last active October 7, 2015 09:11
UIImage+Additions
// UIImage+Additions.h
// Copyright (c) 2012 Tobias Reiss (MIT License)
#import <UIKit/UIKit.h>
@interface UIImage (Additions)
+ (UIImage *)deviceAgnosticImageNamed:(NSString *)name;
- (UIImage *)deviceAgnosticImageFromRect:(CGRect)frame;