Skip to content

Instantly share code, notes, and snippets.

Avatar

Esteban Pintos epintos

  • WeTransfer
  • Amsterdam
View GitHub Profile
@epintos
epintos / main.yml
Created Aug 14, 2020
Apiary Github Action
View main.yml
name: Deploy API Documentation
on:
push:
branches:
- master
jobs:
deploy-doc-apiary:
name: Push API doc to Apiary
@epintos
epintos / mediumOverviewStats.js
Created Jan 20, 2017
Export Medium Overview Stats to CSV
View mediumOverviewStats.js
// 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 Mar 8, 2021
Export Medium Stats Stores to CSV
View mediumStoriesStats.js
// 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 Jul 4, 2018
Authentication For Rails Training
View Gemfile
# ....
gem 'versionist'
gem 'jwt'
# ....
@epintos
epintos / 0010_sidekiq.config
Created Apr 29, 2016
AWS Elastic Beanstalk Sidekiq Config File
View 0010_sidekiq.config
# 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 Mar 7, 2016
Pull Request Github Template Example
View pull_request_template.md

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 Mar 7, 2016
Git Pre Push example to check linters and run tests
View pre-push.sh
#!/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 Jan 14, 2016
Document with token validator
View document.rb
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 Jan 18, 2016
UniqueTokenValidator Concern
View unique_token_validator.rb
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 Jan 14, 2016
AddNameDescriptionDateUniqueIndexToDocument
View add_name_description_date_unique_index_to_document.rb
class AddNameDescriptionDateUniqueIndexToDocument < ActiveRecord::Migration
def change
add_index :document, [:name, :description, :date], unique: true
end
end