This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from twisted.internet import reactor | |
from twisted.internet.protocol import Factory, Protocol | |
import json | |
class IOSChat(Protocol): | |
def connectionMade(self): | |
self.factory.clients.append(self) | |
print "Client list: ", self.factory.clients | |
def connectionLost(self, reason): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- (void)readDataFromStream:(NSInputStream *)inputStream | |
{ | |
while ([inputStream hasBytesAvailable]) { | |
// Read message length | |
unsigned short length; | |
NSInteger bytesRead = [inputStream read:(uint8_t *)&length maxLength:sizeof(unsigned short)]; | |
if (bytesRead != sizeof(unsigned short)) { | |
NSLog(@"Message length bytes not read successfully."); | |
return; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
id observer = [[NSNotificationCenter defaultCenter] addObserverForName:@"blah" object:nil queue:[[NSOperationQueue alloc] init] usingBlock:^(NSNotification *note) { | |
NSLog(@"%@", note.userInfo); | |
[[NSNotificationCenter defaultCenter] removeObserver:observer]; | |
}]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@implementation CustomView | |
@synthesize someLayer; | |
- (void)awakeFromNib | |
{ | |
self.someLayer = [CALayer layer]; | |
[self.layer addSublayer:self.someLayer]; | |
self.someLayer.bounds = self.bounds; | |
self.someLayer.backgroundColor = [UIColor randomColor].CGColor; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
UIImageView *imageView = [[UIImageView alloc] initWithImage:image]; | |
[self.view addSubview:imageView]; | |
imageView.frame = CGRectMake(self.view.frame.size.width/2 - image.size.width/2, self.view.frame.size.height/2 - image.size.height/2, image.size.width, image.size.height); | |
imageView.transform = CGAffineTransformMakeScale(0.01, 0.01); | |
imageView.alpha = 0.5; | |
UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, imageView.frame.size.width, 100)]; | |
label.textAlignment = UITextAlignmentCenter; | |
label.backgroundColor = [UIColor clearColor]; | |
label.textColor = [UIColor whiteColor]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- (void)textViewDidBeginEditing:(UITextView *)textView | |
{ | |
BOOL scrollToLast = self.chatTableView.contentOffset.y >= self.chatTableView.contentSize.height - self.chatTableView.frame.size.height; | |
[UIView animateWithDuration:0.26 animations:^{ | |
CGRect r = self.messageContainerView.frame; | |
r.origin.y = self.view.frame.size.height - 216 - r.size.height; | |
self.messageContainerView.frame = r; | |
r = self.chatTableView.frame; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- (void)textViewDidBeginEditing:(UITextView *)textView | |
{ | |
[UIView animateWithDuration:0.26 animations:^{ | |
CGRect r = self.messageContainerView.frame; | |
r.origin.y = self.view.frame.size.height - 216 - r.size.height; | |
self.messageContainerView.frame = r; | |
r = self.chatTableView.frame; | |
r.size.height = kTableViewEditingHeight; | |
self.chatTableView.frame = r; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
error: The following untracked working tree files would be overwritten by merge: | |
Library/Formula/autojump.rb | |
Please move or remove them before you can merge. | |
Aborting | |
Updating 647eccc..1334683 | |
Error: Failed while executing git pull origin refs/heads/master:refs/remotes/origin/master |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- (void)forceDisplay | |
{ | |
[self.glkView display]; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def stringReceived(self, string): | |
print self.user.name, ":", string | |
try: | |
request = json.loads(string) | |
except BaseException as e: | |
print "stringReceived exception: ", e | |
else: | |
methodName = request['method'] | |
parameters = request['parameters'] | |
method = self.serverMethods[methodName] |