Skip to content

Instantly share code, notes, and snippets.

View nono's full-sized avatar

Bruno Michel nono

  • Cozy Cloud
  • Paris, France
View GitHub Profile
@nono
nono / redis2txt.rb
Created November 28, 2011 23:29
Export data from redis to a plain text files
#!/usr/bin/env ruby
require "redis"
redis = Redis.new
redis.keys("*").each do |key|
val = case redis.type(key)
when "string"
redis.get key
when "list"
@nono
nono / output.json
Created October 9, 2014 10:55
Use null_value for a date field in Elasticsearch mapping
{
"took" : 3,
"timed_out" : false,
"_shards" : {
"total" : 1,
"successful" : 1,
"failed" : 0
},
"hits" : {
"total" : 2,
@nono
nono / rails_log_stathat.rb
Created December 30, 2011 11:07
Parse a Rails log file and send metrics to stathat
#!/usr/bin/env ruby
require 'net/http/persistent'
require 'uri'
require 'thread'
USAGE = <<EOS
Parse a Rails log file and send metrics to stathat
export EMAIL=email
@nono
nono / blowfish.rb
Created June 26, 2012 10:57
How to encrypt and decrypt Blowfish in Ruby 1.9 with https://github.com/drench/blowfish.js
#!/usr/bin/env ruby
require "openssl"
class BF < Struct.new(:key, :pad_with_spaces)
def encrypt(str)
cipher = OpenSSL::Cipher.new('bf-ecb').encrypt
if pad_with_spaces
str += " " until str.bytesize % 8 == 0
cipher.padding = 0
@nono
nono / 1_revs_diff.sh
Last active March 16, 2018 15:15
Playing with CouchDB revisions
~ ❯ curl 'http://localhost:5984/aaa/bbb?revs_info=true'
{"_id":"bbb","_rev":"4-753875d51501a6b1883a9d62b4d33f91","foo":4,"_revs_info":[{"rev":"4-753875d51501a6b1883a9d62b4d33f91","status":"available"},{"rev":"3-efc54218773c6acd910e2e97fea2a608","status":"available"},{"rev":"2-2ee767305024673cfb3f5af037cd2729","status":"available"},{"rev":"1-4a7e4ae49c4366eaed8edeaea8f784ad","status":"available"}]}
~ ❯ curl -X POST 'http://localhost:5984/aaa/_revs_diff' -H 'Accept: application/json' -H 'Content-Type: application/json' -d '{"bbb": ["1-4a7e4ae49c4366eaed8edeaea8f784ad", "2-2ee767305024673cfb3f5af037cd2729"]}'
{}
~ ❯ curl -X POST 'http://localhost:5984/aaa/_revs_diff' -H 'Accept: application/json' -H 'Content-Type: application/json' -d '{"bbb": ["1-4a7e4ae49c4366eaed8edeaea8f784ad", "3-efc54218773c6acd910e2e97fea2a608", "4-ccc", "5-ddd"]}'
{"bbb":{"missing":["4-ccc","5-ddd"],"possible_ancestors":["4-753875d51501a6b1883a9d62b4d33f91"]}}
~ ❯ curl -X POST 'http://localhost:5984/aaa/_revs_diff' -H 'Accept:
@nono
nono / fake-contacts.rb
Created September 11, 2017 16:00
Create fake contacts in CouchDB for Cozy v3
#!/usr/bin/env ruby
# gem install faker rest-client
# ./fake-contacts.rb 100
require 'faker'
require 'json'
require 'rest-client'
Faker::Config.locale = :fr
@nono
nono / .gitignore
Last active July 18, 2017 10:40
Debug renaming big files in Swift
/bug-rename-swift
/random
/vendor
@nono
nono / commands.md
Last active May 4, 2017 07:55
Validation de la carte "Je peux ajouter un trigger @event"

Création de l'instance et des tokens

$ cozy-stack instances client-oauth cozy.tools:8080 http://localhost/ test-event github.com/cozy/cozy-stack
cfb477f48683e0468549abab6501ef47
$ export CLIENT_ID=cfb477f48683e0468549abab6501ef47
$ cozy-stack instances token-oauth cozy.tools:8080 $CLIENT_ID "io.cozy.jobs io.cozy.triggers io.cozy.queues"
eyJhbGciOiJIUzUxMiIsInR5cCI6IkpXVCJ9.eyJhdWQiOiJhY2Nlc3MiLCJpYXQiOjE0OTAzNDIwODYsImlzcyI6ImNvenkubG9jYWw6ODA4MCIsInN1YiI6ImNmYjQ3N2Y0ODY4M2UwNDY4NTQ5YWJhYjY1MDFlZjQ3Iiwic2NvcGUiOiJpby5jb3p5LmpvYnMgaW8uY296eS50cmlnZ2VycyBpby5jb3p5LnF1ZXVlcyJ9.dwAAxCmrOsOHI0b9GFM8txGzaHI5YxmyjanGd_Vxpz9B4p_TTc7Ft5KTCMSbPibgYc3pbl2H6JVAWWjpO6qdrw
$ export ACCESS_TOKEN=eyJhbGciOiJIUzUxMiIsInR5cCI6IkpXVCJ9.eyJhdWQiOiJhY2Nlc3MiLCJpYXQiOjE0OTAzNDIwODYsImlzcyI6ImNvenkubG9jYWw6ODA4MCIsInN1YiI6ImNmYjQ3N2Y0ODY4M2UwNDY4NTQ5YWJhYjY1MDFlZjQ3Iiwic2NvcGUiOiJpby5jb3p5LmpvYnMgaW8uY296eS50cmlnZ2VycyBpby5jb3p5LnF1ZXVlcyJ9.dwAAxCmrOsOHI0b9GFM8txGzaHI5YxmyjanGd_Vxpz9B4p_TTc7Ft5KTCMSbPibgYc3pbl2H6JVAWWjpO6
@nono
nono / 1-instances-add
Last active December 15, 2016 09:54
Command line to test the creation of an OAuth2 client with the new cozy stack
cozy@cozy-stack-v2:~$ ./cozy-stack instances add test.bruno.fr
INFO[0000] Instance created with success for domain test.bruno.fr
INFO[0000] Registration token: "37cddf40d7724988860fa0e03efd30fe"
@nono
nono / conv.go
Last active December 18, 2015 01:39 — forked from jeromenerf/gist:5679866
package main
import (
"fmt"
proj "github.com/pebbe/go-proj-4/proj"
)
const (
// Epsg = "+init=epsg:27572"
Epsg = "+proj=lcc +lat_1=46.8 +lat_0=46.8 +lon_0=2.33722917 +k_0=0.99987742 +x_0=600000 +y_0=2200000 +a=6378249.2 +pm=paris +units=m +no_defs no_defs <>"