Skip to content

Instantly share code, notes, and snippets.

Avatar
🏠
Working from home

Jean-Pierre Pommet jppommet

🏠
Working from home
View GitHub Profile
@jppommet
jppommet / sidekiq_delete_jobs.md
Created Aug 26, 2021 — forked from eparreno/sidekiq_delete_jobs.md
How to delete Sidekiq jobs in a Rails app using ActiveJobs
View sidekiq_delete_jobs.md

How to delete Sidekiq jobs in a Rails app using ActiveJobs

Sidekiq jobs can be enqueued or scheduled. Enqueued means that they are gonna be picked up as soon as possible, scheduled jobs will be enqueued at some specific time.

job_id and jid

When using ActiveJobs, Rails will return a job_id after sending the job to ActiveJobs

job = UserMailer.send_invite(params).deliver_later
@jppommet
jppommet / alias_matchers.md
Created Sep 14, 2017 — forked from JunichiIto/alias_matchers.md
List of alias matchers in RSpec 3
View alias_matchers.md

This list is based on aliases_spec.rb.

You can see also Module: RSpec::Matchers API.

matcher aliased to description
a_truthy_value be_truthy a truthy value
a_falsey_value be_falsey a falsey value
be_falsy be_falsey be falsy
a_falsy_value be_falsey a falsy value
View gist:367fc864c4c859624c143612b955aff3

Pry Cheat Sheet

Command Line

  • pry -r ./config/app_init_file.rb - load your app into a pry session (look at the file loaded by config.ru)
  • pry -r ./config/environment.rb - load your rails into a pry session

Debugger

@jppommet
jppommet / pre-commit.sh
Created Aug 3, 2017
git pre-commit hook rubocop ruby modified/staged files
View pre-commit.sh
#!/bin/sh
#TODO: add exclude <file>.rb in rubocop.yml ?
git status --porcelain | egrep "^(A|AM|^M).+\.rb$" | awk '{print $NF}' | xargs rubocop -a
@jppommet
jppommet / lambda-concurrent.sh
Created Jun 17, 2017 — forked from smithclay/lambda-concurrent.sh
Concurrently execute a lambda function for warming purposes
View lambda-concurrent.sh
#!/bin/bash
# This attempts to concurrently execute an AWS Lambda function. WIP.
# After execution, roughly NUM_EXECUTION containers will be ready
# to accept requests.
# More advanced strategies are out there. Check out @lambdacult on twitter, for example.
AWS_LAMBDA_FUNCTION_NAME=LambdaInfo
NUM_EXECUTIONS=3
View MySQL Timezone Cheatsheet.md

It seems that it does not matter what timezone is on the server as long as you have the time set right for the current timezone, know the timezone of the datetime columns that you store, and are aware of the issues with daylight savings time.

On the other hand if you have control of the timezones of the servers you work with then you can have everything set to UTC internally and never worry about timezones and DST.

Here are some notes I collected of how to work with timezones as a form of cheatsheet for myself and others which might influence what timezone the person will choose for his/her server and how he/she will store date and time.

MySQL Timezone Cheatsheet

@jppommet
jppommet / caddy_server_init.sh
Created Dec 22, 2016
Caddy Server System V init script
View caddy_server_init.sh
#!/bin/bash
# Caddy daemon
# chkconfig: 345 20 80
# description: Caddy daemon
# processname: caddy
DAEMON_PATH="/usr/local/bin"
DAEMON='./caddy'
DAEMONOPTS="-conf=/etc/caddy/Caddyfile -log /var/log/caddy.log"
@jppommet
jppommet / _service.md
Last active Oct 17, 2016 — forked from naholyr/_service.md
Sample /etc/init.d script
View _service.md

Sample service script for debianoids

Look at LSB init scripts for more information.

Usage

Copy to /etc/init.d:

# replace "$YOUR_SERVICE_NAME" with your service's name (whenever it's not enough obvious)
@jppommet
jppommet / run_mysql56.sh
Created Aug 16, 2016
Run MySQL 5.6 locally by skipping mysql.users lookup (w/ previous MySQL 5.7 installation)
View run_mysql56.sh
$ mysqld_safe --bind-address=127.0.0.1 --data-dir=/usr/local/var/mysql --skip-grant-tables --user=root
View homebrew_multiple_mysql_versions.md

Multiple MySQL Versions with Homebrew

For homebrew version 0.9.5.

brew -v # => Homebrew 0.9.5

Install the current version of mysql.

# Install current mysql version
brew install mysql