Skip to content

Instantly share code, notes, and snippets.

View leucos's full-sized avatar
👽
Waiting for aliens

Michel Blanc leucos

👽
Waiting for aliens
  • devops.works
  • Lyon, France
View GitHub Profile
@leucos
leucos / postmortem.md
Created October 22, 2012 07:57
Museomix : post-mortem réseau & IT

MuseoMix 2012

Problématique

Annoncée

  • Réseau
    • Fournir un accès internet aux muséomixeurs, essentiellement WiFi
  • Fournir un accès internet, de préférence filaire, à l'orga et la web team
@leucos
leucos / controller.rb
Created September 28, 2012 08:56
Inject methods and routes in controller from helper
class SomeStuff < Ramaze::Controller
helper :versionner
def index
"Hello world"
end
end
@leucos
leucos / inventory.pl
Created June 28, 2012 09:05
Poor-man's inventory script
#!/usr/bin/perl
use strict;
use threads;
use Thread::Queue::Any;
use Net::OpenSSH;
use Parse::DMIDecode::Constants qw(@TYPES);
use Parse::DMIDecode qw();
@leucos
leucos / rmz.rb
Created June 28, 2012 08:26
Using provide for some actions only
require 'ramaze'
# Put a jpeg in the same directory as this file named 'image.jpg"
# calling index.jpg will yell at user
# calling send_image.jpg will send back image.jpg
class MyController < Ramaze::Controller
map '/'
provide(:jpg, :type => 'image/jpeg') do |action, value|
@leucos
leucos / gist:2985528
Created June 24, 2012 23:42
Ramaze blue_form helper quick example
require 'ramaze'
class MyController < Ramaze::Controller
map '/'
helper :blue_form
def index
# BlueForm requires the passed object to respond_to? key names
@result = OpenStruct.new(request.subset(:textname, :textanother))

Sublime Text 2 – Useful Shortcuts (Linux)

General

⌃-P go to anything (type part of file, :line, @symbol)
^⇧-T go to file
^-R go to methods (@ in goto-anything)
⌃-G go to line (: in goto-anything)
^⌥-P go to project
** toggle side bar
@leucos
leucos / summary.md
Created June 15, 2012 08:54
Fnordmetric helper

Goal

The point is to write a Fnordmetric helper. Fnordmetric is a "statsd-like" metric collector without the Carbon hassle.

Examples

  • I would like to be able to do things like :
 push_timer :hell_yeah
# FNordmetric helper
#
# Define :fnord_redis_url trait in class where helper is used
# e.g. : trait :fnord_redis_url => "redis://redis.example.com:6332"
#
require 'fnordmetric'
module Ramaze
module Helper
module FnordmetricHelper
@leucos
leucos / gist:2896238
Created June 8, 2012 15:41
Rack middleware: Adding cache headers (saved from http://www.hokstad.com/rack-middleware-adding-cache-headers.html)
Vidar Hokstad
Home Blog Ruby Compiler Sliding Stats
2008-03-22 16:02 UTC Rack middleware: Adding cache headers
Posted in: ruby, rack, programming
I'm playing with a small web based RSS reader, and one of the things it does is cache a lot of data to reduce the impact on the sites I follow feeds from. However I realized this a couple of days ago I'd completely forgotten to set cache headers, and I kept hammering my own site.
That wouldn't do, and since my app is using Rack to interface to the webserver, there's a simple solution: Write a tiny Rack middleware class, just like I described in "Rewriting content types with Rack".
The great thing is that because of Rack this class can be used to add cache headers for anything from pure Rack based apps to apps using Rails, Merb, or any number of other Ruby frameworks that has Rack adapters. If you haven't looked into Rack already, do.
@leucos
leucos / gist:2580268
Created May 2, 2012 20:37
ansiblehacking/test-module
$ ../hacking/test-module ./service name=httpd state=started
Traceback (most recent call last):
File "../hacking/test-module", line 53, in <module>
argsfile = open(argspath, 'w')
IOError: [Errno 13] Permission denied: '/.ansible_test_module_arguments'