Skip to content

Instantly share code, notes, and snippets.

@lchanmann
lchanmann / send_a_message.rb
Created January 25, 2011 08:50
Send a message to Geochat group via API
require 'rest_client'
url = 'http://geochat.instedd.org/api/groups/YOURGROUP/messages.rss'
res = RestClient::Resource.new url, 'LOGIN', 'PASSWORD'
res.post :message => '#ping'
@lchanmann
lchanmann / app.rb
Created January 28, 2011 02:13
sinatra application with file_uploader
require 'rubygems'
require 'haml'
require 'sinatra'
require 'sinatra/flash'
require 'file_uploader'
enable :sessions
get '/' do
haml :index
@lchanmann
lchanmann / hello.rb
Created September 10, 2012 02:24
hello thor cli
require 'rubygems'
require 'thor'
class HelloCli < Thor
desc "hi", "Say hi"
def hi
puts "hi !"
end
desc "bye", "Say goodbye"
@lchanmann
lchanmann / clc_logFile.sh
Created February 20, 2016 06:05
sh: clear log file
cat /dev/null > "$logFile"
@lchanmann
lchanmann / number_file.sh
Created February 20, 2016 06:25
sh: number the line in a file (from man paste)
sed = myfile | paste -s -d '\t\n' - -
@lchanmann
lchanmann / poodir-notes.md
Last active July 6, 2016 15:13 — forked from speric/poodir-notes.md
Notes From "Practical Object-Oriented Design In Ruby" by Sandi Metz

Chapter 1 - Object Oriented Design

The purpose of design is to allow you to do design later, and it's primary goal is to reduce the cost of change.

SOLID Design:

  • Single Responsibility Principle: a class should have only a single responsibility
  • Open-Closed Principle: Software entities should be open for extension, but closed for modification (inherit instead of modifying existing classes).
  • Liskov Substitution: Objects in a program should be replaceable with instances of their subtypes without altering the correctness of that program.
  • Interface Segregation: Many client-specific interfaces are better than one general-purpose interface.
@lchanmann
lchanmann / add_munin_backport_ppa.sh
Created August 4, 2016 22:09
Add Munin Backport PPA
sudo add-apt-repository ppa:tuxpoldo/munin
sudo apt-get update
sudo apt-get dist-upgrade
@lchanmann
lchanmann / build_and_install_munin.sh
Created August 4, 2016 22:12
Build munin dependencies and installation
sudo apt-get build-dep munin
sudo apt-get install munin munin-node
@lchanmann
lchanmann / config_munin.sh
Created August 4, 2016 22:13
Configure munin
sudo vi /etc/munin/munin.conf
# Search for graph_strategy and html_strategy
# Change their values to cgi
@lchanmann
lchanmann / munin_plugin.sh
Created August 4, 2016 22:15
Enable munin plugins
sudo munin-node-configure — shell — families=contrib,auto | sh -x