Skip to content

Instantly share code, notes, and snippets.

Jacob David C Cunningham jdc-cunningham

Block or report user

Report or block jdc-cunningham

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@jdc-cunningham
jdc-cunningham / calorie-counter-app-reactjs.js
Created Aug 2, 2019
ReactJS - Calorie Counter App Interface
View calorie-counter-app-reactjs.js
import React, { Component } from 'react';
import './../../misc/styles/layout.scss';
import './BasicInterface.scss';
import { isObject } from './../../misc/js/utilities.js';
import closeIcon from './../../misc/icons/close-icon__chocolate.svg';
class BasicInterface extends Component {
state = {
date: new Date(),
today: null,
@jdc-cunningham
jdc-cunningham / array-serialization-php.php
Created Sep 3, 2018
That one time I reverse engineered array-serialization
View array-serialization-php.php
<?php
// a:0:{}
// a:1:{i:0;i:5694;} // add 5694
// a:2:{i:0;i:5694;i:1;i:5934;} // add 5934
// a:3:{i:0;i:5694;i:1;i:5934;i:2;i:5608;} // add 5608
// a:2:{i:0;i:5694;i:2;i:5608;} remove 5934
// a:3:{i:0;i:5694;i:1;i:5608;i:2;i:5934;} readd 5934
$str = 'a:3:{i:0;i:5694;i:1;i:5934;i:2;i:5608;}';
View remove-scripts-from-string-php.php
<?php
// ps this does not work, use HTML Purifier
// I mean this works, but it's not guaranteed to fix the problem
// wth nested functions don't work as expected hmm
// probably time to learn OOP, look at that $GLOBAL, could not get the final output out of the function
// tried passing it in as parameter, regular global
// another note, to avoid case sensitivity use str_ireplace so you can match script, SCRIPT, ScRiPt, without
// worrying about exact str index position, or just don't do this entirely
@jdc-cunningham
jdc-cunningham / make-call.php
Created May 15, 2018
Make a call through Twilio using PHP and read XML file contents
View make-call.php
/*
The URL is an XML file telling Twilio's phone call "bot?" what to do
View an example here https://gist.github.com/jdc-cunningham/af131c042309d1ccd8acd5bcc626b0de
The code below is from Twilio's example
https://www.twilio.com/docs/voice/make-calls
*/
<?php
@jdc-cunningham
jdc-cunningham / msg.xml
Created May 15, 2018
Sample Twilio XML read by phone call
View msg.xml
<!-- this is based on Twilio's example https://demo.twilio.com/docs/voice.xml -->
<Response>
<Say voice="alice">
Your message
</Say>
</Response>
@jdc-cunningham
jdc-cunningham / encrypt-decrypt-php-defuse.php
Created Apr 16, 2018
encrypt decrypt example using php-defuse
View encrypt-decrypt-php-defuse.php
<?php
// error checking
ini_set('display_errors', 1);
// require php-defuse.phar
require_once('defuse-crypto.phar');
use Defuse\Crypto\Crypto;
use Defuse\Crypto\Key;
View memcache-retrieve-key.php
<?php
// memcache test
$server = 'localhost';
if (!empty($_REQUEST['server'])) {
$server = $_REQUEST['server'];
}
$memcache = new Memcache;
$isMemcacheAvailable = @$memcache->connect($server);
// check memcache
View memcache-set-key.php
<?php
// memcache test
$server = 'localhost';
if (!empty($_REQUEST['server'])) {
$server = $_REQUEST['server'];
}
$memcache = new Memcache;
$isMemcacheAvailable = @$memcache->connect($server);
// check memcache
View memcache-test.php
<?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 Apr 16, 2018
example pre-decrypt sql search with php-defuse
View example-decrypt-select.php
<?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) {
You can’t perform that action at this time.