Skip to content

Instantly share code, notes, and snippets.

@miheykrug
miheykrug / sidekiq_delete_jobs.md
Created June 15, 2023 14:46 — forked from eparreno/sidekiq_delete_jobs.md
How to delete Sidekiq jobs in a Rails app using ActiveJobs

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
@miheykrug
miheykrug / rails-jsonb-queries
Last active September 15, 2020 15:37 — forked from mankind/rails-jsonb-queries
Rails-5 postgresql-9.6 jsonb queries
http://stackoverflow.com/questions/22667401/postgres-json-data-type-rails-query
http://stackoverflow.com/questions/40702813/query-on-postgres-json-array-field-in-rails
#payload: [{"kind"=>"person"}]
Segment.where("payload @> ?", [{kind: "person"}].to_json)
#data: {"interest"=>["music", "movies", "programming"]}
Segment.where("data @> ?", {"interest": ["music", "movies", "programming"]}.to_json)
Segment.where("data #>> '{interest, 1}' = 'movies' ")
Segment.where("jsonb_array_length(data->'interest') > 1")
@miheykrug
miheykrug / monit_conf_qna.txt
Last active June 29, 2018 06:39
monit conf.d qna
### Nginx ###
check process nginx with pidfile /run/nginx.pid
start program = "/usr/sbin/service nginx start"
stop program = "/usr/sbin/service nginx stop"
if cpu > 60% for 2 cycles then alert
if cpu > 80% for 5 cycles then restart
if memory usage > 80% for 5 cycles then restart
if failed host 127.0.0.1 port 80 protocol http
then restart
if 3 restarts within 5 cycles then timeout
@miheykrug
miheykrug / test-guru-question.txt
Created April 3, 2018 18:08
Вопрос о HTML от TestGuru
Простой вопрос по HTML5
Правильный ответ
Неправильный ответ
Еще один неправильный ответ
@miheykrug
miheykrug / Lesson 3
Last active February 28, 2018 23:20
Database test_guru
miheykrug=# CREATE DATABASE test_guru;
CREATE DATABASE
miheykrug=# \c test_guru
Вы подключены к базе данных "test_guru" как пользователь "miheykrug".
test_guru=# CREATE TABLE categories (
id serial PRIMARY KEY,
title varchar(25) NOT NULL
);
@miheykrug
miheykrug / Lesson 1
Created February 25, 2018 17:27
Thinknetica Rails
GET /anything HTTP/1.1
Host: httpbin.org
HTTP/1.1 200 OK
Connection: keep-alive
Server: meinheld/0.6.1
Date: Sun, 25 Feb 2018 17:05:25 GMT
Content-Type: application/json
Access-Control-Allow-Origin: *
Access-Control-Allow-Credentials: true