Skip to content

Instantly share code, notes, and snippets.

@ecaron
ecaron / field.php
Last active March 11, 2020 21:20
Potential replacement for anti-space field.php
<?php
/**
* Renders the field in the visitor-facing form
*
* @package caldera-forms-anti-spam
*/
$recaptcha_version = ( ! empty( $field['config']['recapv'] ) && 1 === $field['config']['recapv'] ) ? 'v3' : 'v2';
// phpcs:disable
@ecaron
ecaron / sample.md
Created June 12, 2018 13:58
This is a sample MarkDown

The largest heading

This is an example. With some changes.

The second largest heading

Showing some things. Making it easy to know what changed.

The smallest heading and what didn't
'use strict';
if (!process.env.API_KEY) {
console.warn('API_KEY must be defined as an environment variable');
process.exit();
}
var bby = require('bestbuy')(process.env.API_KEY);
var async = require('async');
var _ = require('lodash');
@ecaron
ecaron / button.py
Created July 31, 2016 20:59
Python script for listening to Raspberry Pi button push
import requests
import time
import RPi.GPIO as GPIO
url = 'http://nightlight/' # I map this to my internal DNS hosting the node app
gpio_pin=18 # The GPIO pin the button is attached to
longpress_threshold=5 # If button is held this length of time, tells system to leave light on
GPIO.setmode(GPIO.BCM)
GPIO.setup(gpio_pin, GPIO.IN, pull_up_down=GPIO.PUD_UP)
// Code for V2
var sendgrid = require('sendgrid')(sendgrid_api_key);
sendgrid.send({
to: '[email protected]',
from: '[email protected]',
subject: 'Hello World',
text: 'My first email through SendGrid.'
}, function(err, json) {
if (err) { return console.error(err); }
console.log(json);
@ecaron
ecaron / productsActive.head
Created January 7, 2016 20:39
HEAD productsActive.json.tar.gz
HTTP/1.1 200 OK
Date: Thu, 31 Dec 2015 06:00:33 GMT
Expires: Thu, 31 Dec 2015 12:00:33 GMT
Last-Modified: Thu, 31 Dec 2015 05:00:33 GMT
Content-type: application/x-gzip
Content-Length: 3148141412
[
{"name":"productsActive",
"description":"All our products except something and something",
"frequency":"daily",
"xmlPath":" https://api.bestbuy.com/bulk/v2/products/productsActive.xml.tar.gz",
"jsonPath":" https://api.bestbuy.com/bulk/v2/products/productsActive.json.tar.gz"
},
{"name":"productsActiveDigital",
"description":"All current digital downloads",
"frequency":"daily",
@ecaron
ecaron / cssh-ec2-connector.sh
Last active August 29, 2015 14:15
Dynamic shell script to use cssh to connect to multiple EC2 boxes by tag-name, via AWS CLI
#!/bin/bash
# Requirements:
# * AWS CLI installed and activated
# * cssh installed
#
# Usage:
# * Run "cssh-ec2-connector.sh some-tag-name" to have system open windows to all instances
# * Edit the ec2Tags array to have a list of frequently used instances for repeat use
require "optparse"
require "uri"
require "net/http"
###
# This script is taken from http://samsaffron.com/archive/2013/11/13/live-restarts-of-a-supervised-unicorn-process
# It has been modified from the original to:
# 1) Have more intelligent validation of the URL
# 2) Support HTTPS requests
# 3) Colorized output based on type of request
@ecaron
ecaron / 0_reuse_code.js
Last active August 29, 2015 14:06
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console