Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@MrCoffey
MrCoffey / using_whenever.md
Last active January 23, 2021 04:38
Usando whenever con rake

CREANDO TAREAS CON WHENEVER Y RAKE

Es posible que en algún momento lleguemos a necesitar que alguna tarea deba ser ejecutada cada cierto tiempo en estos trabajos se conocen como cronjobs.

En este breve ejemplo exploramos como implementarlos en una applicación de Ruby On Rails, por ejemplo en uno de nuestros tutoriales explicábamos como enviar correos a todos nuestros usuarios con la ayuda de rake, si bien podemos ejecutarla nosotros mismos, sería mucho mejor si alguien hiciera ese trabajo por nosotros. Bueno para esto existe Whenever una gema que nos permite programar tareas haciendo uso de cron log.

La cuestión es que cron, luce así:

SHELL=/bin/bash
#!/usr/bin/env bash
# Modified from https://gist.github.com/Stono/7e6fed13cfd79598eb15
#
# MIT License applies to this script. I don't accept any responsibility for
# damage you may cause using it.
set -ex
if [[ $EUID -ne 0 ]]; then
echo "* This script needs to be run as root"
@MrCoffey
MrCoffey / docker-compose.yml
Created February 25, 2018 04:37
Drone.io configuration file
version: '3.4'
services:
lb:
image: traefik:1.4.5
logging:
driver: json-file
options:
max-size: "10m"
max-file: "3"
@MrCoffey
MrCoffey / Dockerfile
Last active January 20, 2018 23:35
Dockerfile for containers configured to install k8s
#Source: https://github.com/kubernetes/kubernetes/issues/35712
FROM ubuntu
ENV container docker
RUN apt-get -y update
RUN apt-get update -qq && apt-get install -qqy \
apt-transport-https \
ca-certificates \
curl \
lxc \
@MrCoffey
MrCoffey / export_host_env_vars.sh
Created July 23, 2017 22:48
Writes custom ENV variables into aws elastic beanstalk
files:
"/opt/elasticbeanstalk/hooks/appdeploy/pre/02export_host_env_vars.sh":
mode: "000755"
owner: root
group: root
content: |
#!/usr/bin/env bash
echo Defaults:root \!requiretty >> /etc/sudoers
for envvar in `jq '.optionsettings | {"aws:elasticbeanstalk:application:environment"}[] | .[]' /opt/elasticbeanstalk/deploy/configuration/containerconfiguration`
do
@MrCoffey
MrCoffey / new_relic.config
Created January 27, 2017 20:04
Newrelic configuration for elasticbeanstalk
files:
"/opt/elasticbeanstalk/hooks/appdeploy/pre/01-get-env-name.py":
mode: "000755"
owner: root
group: root
content: |
#!/usr/bin/env python
# https://steelpangolin.wordpress.com/2015/01/30/how-to-find-the-name-of-an-elastic-beanstalk-environment-from-inside-one-of-its-instances/
import boto.utils
# Sets the Docker image that will be used as a base.
FROM trenpixster/elixir:1.3.0
# Compiles app
RUN mkdir /app
WORKDIR /app
ENV MIX_ENV prod
# Injects AWS env variables explained below
@MrCoffey
MrCoffey / Dockerrun.aws.json
Created November 25, 2016 16:48
Depltoyment example of a basic dockerrun for multicontainers on beanstalk
{
"AWSEBDockerrunVersion": 2,
"volumes": [
{
"name": "liftit-app",
"host": {
"sourcePath": "/app"
}
},
{
@MrCoffey
MrCoffey / appspec.yml
Last active November 21, 2016 14:54
Basic AWS CodePloy Policies configuration
# This is an appspec.yml template file for use with AWS CodeDeploy.
# The lines in this template starting with the hashtag symbol are
# instructional comments and can be safely left in the file or
# ignored.
# For help completing this file, see the "AppSpec File Reference" in the
# "AWS CodeDeploy User Guide" at
# http://docs.aws.amazon.com/codedeploy/latest/userguide/app-spec-ref.html
# Don't touch version, that's Amazons stuff.
version: 0.0
# Specify "os: linux" if this revision targets Amazon Linux,
@MrCoffey
MrCoffey / private.xml
Created November 11, 2016 03:34
Karabiner configuration for Microsoft Sculpt Key Remapping for Mac OS
<?xml version="1.0"?>
<root>
<devicevendordef>
<vendorname>Microsoft</vendorname>
<vendorid>0x045e</vendorid>
</devicevendordef>
<deviceproductdef>
<productname>Sculpt</productname>