Skip to content

Instantly share code, notes, and snippets.

View timneutkens's full-sized avatar
👋

Tim Neutkens timneutkens

👋
View GitHub Profile
@timneutkens
timneutkens / getpositionfrombottom.jquery.js
Last active June 23, 2016 09:38
Get space between element bottom and document bottom
function getPositionFromBottom(element) {
return $(document).height() - element.offset().top - element.outerHeight()
}
@timneutkens
timneutkens / wp-query-ref.php
Created April 7, 2016 10:31 — forked from luetkemj/wp-query-ref.php
WP: Query $args
<?php
/**
* WordPress Query Comprehensive Reference
* Compiled by luetkemj - luetkemj.com
*
* CODEX: http://codex.wordpress.org/Class_Reference/WP_Query#Parameters
* Source: https://core.trac.wordpress.org/browser/tags/3.9/src/wp-includes/query.php
*/
$args = array(
@timneutkens
timneutkens / fpdf-image.php
Created April 14, 2016 14:36
Insert base64 image data into fpdf
<?php
// load the 'fpdf' extension
require('fpdf.php');
// just for demonstration purpose, the OP gets the content from a database instead
$h_img = fopen('img.jpg', "rb");
$img = fread($h_img, filesize('img.jpg'));
fclose($h_img);
// prepare a base64 encoded "data url"
@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 / 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>
*/
@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
*/
GITDIR='remote'; echo ssh://${USER}@${HOSTNAME}:${PWD}/${GITDIR}.git
/**
* detect a click outside of an element and trigger callbacks based on that click.
* @param trigger
* @param element
* @param openCallback
* @param closeCallback
*/
function DetectClickOutsideOfElement (trigger, element, openCallback, closeCallback) {
var enabled = false;
@timneutkens
timneutkens / bootstrap-popover-hover.js
Last active June 2, 2021 13:24
Keep Bootstrap popover open when the popover itself is being hovered
jQuery('[data-toggle="popover-hover"]').popover({
trigger: 'manual',
html: true,
animation:false,
viewport: '.container'
}).on('mouseenter', function () {
var self = this;
jQuery(this).popover("show");
jQuery(".popover").on('mouseleave', function () {
jQuery(self).popover('hide');
@timneutkens
timneutkens / rewriterules.js
Last active July 4, 2016 08:25
Fast way to create apache rewrite rules
// Create RewriteRule from given variables
function createRewriteString(oldUrl, newUrl, removeDomainPrefix) {
return 'RewriteRule ^' + oldUrl.replace(removeDomainPrefix, '') + '/?$ ' + newUrl + ' [NC,L,R=301]'
}
// Url to path mapping. Seperated by one space.
const urls = `http://example.com/foo/bar /bar/foo
http://example.com/foo/baz /baz/foo`
// Split by line break