Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View everdaniel's full-sized avatar
🏠
Working from home

Ever Daniel Barreto everdaniel

🏠
Working from home
View GitHub Profile
@everdaniel
everdaniel / gist:8967762
Created February 13, 2014 01:01
template.html
{{ streams:cycle stream="sliders" }}
{{ entries }}
{{ if page:slug == stream_field:slug }}
Text goes here if same id's
{{ endif }}
{{/entries}}
{{ /streams:cycle }}
@everdaniel
everdaniel / jsonapi.md
Created December 10, 2013 03:03 — forked from wycats/jsonapi.md

JSON API

There are two JSON API styles:

  • The ID Style
  • The URL Style

The ID style is the easiest to get started with, but requires that your clients be able to guess the URLs for related documents. It also locks your API into a particular URL structure, which may become a problem as your API grows.

The URL style requires less guessing on the client side, and makes clients more resilient to API changes, but is trickier to use with relationships and compound documents.

@everdaniel
everdaniel / json.html
Created October 27, 2013 19:53
Return Low Search results as JSON
{
{exp:low_search:results query="{segment_3}" limit="10"}
{if count == 1}
"search_keywords": "{low_search_keywords}",
"total_results": {total_results},
{/if}
{if count == 1}
"results": [
{/if}
{
@everdaniel
everdaniel / wp_caption.php
Created October 23, 2013 22:30
WordPress Image Caption Filter
<?php
add_filter( 'img_caption_shortcode', 'cleaner_caption', 10, 3 );
function cleaner_caption( $output, $attr, $content ) {
$output2 = null;
$output3 = null;
$pattern = 'http://';
/* We're not worried abut captions in feeds, so just return the output here. */
<?xml version='1.0' encoding='UTF-8'?>
<ResponseDetails>
<Result>Fail</Result>
<ErrorSeverity>Error</ErrorSeverity>
<ErrorDetails></ErrorDetails>
</ResponseDetails>
<?php
/*
Plugin Name: Posts 2 Posts List Widget
Plugin URI: http://friendlywebconsulting.com/
Description: Creates a widget to display posts connected via the Posts 2 Posts plugin by Scribu, found here: http://wordpress.org/extend/plugins/posts-to-posts/
Author: Michelle McGinnis
Author URI: http://friendlywebconsulting.com/
Version: 1.0.0-alpha
*/
// do the comparison between baseline and current dataset here
foreach(array('high_rva', 'mid_rva', 'low_rva') as $type) {
$si = 1;
for($i = 0; $i < count($this->baseline_dataset[$type]); $i++) {
// calculate Hydrologic Alteration Factor
$observed_frequency = $this->comparison_dataset[$type][$i];
$expected_frequency = $this->baseline_dataset[$type][$i] * ($this->years_post / $this->years_pre);
Array
(
[0] => Array
(
[high_rva] => Array
(
[0] => stdClass Object
(
[22] => 0.41666666666667
)
Array
(
[0] => Array
(
[high_rva] => Array
(
[0] => stdClass Object
(
[demand_id] => 22
[si] => 0.41666666666667
Script baseLineData execution took 0.32932496070862 seconds <br />Array
(
[1] => Array
(
[6] => Array
(
[213] => 19
[183] => 22
[184] => 22
[185] => 21