Skip to content

Instantly share code, notes, and snippets.

View Filirom1's full-sized avatar

Romain Filirom1

View GitHub Profile
@Filirom1
Filirom1 / scalr
Created March 10, 2015 15:37
scalr log rotation
# /etc/logrotate.d/scalr
/var/log/scalr/*.log {
daily
missingok
notifempty
rotate 7
compress
}
@Filirom1
Filirom1 / xmllint.rb
Created February 23, 2015 13:05
validate XML in ruby
require 'nokogiri'
require 'active_support/core_ext/hash' #from_xml
valid_xml_str = Nokogiri::XML(str) { |config| config.strict }.to_s
hash = Hash.from_xml(valid_xml_str)
@Filirom1
Filirom1 / elasticsearch.yml
Created February 19, 2015 09:41
very simple ElasticSearch Analyzer
index:
analysis:
analyzer:
default:
type: custom
tokenizer: whitespace
filter: [standard, asciifolding, lowercase]

$ openssl s_client -connect server:636 -showcerts

$ ldapsearch -x -H "ldaps://server:636" -D 'uid=$UUID,dc=example,dc=com' -W

@Filirom1
Filirom1 / xml2json.rb
Created January 23, 2015 16:25
xml2json with base64 decoding
require "rubygems"
require "crack"
require "json"
require "base64"
myXML = Crack::XML.parse(File.read(ARGV[0]))
def decode_base64(parent, myHash)
myHash.each {|key, value|
if value.is_a?(Hash)
decode_base64(key, value)
@Filirom1
Filirom1 / setcomposer.py
Created January 17, 2015 10:31
MusicBrainz Picard Plugin that force Composer to be Album Artist
PLUGIN_NAME = 'Composer becomes Album Artist'
PLUGIN_AUTHOR = 'Romain Philibert'
PLUGIN_DESCRIPTION = '''Set composer value to album artist.'''
PLUGIN_VERSION = "0.1"
PLUGIN_API_VERSIONS = ["0.15"]
from picard.metadata import register_album_metadata_processor
import re
@Filirom1
Filirom1 / eye.py
Created January 15, 2015 21:46
re-tag mp3
import eyed3
import os
import glob;
for filename in glob.glob('/dir/to/mp3/**/**/*.mp3'):
try:
print(filename)
audiofile = eyed3.load(filename)
audiofile.tag.setTextFrame('TCOM', audiofile.tag.album_artist or audiofile.tag.artist)
@Filirom1
Filirom1 / README.md
Created January 12, 2015 17:27
gem2rpm

Build RPM from rubygems

. It will fetch the gem file with the right version Ask for the license if missing Build the SRPM and the RPM using gem2rpm and a custom template

~/gem2rpm.sh simplecov '>=0.6.2'
...
Finish: build phase for rubygem-simplecov-0.9.1-1.el6.src.rpm
@Filirom1
Filirom1 / debug-headers.sh
Created October 8, 2014 07:34
debug http headers with tcpdump
#!/bin/sh
PORT=$1
tcpdump -i lo -A -s 10240 "tcp port $PORT and (((ip[2:2] - ((ip[0]&0xf)<<2)) - ((tcp[12]&0xf0)>>2)) != 0)" | egrep --line-buffered "^........(GET |HTTP\/|POST |HEAD )|^[A-Za-z0-9-]+: " | sed -r 's/^........(GET |HTTP\/|POST |HEAD )/\n\1/g'
@Filirom1
Filirom1 / gist:8f02365c31e4154d8e23
Created September 29, 2014 12:00
Mcollective list fact values
List facts from one server
$ mco inventory server1.example.com
Then list values for one fact for all servers
$ mco rpc rpcutil get_fact fact=memoryfree