Skip to content

Instantly share code, notes, and snippets.

class Derpbot9000 < RTanque::Bot::Brain
NAME = 'derpbot9000'
include RTanque::Bot::BrainHelper
TURRET_FIRE_RANGE = RTanque::Heading::ONE_DEGREE * 1.0
def tick!
turn_randomly
command.speed = MAX_BOT_SPEED
if (target = self.nearest_target)
self.fire_upon(target)
class Derpbot9000 < RTanque::Bot::Brain
NAME = 'derpbot9000'
include RTanque::Bot::BrainHelper
def tick!
turn_randomly
command.speed = MAX_BOT_SPEED
command.turret_heading = sensors.turret_heading - 0.1
command.fire(0.1)
end
# lib/download_counter.rb
def downloads_for(records)
ids = records.all.each.map(&:uuid).join(",")
JSON.parse(Excon.get("/downloads?uuids=#{ids}"))
end
# controller
def index
@episodes = Episode.find_all_by_whatever
@downloads = DownloadCounter.downloads_for(@episodes)
-----BEGIN CERTIFICATE-----
MIIFSjCCBDKgAwIBAgIQdOaH8EhWNAjG4CztgBhDdjANBgkqhkiG9w0BAQUFADBy
MQswCQYDVQQGEwJHQjEbMBkGA1UECBMSR3JlYXRlciBNYW5jaGVzdGVyMRAwDgYD
VQQHEwdTYWxmb3JkMRowGAYDVQQKExFDT01PRE8gQ0EgTGltaXRlZDEYMBYGA1UE
AxMPRXNzZW50aWFsU1NMIENBMB4XDTE0MDQyMjAwMDAwMFoXDTE1MDQyMjIzNTk1
OVowgYwxITAfBgNVBAsTGERvbWFpbiBDb250cm9sIFZhbGlkYXRlZDEuMCwGA1UE
CxMlSG9zdGVkIGJ5IEluc3RyYSBDb3Jwb3JhdGlvbiBQdHkuIExURDEeMBwGA1UE
CxMVRXNzZW50aWFsU1NMIFdpbGRjYXJkMRcwFQYDVQQDFA4qLm5hcnJhdGl2ZS5p
czCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAK4dCVWXj3/wL+fG68Og
buBK42syGaiWoC2OGgGDi9WFp9Gdzxow7NQlhRcKfZjaVGkoLx8EBpBI8LSGWh17
@chadbailey59
chadbailey59 / auto hide tabs.coffee
Last active July 18, 2017 08:40
Auto hide your Atom tab bar if only one tab is open.
# Put this in your init script (Atom ➞ Open Init Script)
tabs = atom.workspaceView.find('.tab-bar')
tabs.on "DOMNodeInserted", ->
# find each tab bar
if (tabs.find('li').length) > 1
tabs.slideDown(300)
else
tabs.slideUp(300)
@chadbailey59
chadbailey59 / gist:9139467
Created February 21, 2014 17:54
Use TextExpander to create a quick Markdown link by entering link text and the first Google result for a search term.

Save this as glucky-markdown.rb somewhere...

#!/usr/bin/env ruby

require 'uri'
require 'json'
require 'net/http'

def goog(msg)
def select2_select(option, opts={})
# same as foundation_select, but for select2
# boxes used throughout the staff app.
originating_select_name = opts[:from]
custom_select = find("select[name='#{originating_select_name}']").parent.find(".select2-container")
# click dropdown
custom_select.find("a.select2-choice").click
# click option with correct text
find("ul.select2-results").find('li', text: option).click
@chadbailey59
chadbailey59 / post-merge
Last active December 11, 2015 22:29
save this as `.git/hooks/post-merge` in any of your repos. Then, when you do a `git pull` (or really any merge I think), if any migrations were updated or the Gemfile was edited, you'll get a handy reminder to migrate or bundle install.
#!/usr/bin/env ruby
# Put me in .git/hooks/post-merge
# Then do chmod a+x .git/hooks/post-merge
migrations = `git diff --name-only master master@{1} | grep db/migrate | wc -l`.strip.to_i
if migrations > 0
puts " "
puts "**************************************************************"
puts "**************************************************************"
@chadbailey59
chadbailey59 / gist:3144491
Created July 19, 2012 14:53
James, I love it.
This looks great.
db2-dfw:/var/www/youversion.com/db/youversiondev# ./migrate
Buildfile: /var/www/youversion.com/db/youversiondev/build.xml
update-database:
[dbdeploy] dbdeploy null
[dbdeploy] Reading change scripts from directory /var/www/youversion.com/db/youversiondev/deltas...
[dbdeploy] Changes currently applied to database:
[dbdeploy] 1..19, 21, 23..27, 29..36, 39
[dbdeploy] Scripts available:
[dbdeploy] 1..36, 38..42