Skip to content

Instantly share code, notes, and snippets.

View Farzy's full-sized avatar

Farzad FARID Farzy

View GitHub Profile
@Farzy
Farzy / count-extensions.rb
Created March 1, 2011 11:09
Count the total size and number of files for each extension in a directory and subdirectories
#!/usr/bin/ruby -w
# encoding=utf8
# vim: ts=4 sw=4 sts=4 et:
# count-ext : Compte le nombre de fichiers ayant une extension donnée
# ainsi que la taille total des fichiers par extension.
#
# Date : 2011/03/01
#
# Copyright (C) 2011 Farzad FARID <ffarid@pragmatic-source.com>
@Farzy
Farzy / maxvoy.rb
Created January 28, 2011 10:31
Sort words by number of consecutive voyels
#!/usr/bin/ruby1.9 -w
# encoding: utf-8
# vim: ts=4 sw=4 sts=4 et:
# Sort a dictionnary by the number of consecutive voyels.
#
# Date: 28/01/2011
#
# Copyright (C) 2011 Farzad FARID <ffarid@pragmatic-source.com>
#
@Farzy
Farzy / mysql-backup.sh
Created November 4, 2010 17:45
Elegant MySQL Daily backup script
#!/bin/bash
# Daily MySQL backup tool
#
# Author: Farzad FARID <ffarid@pragmatic-source.com>
# Date: 04/11/2010
#####################################################################
# PARAMETRAGE BASH
@Farzy
Farzy / ocf:httpd
Created October 20, 2010 11:02
OCF simple httpd script
#!/bin/sh
#
# Resource script for Apache
#
# Description: Manages Apache as an OCF resource in
# an Active-Passive High Availability setup.
#
# Author: F.BOLE
# License: GNU General Public License (GPL)
#
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>com.pragmatic-source.MailImapTunnel</string>
<key>RunAtLoad</key>
<true/>
@Farzy
Farzy / gist:522605
Created August 13, 2010 09:18
Exemple shell variables env
#!/bin/bash
# Lance une commande avec plusieurs variables d'environnement sans polluer le shell principal.
(
TOTO=1
TUTU=2
FOO=bar
export TOTO TUTU FOO
./ma_commande
@Farzy
Farzy / rvm-your-chef.rb
Created July 8, 2010 08:35 — forked from adamhjk/rvm-your-chef.rb
Chef - Invoke rvm and inherit the environment updates
# Check this out, rvm use rbx
ruby_block "rvm use rbx" do
block do
Chef::Mixin::Command.popen4('bash -l -c "rvm use 1.9.1 && env"') do |p,i,o,e|
o.each_line do |line|
env_bits = line.split("=")
ENV[env_bits[0]] = env_bits[1]
end
end
class Chef
module Mixin
module Language
# esearch(:node, 'role\[admin\]')
# recursively search for this role/recipe in all roles
def esearch(context, search)
if context == :role
ret = []
# First solve all roles:
roles = search(:role, search)
@Farzy
Farzy / gemspec
Created May 13, 2010 19:45 — forked from defunkt/gemspec
Quickly create a gemspec
#!/usr/bin/env ruby
# Usage: gemspec [-s] GEMNAME
#
# Prints a basic gemspec for GEMNAME based on your git-config info.
# If -s is passed, saves it as a GEMNAME.gemspec in the current
# directory. Otherwise prints to standard output.
#
# Once you check this gemspec into your project, releasing a new gem
# is dead simple:
#
#! /usr/bin/ruby
require 'chef/config'
require 'chef/search/query'
require 'chef/log'
require 'time'
require 'getoptlong'
require "ohai"
RET = {