Skip to content

Instantly share code, notes, and snippets.

Sébastien Ballarin sebthemonster

View GitHub Profile
View shell_script_template.sh
#!/bin/bash
#================================================================
# HEADER
#================================================================
#% SYNOPSIS
#+ ${SCRIPT_NAME} [-hv] [-o[file]] args ...
#%
#% DESCRIPTION
#% This is a script template
#% to start any good shell script.
@sebthemonster
sebthemonster / README.md
Last active Aug 29, 2015
A little script to parse http server logs with Piwik (piwik.org) script. Log files are in a given directory with sub-directories for each website present in Piwik. Each website has an idsite in Piwik and this idsite is passed to parser script via a piwik.conf file present in website directory
View README.md

Script parsing logs to Piwik analytics

Create web site

  1. Create website in Piwik and get its idsite
  2. Create a directory for this website in /home/analytics/website_logs/ and create in it a directory parsed

For example.org, create /home/analytics/website_logs/example.org dir and /home/analytics/website_logs/example.org/parsed

View bootstrap_form_builder.rb
# FormBuilder for Ruby on Rails which produces HTML code compatible with Twitter Bootstrap
# horizontal forms styles (see here: http://twitter.github.com/bootstrap/base-css.html#forms)
#
# Features:
# * displays validation errors in-line
# * has custom option - label-text - to override default label text for an input
#
# Requirements:
# By default, Rails will wrap a field with validation error in an ugly div tag that breaks
# the layout. To override this behaviour, add
View to_bool2.rb
class Object
def to_boolean
compare_value = self.class == String ? self.downcase : self
case compare_value
when "no","false",false, "0", 0
false
when "yes","true",true, "1", 1
true
else
!!compare_value
@sebthemonster
sebthemonster / USAGE
Created May 22, 2012
A Module to decoupling persistence from business model
View USAGE
#models/article.rb :
require 'persistence_mapper'
require_relative '../persistence/lotissement'
class Article
include Persistence::Mapper
end
#persistence/article.rb :
module Persistence
@sebthemonster
sebthemonster / pre-commit.rspec.rb
Created Oct 25, 2011 — forked from david-hodgetts/pre-commit
pre-commit git hook, runs rspec if branch is master
View pre-commit.rspec.rb
#!/usr/bin/env ruby
# pre-commit git hook
# will run rspec if and only if current branch is master
# script adapted from http://book.git-scm.com/5_git_hooks.html
# source : https://gist.github.com/1141992
NO_COMMIT_MESSAGE = "\aDID NOT COMMIT YOUR FILES!"
FORMAT = :html
You can’t perform that action at this time.