Skip to content

Instantly share code, notes, and snippets.

View mdesantis's full-sized avatar
🐧
Linux forever

Maurizio De Santis mdesantis

🐧
Linux forever
  • Treatwell
  • Lecce, Italy
View GitHub Profile
@mdesantis
mdesantis / gems_list_without_versions.rb
Created September 14, 2011 21:03
Displaying installed gems without version numbers - in one line =)
#!/usr/bin/env ruby
puts `gem list`.split("\n").map{ |gem_with_version| gem_with_version[/^.*?(?= )/] }.join("\n")
@mdesantis
mdesantis / ligament.min.js
Created September 18, 2011 20:15
ligament.js - Minified version
/* Copyright (C) 2011 by Yehuda Katz | MIT */
M={},V={},C={};
@mdesantis
mdesantis / unicorn.rake
Last active January 9, 2021 20:03
Rails tasks for managing unicorn server instances
# Tasks for managing Unicorn instances of a Rails application.
# Compatible with Ruby >= 1.9.2 and Rails >= 2 .
# Unicorn signals: http://unicorn.bogomips.org/SIGNALS.html
namespace :unicorn do
class UnicornPIDError < StandardError; end
def rails_env
Rails.env
@mdesantis
mdesantis / .Xmodmap
Created November 26, 2011 17:58
Solving swapped keys ( <> key is wapped with \| key ) of the italian Apple Keyboard on Ubuntu (from the thread http://forum.ubuntu-it.org/index.php/topic,383892.msg3872344.html )
! Direttive per mappare correttamente la tastiera Apple italiana su Ubuntu,
! cioè, correggere lo scambio dei tasti maggiore/minore con quello di backslash/pipe
!
! 49: codice del tasto maggiore/minore ( <> ) (situato a destra del tasto L-SHIFT)
! 94: codice del tasto backslash/pipe ( \| ) (collocato a sinistra del tasto `uno/punto esclamativo` ( 1! ) )
!
!
! I comandi scritti sotto, eseguiti da terminale sono:
! xmodmap -e "keycode 49 = less greater guillemotleft guillemotright guillemotleft guillemotright" && \
! xmodmap -e "keycode 94 = backslash bar notsign brokenbar notsign brokenbar"
@mdesantis
mdesantis / rails_3_template.rb
Created April 25, 2012 11:20
Rails 3 template (Postgres, RSpec, Capybara, Guard/Linux, Spork)
#!/usr/bin/env ruby -w
#
# Rails 3 template (Postgres, RSpec, Capybara, Guard/libnotify4Linux, Spork)
# This should be used in this way:
#
# rails new APP_NAME -d postgresql -T --skip-bundle -m https://raw.github.com/gist/2489048/rails_3_template.rb
# 1. Non-SSL source proposal (due to bundler bug)
if yes?("Do you want to use the non-SSL source of rubygems.org as gems source?")
# run %q(sed -i 's/https:\/\/rubygems.org/http:\/\/rubygems.org/' Gemfile)
@mdesantis
mdesantis / rock_paper_scissors.rb
Created July 23, 2012 16:19
Circular comparison in Ruby
class RockPaperScissors
ITEMS = %W(A P B N)
def self.compare(item, other_item)
new(item).compare other_item
end
def initialize(item)
@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
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
#
@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
#
@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"