Skip to content

Instantly share code, notes, and snippets.

View timneutkens's full-sized avatar
👋

Tim Neutkens timneutkens

👋
View GitHub Profile
@timneutkens
timneutkens / fix-phpcs.sh
Created July 30, 2017 20:36
Use lint-staged with PHPcs fixer
for var in "$@"
do
./vendor/bin/php-cs-fixer fix --level=psr2 $var
done
@timneutkens
timneutkens / switch.sh
Created March 30, 2017 09:13
Valet PHP switcher
#!/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 March 4, 2024 14:01
Clear console/terminal in node.js the right way
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 January 24, 2017 09:11 — 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.
#!/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.
@timneutkens
timneutkens / README.md
Last active April 15, 2021 12:10
Magento2 | Execute data-mage-init and x-magento-init in dynamic content (ajax request)

Execute data-mage-init and x-magento-init in dynamic content (ajax response)

Trigger .trigger('contentUpdated') on the element where dynamic content is injected.

$.ajax({
    url: 'https://www.example.com',
    method: 'POST',
    data: {
 id: '1'
@timneutkens
timneutkens / index.js
Last active January 10, 2017 12:41
Create empty csv (simple, for small lists)
const list = `
item1
item2
`.trim()
const translate = list.split('\n').map(item => `"${item}",""`).join('\n').trim()
console.log(translate)
@timneutkens
timneutkens / index.sql
Created January 10, 2017 09:07
Truncate media library Magento 2
SET FOREIGN_KEY_CHECKS = 0;
TRUNCATE catalog_product_entity_media_gallery;
SET FOREIGN_KEY_CHECKS = 1;
@timneutkens
timneutkens / get-headers.sh
Created January 4, 2017 09:29
Get headers using curl
alias get-headers='curl -X HEAD -i'
@timneutkens
timneutkens / index.js
Created January 3, 2017 19:56
Use Morgan logger with Micro
// Based on https://www.npmjs.com/package/morgan#vanilla-http-server
const { send } = require('micro')
const morgan = require('morgan')
const logger = morgan('combined')
module.exports = async function (req, res) {
logger(req, res, function (err) {
if (err) {
return send(res, 500, 'Error')
}
@timneutkens
timneutkens / checkout_index_index.xml
Created November 30, 2016 10:01
Disable uiComponent in checkout
<referenceContainer name="content">
<referenceBlock name="checkout.root">
<arguments>
<argument name="jsLayout" xsi:type="array">
<item name="components" xsi:type="array">
<item name="checkout" xsi:type="array">
<item name="children" xsi:type="array">
<item name="authentication" xsi:type="array">
<item name="componentDisabled" xsi:type="boolean">true</item>
</item>