Skip to content

Instantly share code, notes, and snippets.

View tjweir's full-sized avatar

Tyler Weir tjweir

View GitHub Profile
//
// EGOTitledTableViewCell.h
// EGOClasses
//
// Created by Shaun Harrison on 6/2/09.
// Copyright 2009 enormego. All rights reserved.
//
#import <UIKit/UIKit.h>
@implementation CPTextView : CPView
{
DOMElement FIXME_textArea;
id _delegate;
CPScrollView _scrollView;
CPView _contentView;
JSObject _existingSelectStart;
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info {
UIImage *tempImage = [info objectForKey:UIImagePickerControllerEditedImage];
[image setImage:tempImage];
CGSize size = [tempImage size];
CGFloat ratio = 0;
if (size.width > size.height) {
ratio = kImageConstraint / size.width;
/**
* REST interface to Akka's JMX service.
* <p/>
* Here is an example that retreives the current number of Actors.
* <pre>
* http://localhost:9998/management
* ?service=service:jmx:rmi:///jndi/rmi://localhost:1099/jmxrmi
* &component=se.scalablesolutions.akka:type=Stats
* &attribute=counter_NrOfActors
* </pre>
In some cases the type of a method's result may depend on the type of its arguments.
To accurately express the signatures of such methods one may use parametric polymorphism.
A parametrically polymorphic method signature introduces one or more formal type arguments
which can be used throughout the signature and the method body. When the message is sent,
the actual types will be inferred and replace the formal type arguments in the signature.
As an example, consider the signature of -[NSArray[T] mapArrayUsingBlock:]
- (NSArray[X]) mapArrayUsingBlock: (X (^)(T obj) block;
The type term X def introduces a type argument X, which will be inferred to be the type returned
- (BOOL)ccTouchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
UITouch* myTouch = [touches anyObject];
CGPoint location = [myTouch locationInView: [myTouch view]];
location = [[Director sharedDirector]convertCoordinate:location];
m_mouseWorld.Set(location.x/PTM_RATIO, location.y/PTM_RATIO);
// WTF?
// if (m_mouseJoint != NULL)
//multi-part form data upload.
- (NSData *)generatePostDataForData:(NSData *)uploadData
{
// Generate the post header:
NSString *post = [NSString stringWithCString:"--AaB03x\r\nContent-Disposition: form-data; name=\"upload[file]\"; filename=\"somefile\"\r\nContent-Type: application/octet-stream\r\nContent-Transfer-Encoding: binary\r\n\r\n" encoding:NSASCIIStringEncoding];
// Get the post header int ASCII format:
NSData *postHeaderData = [post dataUsingEncoding:NSASCIIStringEncoding allowLossyConversion:YES];
// Generate the mutable data variable:
Let's say you have a bit of a page like so:
<lift:SomeSnippet.section>
<foo:name/>
<lift:SomeSnippet.section>
Now, let's assume that computing whatever is bound to <foo:name/>
takes a long time (maybe it takes a network call, or a long database
query, or whatever). You don't want to hold up your entire page view
on that so.....
/**
* Return a block that computes the next value and returns the next stream instance.
*/
static PLStreamRemainingBlock NextStream (NSNumber *current) {
/** Create a block which will return the next stream value */
PLStreamRemainingBlock f = ^{
PLStreamRemainingBlock remaining;
NSNumber *value;
/* Create the new stream */
/*
Sorry to revive a thread that's two months old, but I thought this might be of help to somebody in the future. Obviously the best solution to this is a simple animation. It's much less resource intensive and it will look better. However, if you're like me and have very little knowledge of animation techniques and no artist to work with, you CAN make a passable waterfall with a particle effect. Keep in mind that when I say passable, I mean exactly that... it's not very pretty, but it gets the job done in a pinch. I'm likely going to try to change this out for an animation once I can figure out how to get the desired effect. In the meantime, though, perhaps someone will find this helpful.
*/
@implementation ParticleWaterfall
- (id) init
{
return [self initWithTotalParticles:100];
}