Skip to content

Instantly share code, notes, and snippets.

require "net/http"
url = URI.parse("http://metadata.google.internal/computeMetadata/v1/project/attributes/")
req = Net::HTTP::Get.new(url.path)
req.add_field("Metadata-Flavor", "Google")
res = Net::HTTP.new(url.host, url.port).start do |http|
http.request(req)
end
@thagomizer
thagomizer / gist:6542064
Created September 12, 2013 18:43
Patch for graph to add deleting nodes
diff -r old/lib/graph.rb new/lib/graph.rb
--- old/lib/graph.rb
+++ new/lib/graph.rb
@@ -371,6 +371,13 @@
end
##
+ # Deletes a node from the graph
+ def delete_node node_name
+ nodes.delete(node_name)
class Strafe < RTanque::Bot::Brain
NAME = 'Strafe Master'
include RTanque::Bot::BrainHelper
TICKS_BETWEEN_SWEEPS = 500
RUN_AWAY_TICKS = 1200
def initialize(arena)
super
@run_away_dest = nil
@thagomizer
thagomizer / strafe.rb
Created May 22, 2013 02:19
StrafeBot
class Strafe < RTanque::Bot::Brain
NAME = 'Strafe Master'
include RTanque::Bot::BrainHelper
TICKS_BETWEEN_SWEEPS = 500
RUN_AWAY_TICKS = 1200
def initialize(arena)
super
@run_away_dest = nil
@thagomizer
thagomizer / fib
Created March 21, 2014 01:36
fib in prolog
fib(0,1).
fib(1,1).
fib(N,F):-
N > 1,
X is N - 2,
Y is N - 1,
fib(X,A),
fib(Y,B),
F is A + B.