Skip to content

Instantly share code, notes, and snippets.

@xfyuan
xfyuan / kill_sidekiq_job.rb
Created March 29, 2022 03:58 — 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
workers.each do |process_id, thread_id, work|
process = Sidekiq::Process.new('identity' => process_id)
process.stop! if process_id == 'integration.3:4:71d1d7f4ef5a'
end
# FOR SCHEDULED JOBS
# you need to know the jid to make this happen
@xfyuan
xfyuan / bare_transitions.js
Created February 4, 2021 01:47 — forked from bnjamin/bare_transitions.js
Transitions stolen from alpine.js
export function transitionIn (el, show = () => {}) {
const attrs = getXAttrs(el, 'transition')
// If any transition attrs.
if (attrs.filter(attr => ['enter', 'enter-start', 'enter-end'].includes(attr.value)).length > 0) {
transitionClassesIn(el, attrs, show)
} else {
// If not, just show that damn thing.
show()
}
@xfyuan
xfyuan / logging.go
Created August 17, 2020 12:39 — forked from panta/logging.go
zerolog with file log rotation (lumberjack) and console output
package logging
import (
"github.com/rs/zerolog"
"github.com/rs/zerolog/log"
"gopkg.in/natefinch/lumberjack.v2"
"os"
"path"
"io"
)
@xfyuan
xfyuan / stimulus.md
Created July 28, 2020 02:40 — forked from mrmartineau/stimulus.md
Stimulus cheatsheet
#!/bin/bash
# Daniel Verner
# CarrotPlant LLC
# 2011
# Backup each mysql databases into a different file, rather than one big file
# Optionally files can be gzipped (dbname.gz)
#
# Usage: dump_all_databases [ -u username -o output_dir -z ]
#
# -u username to connect mysql server
@xfyuan
xfyuan / db.rake
Created July 27, 2020 01:46 — forked from hopsoft/db.rake
Rails rake tasks for dump & restore of PostgreSQL databases
# lib/tasks/db.rake
namespace :db do
desc "Dumps the database to db/APP_NAME.dump"
task :dump => :environment do
cmd = nil
with_config do |app, host, db, user|
cmd = "pg_dump --host #{host} --username #{user} --verbose --clean --no-owner --no-acl --format=c #{db} > #{Rails.root}/db/#{app}.dump"
end
puts cmd
#!/bin/bash
# rev4 - changes suggested by KownBash https://www.reddit.com/r/bash/comments/5cxfqw/i_wrote_a_simple_video_to_gif_bash_script_thought/da19gjz/
# Usage function, displays valid arguments
usage() { echo "Usage: $0 [-f <fps, defaults to 15>] [-w <width, defaults to 480] inputfile" 1>&2; exit 1; }
# Default variables
fps=15
width=480
@xfyuan
xfyuan / Gemfile
Created June 28, 2020 01:57 — forked from dhh/Gemfile
HEY's Gemfile
ruby '2.7.1'
gem 'rails', github: 'rails/rails'
gem 'tzinfo-data', '>= 1.2016.7' # Don't rely on OSX/Linux timezone data
# Action Text
gem 'actiontext', github: 'basecamp/actiontext', ref: 'okra'
gem 'okra', github: 'basecamp/okra'
# Drivers
rm -rf /Applications/Thunder.app/Contents/PlugIns/webgame.xlplugin #遊戲
rm -rf /Applications/Thunder.app/Contents/PlugIns/livestream.xlplugin #美女直播
rm -rf /Applications/Thunder.app/Contents/PlugIns/featuredpage.xlplugin #精選頁面
rm -rf /Applications/Thunder.app/Contents/PlugIns/xlbrowser.xlplugin #迅雷瀏覽器(會導致在迅雷內無法開啟網頁)
rm -rf /Applications/Thunder.app/Contents/PlugIns/xlplayer.xlplugin #迅雷播放器
rm -rf /Applications/Thunder.app/Contents/PlugIns/softmanager.xlplugin #應用卸載
rm -rf /Applications/Thunder.app/Contents/PlugIns/activitycenter.xlplugin #活動中心
rm -rf /Applications/Thunder.app/Contents/PlugIns/myvip.xlplugin #會員中心
rm -rf /Applications/Thunder.app/Contents/PlugIns/advertising.xlplugin #廣告