Skip to content

Instantly share code, notes, and snippets.

Avatar

Kevin Yarmak Ultimater

View GitHub Profile
@Ultimater
Ultimater / test-it.php
Created Aug 2, 2018
Response to "Store function expression to a variable in PHP inside a class" stackoverflow question
View test-it.php
<?php
class Demo
{
static public $var;
public $a;
public function __construct()
{
$this->a = function()
{
@Ultimater
Ultimater / bug.php
Created Jun 15, 2018
Phalcon bug. Run as http://localhost/bug.php
View bug.php
<?php
if( isset($_GET) && isset($_GET['test']) && $_GET['test'] === 'phalcon')
{
$di = new \Phalcon\Di\FactoryDefault();
usleep( 100000 );
exit;
}
$ch1 = curl_init();
@Ultimater
Ultimater / phalcon-php-snippet
Created Jun 15, 2018
Phalcon trying cookie service anywhere
View phalcon-php-snippet
$di = \Phalcon\Di::getDefault();
echo "<pre><p><hr></p>";
if( isset($di) )
{
echo '<strong>di</strong>: <strong style="color:lime">Found</strong>';
} else {
echo '<strong>di</strong>: <strong style="color:red">Not Found</strong>';
}
@Ultimater
Ultimater / .htrouter.php
Created Oct 10, 2017
Central file for serving assets through the PHP built-in server, emulating mod_rewrite, redirects, proper headers, and other stuff you'd expect from apache or nginx like caching etc.
View .htrouter.php
<?php
namespace _htrouter_php;
class htRouter
{
static public $uri = '', $ext = '', $fullFilePath = '';
static public $mimeTypes = [
'css'=>'text/css',
'js'=>'application/javascript',
View micro-router.php
class MicroCollectionHandler
{
public $collection,$handlerIndex;
public function __construct($collection,$handlerIndex)
{
$this->collection = $collection;
$this->handlerIndex = $handlerIndex;
}
public function via($methods)
@Ultimater
Ultimater / discord.coffee.js
Created Sep 8, 2017
Hubot's discord.coffee file served as vanilla JS
View discord.coffee.js
var Adapter, Discord, DiscordBot, EnterMessage, LeaveMessage, Robot, TextChannel, TextMessage, TopicMessage, User, currentlyPlaying, prequire, ref, ref1,
bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; },
extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
hasProp = {}.hasOwnProperty,
slice = [].slice;
try {
ref = require('hubot'), Robot = ref.Robot, Adapter = ref.Adapter, EnterMessage = ref.EnterMessage, LeaveMessage = ref.LeaveMessage, TopicMessage = ref.TopicMessage, TextMessage = ref.TextMessage, User = ref.User;
} catch (_error) {
prequire = require('parent-require');