Skip to content

Instantly share code, notes, and snippets.

View cmar's full-sized avatar

Chris Mar cmar

  • CustomInk
  • Northern, VA
  • X @cmar
View GitHub Profile
@cmar
cmar / reward.py
Created December 5, 2018 13:24
Example Deep Racer Reward Function
# 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
@cmar
cmar / decipher.rb
Last active May 4, 2018 17:00
Use AWS Rekognition to Translate binary code from screenshot
#!/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
@cmar
cmar / docker-compose.yml
Last active May 21, 2017 13:10
docker-compose.yml
# 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:
@cmar
cmar / prepended.rb
Last active May 11, 2017 12:52
example of prepended class methods
class Foo
def self.say
p "hello from Foo"
end
end
module Bar
def self.say
@cmar
cmar / gist:8e947a78470b82899d32
Last active June 28, 2016 16:05
benchmark each_with_object
# 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)
@cmar
cmar / rails_5_template.rb
Created June 18, 2016 21:33
Rails 5 Template
# $ rails new thud -m https://gist.github.com/radar/722911/raw/
gem "rspec-rails", group: "test"
gem "pry"
gem "devise"
@cmar
cmar / gist:7884029
Created December 10, 2013 00:56
Connect 4 from RubyLoCo Hack NIght
require 'pry'
class Board
def initialize
@columns = []
7.times do
@columns << Array.new(6, '_')
end
end
@cmar
cmar / star-wars.rb
Created September 14, 2015 19:48
RubyLoCo Star Wars Hack Night Example
#! /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'
@cmar
cmar / -
Created July 25, 2013 17:25
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'
require 'openssl'
OpenSSL::SSL::VERIFY_PEER = OpenSSL::SSL::VERIFY_NONE