Skip to content

Instantly share code, notes, and snippets.

View mdesantis's full-sized avatar
🐧
Linux forever

Maurizio De Santis mdesantis

🐧
Linux forever
  • Treatwell
  • Taranto, Italy
View GitHub Profile
> rails -v
Rails 5.1.0.rc1
> rails new rails_vue --webpack=vue
create
create README.md
create Rakefile
create config.ru
create .gitignore
create Gemfile
run git init from "."
@mdesantis
mdesantis / delayed_job_init_script.sh
Created March 12, 2013 15:04
Delayed Job init script; it uses start-stop-daemon and supports every Ruby version manager (RVM, rbenv, chruby...)
#!/bin/sh
### BEGIN INIT INFO
# Provides: delayed_job
# Required-Start: $all
# Required-Stop: $local_fs $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: starts the delayed_job instances
# Description: starts the delayed_job server instances using start-stop-daemon
#
begin
require "bundler/inline"
rescue LoadError => e
$stderr.puts "Bundler version 1.10 or later is required. Please update your Bundler"
raise e
end
gemfile(true) do
source "https://rubygems.org"
# Activate the gem you are reporting the issue against.
@mdesantis
mdesantis / sir-trevor.coffee.erb
Created December 21, 2017 13:35
Sir Trevor initializer for Rails
$(document).on 'ready turbolinks:load', ->
SirTrevor.config.language = 'it'
SirTrevor.setDefaults(
language: 'it'
focusOnInit: false
blockTypes: ['Text', 'Image', 'List', 'Heading', 'Quote', 'Video']
defaultType: 'Text'
iconUrl: "<%= asset_path('sir-trevor/build/sir-trevor-icons.svg') %>"
uploadUrl: "/admin/uploads/images"
@mdesantis
mdesantis / unicorn_init_script.sh
Last active March 21, 2018 13:18 — forked from romaimperator/unicorn_init_script.sh
Unicorn init script; it uses start-stop-daemon and supports every Ruby version manager (RVM, rbenv, chruby...)
#!/bin/sh
### BEGIN INIT INFO
# Provides: unicorn
# Required-Start: $all
# Required-Stop: $network $local_fs $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: starts the unicorn instances
# Description: starts the unicorn server instances using start-stop-daemon
#
@mdesantis
mdesantis / delayed_job_init_script.sh
Last active July 2, 2018 20:07
Delayed Job init script; it uses start-stop-daemon and supports every Ruby version manager (RVM, rbenv, chruby...)
#!/bin/sh
### BEGIN INIT INFO
# Provides: delayed_job
# Required-Start: $all
# Required-Stop: $local_fs $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: starts the delayed_job instances
# Description: starts the delayed_job server instances using start-stop-daemon
#
<?xml version="1.0"?>
<!DOCTYPE tsung SYSTEM "/usr/share/tsung/tsung-1.0.dtd" [] >
<tsung loglevel="info">
<clients>
<client host="localhost" use_controller_vm="true" maxusers="60000"/>
</clients>
<servers>
<server host="localhost" port="3334" type="tcp"></server>
</servers>
@mdesantis
mdesantis / guix-install.sh
Last active September 26, 2018 17:06
GNU Guix v0.15.0 installer, non interactive version (suitable for Docker; modified from https://git.savannah.gnu.org/cgit/guix.git/plain/etc/guix-install.sh?h=v0.15.0)
#!/bin/bash
# GNU Guix --- Functional package management for GNU
# Copyright © 2017 sharlatan <sharlatanus@gmail.com>
# Copyright © 2018 Ricardo Wurmus <rekado@elephly.net>
# Copyright © 2018 Efraim Flashner <efraim@flashner.co.il>
#
# This file is part of GNU Guix.
#
# GNU Guix is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by
@mdesantis
mdesantis / sidekiq-reset.rb
Created April 24, 2020 15:37
Sidekiq reset one-liner
require 'sidekiq/api'; [Sidekiq::RetrySet.new, Sidekiq::ScheduledSet.new, Sidekiq::DeadSet.new, Sidekiq::Stats.new.queues].each(&:clear); Sidekiq::Stats.new.reset
@mdesantis
mdesantis / postgresql_like_index.rb
Last active July 23, 2020 09:31
Rails migration adding PostgreSQL index for LIKE when the pattern is both left-anchored and right-anchored
# It supports queries like:
# ModelName.where(ModelName.arel_table[:columnname].lower.matches 'searchterm')
class PostgresqlLikeIIndex < ActiveRecord::Migration
def up
enable_extension 'pg_trgm'
execute <<~SQL
CREATE INDEX index_tablename_on_columnname_lower
ON tablename USING gin (lower(columnname) gin_trgm_ops)
SQL