Skip to content

Instantly share code, notes, and snippets.

View Ultimater's full-sized avatar

Kevin Yarmak Ultimater

View GitHub Profile
@Ultimater
Ultimater / discord.coffee.js
Created September 8, 2017 20:14
Hubot's discord.coffee file served as vanilla 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');
@Ultimater
Ultimater / micro-router.php
Created September 15, 2017 21:10
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 / .htrouter.php
Created October 10, 2017 00:44
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.
<?php
namespace _htrouter_php;
class htRouter
{
static public $uri = '', $ext = '', $fullFilePath = '';
static public $mimeTypes = [
'css'=>'text/css',
'js'=>'application/javascript',
@Ultimater
Ultimater / phalcon-php-snippet
Created June 15, 2018 02:50
Phalcon trying cookie service anywhere
$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 / bug.php
Created June 15, 2018 07:01
Phalcon bug. Run as http://localhost/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 / test-it.php
Created August 2, 2018 04:07
Response to "Store function expression to a variable in PHP inside a class" stackoverflow question
<?php
class Demo
{
static public $var;
public $a;
public function __construct()
{
$this->a = function()
{