Skip to content

Instantly share code, notes, and snippets.

View crohr's full-sized avatar
➡️
Cheaper, faster GitHub Actions with runs-on.com

Cyril Rohr crohr

➡️
Cheaper, faster GitHub Actions with runs-on.com
View GitHub Profile
# Author: Cyril Rohr
# This has been gemified into the cacheability gem (http://github.com/cryx/cacheability/tree/master)
require 'rubygems'
require 'rest_client' # sudo gem install rest-client
require 'rack/cache' # sudo gem install rack-cache
module RestClient
# this is a quick hack to show how you can use rack-cache as a powerful client cache.
class CacheableResource < Resource
@crohr
crohr / url_dsl.rb
Created December 15, 2009 14:46 — forked from defunkt/url_dsl.rb
require 'open-uri'
# url dsl -- the ultimate url dsl!
#
# You just can't beat this:
#
# $ irb -r url_dsl
# >> include URLDSL
# => Object
# >> http://github.com/defunkt.json
crohr@parachute:~/dev/puppet-repo[master]$ cap puppet:testing MODULE=api-g5k HOST=api-server.lyon.grid5000.fr SITE=lyon
* executing `puppet:testing'
triggering before callbacks for `puppet:testing'
* executing `computehosts'
* executing `module:upload'
--> Uploading module api-g5k on lyon for testing
rsync -e "ssh -o ConnectTimeout=15 -F ./config/ssh_config" -rl --delete --exclude '.git*' modules/api-g5k/ [email protected]:/srv/puppet/testing/modules/api-g5k
Warning: Permanently added 'puppet.lyon.grid5000.fr' (RSA) to the list of known hosts.
triggering after callbacks for `puppet:testing'
* executing `puppet:launch'
+----+-------------+---------------------------+--------+--------------------------+---------+---------+-------------------------------------+--------+----------------------------------------------+
| id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra |
+----+-------------+---------------------------+--------+--------------------------+---------+---------+-------------------------------------+--------+----------------------------------------------+
| 1 | SIMPLE | jobs | ALL | state,state_id,accounted | NULL | NULL | NULL | 753098 | Using where; Using temporary; Using filesort |
| 1 | SIMPLE | moldable_job_descriptions | eq_ref | PRIMARY | PRIMARY | 4 | oar2.jobs.assigned_moldable_job | 1 | |
| 1 | SIMPLE | assign
def launch_server
server = TCPServer.new(7910)
while (session = server.accept)
Thread.new do
begin
command = session.readline.chomp
rescue
# If input is a ^c close client session and wait for a new one
session.close
next
until jobs.empty? do
job = jobs.shift
if job.reload['state'] == 'running'
begin
job.parent.deployments.submit({
:nodes => job['assigned_nodes'],
:environment => 'lenny-x64-nfs_rc@granquet'
)
rescue Restfully::HTTP::ServerError => e
puts e.message
[email protected](xenu):/var/apps/events-api/HEAD/current$ curl -kvi -x proxy:3128 "https://www.grid5000.fr/cgi-bin/bugzilla3/buglist.cgi?query_format=advanced&short_desc_type=allwordssubstr&short_desc=&long_desc_type=substring&sc=&bug_file_loc_type=allwordssubstr&bug_file_loc=&status_whiteboard_type=allwordssubstr&status_whiteboard=&emailcc1=1&emailtype1=exact&email1=events%40lists.grid5000.fr&emailassigned_to2=1&emailreporter2=1&emailqa_contact2=1&emailcc2=1&emailtype2=substring&email2=&bugidtype=include&bug_id=&chfieldfrom=&chfieldto=Now&chfieldvalue=&cmdtype=doit&order=Reuse+same+sort+as+last+time&field0-0-0=noop&type0-0-0=noop&value0-0-0="
* About to connect() to proxy proxy port 3128 (#0)
* Trying 172.24.120.23... connected
* Connected to proxy (172.24.120.23) port 3128 (#0)
* Establish HTTP proxy tunnel to www.grid5000.fr:443
> CONNECT www.grid5000.fr:443 HTTP/1.0
> Host: www.grid5000.fr:443
> User-Agent: curl/7.18.2 (x86_64-pc-linux-gnu) libcurl/7.18.2 OpenSSL/0.9.8g zlib/1.2.3.3
##
# :method: get(/grid5000/sites/:site_uid/deployments[.:format])
#
# :call-seq:
# GET /grid5000/sites/:site_uid/deployments[.:format]
#
# Get the list of deployments launched on a specific site.
#
# == URI parameters
# <tt>site_uid</tt>:: the UID of the site (e.g. "rennes").
@crohr
crohr / authn.rb
Created June 15, 2011 20:45
Trying to abort upload if no authentication provided
require 'goliath'
require 'tempfile'
class Authn < Goliath::API
def protected!(env)
raise Goliath::Validation::UnauthorizedError.new unless authorized?(env)
end
def authorized?(env)

Cyril Rohr

Ruby & RubyOnRails developer. Interested in information retrieval, machine learning techniques, distributed software architectures, cloud computing, REST and HTTP APIs, and web development in general.

Website: http://crohr.me | Phone: +33-6-33-85-83-32 | Skype: cyril.rohr

Work Experience