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
@jdc-cunningham
jdc-cunningham / bl-monocle-ar-gists.py
Last active March 9, 2023 22:02
Brilliant Labs Monocle AR - different scenes
import time
import device
import display
def draw_welcome(placeholder_arg):
display.text("Welcome, <name>", 150, 175, 0xffffff)
def weather_report(placeholder):
display.text("Weather in <Location>", 100, 125, 0xffffff)
display.text("43F Cloudy", 100, 175, 0xffffff)
@jdc-cunningham
jdc-cunningham / sample.json
Last active October 8, 2022 17:36
Sample app interaction JSON pattern
{
"url": "",
"auth_interactions": [
{
"type": "input",
"name": "email",
"dom_target": "input[type=email]",
"value_lookup": "random-string-for-env"
},
{
const processBuySells = (activePortfolio, fills) => {
const btcBuys = [];
const btcSells = [];
// transfers, this is a special case
if (parseInt(activePortfolio) === 1) {
const transferredArr = JSON.parse(process.env.TRANSFERRED_BTC_ARR);
transferredArr.forEach(transfer => {
btcBuys.push({
size: parseFloat(transfer.size),
@jdc-cunningham
jdc-cunningham / calorie-counter-app-reactjs.js
Created August 2, 2019 01:04
ReactJS - Calorie Counter App Interface
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 September 3, 2018 20:52
That one time I reverse engineered array-serialization
<?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;}';
<?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 05:50
Make a call through Twilio using PHP and read XML file contents
/*
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 05:47
Sample Twilio XML read by phone call
<!-- 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 April 16, 2018 23:26
encrypt decrypt example using php-defuse
<?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;
@jdc-cunningham
jdc-cunningham / memcache-retrieve-key.php
Created April 16, 2018 23:11
retrieve key from memcache
<?php
// memcache test
$server = 'localhost';
if (!empty($_REQUEST['server'])) {
$server = $_REQUEST['server'];
}
$memcache = new Memcache;
$isMemcacheAvailable = @$memcache->connect($server);
// check memcache