Skip to content

Instantly share code, notes, and snippets.

View emmanuelsw's full-sized avatar
🦊
Working from home

Emmanuel Deossa emmanuelsw

🦊
Working from home
View GitHub Profile
@emmanuelsw
emmanuelsw / Progress.vue
Last active August 5, 2021 03:16
Vue 3 Progress bar component
<!-- src/components/shared/Progress.vue -->
<template>
<div
class="progress"
:style="{
'width': percent+'%',
'height': show ? height : '0px',
'background-color': canSuccess? color : failedColor,
'opacity': show ? 1 : 0
@emmanuelsw
emmanuelsw / lists.ex
Created April 24, 2020 04:24
lists.ex
defmodule Lists do
def len([]), do: 0
def len([_h|t]), do: 1 + len(t)
def sum([]), do: 0
def sum([h|t]), do: h + sum(t)
def double([]), do: []
def double([h|t]), do: [ 2*h | double(t) ]
@emmanuelsw
emmanuelsw / cloudSettings
Last active January 4, 2022 17:41
VS Code Config
{"lastUpload":"2022-01-04T16:33:17.221Z","extensionVersion":"v3.4.3"}
@emmanuelsw
emmanuelsw / sheet_controller.rb
Last active March 13, 2019 17:48
Base64 to image and upload to AWS using ActiveStorage
def update_sign
sheet = Sheet.find(params[:id])
encoded_image = params[:sign].split(",")[1]
decoded_image = Base64.decode64(encoded_image)
filename = "firma-#{sheet.id}.svg"
File.open("#{Rails.root}/storage/#{filename}", "wb") { |f| f.write(decoded_image) }
sheet.image.attach(io: File.open("#{Rails.root}/storage/#{filename}"), filename: filename)
FileUtils.rm("#{Rails.root}/storage/#{filename}")
render json: rails_blob_path(sheet.image, disposition: "inline")
end