Skip to content

Instantly share code, notes, and snippets.

Angel S. Moreno angelxmoreno

Block or report user

Report or block angelxmoreno

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View linked-entities-composer.json
{
"name": "angelxmoreno/cakephp-linked-entities",
"description": "LinkedEntities plugin for CakePHP 3.x",
"homepage": "https://github.com/angelxmoreno/cakephp-linked-entities",
"support": {
"issues": "https://github.com/angelxmoreno/cakephp-linked-entities/issues"
},
"type": "cakephp-plugin",
@angelxmoreno
angelxmoreno / phpunit.xml.dist
Created Aug 31, 2018
LinkedEntities phpunit.xml.dist
View phpunit.xml.dist
<?xml version="1.0" encoding="UTF-8"?>
<phpunit
colors="true"
verbose="true"
processIsolation="false"
stopOnFailure="false"
syntaxCheck="false"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
@angelxmoreno
angelxmoreno / AfterSaveOrDeleteBehavior.php
Created Aug 23, 2018
CakePHP 3 Behavior to adds a Model\Table callback triggered after a save or after a delete
View AfterSaveOrDeleteBehavior.php
<?php
namespace FiveTalents\Model\Behavior;
use Cake\Datasource\EntityInterface;
use Cake\Event\Event;
use Cake\ORM\Behavior;
/**
* AfterSaveOrDelete behavior
@angelxmoreno
angelxmoreno / serverless-php.md
Last active Aug 14, 2018
Example of running PHP code on AWS Lambda
View serverless-php.md
View function.php
<?php
class Helper {
public function render(array $payment_methods, $error_saving_plans = false, $boleto_tab_checked = false)
{
$html = '';
foreach (self::TAB_NAMES as $tab_name) {
$payment_enabled = $this->isPaymentEnabled($tab_name, $payment_methods);
$tab_disabled = $this->isTabDisabled($tab_name, $error_saving_plans);
$checked = $this->shouldBeChecked($tab_name, $payment_enabled, $tab_disabled, $boleto_tab_checked);
@angelxmoreno
angelxmoreno / HomeController.php
Created Apr 18, 2017
Sample Slim Framework Controller
View HomeController.php
<?php
namespace App\Controllers;
use Psr\Http\Message\ServerRequestInterface as Request;
use Psr\Http\Message\ResponseInterface as Response;
use Interop\Container\ContainerInterface as Container;
class HomeController
{
/**
View cache.php
<?php
public function longDbCall()
{
$cache_key = $this->cache->generateKey('longDbCall');
return $this->cache->remember($cache_key, function () {
return $this->__longDbCall();
});
}
View index.php
<?php
use Phalcon\Mvc\Application as PhalconApplication;
use Phalcon\Config as PhalconConfig;
error_reporting(E_ALL);
define('DS', DIRECTORY_SEPARATOR);
define('WEBROOT_PATH', __DIR__ . DS);
define('ROOT_PATH', dirname(WEBROOT_PATH) . DS);
define('APP_PATH', ROOT_PATH . 'app' . DS);
View tic tac toe
require 'tic_tac_toe_cn'
game = Tic_Tac_Toe.new
board = Array.new(3) {Array.new(3)}
game.initBoard(board)
puts "Starting Tic Tac Toe"
puts "Player 1 choose X or O"
playerOne = gets.chomp.upcase
if playerOne == "X"
playerTwo = "O"
View gist:dd779ecc060463242739f7c35eb91a63
By adding this gem to our project we will be able to use methods of the Tic_Tac_Toe class (these methods are listed below)
.new - makes a new Tic Tac Toe object
.initBoard(board) - makes a cell block from the dimensions of board object
.winningRows(board) - checks the board object to see if a row contains 3 of the same symbol
.winningCols(board) - checks the board object to see if a col contains 3 of the same symbol
.winningDiagonals(board) - checks the board object to see if a diagonal contains 3 of the same symbol
.displayBoard(board) - displays board object in the terminal
.fullBoard(board) - checks to see if the board object is full
.turnPlayed(board,player,player_choice) - checks to see if a valid move was played by checking the board object, player symbol and location that the player picked
You can’t perform that action at this time.