Skip to content

Instantly share code, notes, and snippets.

@wellsmuker
wellsmuker / kill_sidekiq_job.rb
Created March 14, 2023 06:19 — forked from Chocksy/kill_sidekiq_job.rb
Kill sidekiq jobs by process id for busy jobs and by jid for other sets.
# FOR BUSY JOBS
# take the process_id from the /busy page in sidekiq and kill the longest running one.
workers = Sidekiq::Workers.new
long_process_id = 'integration.3:4:71111aaa111' # Eg: 'integration.3:4:71d1d7f4ef5a'
workers.each do |process_id, thread_id, work|
process = Sidekiq::Process.new('identity' => process_id)
process.stop! if process_id == long_process_id
end
# FOR SCHEDULED JOBS
@wellsmuker
wellsmuker / rails-jsonb-queries
Created November 23, 2022 12:14 — forked from mankind/rails-jsonb-queries
Ruby on 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")
@wellsmuker
wellsmuker / 202005281327.md
Created September 28, 2022 11:26 — forked from qwfys/202005281327.md
国内拉取google kubernetes镜像

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

@wellsmuker
wellsmuker / select_controller.js
Created August 9, 2022 13:32 — forked from tabishiqbal/_form.html.erb
Tom-Select Example with Stimulus
import { Controller } from "stimulus"
import TomSelect from "tom-select"
export default class extends Controller {
static values = { url: String }
connect() {
this.initTomSelect()
}
@wellsmuker
wellsmuker / picker-controller.js
Created May 4, 2022 13:04 — forked from lanks/picker-controller.js
Date range picker stimulus example
import { Controller } from "stimulus"
import moment from 'moment';
export default class extends Controller {
static targets = [ "date_range" ]
connect() {
if(this.date_rangeTarget) {
let selectedRange = false
$(this.date_rangeTarget).daterangepicker({
showCustomRangeLabel: false,
alwaysShowCalendars: true,
ffmpeg -protocol_whitelist file,http,https,tcp,tls,crypto -i "m3u8 url" -c copy "03 - filename.mp4"
@wellsmuker
wellsmuker / init.vim
Created December 15, 2019 11:56 — forked from benawad/init.vim
" Specify a directory for plugins
call plug#begin('~/.vim/plugged')
Plug 'neoclide/coc.nvim', {'branch': 'release'}
Plug 'scrooloose/nerdtree'
"Plug 'tsony-tsonev/nerdtree-git-plugin'
Plug 'Xuyuanp/nerdtree-git-plugin'
Plug 'tiagofumo/vim-nerdtree-syntax-highlight'
Plug 'ryanoasis/vim-devicons'
Plug 'airblade/vim-gitgutter'
@wellsmuker
wellsmuker / keep_alive.rb
Created August 5, 2019 18:52 — forked from titusfortner/keep_alive.rb
Use Keep Alive in Selenium Ruby
module Selenium
module WebDriver
module Remote
module Http
class KeepAlive < Default
def close
super
@http.finish if @http&.started?
end
@wellsmuker
wellsmuker / script.pl
Created July 19, 2019 19:44 — forked from bessarabov/script.pl
Script to generate data shown in post 'At what time of day does famous programmers work? Part 2. Workweek vs Weekend.' — https://ivan.bessarabov.com/blog/famous-programmers-work-time-part-2-workweek-vs-weekend
#!/usr/bin/perl
# This script is made to show graphs with git commit time made on workweek vs weekend
#
# The desription of this script and results of its usage is avaliable at:
# https://ivan.bessarabov.com/blog/famous-programmers-work-time-part-2-workweek-vs-weekend
#
# usage:
#
# git log --author="Sebastian Riedel" --format="%H %ai" | perl script.pl