Skip to content

Instantly share code, notes, and snippets.

View laruiss's full-sized avatar
🏠
Working from home

Stanislas Ormières laruiss

🏠
Working from home
View GitHub Profile
@laruiss
laruiss / laruiss.zsh-theme
Created September 7, 2015 09:46
My oh my zsh theme
# Color shortcuts
RED=$fg[red]
YELLOW=$fg[yellow]
GREEN=$fg[green]
WHITE=$fg[white]
BLUE=$fg[blue]
RED_BOLD=$fg_bold[red]
YELLOW_BOLD=$fg_bold[yellow]
GREEN_BOLD=$fg_bold[green]
WHITE_BOLD=$fg_bold[white]
# Install brew
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
# Install wget
brew install wget
# Install Chrome
wget https://dl.google.com/chrome/mac/stable/GGRO/googlechrome.dmg
open googlechrome.dmg
@laruiss
laruiss / webpack.config.js
Last active October 15, 2017 16:19
Minimal Webpack config (Webpack post series)
module.exports = {
 entry: './src/index.js',
 output: {
 filename: 'build/bundle.js'
 }
}
@laruiss
laruiss / add.js
Created October 15, 2017 16:20
Simple CommonJS module
function add (a, b) {
 return a + b
}
module.exports = add
@laruiss
laruiss / add.js
Created October 15, 2017 16:22
Simple ESM
function add (a, b) {
 return a + b
}
export default add
@laruiss
laruiss / index.js
Last active October 15, 2017 18:01
ESM file with import
import add from './add'
console.log(add(1, 2))
@laruiss
laruiss / add.js
Last active October 15, 2017 18:03
ESM file with ES2015 syntax and export
function add (a, b) {
return a + b
}
const sum = (...args) => args.reduce(add)
export default sum
@laruiss
laruiss / use-of-with-pkg.js
Last active October 15, 2017 18:05
with-pkg
var exit = require('exit')
var join = require('path').join
var fullPackagePath = join(process.cwd(), 'package.json')
var pkg = require(fullPackagePath)
const varsToInterpolate = process.argv.slice(2)
const vars = getInterpolations(varsToInterpolate)
function getInterpolations() {
@laruiss
laruiss / .zshrc
Last active November 17, 2017 13:48
.zshrc part for npm bin path
# For zsh only: don't put this for bash
precmd() { eval "$PROMPT_COMMAND" }
__OLD_PATH=$PATH
function updatePATHForNPM() {
export PATH=$(npm bin):$__OLD_PATH
}
function node-mode() {
PROMPT_COMMAND=updatePATHForNPM
function getQueryStringAsObject(uri) {
const link = document.createElement('a')
link.href = uri || location
const queryString = link.search
const qsAsObject = {};
queryString.replace(
/([^?=&]+)(?:=([^&]*))?/g,
function($0, $1, $2) {
qsAsObject[$1] = decodeURI($2) || true;
}