Skip to content

Instantly share code, notes, and snippets.

View jdc-cunningham's full-sized avatar

Jacob David C Cunningham jdc-cunningham

View GitHub Profile
<?php
// memcache test
$server = 'localhost';
if (!empty($_REQUEST['server'])) {
$server = $_REQUEST['server'];
}
$memcache = new Memcache;
$isMemcacheAvailable = @$memcache->connect($server);
// check memcache
@jdc-cunningham
jdc-cunningham / memcache-test.php
Created April 16, 2018 23:04
example memcache test
<?php
// memcache test
$server = 'localhost';
if (!empty($_REQUEST['server'])) {
$server = $_REQUEST['server'];
}
$memcache = new Memcache;
$isMemcacheAvailable = @$memcache->connect($server);
@jdc-cunningham
jdc-cunningham / example-decrypt-select.php
Last active April 16, 2018 21:40
example pre-decrypt sql search with php-defuse
<?php
$fruit_names = [];
$stmt = $dbh->prepare('SELECT id, fruit_name FROM fruits');
if ($stmt->execute()) {
$result = $stmt->fetchAll();
$result_count = count($result);
if ($result_count > 0) {
foreach($result as $row) {
@jdc-cunningham
jdc-cunningham / sample.sql
Created April 16, 2018 21:24
example-sql
SELECT fruit_name FROM fruits WHERE fruit_name = :fruit_name
@jdc-cunningham
jdc-cunningham / grab-solar-data-send.py
Last active March 9, 2018 11:20
Example analog data grab from a solar panel with Adafruit's library on the MCP3008 with a POST request to a posttestserver endpoint
# this code is based on the Adafruit MCP3008 library being installed and the ADC being properly wired to your Raspberry Pi
# and source of analog data
# for math division
from __future__ import division
# Import SPI library (for hardware SPI) and MCP3008 library.
import Adafruit_GPIO.SPI as SPI
import Adafruit_MCP3008
@jdc-cunningham
jdc-cunningham / split-date-time.php
Last active January 24, 2023 08:31
PHP date time to date, time split function with period
<?php
// made this way so it only has to be called once
// did a dumb thing using a date/time storage with separate date time fields in MySQL with hourly period in the time part
// harder to sort natively with MySQL
function split_date_time($cur_date_time) {
// split date_time components
$date_time_split = explode(' ', $cur_date_time);
// return array
@jdc-cunningham
jdc-cunningham / flex-set.css
Last active May 24, 2018 21:10
flex set for basic layout
.flex {
display: flex;
}
/* alignment */
/* top */
.flt {
justify-content: flex-start; /* x-axis */
align-items: flex-start; /* y-axis */
}
.fct {
@jdc-cunningham
jdc-cunningham / gist:bfef0e3824c2bc132ebc2032e0c1437e
Created October 4, 2017 12:53
PHP Slack Webhook Function Using CURL
function sendWebhook($message) {
$webhook_url = "";
// slack webhook test
$data = "payload=" . json_encode(array(
"text" => $message
));
$ch = curl_init($webhook_url);