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 / 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 / change_feed.md
Last active September 29, 2015 13:54
Couchdb changes for files/folders operations

Folders

Create

{ id: "5ddd48869033f0595a9619d46805e0da",
  changes: [ { rev: "1-21b1243be5cc354143d8613575225a74" } ],
  doc:
   { path: "/parent",
     name: "foo",
@nono
nono / analysis.yaml
Last active August 29, 2015 14:08
I can't understand why Elasticsearch can't find Europe with a snowball analyzer...
text:
- "Western Europe antiquities"
- "Antiquités de l'Europe occidentale"
analyzer:
snowball_en:
type: snowball
language: English
snowball_fr:
type: custom
@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 / Profiling
Created March 28, 2014 10:12
Profiling a request, with a bottleneck on therubyracer
100.0% - …/bin/unicorn#<main>
167 Collapsed methods (show)
100.0% - …/action_view/template.rb#block in render
97.0% - …/complete_creations/_single_address.html.haml#_app_views_orders_wizard_complete_creations__single_address_html_haml__386521348274838379_97485080
20 Collapsed methods (show)
97.0% - …/complete_creations/_single_address.html.haml#block in _app_views_orders_wizard_complete_creations__single_address_html_haml__386521348274838379_97485080
85.0% - …/complete_creations/_single_address.html.haml#each_with_index
21 Collapsed methods (show)
85.0% - …/ordering/complete_creations.rb#option_price_structure
83.0% - …/ordering/complete_creations.rb#option_base_price_with_sale_applied
@nono
nono / Gemfile
Last active August 29, 2015 13:56
Error when paginating the results of a complex query with es-model
source 'https://rubygems.org'
gem "ansi"
gem "jbuilder"
gem "sqlite3"
gem "activerecord"
gem "kaminari"
gem "elasticsearch-model", :github => "elasticsearch/elasticsearch-rails"