Skip to content

Instantly share code, notes, and snippets.

AppBadgeViewDragType = "AppBadgeViewDragType";
function hypot(x,y) {
var hyp = Math.sqrt(x*x + y*y);
return hyp;
}
@implementation AppBadgeItemView : CPView
{
@import <AppKit/AppKit.j>
@import <Foundation/Foundation.j>
@implementation STSplitView : CPSplitView
{
}
- (id)initWithFrame:(CGRect)frame {
self = [super initWithFrame:frame];
if (self) {
/*!
@class STWindow.j
@abstract Custom CPWindow class for apps
@detail STWindow is the default window class for apps in StockTwits Desktop. This window class is made to be subclassed.
To enable the menu items, window controllers of the subclass must implement -newWindow: and -showPreferences:
*/
@import <AppKit/AppKit.j>
@import <Foundation/Foundation.j>
var thisDict;
thisDict = [CPDictionary dictionaryWithObjectsAndKeys: appLauncherView,
CPViewAnimationTargetKey,
(open) ? CPViewAnimationFadeOutEffect : CPViewAnimationFadeInEffect,
CPViewAnimationEffectKey];
[anims addObject:thisDict]; //BOOL open determines which effect will occur
animation = [[CPViewAnimation alloc] initWithViewAnimations:anims];
//[animation setAnimationBlockingMode:CPAnimationBlocking];
@dbrajkovic
dbrajkovic / ManageWatchListsController.j
Created April 17, 2011 21:12
Example of Editable CPTableView
@implementation ManageWatchListsController : CPObject
{
@outlet CPTableView watchListTableView;
@outlet CPButtonBar buttonBar;
CPArray watchLists;
var selectedWatchList;
}
-(void)init
{
@dbrajkovic
dbrajkovic / locator.js
Created August 26, 2011 19:04
browser geolocation example script
var map;
var geocoder;
function addAddressToMap(response)
{
map.clearOverlays();
if (!response || response.Status.code != 200)
{
alert("Sorry, we were unable to geocode that address");
}
@dbrajkovic
dbrajkovic / location.js
Created August 26, 2011 19:05
HTML5 Geolocation script example
var map;
var geocoder;
function addAddressToMap(response)
{
map.clearOverlays();
if (!response || response.Status.code != 200)
{
alert("Sorry, we were unable to geocode that address");
}
@dbrajkovic
dbrajkovic / gist:1581185
Created January 9, 2012 04:47
Singlton
+ (id)allocWithZone:(NSZone *)zone {
return [[self sharedManager] retain];
}
- (id)copyWithZone:(NSZone *)zone {
return self;
}
- (id)retain {
return self;
}
- (unsigned)retainCount {
@dbrajkovic
dbrajkovic / UIColor-Hex.h
Created January 24, 2012 22:42
UIColor category which returns a UIColor with a given Hex Code and alpha value
@interface UIColor (Hex)
+ (UIColor *)colorWithHex:(NSString *)hex alpha:(CGFloat)alpha;
- (UIColor *)initWithHex:(NSString *)hex alpha:(CGFloat)alpha;
@end
@dbrajkovic
dbrajkovic / gist:1934933
Created February 28, 2012 20:35
NSDictionary Hash
2012-02-28 15:09:52.944 Untitled[27437:707] {
"#business_information" = {
"-moz-text-shadow" = "1px 1px 1px #333333";
"-ms-text-shadow" = "1px 1px 1px #333333";
"-o-text-shadow" = "1px 1px 1px #333333";
"-webkit-text-shadow" = "1px 1px 1px #333333";
"background-color" = red;
"background-image" = "none !important";
"border-top" = "1px solid #fe8184";
color = "#fff !important";