This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/perl | |
open(INFILE1, "<list_of_classes.txt") or die "Couldn't open file, $!"; | |
@listOfClasses = <INFILE1>; | |
@items = (); | |
#Split all the items of the list which might be |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/perl | |
#The original one I wrote back in 2014 because I don't know sed and awk. | |
open(INFILE1, "<list_of_classes.txt") or die "Couldn't open file, $!"; | |
@listOfClasses = <INFILE1>; | |
@items = (); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* This is a simple search function by ID. An alternate ID(AID) key is a candidate key that | |
* is UNIQUE and is a natural key. This is used when surrogate keys are applied but a | |
* user want to search by a unique identifying name. Whilst primary keys(PK) called 'id' | |
* are UNSIGNED INT, the AID keys are usually VARCHAR. Such an example is a User entity. | |
* A user entity has 'id' as PK and 'username' as its AID. When someone wants to search | |
* by 'username'. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- Assuming the the table design is like this | |
-- | |
-- Table Name: school_calendar | |
-- Columns | |
-- id - INT NOT NULL PRIMARY KEY | |
-- semester - VARCHAR (255) NOT NULL | |
-- date_start - DATE | |
-- date_end - DATE | |
-- | |
-- The data will be as follows |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace DeltaX\Models; | |
use Illuminate\Database\Eloquent\Model; | |
use Carbon\Carbon; | |
class SchoolCalendar extends Model { | |
protected $guarded = ['created_at', 'updated_at', 'is_deleted']; | |
protected $hidden = ['created_at', 'updated_at', 'is_deleted']; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
public function getAcademicYearAttribute(){ | |
$year_start = Carbon::parse($this->date_start)->year; | |
$year_end = Carbon::parse($this->date_end)->year; | |
$academic_year = | |
self::select(['date_start','date_end', 'semester']) | |
->whereYear('date_start', $year_start) | |
->where(function($q) use ($year_end){ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
//With enough logic and math, one adept programmer can use this to determine what school year a semester belongs to. | |
//Using only the declared arguments of this lone user-defined function. | |
//Tested using PHP Fiddle (http://phpfiddle.org/) | |
define ('INTO_SEMESTERS', 2); | |
define ('INTO_TRIMESTERS', 4); | |
define ('INTO_QUARTERS', 3); | |
function getNsterOfYear($division, $date, $monthStart){ | |
$month = date_parse_from_format('Y-n-d', $date)['month']; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* INVOLVED TABLES | |
* | |
* TABLE: students | |
* id | |
* user_id | |
* degree_id | |
* ... | |
* | |
* TABLE: degrees |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$dummy= [ | |
'Alpha' => null, | |
'Beta' => null, | |
'Charlie' => null | |
]; | |
switch ($dummy['Alpha']) { | |
case is_array($dummy['Alpha']) : |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$dummy= [ | |
'Alpha' => null, | |
'Beta' => null, | |
'Charlie' => null | |
]; | |
switch (gettype($dummy['Alpha'])) { | |
case 'array' : | |
echo 'Alpha, according to this switch statement, is Array'; |
OlderNewer