Skip to content

Instantly share code, notes, and snippets.

@epintos
epintos / main.yml
Created August 14, 2020 09:45
Apiary Github Action
name: Deploy API Documentation
on:
push:
branches:
- master
jobs:
deploy-doc-apiary:
name: Push API doc to Apiary
@epintos
epintos / mediumOverviewStats.js
Created January 20, 2017 20:21
Export Medium Overview Stats to CSV
// Max value of the Minutes Read Graph
minutesReadMaxAxis = 810
// Max value of the Views Graph
viewsMaxAxis = 431
// Max value of the Visitors Graph
visitorsMaxAxis = 344
// First date of the graph (US Format)
initialDay = new Date('12/22/2016')
// Days in the graphs
@epintos
epintos / mediumStoriesStats.js
Last active January 22, 2023 10:39
Export Medium Stats Stores to CSV
// Run Inspector Console in chrome and copy and paste the following code in the /stats/stories view
function download(filename, text) {
var pom = document.createElement('a');
pom.setAttribute('href', 'data:text/plain;charset=utf-8,' + encodeURIComponent(text));
pom.setAttribute('download', filename);
if (document.createEvent) {
var event = document.createEvent('MouseEvents');
event.initEvent('click', true, true);
@epintos
epintos / Gemfile
Last active July 4, 2018 15:12
Authentication For Rails Training
# ....
gem 'versionist'
gem 'jwt'
# ....
@epintos
epintos / 0010_sidekiq.config
Created April 29, 2016 14:50
AWS Elastic Beanstalk Sidekiq Config File
# Original: http://www.snip2code.com/Snippet/256399/Amazon-Elastic-Beanstalk-Sidekiq
commands:
create_pre_dir:
command: "mkdir /opt/elasticbeanstalk/hooks/appdeploy/pre"
ignoreErrors: true
create_post_dir:
command: "mkdir /opt/elasticbeanstalk/hooks/appdeploy/post"
ignoreErrors: true
create_restartappserver_pre_dir:
command: "mkdir /opt/elasticbeanstalk/hooks/restartappserver/pre"
@epintos
epintos / pull_request_template.md
Created March 7, 2016 20:15
Pull Request Github Template Example

Summary

[Change!] Describe your feature, problems you had, notes, improvements and others.

Screenshots

[Change!] Upload screenshots of those views you changed.

Trello Card

@epintos
epintos / pre-push.sh
Created March 7, 2016 20:04
Git Pre Push example to check linters and run tests
#!/bin/sh
echo 'Running Rspec tests'
RUN_CHECK_CMD='bundle exec rspec spec -fd'
RUN_TESTS_OUTPUT=`${RUN_CHECK_CMD}`
if [ $? -eq 1 ]
then
echo "Can't commit! You've broken Rspec tests!!!"
exit 1
@epintos
epintos / document.rb
Created January 14, 2016 21:34
Document with token validator
class Document < ActiveRecord::Base
include UniqueTokenValidator
UNIQUE_FIELDS = {
key: :name,
scope: [:description, :date],
condition: proc { |obj| some_method(obj) }
}
validates UNIQUE_FIELDS[:key], uniqueness: {
@epintos
epintos / unique_token_validator.rb
Last active January 18, 2016 17:39
UniqueTokenValidator Concern
module UniqueTokenValidator
extend ActiveSupport::Concern
included do
validates :unique_token, uniqueness: true, allow_nil: true
before_validation :generate_unique_token
end
def generate_unique_token
if !self.class::UNIQUE_FIELDS[:condition].present? ||
@epintos
epintos / add_name_description_date_unique_index_to_document.rb
Created January 14, 2016 21:19
AddNameDescriptionDateUniqueIndexToDocument
class AddNameDescriptionDateUniqueIndexToDocument < ActiveRecord::Migration
def change
add_index :document, [:name, :description, :date], unique: true
end
end