Skip to content

Instantly share code, notes, and snippets.

Avatar

Tim Lytle tjlytle

View GitHub Profile
View benford.php
<?php
$limit = 1000000;
$counts = [
'1' => 0,
'2' => 0,
'3' => 0,
'4' => 0,
'5' => 0,
'6' => 0,
'7' => 0,
View index.html
<html>
<head/>
<body>
<a target="_blank" href='chrome-extension://maldgfaihandkckmgabpbkgnjbafnbog/settings.html'>Configure Extension</a>
</body>
</html>
View library-responder.php
<?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');
}
View simple-responder.php
<?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)
View api-design-longhorn.md

Hands On API Design

http://bit.ly/longhorn-api (this gist)

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 Mar 13, 2017
Routing /api in nginx
View example.conf
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;
}
View edit.js
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]);
View README.md

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:

View ClientFactory.php
<?php
use Zend\ServiceManager\AbstractFactoryInterface;
use Zend\ServiceManager\ServiceLocatorInterface;
class ClientFactory implements AbstractFactoryInterface
{
protected $services = [
'Nexmo\Sms',
'Nexmo\Voice',
'Nexmo\Developer',
View gist:2f1bc52bc09556e764fe
<vxml version = "2.1" >
<form>
<field name="department">
<prompt>Please say sale or support. </prompt>
<grammar mode="voice" root="top">
<rule id="top">
<one-of>
<item>sales</item>
<item>support</item>
</one-of>