Skip to content

Instantly share code, notes, and snippets.

Avatar

Mathieu Arnold mat813

View GitHub Profile
View summarize.rb
module Jekyll
module Filters
def summarize(str, splitstr = /\s*<div id="extended">/)
str.split(splitstr)[0]
end
end
end
View stretch_box.rb
def stretch_box(ratio, point, options, &block)
x, y = if ratio.is_a?(Array)
ratio.map(&:to_f)
else
[ratio.to_f, 1.0]
end
options[:width] = options[:width] / x
options[:height] = options[:height] / y if options.key?(:height)
point[0] += bounds.absolute_left
point[1] += bounds.absolute_bottom
View lines_grid.rb
def lines_grid(s1=10, s2=100)
save_graphics_state do
stroke_color('EEEEEE')
fill_color('000000')
stroke do
line_width(0.5)
0.step(bounds.right, s1).each do |i|
line([i, 0], [i, bounds.top]) if (i%s2 != 0)
end
0.step(bounds.top, s1).each do |i|
View gist:975210
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;
@mat813
mat813 / rescan-itunes.scpt
Created May 27, 2011
rescan iTunes library…
View rescan-itunes.scpt
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
View film.rb
#!/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
View film.html
<?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;
@mat813
mat813 / rollover.sh
Created Jun 15, 2011
Rollover zones with OpenDNSSEC
View rollover.sh
#!/bin/sh
if [ -z $1 ]
then
echo "$0 zones"
exit 1
fi
for zone in $@
do
@mat813
mat813 / ds_submit.rb
Created Jun 18, 2011
DS Submit command to add SHA1 and SHA256 DS to the lot
View ds_submit.rb
#!/usr/bin/env ruby
require 'rubygems'
require 'dnsruby'
module Dnsruby
class RR
class DS
def rdata_to_string
if (@key_tag != nil)
View ftptls.rb
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")