Skip to content

Instantly share code, notes, and snippets.

@beniutek
beniutek / direct_uploads_controller.rb
Last active November 1, 2023 17:23
Active Storage Direct Upload with multiple services
# This is taken from: https://github.com/rails/rails/blob/main/activestorage/app/controllers/active_storage/direct_uploads_controller.rb
# Have to override this controller because it's actually the easiest way (IMO)
# to let us choose which service to use for a blob that doesn't use
# the default rails active storage service
# place it in the app/controllers/active_storage folder
class ActiveStorage::DirectUploadsController < ActiveStorage::BaseController
# by default, active storage doesn't do any authorization, we choose to do it on our own via devise `authenticate_user!`
# we also get `current_user` thanks to devise
before_action :authenticate_user!
@beniutek
beniutek / obstacle_avoidance
Created December 31, 2019 00:26
obstacle avoidance code for robotbenchmark
# author: beniutek
import math
from controller import Robot
from controller import Compass
def getBearingInDegrees(compass):
north = compass.getValues()
rad = math.atan2(north[0], north[2]);
bearing = (rad - 1.5708) / math.pi * 180.0;
### Keybase proof
I hereby claim:
* I am beniutek on github.
* I am beniutek (https://keybase.io/beniutek) on keybase.
* I have a public key ASAfbvSw6AOzTdspKJNzqfZXtx97HX9BYHaiTxRLqMbZdAo
To claim this, I am signing this object: