Skip to content

Instantly share code, notes, and snippets.

View timneutkens's full-sized avatar
👋

Tim Neutkens timneutkens

👋
View GitHub Profile
@timneutkens
timneutkens / codeigniter-export-language.php
Created April 29, 2016 07:13
Export specific language directory to csv
<?php
/**
* PHP version 5.4
* @category Export
* @package Language
* @author Tim Neutkens <tim@weprovide.com>
* @license MIT <https://opensource.org/licenses/MIT>
* @link <weprovide.com>
*/
import {useState, useEffect} from 'react'
function useMounted() {
const [isMounted, setMounted] = useState(false)
useEffect(() => setMounted(true), [])
return isMounted
}
// const isMounted = useMounted()
@timneutkens
timneutkens / wordpress-dbsync.sh
Created April 24, 2016 20:45
Export / import wordpress database oneliner
# Uses these 2 tools:
# http://wp-cli.org/
# https://github.com/xwp/wp-cli-ssh
# Remote to local
wp ssh db export - --host=production | wp db import -
# Local to remote BEWARE THIS IS DANGEROUS BUT KEPT AS REFERENCE
wp db export - | wp ssh db import - --host=production
@timneutkens
timneutkens / getconfig.md
Last active March 24, 2019 17:45 — forked from wsakaren/gist:3a26a61347cbe485677f
Mage::getStoreConfig in Magento 2 compared to Magento 1

Magento 1.x:

Mage::getStoreConfig('carriers/shipper/active')

Magento 2.x (using constructor injection):

protected $scopeConfig;
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')
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]
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
@timneutkens
timneutkens / get-excerpt.php
Last active October 27, 2018 00:14
Get excerpt of string
<?php
/**
* Small utility function to get an excerpt. Standard length is 100 characters
*
* @param $string
* @param int $start_postion
* @param int $max_length
*
* @return string
*/
@timneutkens
timneutkens / ip.sh
Created August 15, 2016 11:47
Get your external IP adress
alias ip='dig +short myip.opendns.com @resolver1.opendns.com'