Skip to content

Instantly share code, notes, and snippets.

@stephan-v
stephan-v / is_installed.sh
Created July 14, 2018 15:18 — forked from JamieMason/is_installed.sh
Check if a program exists from a bash script.Thanks to twitter.com/joshnesbitt and twitter.com/mheap for the help with detecting npm packages.
#!/bin/bash
# Functions ==============================================
# return 1 if global command line program installed, else 0
# example
# echo "node: $(program_is_installed node)"
function program_is_installed {
# set to 1 initially
local return_=1
@stephan-v
stephan-v / lambda-not-anon.md
Created February 23, 2018 08:30
The distinction between anonymous functions and lambdas in JavaScript.

TL;DR - Lambda means "function used as data".

Anonymous function means "function without a name".

This is one of the relatively few cases where the Wikipedia definition of a word, while not entirely wrong, is misleading. Lambdas and anonymous functions are distinct ideas.

These ideas are commonly confused because in many programming languages (and lambda calculus) all lambdas are anonymous or vise verse.

In JavaScript, not all lambdas are anonymous, and not all anonymous functions are lambdas, so the distinction has some practical meaning.

@stephan-v
stephan-v / SvgInline.vue
Last active July 31, 2017 14:25
Code splitting SVG images with Webpack.
import(/* webpackChunkName: "js/svg/[request]" */ `resources/assets/images/svg/${this.name}.svg`)
.then((module) => {
this.svg = module;
}
).catch(error => 'An error occured while loading the svg');
<template>
<div class="filter">
<h4>{{ translation }}</h4>
<div class="checkbox" v-for="(value, index) in range" :key="index">
<label>
<input type="checkbox" :value="index" v-model.number="values">
<span class="value">{{ value }}</span>
<span class="background"></span>
@stephan-v
stephan-v / SearchFilter.vue
Last active July 7, 2017 13:59
Search filter component.
<template>
<div class="filter">
<h4>{{ title }}</h4>
<div class="checkbox" v-for="(value, key) in range">
<label>
<input type="checkbox" :value="key" v-model.number="items">
<span class="value">{{ value }}</span>
<span class="background"></span>
@stephan-v
stephan-v / Autocomplete.vue
Last active May 31, 2017 13:53
Vue autocomplete
<template>
<div class="relative">
<input type="text"
autocomplete="off"
class="form-control"
id="destination"
name="destination"
:placeholder="placeholder"
v-model="query"
@keydown="keydown">
@stephan-v
stephan-v / webpack.mix.js
Created May 24, 2017 08:19
Webpack configuration file.
const mix = require('laravel-mix');
const DashboardPlugin = require('webpack-dashboard/plugin');
const webpack = require('webpack');
const path = require('path');
/*
|--------------------------------------------------------------------------
| Mix Asset Management
|--------------------------------------------------------------------------
|
https://css-tricks.com/svg-artboard-sizing/
https://jsfiddle.net/7nyg1h8w/1/
phpunit ~/CodeCoverage --coverage-html
@stephan-v
stephan-v / self.static.php
Created December 8, 2016 15:38 — forked from jasonrhodes/self.static.php
Self vs Static in PHP
<?php
class A
{
public static $var = "I'm set in A!<br>";
public static function getStatic() {
echo static::$var;
}
public static function getSelf() {