Skip to content

Instantly share code, notes, and snippets.

🚀
Writing code

Tim Neutkens timneutkens

  • Knegsel, The Netherlands
Block or report user

Report or block timneutkens

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
View next.config.js
require('dotenv').config();
const withCSS = require('@zeit/next-css');
const path = require('path');
const Dotenv = require('dotenv-webpack');
const withImages = require('next-images');
const withTypescript = require('@zeit/next-typescript');
const withOffline = require('next-offline');
const {PHASE_DEVELOPMENT_SERVER, PHASE_PRODUCTION_BUILD} = require('next/constants')
View Server.js
const TOP_PATHS = new Set(
readdirSync(join(__dirname, '..', 'pages'))
.map(f => f.replace(/\.js$/, ''))
.concat(['', 'static', '_next'])
)
function topRoutesMiddleware(req, res, goNext) {
const topPath = req.path.split('/', 2)[1]
View import-script.js
export default function importScript(src) {
return new Promise((resolve, reject) => {
const loaded = Boolean(document.querySelector(`script[src="${src}"]`))
if (loaded) return resolve()
const script = document.createElement('script')
script.type = 'text/javascript'
script.src = src
script.async = true
View withData.js
import React from 'react'
import PropTypes from 'prop-types'
import { ApolloProvider, getDataFromTree } from 'react-apollo'
import Head from 'next/head'
import initApollo from './initApollo'
// Gets the display name of a JSX component for dev tools
function getComponentDisplayName (Component) {
return Component.displayName || Component.name || 'Unknown'
}
View new.md
@timneutkens
timneutkens / index.js
Last active Sep 9, 2017
Unique array values
View index.js
const yourArray = [1,2,1,3,3]
Array.from(new Set(yourArray)) // [1,2,3]
@timneutkens
timneutkens / fix-phpcs.sh
Created Jul 30, 2017
Use lint-staged with PHPcs fixer
View fix-phpcs.sh
for var in "$@"
do
./vendor/bin/php-cs-fixer fix --level=psr2 $var
done
@timneutkens
timneutkens / switch.sh
Created Mar 30, 2017
Valet PHP switcher
View switch.sh
#!/bin/bash
if [ -z "$1" ]; then
echo "Please provide a version. For example: php56, php70 or php71"
echo "Valet only supports PHP 5.6+"
exit
fi
if ! brew ls --versions $1 > /dev/null; then
echo "Installing $1"
brew install $1
@timneutkens
timneutkens / index.js
Last active Apr 24, 2019
Clear console/terminal in node.js the right way
View index.js
const readline = require('readline')
const blank = '\n'.repeat(process.stdout.rows)
console.log(blank)
readline.cursorTo(process.stdout, 0, 0)
readline.clearScreenDown(process.stdout)
@timneutkens
timneutkens / db-open
Last active Jan 24, 2017 — forked from helderco/db-open
Edited for Docker for Mac - Script to open a mysql database in Sequel Pro from a service in docker-compose.
View db-open
#!/bin/bash
set -e
show_help() {
cat << EOF
Usage: ${0##*/} [-u USER] [-p PASS] [-P PORT] [-H HOST] [DATABASE]
${0##*/} -h
Open a standard connection in Sequel PRO.
You can’t perform that action at this time.