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
# example reward function for reinforcement training | |
def reward_function (on_track, x, y, distance_from_center, car_orientation, progress, | |
steps, throttle, steering, track_width, waypoints, closest_waypoint): | |
import math | |
marker_1 = 0.1 * track_width | |
marker_2 = 0.25 * track_width | |
marker_3 = 0.5 * track_width |
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
#!/usr/bin/env ruby | |
# You will need to setup your aws keys in your ENV | |
# AWS_SECRET_ACCESS_KEY | |
# AWS_ACCESS_KEY_ID | |
# and also enable the user to have access to Rekognition:detect_text in IAM | |
require 'aws-sdk' | |
# Screenshot from email https://s3.amazonaws.com/spdev/inkovate-binary-2018.jpg |
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
# add this file to your project and run | |
# docker-compose up | |
# point your database.yml to postgres on localhost:5432 | |
version: '2' | |
services: | |
db: | |
image: postgres | |
ports: | |
- "5432:5432" | |
environment: |
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
class Foo | |
def self.say | |
p "hello from Foo" | |
end | |
end | |
module Bar | |
def self.say |
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
# each_with_index, each_with_object and inject({}) are all %50 slower then #each | |
# simple each with an addition noop | |
[4] pry(main)> puts Benchmark.measure { (1..10_000_000).each { |i| i + 1 } } | |
0.450000 0.000000 0.450000 ( 0.448808) | |
# each_with_index | |
[5] pry(main)> puts Benchmark.measure { (1..10_000_000).each_with_index { |i, index| i + 1 } } | |
0.650000 0.000000 0.650000 ( 0.645812) |
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
# $ rails new thud -m https://gist.github.com/radar/722911/raw/ | |
gem "rspec-rails", group: "test" | |
gem "pry" | |
gem "devise" |
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
require 'pry' | |
class Board | |
def initialize | |
@columns = [] | |
7.times do | |
@columns << Array.new(6, '_') | |
end | |
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
#! /usr/bin/env ruby | |
# RubyLoCo Star Wars Hack Night | |
# Documentation https://swapi.co/documentation | |
require 'bundler/inline' | |
# true to install gems | |
gemfile false do | |
source 'https://rubygems.org' | |
gem 'httparty' |
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
it 'subscribes new users to a mailing list' do | |
@usps.should_receive(:picked_up?).with('EJ958083578US').and_return(true) | |
post '/pickup_check', message.to_json, auth | |
last_response.status.should == 200 | |
json = JSON.parse last_response.body | |
json['message_id'].should eq 'abc' | |
json['messages'].first['message'].should eq 'shipment:dispatch' | |
json['messages'].first['payload']['shipment_number'].should eq 'H12345678901' |
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
require 'openssl' | |
OpenSSL::SSL::VERIFY_PEER = OpenSSL::SSL::VERIFY_NONE |
NewerOlder