Skip to content

Instantly share code, notes, and snippets.

View benfavre's full-sized avatar
💻
At the office

Webdesign29 benfavre

💻
At the office
View GitHub Profile
@benfavre
benfavre / gist:2053331
Created March 16, 2012 22:39 — 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
* Source: http://core.trac.wordpress.org/browser/tags/3.3.1/wp-includes/query.php
*/
$args = array(
@benfavre
benfavre / pods2.x_gravityforms_helper.php
Last active December 10, 2015 05:58 — forked from anonymous/gravityforms.php
Pods 2.0 Gravity Forms input helper. Use a text or code field.
<?php
wp_enqueue_style( 'pods-select2' );
wp_enqueue_script( 'pods-select2' );
$attributes = array();
$attributes[ 'tabindex' ] = 2;
$pick_limit = (int) pods_var( 'pick_limit', $options, 0 );
$name .= '[]';
$attributes[ 'multiple' ] = 'multiple';
if ( !is_array( $options[ 'data' ] ) && false !== $options[ 'data' ] && 0 < strlen( $options[ 'data' ] ) )
@benfavre
benfavre / load_async.js
Last active December 16, 2015 05:39 — forked from ngryman/snippet.js
Load Javascript files asynchonously
/*
* Updated to use the function-based method described in http://www.phpied.com/social-button-bffs/
* Better handling of scripts without supplied ids.
*
* N.B. Be sure to include Google Analytics's _gaq and Facebook's fbAsyncInit prior to this function.
*/
(function(d, u) {
var s = d.scripts[0],
i = u.length, g;
@benfavre
benfavre / functions.php
Created April 22, 2013 18:36
Cleanup Shortcode #WordPress #functions.php
<?php
// A mettre dans functions.php
add_filter('the_content', 'clean_p_shortcode');
function clean_p_shortcode($content){
$array = array (
'<p>[' => '[',
']</p>' => ']',
']<br />' => ']'
);
/*
Allows for ajax requests to be run synchronously in a queue
Usage::
var queue = new $.AjaxQueue();
queue.add({
url: 'url',
<?php
// Add custom meta to user profile screen
add_action( 'show_user_profile', 'example_show_extra_profile_fields' );
add_action( 'edit_user_profile', 'example_show_extra_profile_fields' );
function example_show_extra_profile_fields( $user ) { ?>
<h3>Payment information</h3>
@benfavre
benfavre / -README.md
Created February 19, 2016 17:44 — forked from jirutka/-README.md
How to use terminal on Windows and don’t go crazy…

How to use terminal on Windows without going crazy…

Windows is really horrible system for developers and especially for devops. It doesn’t even have a usable terminal and shell, so working with command line is really pain in the ass. If you really don’t want to switch to any usable system (OS X, Linux, BSD…), then this guide should help you to setup somewhat reasonable environment – usable terminal, proper shell, ssh client, git and Sublime Text as a default editor for shell.

Install stuff

  1. Download and install Git for Windows* with:
    • [✘] Use Git from the Windows Command Prompt
  • [✘] Checkout as-is, commit Unix-style line endings
@benfavre
benfavre / README.md
Created October 26, 2016 23:44 — forked from dbu/README.md
Convert NelmioApiDocBundle annotations to Swagger PHP

A Symfony command to convert from NelmioApiDocBundle annotations to Swagger-PHP annotations.

This code is provided as is. Make sure to have your code committed to version control before running the command. Check if things work out and if not, use version control to reset the automated changes and fix the command.

@benfavre
benfavre / gen.sh
Created January 15, 2017 00:15 — forked from thomasyip/gen.sh
Generate self-signed alternate dns (wildcard) ssl certificate with a single script
#!/bin/bash
# file: gen.sh
# usage: ./gen.sh [name]
ROOT=rootCA
NAME=${1:-device}
EXTS=( key cnf csr crt )
ROOT_NAME=rootCA
ROOT_EXTS=( key pem )
@benfavre
benfavre / Dockerfile
Created January 17, 2017 23:23 — forked from jmyrland/Dockerfile
Docker mounted volume removes node_modules
# Set the base image to stable version of node
FROM node:0.12.2
# Install nodemon
RUN npm install -g nodemon
# Provides cached layer for node_modules
COPY package.json /tmp/package.json
RUN cd /tmp && npm install --production
RUN mkdir -p /app && cp -a /tmp/node_modules /app/