Skip to content

Instantly share code, notes, and snippets.

@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 */
@adamwathan
adamwathan / v-cloak.md
Last active February 26, 2023 14:26
Useful CSS utilities for Vue.js cloaking

Handy helpers for controlling visibility of elements until Vue has compiled.

Use like:

<div v-cloak>
  <h1>
    <span class="v-cloak--inline">Loading...</span> <!-- Only displayed before compiling -->
    <span class="v-cloak--hidden">{{ post.title }}</span> <!-- Hidden until compiling is finished -->
 
@muhittin
muhittin / credit_card_type.php
Created February 12, 2013 15:03
MasterCard: Must have a prefix of 51 to 55, and must be 16 digits in length. Visa: Must have a prefix of 4, and must be either 13 or 16 digits in length. American Express: Must have a prefix of 34 or 37, and must be 15 digits in length. Diners Club: Must have a prefix of 300 to 305, 36, or 38, and must be 14 digits in length. Discover: Must have…
function credit_card_type($ccNum)
{
if (ereg("^5[1-5][0-9]{14}$", $ccNum))
return "Mastercard";
if (ereg("^4[0-9]{12}([0-9]{3})?$", $ccNum))
return "Visa";
if (ereg("^3[47][0-9]{13}$", $ccNum))
return "American Express";
@JeffreyWay
JeffreyWay / laravel4.md
Created November 19, 2012 16:37
Laravel 4 Thoughts/Questions/Etc.

Laravel 4 Thoughts/Questions/Etc.

This is just a random list of notes, as I dig into Laravel 4. If you have any feedback/solutions, please leave a comment. I'll be compiling everything for an article on Nettuts+, when the framework is officially in Beta. This will be updated over the course of the week.

  • Running composer dump-autoload after every new controller is a pain. Can this not be automated through artisan controller:make ControllerName?

  • Seems that some of the View HTML helpers are missing. No HTML::script().

  • Route::resource('tasks', 'TasksController') doesn't seem to create named routes. This is a big deal, if not. What's the solution?

@muhittin
muhittin / strip_tags.js
Created August 15, 2012 09:29
strip_tags for Javascript
var text = '<div class="foo">bar</div>';
text.replace(/(<([^>]+)>)/ig,""); // Returns: bar