Skip to content

Instantly share code, notes, and snippets.

Patrick Browne ptbrowne

Block or report user

Report or block ptbrowne

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@ptbrowne
ptbrowne / README.md
Last active Nov 1, 2018
Automatically add emojis to your commits
View README.md

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 Aug 28, 2017
easy_i18n.py
View README.md

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 Aug 28, 2017
Removing css module from a repository
View README.md

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 / App.js
Created May 29, 2017
standard test
View App.js
const App = function () {
return <div>Hello World !</div>
}
export default App
@ptbrowne
ptbrowne / queryAll.js
Created May 12, 2017
queryAll for cozy client
View queryAll.js
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
View admin.py
class LeafletJSONField(JSONField):
widget = LeafletWidget(width='100%', height='400px')
def process_formdata(self, valuelist):
if valuelist:
value = valuelist[0]
if not value:
self.data = None
return
try:
View make-gif.sh
#!/bin/sh
# Make a gif from a video using optimized palette
#
# Usage: make-gif video.mov video.gif 200
#
# Will output a gif with width 200px
# You can use iw in the width expression to have the width of the input
# video : iw*0.5 will make the gif half the size of the video (useful
# for Retina displays)
#
@ptbrowne
ptbrowne / csv-mail-filter.py
Created Sep 6, 2016
Parse mailFilters.xml from Gmail to CSV, only supports to and forwardTo
View csv-mail-filter.py
from collections import defaultdict
from xml.etree import cElementTree as ET
def etree_to_dict(t):
# remove namespace
if hasattr(t.tag, 'find'):
i = t.tag.find('}')
if i >= 0:
t.tag = t.tag[i+1:]
View webpack-dev-server-index.js
var url = require('url');
var SockJS = require("sockjs-client");
var stripAnsi = require('strip-ansi');
var scriptElements = document.getElementsByTagName("script");
var scriptHost = scriptElements[scriptElements.length-1].getAttribute("src").replace(/\/[^\/]+$/, "");
// If this bundle is inlined, use the resource query to get the correct url.
// Else, get the url from the <script> this file was called with.
var urlParts;
if (typeof __resourceQuery === "string" && __resourceQuery) {
View gist:167b192fb169dcb027b07032cbeb9c7f
// ==UserScript==
// @name Ornikar Keyboard Shortcuts
// @namespace http://tampermonkey.net/
// @version 0.1
// @description Add ABCD shortcuts to Ornikar questions
// @author Patrick Browne
// @match https://www.ornikar.com/*
// @grant none
// ==/UserScript==
You can’t perform that action at this time.