Skip to content

Instantly share code, notes, and snippets.

View ptbrowne's full-sized avatar

Patrick Browne ptbrowne

View GitHub Profile
@ptbrowne
ptbrowne / index.js
Created August 13, 2020 13:49
Registers firebase device token into the oauth client
const { createClientInteractive } = require('cozy-client/dist/cli')
const { ArgumentParser } = require('argparse')
const main = async () => {
const parser = new ArgumentParser()
parser.addArgument('--url', { defaultValue: 'http://cozy.tools:8080' })
parser.addArgument('--platform')
parser.addArgument('--registrationToken')
const client = await createClientInteractive({
@ptbrowne
ptbrowne / rlink.sh
Last active January 21, 2020 09:09
Like yarn link but with rsync/nodemon
@ptbrowne
ptbrowne / README.md
Last active July 23, 2019 08:28
Simple command cache

If you deal with commands that can take several seconds but always return the same result and you need to transform the result with pipe chain (jq / grep / awk), it can be annoying to wait for those seconds while you incrementally build the command, when you know the result has not changed.

cache.js can help you by caching the result of the command to /tmp and returning the result immediately.

Installation

@ptbrowne
ptbrowne / fzf-usages.md
Created July 17, 2019 10:55
FZF usages

pk.fish

Interactively kills a process

ps aux | fzf | tr -s ' ' | cut -d ' ' -f 2 | xargs kill

lab.mr-browse-interactive.fish

@ptbrowne
ptbrowne / alphabet.py
Last active July 13, 2018 15:42
alphabet.py
from collections import defaultdict
import sys
from copy import deepcopy
def find_common_prefix(word1, word2):
"""Find the longest common prefix between two words"""
i = 0
l1 = len(word1)
l2 = len(word2)
while l1 > i and l2 > i and word1[i] == word2[i]:
@ptbrowne
ptbrowne / jscodeshift.html
Created March 14, 2018 08:50
JSCodeshift Remark
<!DOCTYPE html>
<html>
<head>
<title>JSCodeshift</title>
<meta charset="utf-8">
<style>
@import url(https://fonts.googleapis.com/css?family=Yanone+Kaffeesatz);
@import url(https://fonts.googleapis.com/css?family=Droid+Serif:400,700,400italic);
@import url(https://fonts.googleapis.com/css?family=Ubuntu+Mono:400,700,400italic);
@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
@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 / 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 / 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