Skip to content

Instantly share code, notes, and snippets.

View jchamb's full-sized avatar

Jake Chamberlain jchamb

View GitHub Profile
@jchamb
jchamb / dd-trace-wrap.js
Created February 18, 2021 12:39
Wrap feathers service methods with DD traces
const ddTrace = require('dd-trace');
module.exports = function (app) {
if (process.env.LOCAL) return;
const tracer = ddTrace.init({
tags: ['app:fx-' + process.env.NODE_ENV],
env: process.env.NODE_ENV,
logInjection: true
});
@jchamb
jchamb / requestData.php
Created September 1, 2017 16:46
ZF2 convert all request data to an array from a controller
function getRequestData()
{
if( empty($this->request) )
$this->request = $this->getRequest();
$post = $this->request->getPost()->toArray();
$get = $this->request->getQuery()->toArray();
$headers = $this->request->getHeaders()->toArray();
$body = $this->request->getContent() !== ''
? json_decode($this->request->getContent(), true)
@jchamb
jchamb / fx-layouts.php
Created November 18, 2015 00:31
Wordpress template layouts
<?php
function fx_layout_content()
{
load_template( FX_Layouts::$main_template );
}
function fx_layout_base()
{
return FX_Layouts::$base;
@jchamb
jchamb / gist:933dc7572e9e87aad450
Created April 15, 2015 15:58
Fix for CF7 add_uploaded_file
public function add_uploaded_file( $name, $file_path ) {
$mail = $this->contact_form->prop('mail');
$this->uploaded_files[$name] = $file_path;
if ( empty( $this->posted_data[$name] ) ) {
$this->posted_data[$name] = basename( $file_path );
$mail['attachments'] .= "[$name]\n";
$this->form->set_properties( array('mail' => $mail) );
}
@jchamb
jchamb / gist:fdf7d12b0191cb852056
Last active July 25, 2023 16:59
Woocommerce Free Downloads without checkout
function direct_free_downloads_button($button)
{
global $product;
if( $product->is_downloadable() AND $product->get_price() == 0 )
{
$files = $product->get_files();
$files = array_keys($files);
$download_url = home_url('?download_file='.$product->id.'&key='.$files[0].'&free=1' );