Skip to content

Instantly share code, notes, and snippets.

View donrestarone's full-sized avatar
🤖
Building products

Don Restarone donrestarone

🤖
Building products
View GitHub Profile
@donrestarone
donrestarone / vboxcheatsheet.md
Created October 12, 2020 18:07
virtualbox cheatsheet

list virtualbox volumes

VBoxManage list hdds

resize a volume

VBoxManage modifyhd uui-from-last-step size-in-mb
@donrestarone
donrestarone / ubuntu-server-rails-setup.sh
Last active November 4, 2020 23:39
a simple script for installing rails and dependencies on an ubuntu server
#to run curl link_to_this_raw_gist | sudo bash
sudo apt-get update -y && sudo apt-get upgrade -y
sudo apt install curl -y
sudo apt-get install tmux -y
sudo apt install nodejs -y && sudo apt install npm -y
sudo apt-get install htop build-essential zlib1g-dev openssl libreadline6-dev git-core zlib1g libssl-dev libyaml-dev libsqlite3-dev sqlite3 libxml2-dev libxslt-dev autoconf automake libtool bison libgecode-dev -y && sudo apt-get install libpq-dev -y
echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bashrc && echo 'eval "$(rbenv init -)"' >> ~/.bashrc
git clone https://github.com/sstephenson/rbenv.git ~/.rbenv && git clone https://github.com/sstephenson/ruby-build.git ~/.rbenv/plugins/ruby-build
@donrestarone
donrestarone / run.py
Created October 10, 2020 14:04
python script for object_detectr
import numpy as np
import os
import six.moves.urllib as urllib
import sys
import tarfile
import tensorflow as tf
import zipfile
from collections import defaultdict
from io import StringIO
@donrestarone
donrestarone / create.html.erb
Created October 10, 2020 13:50
analysis result view for object_detectr
<div class="jumbotron mb-0">
<h1 class="display-4">Result</h1>
<p class="lead">Here is your analysis</p>
<hr class="my-4">
<div class="d-block text-center my-4">
<%= link_to 'Analyze another image', root_path, class: 'btn btn-primary btn-lg' %>
</div>
<% if @analyzed_image&.analyzed_image %>
<div class="container-fluid text-center">
<%= image_tag url_for(@analyzed_image.analyzed_image), class: 'img-fluid' %>
@donrestarone
donrestarone / main.js
Created October 10, 2020 13:48
javascript file for image_detectr
window.addEventListener('DOMContentLoaded', (event) => {
const analyzeButton = document.querySelector('#start-analysis');
const loadingButton = document.querySelector('#started-analysis');
console.log(analyzeButton)
$("#new_image").submit(function() {
analyzeButton.classList.add('d-none')
loadingButton.classList.remove('d-none')
@donrestarone
donrestarone / new.html.erb
Created October 10, 2020 13:45
landing page for object_detectr
<div class="jumbotron mb-0">
<h1 class="display-4">Image Classifier</h1>
<p class="lead">Upload an image for analysis</p>
<hr class="my-4">
<%= form_for @image do |f| %>
<div class="form-group">
<%= f.label 'Please select an image you would like analyzed' %>
<%= f.file_field :captured_image, class: 'form-control-file', id: 'uploaded-image' %>
<div class="container text-center my-2">
<img src="" alt="" id="uploaded-image-preview" class="img-fluid w-50">
@donrestarone
donrestarone / images_controller.rb
Created October 10, 2020 13:28
images controller file for object_detectr
class ImagesController < ApplicationController
before_action :image_params, only: [:create]
def create
analysis_session_token = current_visit.visitor_token
path_to_rails = Rails.root.to_s.split('/')
path_to_rails.pop
image = Image.create(image_params)
image.update(analyzing: true)
image.captured_image.variant(resize_to_limit: [800, 800]).processed
path_to_python = "#{path_to_rails.join('/')}/models/research/object_detection"
@donrestarone
donrestarone / routes.rb
Created October 10, 2020 13:24
route file for object_detectr
Rails.application.routes.draw do
resources :images, only: [:create, :new, :index]
root to: "images#new"
end
@donrestarone
donrestarone / image_analysis.rb
Created October 10, 2020 13:19
imag analysis model for object_detectr
class ImageAnalysis < ApplicationRecord
belongs_to :image
has_one_attached :analyzed_image
validate :analyzed_image?
private
def analyzed_image?
errors.add(:base, 'Please upload a valid image (PNG, JPG/JPEG).') unless analyzed_image.attached?
@donrestarone
donrestarone / image.rb
Created October 10, 2020 13:14
image model for object-detectr
class Image < ApplicationRecord
has_one_attached :captured_image
has_one :image_analysis, dependent: :destroy
validate :captured_image?
private
def captured_image?
errors.add(:base, 'Please upload a valid image (PNG, JPG/JPEG).') unless captured_image.attached?