Skip to content

Instantly share code, notes, and snippets.

View timneutkens's full-sized avatar
👋

Tim Neutkens timneutkens

👋
View GitHub Profile
@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(
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 / 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 / config-load-data-infile.yml
Created July 4, 2016 08:24
Enable LOAD DATA INFILE Symfony Doctrine
doctrine:
dbal:
option:
# This is PDO::MYSQL_ATTR_LOCAL_INFILE
1001: true
@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
@timneutkens
timneutkens / countposts.php
Created July 11, 2016 12:57
WPML wp_count_posts fix. Taken from http://pastebin.com/E5nMcF25
function count_posts($language_code = '', $post_type = 'post', $post_status = 'publish'){
global $sitepress, $wpdb;
//get default language code
$default_language_code = $sitepress->get_default_language();
//adjust post type to format WPML uses
switch($post_type){
case 'page':
@timneutkens
timneutkens / findtypekitfonts.js
Created July 15, 2016 07:31
Find typekit fonts. Run this in your console.
$('html').attr('class')
.split(' ')
.filter( function (word) {
return word.match(/wf-(.*)-active/g); }
)
.forEach( function (font) {
console.log(font.replace(/wf-|-active/g, ''))
})
@timneutkens
timneutkens / swiper.css
Last active July 22, 2016 07:43
Swiper.js horizontal slider styling
.swiper-container {
position: relative;
overflow: hidden;
width: 100%;
}
.swiper-wrapper {
position: relative;
width: 10000%;
}
@timneutkens
timneutkens / .vimrc
Created July 23, 2016 12:02
Enable vim syntax highlighting for mac
filetype plugin indent on
syntax on