Skip to content

Instantly share code, notes, and snippets.

View TheRealJAG's full-sized avatar
🎯
Focusing

Jorge A. Gonzalez TheRealJAG

🎯
Focusing
View GitHub Profile
<?php
/**
* Get additional products from a brand in associated categories
* @param $brand_id
* @param $product_id
* @param $category_ids
* @return $collection
*/
public function getMoreFromBrand($brand_id, $product_id, $category_ids=0, $platform='desktop') {
@TheRealJAG
TheRealJAG / alex
Last active December 9, 2016 20:57
// This gives us the opportunity to specify things like extra header
// information and page title and all that
$extra_head = 'heads'.$slash.$subdir.basename($safepage);
$js = 'js/'.$subdir.basename($safepage, '.php').'.js';
$css = 'css/'.$subdir.basename($safepage, '.php').'.css';
/*
* If we cannot find an individual controller files, search for controller files
* that will blanket the entire directory. Failing upwards.
@TheRealJAG
TheRealJAG / rpn.php
Last active October 11, 2018 05:53
'Reverse Polish Notation' calculator in PHP
<?php
/**
* Class RPN
* Challenge: Create a 'Reverse Polish Notation' calculator in PHP
* @author Jorge A. Gonzalez <adnasium@gmail.com>
* @copyright 2016
*/
class RPN
@TheRealJAG
TheRealJAG / path.php
Last active September 23, 2019 02:06
Write a function that provides change directory (cd) function for an abstract file system.
<?php
class Path {
public $currentPath;
function __construct($path) {
$this->currentPath = $path;
}
public function cd($newPath) {
-- Adminer 4.1.0 MySQL dump
SET NAMES utf8;
SET time_zone = '+00:00';
SET foreign_key_checks = 0;
SET sql_mode = 'NO_AUTO_VALUE_ON_ZERO';
DROP TABLE IF EXISTS `emp`;
CREATE TABLE `emp` (
`id` int(11) NOT NULL AUTO_INCREMENT,
@TheRealJAG
TheRealJAG / appendChildren.html
Last active May 17, 2016 17:39
Append child divs to each parent
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Widgets</title>
<script src="https://code.jquery.com/jquery-1.11.0.js"></script>
<script type="text/javascript">
<!--
$(document).ready(function() {
<?php
class AreAnagrams
{
public static function areStringsAnagrams($a, $b)
{
return(count_chars($a, 1) == count_chars($b, 1));
}
}
// For testing purposes (do not submit uncommented):
<script src="https://code.jquery.com/jquery-1.11.0.js"></script>
<script type="text/javascript">
<!--
$(document).ready(function() {
registerHandlers();
function registerHandlers() {
$('a').click(function(){
<script src="https://code.jquery.com/jquery-1.11.0.js"></script>
<script type="text/javascript">
<!--
$(document).ready(function() {
//To gain acccess to DOM, place the function inside $(document).ready
registerClickHandler();
function registerClickHandler() {
@TheRealJAG
TheRealJAG / longestrun.php
Last active May 17, 2016 17:40
Longest Run
<?php
class Run
{
public static function indexOfLongestRun($str)
{
$strlen = strlen( $str );
$strlen=$strlen-1;
$maxIndex = 0;