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
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.
> 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 August 29, 2015 14:11
PostgreSQL unique constraint handler: it sets the record as invalid if a PostgreSQL unique constraint error is raised on record saving
# 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
@mdesantis
mdesantis / keybase.md
Created September 24, 2014 09:41
Keybase proof

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 September 5, 2014 14:53
Bypass Heroku connection on 5000 port (useful for troubled networks, such as italian ISP Fastweb)
#!/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 August 29, 2015 13:56
web benchmark: appunti
# 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).
@mdesantis
mdesantis / etc_deb_diff.sh
Last active December 16, 2015 08:19
Diff between package etc contents and current etc contents
#!/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 May 28, 2023 16:11
Schedule script for using Whenever toghether with rbenv
# 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"