Skip to content

Instantly share code, notes, and snippets.

Cody Scott codyphobe

Block or report user

Report or block codyphobe

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
@codyphobe
codyphobe / isSunSup.php
Last active Nov 15, 2018 — forked from bramus/isSunSup.php
PHP: Is The Sun Up (standalone version)?
View isSunSup.php
<?php
function sunIsUp(\DateTime $when, $lat, $lon): bool
{
$whenTimestamp = $when->getTimestamp();
[$sunriseTimestamp, $sunsetTimestamp] = array_map(function ($f) use ($whenTimestamp, $lat, $lon) {
return $f($whenTimestamp, SUNFUNCS_RET_TIMESTAMP, $lat, $lon);
}, ['date_sunrise', 'date_sunset']);
@codyphobe
codyphobe / HasUuid.php
Created Jul 10, 2018 — forked from calebporzio/HasUuid.php
A little trait to add to models that will have Uuids
View HasUuid.php
<?php
// Example usage in a model:
class ExampleModel extends Model
{
use HasUuid;
protected $primaryKey = 'uuid';
@codyphobe
codyphobe / in-memory-sqlite-database.php
Created Sep 26, 2017 — forked from reinink/in-memory-sqlite-database.php
Give users completely safe sandboxed raw SQL reporting abilities
View in-memory-sqlite-database.php
<?php
// Create in-memory SQLite database
$sqlite = new PDO('sqlite::memory:');
// Generate schema (for whatever tables you want)
$sqlite->prepare('CREATE TABLE users(id, family_id, first_name, last_name, email)')->execute();
$sqlite->prepare('CREATE TABLE families(id, name, phone, address)')->execute();
// Insert pre-defined data
@codyphobe
codyphobe / _readme.md
Created Aug 15, 2017 — forked from BenTech2/_readme.md
PretendYoureXyzzy Server Installation
View _readme.md

WARNING: This guide is still being written... after 3 days of research and trial/error i have setup a working server and now am shareing the process since theres no documentation on the internet for it.

How To Setup a PretendYoureXyzzy Server

Ubuntu 14.04 Server or Desktop

NOTE - you will need a linux (or M$ windows, but i could not get it tomcat emulator to work) GUI environment for eclipse to build the WAR file for the server, unless you plan to use Ubuntu Desktop for the server.

Setup the Tomcat Server

@codyphobe
codyphobe / delete-all-discord-messages.js
Created Aug 1, 2017
Deleting every message from a channel using DiscordJS
View delete-all-discord-messages.js
const client = new Discord.Client();
client.on('message', msg => {
let deleteStuff = () => {
let count = 0;
msg.channel.fetchMessages({limit: 100})
.then(messages => {
let messagesArr = messages.array();
let messageCount = messagesArr.length;
@codyphobe
codyphobe / SearchThreads.php
Created Jul 20, 2017 — forked from driesvints/SearchThreads.php
Multiple method query objects
View SearchThreads.php
<?php
namespace App\Queries;
use App\Models\Thread;
use Illuminate\Contracts\Pagination\Paginator;
class SearchThreads
{
public function __construct()
@codyphobe
codyphobe / SearchThreads.php
Created Jul 20, 2017 — forked from driesvints/SearchThreads.php
Invokable query object
View SearchThreads.php
<?php
namespace App\Queries;
use App\Models\Thread;
use Illuminate\Contracts\Pagination\Paginator;
class SearchThreads
{
public function __construct()
@codyphobe
codyphobe / UuidTrait.php
Created Jun 13, 2017 — forked from hongaar/UuidTrait.php
Laravel UuidTrait for Eloquent
View UuidTrait.php
<?php
use Rhumsaa\Uuid\Uuid;
trait UuidTrait
{
/**
* Boot the Uuid trait for the model.
*
* @return void
@codyphobe
codyphobe / FetchGitHubTotals.php
Created May 29, 2017 — forked from mpociot/FetchGitHubTotals.php
GitHub component for the excellent Spatie dashboard package from https://github.com/spatie/dashboard.spatie.be
View FetchGitHubTotals.php
<?php
namespace App\Components\GitHub;
use App\Events\GitHub\FileContentFetched;
use App\Events\GitHub\TotalsFetched;
use GitHub;
use Illuminate\Console\Command;
class FetchGitHubTotals extends Command
You can’t perform that action at this time.