Skip to content

Instantly share code, notes, and snippets.

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];
/*!
@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>
@import <AppKit/AppKit.j>
@import <Foundation/Foundation.j>
@implementation STSplitView : CPSplitView
{
}
- (id)initWithFrame:(CGRect)frame {
self = [super initWithFrame:frame];
if (self) {
AppBadgeViewDragType = "AppBadgeViewDragType";
function hypot(x,y) {
var hyp = Math.sqrt(x*x + y*y);
return hyp;
}
@implementation AppBadgeItemView : CPView
{
@dbrajkovic
dbrajkovic / setupButtonBar.j
Created March 16, 2011 18:35
This assumes you created a CPButtonBar
var buttonBar = [[CPButtonBar alloc] initWithFrame:CGRectMake(0,0,100,32)]; //you need to use your own frame obviously
[someSuperView addSubview:buttonBar];
var addButton = [CPButtonBar plusButton];
[addButton setAction:@selector(add:)];
[addButton setTarget:self];
[addButton setEnabled:YES];
var minusButton = [CPButtonBar minusButton];
/*
* More info at: http://phpjs.org
* http://phpjs.org/functions/index
*
* php.js is copyright 2009 Kevin van Zonneveld.
* Dual licensed under the MIT (MIT-LICENSE.txt)
* and GPL (GPL-LICENSE.txt) licenses.
*
* Conversion to Objective-J copyright 2009 Philippe Laval
* Licenced under the same MIT, GPL dual licences.
@dbrajkovic
dbrajkovic / STAttachedWindow.j
Created March 9, 2011 14:58
A subclass of TNAttachedWindow that prevents a window from going too far to the left off screen.
/*
* STAttachedWindow.j
* stocktwits-desktop-2
*
* Created by Daniel Brajkovic on 12/13/10.
* Copyright Witton Technology Group 2010. All rights reserved.
*/
@import "TNAttachedWindow.j"
var addButton = [CPButtonBar plusButton];
[addButton setAction:@selector(add:)];
[addButton setTarget:self];
[addButton setEnabled:YES];
var minusButton = [CPButtonBar minusButton];
[minusButton setAction:@selector(remove:)];
[minusButton setTarget:self];
[minusButton setEnabled:YES];
[buttonBar setButtons:[addButton, minusButton]];
require 'net/http'
require 'uri'
#1: Simple POST
res = Net::HTTP.post_form(URI.parse('http://www.example.com/search.cgi'),
{'q'=>'ruby', 'max'=>'50'})
puts res.body
#2: POST with basic authentication
res = Net::HTTP.post_form(URI.parse('http://jack:[email protected]/todo.cgi'),
+(void)updateAccount:(CPDictionary)accountParams delegate:(id)delegate
{
var urlString = [CPString stringWithFormat:@"http://api.webservice.com/account/update.json"];
var request = [self requestWithURLString:urlString];
var name = [accountParams valueForKey:@"name"];
var username = [accountParams valueForKey:@"username"];
var email = [accountParams valueForKey:@"email"];
var postBody = [CPString stringWithFormat:@"name=%@&username=%@&email=%@", name, username, email];
[request setValue:[postBody length] forHTTPHeaderField:@"Content-Length"];
[request setHTTPMethod:@"POST"];