Skip to content

Instantly share code, notes, and snippets.

View marvindpunongbayan's full-sized avatar

Marvin Punongbayan marvindpunongbayan

  • Chromedia Inc.
  • Philippines, Manila
View GitHub Profile
@marvindpunongbayan
marvindpunongbayan / REQUEST
Last active January 26, 2022 06:51
salesforceUpdateCompany endpoint
mutation {
salesforceUpdateCompany(
input: {
salesforceUserId: "USER_TEST_ID_1" # Salesforce user's id who currently accessing the edit page
clientId: "Put here the client ID that I given to you"
secretKey: "Put here the secretKey that I given to you"
salesforceCompanyId: "COMPANY_TEST_ID" # Salesforce organization's id (same value from onboarding)
companyName: "Verizon"
description: "Description if there's a content"
website: "verizon.test"
def calculate_score
questions = self.exam.questions.published
user_answers = self.answers
answered_questions_ids = user_answers.pluck(:exam_question_id)
# Counting the right answer to get the percentage
if exam.small_bite?
total_correct = 0
total_score = questions.not_essays.count
questions.each do |question|
- # SmallBite - Checks
- # SmallBiteSetContent - Surveys
- exam_questions = @object.exam_questions.published.sort_by_position
.row-fluid
.col-sm-12
.heading-block{class: "#{'clean-header' if clean_layout?}"}
.link-menu{class: "#{'clearfix' if clean_layout?}"}
.button-set{style: ("display: none;" if params[:q].present?)}
- if @object.is_a?(SmallBite)
- if admin? || (@object.group.present? && can_manage?(object: @object.group)
@marvindpunongbayan
marvindpunongbayan / aws_move.rb
Last active January 15, 2020 07:54
AWS Move & Rename Folder and Files
# Using aws-sdk and aws-sdk-s3 v1.
# Allows to move a folder and files inside of it to other directory
# Allows to rename a file or folder.
# Thanks to: https://gist.github.com/peterwake/49a829d2062ad3c5962435341692a680
# Usage:
# s3 = Aws::S3::Resource.new(credentials)
# s3_move = S3::Move.new(s3, ENV['S3_BUCKET_NAME'])
# s3_move.move_folder(old_key: object_path, new_key: new_object_path, mode: "rename")
# Controller Action
def custom_download
id = params[:id]
# model variable should have value like: Slide, DriveDocument, User, etc.
model = params[:model]
# file variable: should have paperclip object name like: attachment, image, etc.
file = params[:file]
if model.present? && id.present? && file.present?