Skip to content

Instantly share code, notes, and snippets.

View makoru-hikage's full-sized avatar
🐮
Perhaps

Kurt Ma. Coll makoru-hikage

🐮
Perhaps
View GitHub Profile
@makoru-hikage
makoru-hikage / DetermineFirstPart.sql
Last active March 2, 2017 10:21
A query that determines the 1st part (regardless of division type) of an academic year by means of starting and ending date.
SET @yds = 2016;
SET @yde = 2016;
SET @type = 'Semester';
SELECT
*
FROM
school_calendar
WHERE
part_number = 1
@makoru-hikage
makoru-hikage / CourseEnrollmentEligibility.php
Last active March 8, 2017 07:51
Checks if a student is eligible to take a course.
<?php
/**
* CourseEnrollmentEligibility
*/
class CourseEnrollmentEligibility extends ModelService {
/**
@makoru-hikage
makoru-hikage / MenuService.php
Created March 16, 2017 00:02
Still needs to be improved...
<?php
namespace DeltaX\Crud\MenuService;
use DeltaX\ContentAccess\ContentAccessInterface;
/**
* MenuService
*/
@makoru-hikage
makoru-hikage / StudentChecklist.php
Created April 9, 2017 21:10
Just some random gist, a demonstration of "return $this" pattern
<?php
namespace DeltaX\Aegis\ModelServices\GradesRegistry;
use DeltaX\Aegis\MenuServices\Checklist;
use Carbon\Carbon;
use DeltaX\Utilities as U;
class StudentChecklist extends Checklist {
@makoru-hikage
makoru-hikage / continueBreak.php
Last active June 20, 2017 12:11
Shows the use of continue 2 and the problem with switch inside a loop.
<?php
public function setSort(array $items){
$columnOrders = [];
foreach ($items as $item) {
$itemStartsWithAlpha = preg_match('/^\W[A-Za-z]*/', $item);
if (! $itemStartsWithAlpha) {
<?php
/**
* Accept an array of instances of
* MenuService. Each will process their
* input data then return their output
* data so the next instance can use
* the output data as their input data.
* When there is no instance left in
* the array, the last one shall be returned
@makoru-hikage
makoru-hikage / MenuService.php
Created August 7, 2017 07:11
The MenuService technique...
<?php
namespace DeltaX\Crud\MenuService;
/**
* Use to process input from Query Strings
* or HTTP Request bodies. Process Data determines
* if it'll a last step.
*
*/
@makoru-hikage
makoru-hikage / someRandomSnippet.php
Created August 25, 2017 00:55
What can you infer? This is a function that fetches a certain student record. It's validated and authenticated.
<?php
public function getChecklist($request, $response, $urlParams){
$input = $request->getQueryParams();
$input['student_number'] = $urlParams['student_number'];
$output = (new MultipleReadModule ($input))
->setRepository(new CentralRepository)
->setModelService('DeltaX\Aegis\ModelServices\GradesRegistry\StudentChecklist')
@makoru-hikage
makoru-hikage / is_prime.py
Created October 10, 2017 02:58
A simple "IS PRIME?" algorithm made while being allergic to "else" statement
def is_prime(x):
divisor = 1
while divisor < x:
if divisor > 1 and (x % count) == 0:
return False
divisor += 1
return True
@makoru-hikage
makoru-hikage / summation_notation.py
Last active October 12, 2017 11:47
A simple implementation of summation notation in Python
"""
## Derived from here:
## https://math.stackexchange.com/questions/1694311/is-sigma-sigma-a-mathematical-way-of-doing-a-for-loop/1694322
## (c) CC-BY-SA 3.0
"""
## Definition
def sum_notation(i=0, end=1, f= lambda x : x):
return f(i) + sum_notation(i+1, end, f) if (i <= end) else 0