Skip to content

Instantly share code, notes, and snippets.

View taptapdan's full-sized avatar

Daniel Fiore taptapdan

View GitHub Profile
@taptapdan
taptapdan / coco.hunting.party.js
Created January 17, 2016 19:27
CodeCombat: Hunting Party Solution
// http://codecombat.com/play/level/hunting-party
// Strategy: move all troops continuously to the right,
// making sure to keep the archers behind the frontline
// so that the soldiers take the enemy attacks. Player
// character follows along the front line and heals
// any soldier/archer that is below max health.
var front = [ 30, 30, 30 ]; // Frontline for Groups
@taptapdan
taptapdan / wordpress.hide.profile.photo.js
Created January 4, 2016 18:33
Wordpress: jQuery to Hide Google Profile Avatars Ad Link on Profile Page
$("table.form-table td:contains('Google Profile Avatars')").hide();
@taptapdan
taptapdan / coco.binary.search.js
Last active January 1, 2016 23:41
CodeCombat: Binary Search Solution
// http://codecombat.com/play/level/binary-search
// Guess the number that the paladin is thinking of each round.
// She will indicate whether the answer is a higher or lower number after each guess.
// She moves to x<39.5 if lower and x>40.5 if higher
// and x==40 if correct.
// The paladin's maxNum property is the upper bound of the number.
var paladin = this.findNearest(this.findFriends());
@taptapdan
taptapdan / coco.black.diamond.js
Created January 1, 2016 19:11
CodeCombat: Black Diamond Solution
// track positions for safe route back to center
var positionStack = [];
// track last target, to determine changes
var lastTarget = { x: 40, y: 34 };
loop {
var gem = this.findNearest(this.findItems());
if (gem) {
@taptapdan
taptapdan / coco.backwoods.treasure.js
Created January 1, 2016 18:40
CodeCombat: Backwoods Treasure Solution
// Returns Best Coin to Move Toward
this.bestCoin = function() {
var bestCoin = null;
var coinRank = 0;
var coins = this.findItems();
for (var i=0; i < coins.length; i++) {
if ( coins[i].value / this.distanceTo(coins[i]) > coinRank ) {
coinRank = coins[i].value / this.distanceTo(coins[i]);
bestCoin = coins[i];
@taptapdan
taptapdan / coco.boulder.woods.js
Created December 26, 2015 19:32
CodeCombat: Boulder Woods Solution
// Use isPathClear to move around the randomly positioned boulders.
// Automatic pathfinding doesn't work in Boulder Woods.
loop {
var angle = Math.PI / 2 - Math.PI / 16;
while (angle >= -Math.PI / 2) {
var targetX = this.pos.x + 5 * Math.cos(angle);
var targetY = this.pos.y + 5 * Math.sin(angle);
// Use isPathClear between your current pos and the target.
targetPos = { x: targetX, y: targetY };
@taptapdan
taptapdan / coco.backwoods.brawl.js
Created December 26, 2015 19:17
CodeCombat: Backwoods Brawl Solution
// Stay alive for one minute.
// If you win, it gets harder (and more rewarding).
// If you lose, you must wait a day before you can resubmit.
// Remember, each submission gets a new random seed.
// Determines if Warrior should use cleave
// When?
// - If cleave is ready AND
// - If there are more than 2 enemies within cleave range
this.shouldCleave = function() {
@taptapdan
taptapdan / functions.php
Last active December 14, 2015 17:36
Wordpress, Post Formats, Link -- Adding Support to Widgets
// functions.php
add_theme_support( 'post-formats', array( 'link' ) );
@taptapdan
taptapdan / command line
Last active December 5, 2015 04:23
RailsTutorial Chapter 10 // Configuring CarrierWave to use S3 // Setting Heroku Environment Variables
$ heroku config:set S3_ACCESS_KEY=<access key>
$ heroku config:set S3_SECRET_KEY=<secret key>
$ heroku config:set S3_BUCKET=<bucket name>
$ heroku config:set S3_REGION=<bucket region>
@taptapdan
taptapdan / carrier_wave.rb
Last active December 5, 2015 04:23
RailsTutorial Chapter 10 // Configuring CarrierWave to use S3 // config/initializers/carrier_wave.rb
# config/initializers/carrier_wave.rb
if Rails.env.production?
CarrierWave.configure do |config|
config.fog_credentials = {
# Configuration for Amazon S3
:provider => 'AWS',
:aws_access_key_id => ENV['S3_ACCESS_KEY'],
:aws_secret_access_key => ENV['S3_SECRET_KEY'],
:region => ENV['S3_REGION']