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 / inline-worker-blob.html
Last active December 14, 2015 22:48
A simple example of spawning an inline worker using Blob API.
<html>
<body>
<script id="worker" type="text/worker">
onmessage = function(e) { postMessage('worker: ' + e.data); }
</script>
<script type="text/ecmascript">
var blob = new Blob([
document.querySelector('#worker').textContent
@basecode
basecode / filter_foreignobject.js
Created August 2, 2012 22:46
SVGFilter + SVGForeignObjectElement
<svg width="500" height="500" style="background-color:orange;" version="1.1" xmlns="http://www.w3.org/2000/svg">
<defs>
<filter id="dropShadowStack">
<feGaussianBlur stdDeviation="3"/>
<feOffset dx="3" dy="3" result="offsetblur"/>
<feFlood flood-color="#720"/>
<feComposite in2="offsetblur" operator="in"/>
<feMerge>
<feMergeNode/>
<feMergeNode in="SourceGraphic"/>
@basecode
basecode / myTestConfig.js
Created July 26, 2012 00:15
A Test JSON file
{"BackgroundColor":"#000"}
@basecode
basecode / CGGeometry+Additions.h
Created July 19, 2012 19:11
CGGeometry+Additions
// CGGeometry+Additions.h
// Copyright (c) 2012 Tobias Reiss (MIT License)
#import <CoreGraphics/CGGeometry.h>
CG_INLINE CGRect CGRectScale(CGRect rect, CGFloat mult) {
CGPoint origin = rect.origin;
CGSize size = rect.size;
return CGRectMake(origin.x * mult, origin.y * mult, size.width * mult, size.height * mult);
}
@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;
@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 / 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 / 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;
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@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 //-->