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 / 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 / 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
<?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 / 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;}';
@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,
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 / 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"
},
{
@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 / flappy-bird.py
Created March 10, 2023 00:28
Flappy Bird for Monocle AR
import time
import touch
import display
bird_up = True # EricAndre
col_pos_x = 600
bird_pos_y = 280
game_over = False
def move_up(arg):
import display
display.hline(230, 110, 10, 0xFD0003)
display.hline(240, 110, 10, 0xFD0003)
display.hline(250, 110, 10, 0xFD0003)
display.hline(260, 110, 10, 0xFD0003)
display.hline(270, 110, 10, 0xFD0003)
display.hline(280, 110, 10, 0xFD0003)
display.hline(220, 120, 10, 0xFD0003)
display.hline(230, 120, 10, 0xFD0003)
display.hline(240, 120, 10, 0xFD0003)