Skip to content

Instantly share code, notes, and snippets.

View prdanelli's full-sized avatar
👋

Paul Danelli prdanelli

👋
View GitHub Profile
@lazaronixon
lazaronixon / dropzone_controller.js
Last active March 9, 2024 05:14
Dropzone.js + Stimulus + Active Storage
import { Controller } from "stimulus"
import { DirectUpload } from "@rails/activestorage"
import Dropzone from "dropzone"
import { getMetaValue, findElement, removeElement, insertAfter } from "helpers"
Dropzone.autoDiscover = false
export default class extends Controller {
static targets = [ "input" ]
@wbotelhos
wbotelhos / clear-sidekiq-jobs.sh
Last active April 2, 2024 10:04
Clear Sidekiq Jobs
require 'sidekiq/api'
# 1. Clear retry set
Sidekiq::RetrySet.new.clear
# 2. Clear scheduled jobs
Sidekiq::ScheduledSet.new.clear
@danidiaz
danidiaz / netrw.txt
Created October 7, 2016 20:57
Vim's netrw commands.
--- ----------------- ----
Map Quick Explanation Link
--- ----------------- ----
< <F1> Causes Netrw to issue help
<cr> Netrw will enter the directory or read the file |netrw-cr|
<del> Netrw will attempt to remove the file/directory |netrw-del|
<c-h> Edit file hiding list |netrw-ctrl-h|
<c-l> Causes Netrw to refresh the directory listing |netrw-ctrl-l|
<c-r> Browse using a gvim server |netrw-ctrl-r|
<c-tab> Shrink/expand a netrw/explore window |netrw-c-tab|
@olegantonyan
olegantonyan / audio_volume_normalize.rb
Created May 25, 2016 06:58
Normalize audio volume using ffmpeg and ruby
def normalize_volume(file)
output = `ffmpeg -i '#{file}' -af "volumedetect" -f null /dev/null 2>&1`
raise "Error getting audio volume from #{file} (#{$?})" unless $?.success?
max_volume = output.scan(/max_volume: ([\-\d\.]+) dB/).flatten.first
mean_volume = output.scan(/mean_volume: ([\-\d\.]+) dB/).flatten.first
return if !max_volume || !mean_volume
max_volume = max_volume.to_f
mean_volume = mean_volume.to_f
target_volume = -14.0
adjustment = target_volume - mean_volume
@janko
janko / 1-activerecord.rb
Last active June 13, 2023 20:00
INSERTing 50,000 records into a database in ActiveRecord, Arel, SQL, activerecord-import and Sequel.
require "active_record"
ActiveRecord::Base.establish_connection(adapter: "sqlite3", database: ":memory:")
ActiveRecord::Migration.class_eval do
create_table(:records) do |t|
t.string :column
end
end
data = 50_000.times.map { |i| Hash[column: "Column #{i}"] }
@u0d7i
u0d7i / disable_vim_auto_visual_on_mouse.txt
Last active February 27, 2024 14:08
Disable vim automatic visual mode on mouse select
Disable vim automatic visual mode on mouse select
issue: :set mouse-=a
add to ~/.vimrc: set mouse-=a
my ~/.vimrc for preserving global defaults and only changing one option:
source $VIMRUNTIME/defaults.vim
set mouse-=a
# Get Sublime Text to use your rvm ruby without hardcoding a `$USER`.
#
# Include the configurations below the commend in the appropriate file listed below:
#
# - OS X ST2: ~/Library/Application Support/Sublime Text 2/Packages/Ruby/Ruby.sublime-build
# - OS X ST3: ~/Library/Application Support/Sublime Text 3/Packages/User/Ruby.sublime-build
# - Linux ST2: ~/.config/sublime-text-2/Packages/Ruby/Ruby.sublime-build
# - Linux ST3: ~/.config/sublime-text-3/Packages/User/Ruby.sublime-build
{
@MohamedAlaa
MohamedAlaa / tmux-cheatsheet.markdown
Last active May 3, 2024 19:09
tmux shortcuts & cheatsheet

tmux shortcuts & cheatsheet

start new:

tmux

start new with session name:

tmux new -s myname