Skip to content

Instantly share code, notes, and snippets.

View bpierre's full-sized avatar
✌️

Pierre Bertet bpierre

✌️
View GitHub Profile
@bpierre
bpierre / emotion-plugin-css-unit.js
Last active April 9, 2021 14:24
Custom CSS units implemented with @emotion/cache as a stylis plugin
import { CacheProvider } from "@emotion/react"
import createCache from "@emotion/cache"
function cssUnitPlugin(unitInPx = 8, unit = "gu") {
const re = new RegExp("([0-9]+)" + unit, "g")
const convert = (value) => value.replace(re, replacer)
const replacer = (_, value) => `${value * unitInPx}px`
return (element) => {
if (element.type === "decl" && element.value.includes(unit)) {
@bpierre
bpierre / README.md
Last active February 15, 2024 18:40
Switch To Vim For Good

Switch To Vim For Good

NOTE: This guide has moved to https://github.com/bpierre/switch-to-vim-for-good

This guide is coming from an email I used to send to newcomers to Vim. It is not intended to be a complete guide, it is about how I switched myself.

My decision to switch to Vim has been made a long time ago. Coming from TextMate 1, I wanted to learn an editor that is Open Source (so I don’t lose my time learning a tool that can be killed), cross platform (so I can use it everywhere), and powerful enough (so I won’t regret TextMate). For these reasons, Vim has always been the editor I wanted to learn, but it took me several years before I did it in a way that works for me. I tried to switch progressively, using the Janus Vim distribution for a few months, then got back to using TextMate 2 for a time, waiting for the next attempt… here is what finally worked for me.

Original gist with comments: https://gist.github.com/bpierre/0a0025d348b6001394e0

## Colours and font styles
## Syntax: echo -e "${FOREGROUND_COLOUR}${BACKGROUND_COLOUR}${STYLE}Hello world!${RESET_ALL}"
# Escape sequence and resets
ESC_SEQ="\x1b["
RESET_ALL="${ESC_SEQ}0m"
RESET_BOLD="${ESC_SEQ}21m"
RESET_UL="${ESC_SEQ}24m"
# Foreground colours

Keybase proof

I hereby claim:

  • I am bpierre on github.
  • I am bpierre (https://keybase.io/bpierre) on keybase.
  • I have a public key whose fingerprint is D737 C824 4126 75D9 89E9 4835 5277 8183 234D C59F

To claim this, I am signing this object:

@bpierre
bpierre / gist:10526379
Created April 12, 2014 09:17
keybase.md
### Keybase proof
I hereby claim:
* I am bpierre on github.
* I am bpierre (https://keybase.io/bpierre) on keybase.
* I have a public key whose fingerprint is 219A B92C E852 719D 99C3 5A1B 17B2 82B4 3284 3D18
To claim this, I am signing this object:
@bpierre
bpierre / hash.js
Created February 23, 2014 17:56
Mini location.hash system + mini routing system (useful with PhoneGap)
/*
* Mini location.hash update system
*
* Usage:
*
* var createHash = require('./hash');
* var hash = createHash('!/', function(value) {
* // Value updated
* });
*
@bpierre
bpierre / gist:4991393
Created February 19, 2013 23:52
Results of the markdown-testsuite with markdown-js
not ok test/markdown-testsuite.t.js .................. 51/102
Command: "node" "markdown-testsuite.t.js"
TAP version 13
ok 1 2-paragraphs-hard-return-spaces
ok 2 2-paragraphs-hard-return
ok 3 2-paragraphs-line-returns
ok 4 2-paragraphs-line-spaces
ok 5 2-paragraphs-line-tab
ok 6 ampersand-text-flow
ok 7 ampersand-uri
@bpierre
bpierre / sfrbox-host.sh
Created December 3, 2012 13:40
Add a custom domain on a Neuf/SFR Box, from CLI
#!/bin/sh
die () {
echo >&2 "$@"
exit 1
}
[ "$#" -eq 2 ] || die "2 arguments required (IP and Domain), $# provided"
LOGIN="admin"
@bpierre
bpierre / kib.js
Created November 14, 2012 00:03
Another boring keyboard library
/*jshint browser:true */
(function(name, definition) {
if (typeof define == 'function') {
define(definition);
} else if (typeof module != 'undefined') {
module.exports = definition();
} else {
this[name] = definition();
}
})('kib', function(){
@bpierre
bpierre / index.html
Created October 15, 2012 11:37
SUPER #7
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>SUPER #7</title>
<style>
html { display: table; width: 100%; height: 100%; background: #000; }
body { display: table-cell; vertical-align:middle; text-align:center; margin: 0; }
canvas { margin: 0; }
h1 { color: #fff; margin: 0 0 10px; font:24px sans-serif; }