Skip to content

Instantly share code, notes, and snippets.


Owen Peredo Diaz owen2345

View GitHub Profile
owen2345 / main_helper.rb
Created Jun 15, 2016
Perspective Theme (one click install). Template url:
View main_helper.rb
module Themes::PerspectiveTheme::MainHelper
def self.included(klass)
klass.helper_method [:perspective_social_networks] rescue "" # here your methods accessible from views
def perspective_theme_settings(theme)
# callback to save custom values of fields added in my_theme/views/admin/settings.html.erb
# callback called after theme installed
owen2345 / index.html
Created Jun 24, 2014
html5 encode using bootstrap 2
View index.html
<!DOCTYPE html>
<html lang="en">
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
<meta name="description" content="Html5 encode using bootstrap, Lesscss"/>
<meta name="keywords" content="Bootstrap, Lesscss, HTML5, CSS3, Crossbrowser"/>
<meta name="author" content="Owen Peredo Diaz"/>
<meta charset="utf-8"/>
<link rel="icon" href="img/favicon.ico" />
owen2345 / gist:26ab63cbe6af0f2194886c21417c49c1
Last active Nov 1, 2020
Configure e2e tests using cypress for dockerized projects
View gist:26ab63cbe6af0f2194886c21417c49c1
#// .github/actions/ruby.yml => Google actions
# Note: Includes error silence to avoid invalid "exit 0" when opening cypress service (cypress bug)
- name: E2e tests
run: docker-compose run test_content_service bash -c "CI=true foreman start -f Procfile-test-e2e 2> /dev/null"
#// Procfile-e2e ==> Start all required services (rails, react app and then init cypress awaiting for react port)
test_api_server: rm -f tmp/pids/; bundle exec rails s -e test -p 3031 -b '' --pid tmp/pids/
frontend: cd frontend/ && PORT=3030 BROWSER=none RAILS_PORT=3031 yarn start test --silent
owen2345 / ruby.yaml
Created Aug 12, 2020
micro services + micro frnotends CI
View ruby.yaml
name: Content System
- master
- develop
- staging
owen2345 / repair_nested_params.rb
Last active Jun 19, 2020
Repair numbers converted into string (Rails 4)
View repair_nested_params.rb
repair_nested_params({id: '11', age: '25'}) # Sample
def repair_nested_params(obj)
obj.each { |key, value| obj[key] = parse_value(value) }
def parse_value(value)
return repair_nested_params(value) if value.is_a?(Hash)
return if value.is_a?(Array)
return value unless value.is_a?(String)
owen2345 / delayed_job_ext.rb
Last active Mar 20, 2020
Delayed job: uniqueness support, sequential execution support, keep successful jobs
View delayed_job_ext.rb
# frozen_string_literal: true
# config/initializers/delayed_job_ext.rb
# unique jobs across workers
# Sample: my_model.delay(across_uniq_key: 'article-19').create
# Sample: my_model.delay(across_uniq_key: 'article-19').update
# Sample: my_model.delay(across_uniq_key: 'article-19').destroy
# ==> the jobs will be processed in serial, not in parallel:
# can not call update before create or run both at the same time
Delayed::Job.class_eval do
owen2345 / _myslider.html.erb
Last active Mar 13, 2020
Camaleon CMS Create Own Custom Fields (Complex)
View _myslider.html.erb
<div class="group-input-fields-content" data-callback-render="render_my_custom_slider">
<div class="form-group">
<div class="input-group">
<input data-dimension="<%= field.options[:dimension] %>" data-versions="<%= field.options[:versions] %>" data-thumb_size="<%= field.options[:thumb_size] %>" type="url" name="<%= field_name %>[<%= field.slug %>][values][][image]" class="data-error-place-parent image_field form-control <%= "required" if field.options[:required].to_s.to_bool %>"/>
<span class="input-group-addon btn_upload" onclick="load_upload_image_field($(this).prev());"><i class="fa fa-upload"></i> <%= t('camaleon_cms.admin.button.upload_image')%> <%= "(#{field.get_option('dimension')})" if field.get_option('dimension').present? %></span>
<div class="clearfix">
owen2345 / uniqueness_job.rb
Created Sep 20, 2019
Sidekiq uniqueness jobs. Permits to avoid duplicated jobs already enqueued or scheduled.
View uniqueness_job.rb
# frozen_string_literal: true
require 'sidekiq/api'
module UniquenessJob
extend ActiveSupport::Concern
included do
class << self
alias_method :client_push_old, :client_push
def client_push(item)
owen2345 / Gemfile
Created Aug 31, 2019
Multiple man subscribe testing
View Gemfile
gem 'multiple_man'
gem 'bunny-mock'
owen2345 / result.yaml
Last active May 8, 2019
Yaml does not permit to share values between documents in the same file. Then this script helps with that problem.
View result.yaml
apiVersion: extensions/v1beta1
kind: Deployment
env: &env_vars
val1: "val1"
val2: "val2"
apiVersion: extensions/v1beta1
kind: Service