Skip to content

Instantly share code, notes, and snippets.

View ptbrowne's full-sized avatar

Patrick Browne ptbrowne

View GitHub Profile
@ptbrowne
ptbrowne / queryAll.js
Created May 12, 2017 07:44
queryAll for cozy client
const queryAll = function (cozyClient, mangoIndex, options) {
return new Promise((resolve, reject) => {
const documents = []
const fetch = function () {
return cozyClient.data.query(mangoIndex, options)
.then(onSuccess)
.catch(reject)
}
const onSuccess = function (docs, response) {
debugger
@ptbrowne
ptbrowne / App.js
Created May 29, 2017 09:18
standard test
const App = function () {
return <div>Hello World !</div>
}
export default App
@ptbrowne
ptbrowne / README.md
Last active August 28, 2017 10:03
Removing css module from a repository

To remove CSS modules from a repository, these steps can help.

codemod --extension 'jsx' 'styles\[(.*?)\]' '\1' # className={styles['a]} -> className={'a'}
find . | grep '.jsx$' | xargs jscodeshift --parser babel -t simpleClassNames.js # className={classNames('a', 'b', 'c')} -> className='a b c'

Check well, adjust manually and you are good to go.

@ptbrowne
ptbrowne / README.md
Last active August 28, 2017 13:34
easy_i18n.py

You have a translation file full of English. You want to translate it to French easily.

1. Output all translation strings

python easy_i18n.py en.json output

2. Copy those strings into Google Translate

@ptbrowne
ptbrowne / README.md
Last active March 2, 2024 12:59
Automatically add emojis to your commits

To automatically add emojis to your commits, you can use the commit-msg hook.

$ git init
$ ln -s commit-msg-emoji .git/hooks/commit-msg
@ptbrowne
ptbrowne / readme.md
Last active September 20, 2017 15:01
Replace several strings from file

You have a file where you want to replace several strings.

Example :

file.json

[
  {"category": "personalCare"},
  {"category": "atm"},
@ptbrowne
ptbrowne / horizontal-bar-chart.py
Created October 24, 2017 21:16
Horizontal bar chart with autolabel
# a stacked bar plot with errorbars
%config InlineBackend.figure_format = 'retina'
import pandas as pd
from random import random
import matplotlib.pyplot as plt
def autolabel(rects):
"""
Attach a text label above each bar displaying its height
@ptbrowne
ptbrowne / predict-requires.py
Created January 12, 2018 11:02
Predict requires according to variables used
#-*- coding: utf-8 -*-
import fnmatch
import os
def glob(dir, pattern):
for root, dirnames, filenames in os.walk(dir):
for filename in fnmatch.filter(filenames, pattern):
yield os.path.join(root, filename)
@ptbrowne
ptbrowne / cozy-docs.md
Last active January 26, 2018 09:48
Retours de ma copine sur Cozy

Retours de ma copine (maureenlebars.mycozy.cloud)

Général

Interface claire, pas de boutons, contente de son Cozy.

Login

Apres s'être inscrite pour revenir sur son cozy elle est passée par Sign In et la on lui a demandé une URL et elle savait pas quoi mettre.

@ptbrowne
ptbrowne / make-doc.py
Last active February 26, 2018 15:51
make-doc and executes samples
"""
Will render markdown to markdown.
Will execute execbash code blocks and add their output to the code block.
"""
import mistune
import sh
from textwrap import wrap