Skip to content

Instantly share code, notes, and snippets.

View mqu's full-sized avatar
🏠
Working from home

Marc Quinton mqu

🏠
Working from home
  • DGAC / DTI
  • Toulouse / France
View GitHub Profile
@torsten
torsten / proxy.rb
Last active April 30, 2024 17:53
A quick HTTP proxy server in Ruby.
#!/usr/bin/env ruby
# A quick and dirty implementation of an HTTP proxy server in Ruby
# because I did not want to install anything.
#
# Copyright (C) 2009-2014 Torsten Becker <torsten.becker@gmail.com>
#
# Permission is hereby granted, free of charge, to any person obtaining
# a copy of this software and associated documentation files (the
# "Software"), to deal in the Software without restriction, including
# without limitation the rights to use, copy, modify, merge, publish,
@jamis
jamis / recursive-backtracker.rb
Created December 24, 2010 22:41
Implementation of the recursive backtracking algorithm for maze generation
# Recursive backtracking algorithm for maze generation. Requires that
# the entire maze be stored in memory, but is quite fast, easy to
# learn and implement, and (with a few tweaks) gives fairly good mazes.
# Can also be customized in a variety of ways.
DIRS = (N, S, E, W = 1, 2, 4, 8)
DX = { E => 1, W => -1, N => 0, S => 0 }
DY = { E => 0, W => 0, N => -1, S => 1 }
OPPOSITE = { E => W, W => E, N => S, S => N }
@tomohiro
tomohiro / issues.rb
Created June 24, 2011 05:53
Redmine REST API sample
#!/usr/bin/env ruby
require 'rubygems'
require 'active_resource'
class Issue < ActiveResource::Base
self.site = 'http://localhost'
self.user = 'user'
self.password = 'password'
end
<?php
/**
* Classe de connexion à la Freebox.
*
* N'hésitez pas à la surclasser pour définir vos propres méthodes s'appuyant
* sur celles qui sont présentes ici.
*
* Exemple d'utilisation :
* <?php
* require('freebox_client.class.php');
@bobmagicii
bobmagicii / gist:3180599
Created July 26, 2012 06:35
Apache log in JSON format...
LogFormat "{ \"Time\":%{%s}t, \"RemoteIP\":\"%a\", \"Host\":\"%V\", \"Port\":\"%p\", \"Request\":\"%U\", \"Query\":\"%q\", \"File\":\"%f\", \"Method\":\"%m\", \"Status\":\"%s\", \"UserAgent\":\"%{User-agent}i\", \"Referer\":\"%{Referer}i\" }" jsonlog
CustomLog "/var/log/apache2/access-json.log" jsonlog
@smazhara
smazhara / gist:4740692
Last active May 16, 2021 19:55
Ruby AES128 encrypt-decrypt example
require "openssl"
require "base64"
include Base64
@lambdalisue
lambdalisue / install_pdfocr_debian.sh
Created May 3, 2014 08:27
A shell script to install pdfocr (Debian wheezy)
#!/usr/bin/env bash
URL="https://github.com/gkovacs/pdfocr.git"
INSTALL_DIR="/opt/pdfocr"
INSTALL_PREFIX="/usr/local"
if ! type git > /dev/null 2>&1; then
echo "'git' is not found. Install it with the command below and try again"
echo
echo " $ sudo aptitude install git"
echo
@kouk
kouk / Example health-check script with systemd socket activation
Last active March 13, 2023 16:42
Simple HTTP health-check by abusing systemd socket activation with shell scripts
$ curl --dump-header - localhost:12345
HTTP/1.0 404 Not Found
Content-Type: text/html
Content-Length: 43
Date: Fri, 05 Dec 2014 17:48:56 +0000
<html>
<body>
<h1>WUT</h1>
</html>
@vigevenoj
vigevenoj / mqtt2influxdb.rb
Last active February 27, 2017 08:13
bmp085 -> beagleboneblack -> mqtt -> ruby -> influxdb -> graphs!
#!/opt/rh/ruby193/root/usr/bin/ruby
# -*- encoding: utf-8 -*-
#
# mqtt & influxdb sample...
#
# libraries
# $ gem install mqtt
# $ gem install influxdb
#
@emaraschio
emaraschio / SOLID.markdown
Last active May 24, 2023 07:18
SOLID Principles with ruby examples

#SOLID Principles with ruby examples

##SRP - Single responsibility principle A class should have only a single responsibility.

Every class should have a single responsibility, and that responsibility should be entirely encapsulated. All its services should be narrowly aligned with that responsibility, this embrace the high cohesion.

##OCP - Open/closed principle Software entities should be open for extension, but closed for modification.