Skip to content

Instantly share code, notes, and snippets.

View mat813's full-sized avatar

Mathieu Arnold mat813

View GitHub Profile
@mat813
mat813 / bind_conf.treetop
Created April 24, 2012 15:34
simple named.conf parsing
require 'ip'
grammar BindConf
include IP
rule entries
(zone / key / server)* {
%w(zone key server).each do |i|
module_eval <<-eot, __FILE__, __LINE__+1
def each_#{i}(&block)
@mat813
mat813 / diag.rb
Created March 1, 2012 17:08
taille écran / résolution / pixels
def diag(seize,neuf,inch,pixels)
ratio = (seize**2+neuf**2)**0.5
cms = inch*2.54
taille = [seize, neuf].map {|v| (v*cms/ratio).round(2)}
taille << (taille[0]/pixels*10).round(4)
taille << pixels*neuf/seize
return taille
end
@mat813
mat813 / named.aug
Created July 5, 2011 15:29
Bind's config augias lense (WIP)
(*
Module: Named
parses /etc/namedb/named.conf
Author: Mathieu Arnold <mat@FreeBSD.org>
About: Reference
This lens tries to keep as close as possible to the bind documentation where
possible. An online source being :
http://www.freebsd.org/cgi/man.cgi?query=syslog.conf&sektion=5
require 'socket'
require 'openssl'
require 'net/ftp'
module Net
class FTPTLS < FTP
def login(user = "anonymous", passwd = nil, acct = nil)
@ctx = OpenSSL::SSL::SSLContext.new('SSLv3')
@ctx.verify_mode = OpenSSL::SSL::VERIFY_NONE
voidcmd("AUTH TLS")
@mat813
mat813 / ds_submit.rb
Created June 18, 2011 11:20
DS Submit command to add SHA1 and SHA256 DS to the lot
#!/usr/bin/env ruby
require 'rubygems'
require 'dnsruby'
module Dnsruby
class RR
class DS
def rdata_to_string
if (@key_tag != nil)
@mat813
mat813 / rollover.sh
Created June 15, 2011 14:05
Rollover zones with OpenDNSSEC
#!/bin/sh
if [ -z $1 ]
then
echo "$0 zones"
exit 1
fi
for zone in $@
do
<?xml version='1.0' encoding='utf-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns='http://www.w3.org/1999/xhtml'>
<head>
<title>Films</title>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.js" type="text/javascript"></script>
<script type="text/javascript">
//<![CDATA[
var start = 9;
var end = 23;
#!/usr/bin/env ruby
input = $stdin.readlines.map do |l|
l.chomp!
title = true
l.split(/\s+/).inject([""]) do |acc, a|
if /^\d?\d:\d\d$/ =~ a
title = false
acc << a.sub(/^0/, '')
elsif title
@mat813
mat813 / rescan-itunes.scpt
Created May 27, 2011 20:18
rescan iTunes library…
tell application "System Events"
repeat
delay 0.05
try
click UI element "Suivant" of window 1 of application process "iTunes"
end try
end repeat
end tell
@mat813
mat813 / gist:975210
Created May 16, 2011 19:58
rib valid
function isRIBvalid(banque, guichet, compte, clef) {
var tab= "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
var tab1="123456789123456789234567890123456789".split("");
while (compte.match(/\D/) != null)
compte=compte.replace(/\D/, tab1[tab.indexOf(compte.match(/\D/))]);
var compte=parseInt(compte, 10);
a=banque % 97;
a=a*100000+parseInt(guichet, 10);
a=a%97;
a=a*Math.pow(10, 11) + compte;