Skip to content

Instantly share code, notes, and snippets.

View johnie's full-sized avatar
httpster

Johnie Hjelm johnie

httpster
View GitHub Profile
@johnie
johnie / app.js
Created January 23, 2015 19:51
Setting up express and nunjucks with custom views folder
/*----------------------------------------------------------*\
Setting up express and nunjucks with custom views folder
\*----------------------------------------------------------*/
var express = require('express');
var app = express();
var nunjucks = require('nunjucks');
var path = require('path');
@johnie
johnie / computedstyle.js
Created April 8, 2015 11:42
Get computed style
function _getComputedStyle(element){
var style,
_element = element;
while(_element && _element.nodeType !== 1){
_element = _element.parentNode;
}
style = _element && _element.nodeType == 1 ? window.getComputedStyle(_element) : null;
return style;

Keybase proof

I hereby claim:

  • I am johnie on github.
  • I am johnie (https://keybase.io/johnie) on keybase.
  • I have a public key whose fingerprint is A42B C411 5BAC 7FE1 5728 150A A84A 4594 6E00 E128

To claim this, I am signing this object:

<div class="bottom" style="text-align: right;">
<div class="flexible-layouts__btn-wrap">
<div class="flexible-layouts papi-hide">
<div class="flexible-layouts-arrow"></div>
<ul>
<?php foreach ( $items as $layout ): ?>
<li data-papi-json="<?php echo $options->slug; ?>_<?php echo $layout['slug']; ?>_flexible_json"><?php echo $layout['title']; ?></li>
<?php endforeach; ?>
</ul>
@johnie
johnie / customize-api.php
Last active August 29, 2015 14:21
Custom Controller for latest posts
<?php
$wp_customize->add_control( new WP_Customize_Latest_Post_Control( $wp_customize, 'latest_post_control', array(
'label' => __( 'Select A Featured Post', 'mytheme' ),
'section' => 'header_section',
'settings' => 'featured_post',
'post_type' => 'page'
)));
@johnie
johnie / ajax-action.php
Last active September 5, 2015 12:00 — forked from danielpataki/ajax-action.php
Ajax in WordPress
<?php
add_action( 'wp_ajax_button_click', 'user_clicked' );
function user_clicked() {
update_user_meta( get_current_user_id(), 'clicked_link', 'yes' );
wp_redirect( $_SERVER['HTTP_REFERER'] );
exit();
}
<?php
/**
* Force enable a plugin.
*
* @param array $plugins
*
* @return array
*/
add_filter( 'option_active_plugins', function ( $plugins ) {
@johnie
johnie / last_business_day_of_month.js
Created June 1, 2016 22:27 — forked from arch1t3ct/last_business_day_of_month.js
Javascript (Node.js) function for getting last working/business day of the month.
/**
* Finds last working/business day of the month.
*
* Not tested for cross-browser compability. Works in Node.js though.
*
* EXAMPLES:
*
* 1. Returns last day of the last month of the current year:
*
* var result = lastBusinessDayOfMonth();
@johnie
johnie / curl.php
Created August 26, 2016 07:51
Make Curl call
<?php
/**
* Make Curl call.
*
* @param string $url URL to curl
* @param string $method GET or POST, Default GET
* @param mixed $data Data to post, Default false
* @param mixed $headers Additional headers, example: array ("Accept: application/json")
* @param bool $returnInfo Whether or not to retrieve curl_getinfo()
@johnie
johnie / uninstall_docker.sh
Created September 8, 2016 21:01
Uninstall Docker
#!/bin/bash
# Uninstall Script
if [ "${USER}" != "root" ]; then
echo "$0 must be run as root!"
exit 2
fi
while true; do