Skip to content

Instantly share code, notes, and snippets.

View tjlytle's full-sized avatar

Tim Lytle tjlytle

View GitHub Profile
@tjlytle
tjlytle / imageColor.php
Created November 17, 2009 19:19
Class to find 'average' image color.
<?php
/**
* imageColor
*
* Shows three methods to find the 'average' image color.
*
* Each function expects a gd image object.
*
* imageColor::averageResize($image) resizing to 1px, and checking the color.
* imageColor::averageBorder($image) find the average color of all border pixels.
@tjlytle
tjlytle / voicemail.php
Created February 27, 2011 00:21
Sample script to go directly to voicemail.
<?php
require_once 'client.php'; //setup the Twilio rest client and assorted vars
$number = '1235556789'; //the number you're calling
$data = array('From' => $callerID,
'To' => $number,
'Url' => "http://twimlets.com/message?Message%5B0%5D=Voicemail&");
//place both calls
$call1 = $client->request("$version/Accounts/$accountSid/Calls", 'POST', $data);
<?php
$limit = 1000000;
$counts = [
'1' => 0,
'2' => 0,
'3' => 0,
'4' => 0,
'5' => 0,
'6' => 0,
'7' => 0,
<html>
<head/>
<body>
<a target="_blank" href='chrome-extension://maldgfaihandkckmgabpbkgnjbafnbog/settings.html'>Configure Extension</a>
</body>
</html>
<?php
require_once __DIR__ . '/vendor/autoload.php';
$client = new \Nexmo\Client(new \Nexmo\Client\Credentials\Basic(NEXMO_KEY, NEXMO_SECRET));
try {
$inbound = \Nexmo\Message\InboundMessage::createFromGlobals();
} catch (Exception $e) {
error_log('could not parse inbound message');
}
<?php
if (!isset($_POST['msisdn'], $_POST['to'], $_POST['text'])) {
return; // not a nexmo request
}
if ("yes" === strtolower(substr($_POST['text'], 0, 3))) {
// here's where you need to do something to store the inbound phone number
error_log('got message from: ' . $_POST['msisdn']);
// reply with the message (this is a bit hacky, but should work anywhere)

Hands On API Design

Tutorial Requirements

Don't stress over this. Even if you come without a laptop, you should be able to learn from the tutorial.

  • A laptop with an internet connection, pen, and paper will be all that’s needed to activly participate in most of the tutorial.
  • If you want to follow along during the coding, any modern(5.3+) PHP development environment will work.
@tjlytle
tjlytle / example.conf
Created March 13, 2017 16:30
Routing /api in nginx
location /api/ {
alias /;
fastcgi_pass api:9000;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME /path/to/public/index.php;
fastcgi_param REQUEST_URI $request_filename;
}
if(!process.argv[2]){
console.log('must pass a spec to edit');
process.exit();
}
require("swagger-editor/package.json"); // swagger-editor is a peer dependency.
var editor = require("swagger-editor-server");
editor.edit(process.argv[2], process.argv[3]);
@tjlytle
tjlytle / README.md
Last active September 30, 2016 01:24

LaraconUS 'Advice' Demo

If you want to troll your friends with this, here you go. Caution, if [used in a live demo][1], [may][2] [have][3] [unexpected][4] [results][5].

Super Importaint Note: The get() method used here is basically a prototype, so it certianly may change. /warning

App Setup

Add this to composer.json, to bring in both the Nexmo client and Laravel package as their currently in beta: