Skip to content

Instantly share code, notes, and snippets.

Avatar
🐧
Linux forever

Maurizio De Santis mdesantis

🐧
Linux forever
  • Treatwell
  • Taranto, Italy
View GitHub Profile
View gist:214982b377e94020980347eaf21b8efc
> 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 / unique_constraint_handler.rb
Last active Aug 29, 2015
PostgreSQL unique constraint handler: it sets the record as invalid if a PostgreSQL unique constraint error is raised on record saving
View unique_constraint_handler.rb
# Usage example:
#
# class User < ActiveRecord::Base
# include UniqueConstraintHandler
# handle_unique_constraint_on :email
# end
#
# User.create email: 'test@example.com'
# user = User.create email: 'test@example.com'
# user.new_record? #=> true
View keybase.md

Keybase proof

I hereby claim:

  • I am mdesantis on github.
  • I am mdesantis (https://keybase.io/mdesantis) on keybase.
  • I have a public key whose fingerprint is F5F7 7045 0619 72C4 1130 5FD1 477C 5D30 1F85 13A9

To claim this, I am signing this object:

@mdesantis
mdesantis / heroku-bypass-5000.sh
Created Sep 5, 2014
Bypass Heroku connection on 5000 port (useful for troubled networks, such as italian ISP Fastweb)
View heroku-bypass-5000.sh
#!/bin/bash
echo 127.0.0.1 rendezvous-eu-west-1-a.runtime.heroku.com >> /etc/hosts
ssh -L 5000:rendezvous-eu-west-1-a.runtime.heroku.com:5000 remoteuser@remoteserver
@mdesantis
mdesantis / web-benchmark-appunti.md
Last active Aug 29, 2015
web benchmark: appunti
View web-benchmark-appunti.md
View rails_json_session.rb
# Hack to change the Rails cookie serializer from Marshal to JSON and therefore allow the session
# to be shared between different languages but also avoid that someone knowing the
# cookie secret key could execute arbitrary code on the server by unmarshalling
# modified Ruby code added to the session/permanent cookie.
#
# Note that all users will beed to login again since both the remember me cookie and the session cookies
# won't be valid. Note also that the remember me cookie is tested multiple times per request even when it fails.
# for performance reasons you might want to delete it if these extra cycles are too costly for you.
#
# Rails 4 (not tested on Rails 3).
View rails_json_cookie_session_store.rb
@mdesantis
mdesantis / etc_deb_diff.sh
Last active Dec 16, 2015
Diff between package etc contents and current etc contents
View etc_deb_diff.sh
#!/bin/bash
# From this stackexchange question: http://unix.stackexchange.com/questions/72746
set -e
package=php5-fpm
mkdir $package
cd $package
@mdesantis
mdesantis / schedule.rb
Last active Jan 29, 2022
Schedule script for using Whenever toghether with rbenv
View schedule.rb
# Schedule script for using Whenever toghether with rbenv
#
# Whenever: https://github.com/javan/whenever
# rbenv: https://github.com/sstephenson/rbenv
set :env_path, '"$HOME/.rbenv/shims":"$HOME/.rbenv/bin"'
# doesn't need modifications
# job_type :command, ":task :output"
@mdesantis
mdesantis / delayed_job_init_script.sh
Last active Jul 2, 2018
Delayed Job init script; it uses start-stop-daemon and supports every Ruby version manager (RVM, rbenv, chruby...)
View delayed_job_init_script.sh
#!/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
#