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
// 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);
<?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
*/
<?xml version='1.0' encoding='UTF-8'?>
<ResponseDetails>
<Result>Fail</Result>
<ErrorSeverity>Error</ErrorSeverity>
<ErrorDetails></ErrorDetails>
</ResponseDetails>
@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. */
@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 / 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 / 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 / import.sh
Created March 6, 2014 21:17
Bash script example for data import
#!/bin/bash
WORKDIR="$( cd "$( dirname "$0" )" && pwd )"
DB_USER="user"
DB_PASSWORD="pasword"
DB_NAME="database_name"
FILE_PROC="$WORKDIR/processing"
FILE_COMP="$WORKDIR/completed"
if [ -e $FILE_PROC ]
then
<?php
public function insertacomenta($idtema_foro = NULL) {
if (is_null($idtema_foro)) {
// podes mostrar una página de error
show_error('ID Tema no disponible');
// o podes hacer un redirect
$this->session->set_flashdata('error', 'ID Tema no disponible');
redirect('foros');
}
<?php
function aumentacoment($idtema_foro) {
$this->db->set('comentarios', 'comentarios + 1', FALSE);
$this->db->where('idtema_foro', $idtema_foro);
return $this->db->update('tema_foros', $data);
}