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
CGFloat xOffset = 240 - (((player.hand.count*20)+52)/2); | |
__block CGPoint location = CGPointMake ((CGFloat) xOffset, (CGFloat) 0); | |
[player.hand enumerateObjectsUsingBlock:^(RMSPlayingCard *obj, NSUInteger idx, BOOL *stop) { | |
NSString *rank = obj.rank; | |
NSString *suit = obj.suit; | |
UIImage *cardImage = [UIImage imageNamed:[NSString stringWithFormat:@"%@%@.png", [[suit substringToIndex:1] lowercaseString], [[rank substringToIndex:1] lowercaseString]]]; | |
UIImageView *cardView = [[UIImageView alloc] initWithFrame:CGRectMake(location.x, location.y, cardImage.size.width, cardImage.size.height)]; | |
[cardView setImage:cardImage]; | |
[self.handView addSubview: cardView]; |
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)removeAllSubviewsFrom:(UIView *)view { | |
NSArray *subviews = [view subviews]; | |
for (UIView *subview in subviews) { | |
[subview removeFromSuperview]; | |
} | |
} |
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)testEndConditionsDeck { | |
RMSGoFishGame *game = [RMSGoFishGame new]; | |
[game deal]; | |
RMSGoFishPlayer *player1 = [game.players objectAtIndex:(NSUInteger)0]; | |
RMSGoFishPlayer *player2 = [game.players objectAtIndex:(NSUInteger)1]; | |
RMSGoFishPlayer *player3 = [game.players objectAtIndex:(NSUInteger)2]; | |
RMSGoFishPlayer *player4 = [game.players objectAtIndex:(NSUInteger)3]; | |
game.deck.cards = [NSMutableArray new]; | |
[game gameLoop]; | |
STAssertEquals(player1.hand.count, (NSUInteger)5,@"Player 1 played after the game was over!"); |
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 save(game) | |
File.open(game.key, 'w') do |file| | |
file.write(game.to_yaml) | |
end | |
end | |
def retrieve(game_id) | |
File.open(game_id, 'r') do |file| | |
YAML::load(file) | |
end |
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
#!/bin/bash | |
# CentOS rbenv system wide installation script | |
# Forked from https://gist.github.com/1237417 | |
# Installs rbenv system wide on CentOS 5/6, also allows single user installs. | |
# Install pre-requirements | |
yum install -y gcc-c++ patch readline readline-devel zlib zlib-devel libyaml-devel libffi-devel openssl-devel \ | |
make bzip2 autoconf automake libtool bison iconv-devel git-core |
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
# Update, upgrade and install development tools: | |
apt-get update | |
apt-get -y upgrade | |
apt-get -y install build-essential | |
apt-get -y install git-core curl | |
apt-get -y install libssl-dev | |
apt-get -y install libreadline5 libreadline5-dev | |
apt-get -y install zlib1g zlib1g-dev | |
# for passenger needed |
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
#!/bin/sh | |
set -e | |
# Example init script, this can be used with nginx, too, | |
# since nginx and unicorn accept the same signals | |
# Feel free to change any of the following variables for your app: | |
TIMEOUT=${TIMEOUT-60} | |
USER=your_deploy_user | |
APP_ROOT=/path/to/app/ | |
CURRENT_ROOT=$APP_ROOT/current |
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
#!/sbin/runscript | |
# unicorn init script for Gentoo Linux | |
APP_ROOT=/var/www/apps/your_app | |
RAILS_ROOT=$APP_ROOT/current | |
USER=your_user | |
extra_commands="reload" | |
depend() { |
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
Architecture: Rails 3.2, Solr 1.4 with sunspot_solr gem, Apache HTTP server as reverse proxy to | |
Rails app, Jquery UI | |
Note: I don't care about the distinction between autocomplete and autosuggest. I am implementing what some | |
people call autosuggest, and I'm calling it autocomplete. | |
Given the above existing architecture, I want to add an autocomplete field into my app for a single | |
attribute on a single model. It needs to be fast and secure (duh). The search target field could have | |
white space and the search input should allow it, e.g., if I search with "iker's gui" it should 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
#!/bin/bash | |
### BEGIN INIT INFO | |
# Provides: sidekiq beta | |
# Required-Start: $syslog $remote_fs | |
# Required-Stop: $syslog $remote_fs | |
# Should-Start: $local_fs | |
# Should-Stop: $local_fs | |
# Default-Start: 2 3 4 5 | |
# Default-Stop: 0 1 6 | |
# Short-Description: sidekiq for fieldvault |
OlderNewer