Skip to content

Instantly share code, notes, and snippets.

View mpociot's full-sized avatar

Marcel Pociot mpociot

View GitHub Profile
"#title" : {
color: 'black',
font: { fontFamily:'Arial', fontSize: '20dp', fontWeight:'bold' },
left: '0', top: 0,
width: Titanium.UI.FILL,
textAlign: "center",
},
"#subtitle" : {
color: 'gray',
font: { fontFamily:'Arial', fontSize: '14dp' },
@mpociot
mpociot / moment.js
Last active August 29, 2015 14:14
Localize moment.js for use in Appcelerator Titanium
var moment = require("alloy/moment");
function processRelativeTime(number, withoutSuffix, key, isFuture) {
var format = {
'm': ['eine Minute', 'einer Minute'],
'h': ['eine Stunde', 'einer Stunde'],
'd': ['ein Tag', 'einem Tag'],
'dd': [number + ' Tage', number + ' Tagen'],
'M': ['ein Monat', 'einem Monat'],
'MM': [number + ' Monate', number + ' Monaten'],
@mpociot
mpociot / MyModule.js
Last active August 29, 2015 14:15
CommonJS Module
var localVariable;
exports.init = function( foo )
{
Ti.API.info( "I do stuff" );
localVariable = foo;
};
exports.helloWorld = function()
{
@mpociot
mpociot / cert.php
Created April 13, 2015 08:11
Get expiration date from provisioning profile certificate data
// https://packagist.org/packages/phpseclib/phpseclib
// composer require "phpseclib/phpseclib": "0.3.10"
$certData = base64_decode( OBTAINED_CERTIFICATE_BASE64_STRING_FROM_PLIST );
$issuer = new File_X509();
$cert = $issuer->loadX509( $certData );
$exirationDate = $cert['tbsCertificate']['validity']['notAfter']['utcTime'];
@mpociot
mpociot / HasCompositeKey.php
Created May 17, 2016 13:32
Trait for Laravel 5 models that have composite keys.
<?php
namespace App\Traits;
use Exception;
use Illuminate\Database\Eloquent\Builder;
/**
* Use this trait if your model has a composite primary key.
* The primary key should then be an array with all applicable columns.
<?php
namespace Mpociot\SlackBot;
class PizzaConversation extends Conversation
{
protected $size;
protected $topping;
public function askSize()
{
@mpociot
mpociot / Authorization.php
Last active June 22, 2018 18:42
Simple BotMan middleware to limit the bot, so that it only responds to certain allowed users.
<?php
namespace Mpociot\BotMan\Middleware;
use Mpociot\BotMan\Message;
use Mpociot\BotMan\Interfaces\MiddlewareInterface;
class Authorization implements MiddlewareInterface
{
/** @var array */
@mpociot
mpociot / TelegramInlineQueryDriver.php
Created January 2, 2017 23:29
BotMan messaging driver that adds support for Telegram inline queries.
<?php
namespace Mpociot\BotMan\Drivers;
use Mpociot\BotMan\Answer;
use Mpociot\BotMan\Message;
use Mpociot\BotMan\Question;
use Illuminate\Support\Collection;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;

Have you tried to write a Chatbot for messaging platforms like Facebook or Slack? It is quite cumbersome as each messaging platform has its own way of communicating with your application. Let us find out how to simplify this task and create an intelligent multi-platform Chatbot using PHP and BotMan.

@mpociot
mpociot / AlexaDriver.php
Created May 11, 2017 19:52
This is an Amazon Alexa driver to work in combination with the BotMan chatbot library.
<?php
namespace App;
use Alexa\Response\Response as AlexaResponse;
use Illuminate\Support\Collection;
use Mpociot\BotMan\Answer;
use Mpociot\BotMan\Drivers\Driver;
use Mpociot\BotMan\Interfaces\UserInterface;
use Mpociot\BotMan\Message;