Skip to content

Instantly share code, notes, and snippets.

Theodore R. Smith hopeseekr

Block or report user

Report or block hopeseekr

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
@hopeseekr
hopeseekr / phones.js
Created Oct 3, 2019
Formatting phones
View phones.js
phone: {
get: function() {
return this.value;
},
// setter
set: function(newValue) {
if (newValue.length === 1) {
this.value = "(" + newValue;
} else if (newValue.length === 4) {
this.value = newValue + ") ";
@hopeseekr
hopeseekr / README.md
Created Jun 13, 2019
DTOs in Action: The ColorSpeaker Project
View README.md

ColorSpeaker was inspired by the article Tests and types [mirror] that was posted to /r/PHP two days ago.

Its aim is to be an easy-to-use converter for different types of color models (RGB, CSS hex codes, HSV, HSL, etc.). It is also meant to be a real-world example of the power of Data Transfer Objects (DTOs). I specifically created this for one of my apprentices whom I taught DTOs to the night before I read the above article, and thought this would be a perfect project for showcasing DTOs.

I developed it in three distinct iterations:

  1. [v0.25 tag]: A virtually literal implementation of the article's one color DTO (RGBSpeaker and RGBColor). This is a great place to start learning about DTOs and is meant to be used in conjunction with the article that inspired it.
  2. **[[v0.50](https://github.c
@hopeseekr
hopeseekr / fractal-20190611.txt
Created Jun 12, 2019
A beautiful ASCIII fractal
View fractal-20190611.txt
x x x x x x x x x x x x x x x x x x x x x x x x x
x x x x x x x x x x x x A A A A A A A x x x x x x x x x x x x
x x x x x x x x x x x x A A A A A A A A A A A A A A x x x x x x x x x x x
x x x x x x x x x x x v v A A A A A A A A A v v x x x x x x x x x x x
x x x x x x x x x x x v A A A A A A A A A A A A v x x x x x x x x x x
x x x x x x x x x x A A A A A A A A A A A A A A A x x x x x x x x x x
x x x x x x x x x x v v v v v A A A A A A v v v v v x x x x x x x x x
x x x x x x x x x v v v v A A A A A A A A A v v v v x x x x x x x x x
x x x x x x x x x v v v A A A A A A A A A A A A v v v x x x x x x x x
x x x x x x x x v v v v v v A A A A A A A A A v v v v v v x x x x x x x x
View gem.txt
xgxgxgxgxgxgxgxgxgxgxgxgxgxgxgxgxgxgxgxgxgxgxgxgxgxgxgxgxgxgxgxgxgxgx
gxgoyxgoyxgoyxgoyxgxyogxyogxyogxyogxyogxyogxyogxyogxyogxyogxyogxyogxg
xgoyxgoyxgoyxgoyxgoycccycccycccycccycccycccycccycccyogxyogxyogxyogxyx
goyxgoyxgoyxgoyxgoycccysgcysgcysgcysgcysgcysgcysgcccgxyogxyogxyogxyog
xyxgoyxgoyxgoyxgoycgsycccysgsycccysgsycccysgsycccysgcyogxyogxyogxyogx
gxgoyxgoyxgoyxgoycccycccysgsysgcysgsysgcysgsysgcccgcccgxyogxyogxyogxg
xgoyxgoyxgoyxgoycgsysgsycccycccysgsysgsycccycccysgsysgcyogxyogxyogxyx
goyxgoyxgoyxgoycccysgsycccysgcysgsysgsysgcysgcccgsysgcccgxyogxyogxyog
xyxgoyxgoyxgoycgsycgsycgsycccysgsysgsysgsycccysgcysgcysgcyogxyogxyogx
gxgoyxgoyxgoycccycccycccycccysgsysgsysgsysgcccgcccgcccgcccgxyogxyogxg
View php_stumper.php
<?php
function asdf()
{
function asd() { echo "Hi\n"; }
asd();
}
asdf();
asd();
@hopeseekr
hopeseekr / howto_git_submodules.sh
Created Mar 19, 2019
HOWTO Split Huge Subdirectories into Git Submodules
View howto_git_submodules.sh
# First, split the huge directory into its own standalone branch.
git subtree split -P v1/fpdf/assets/img -b api_fpdf_asset_images
# Second, push the huge directory into its own repository.
pushd ..
mkdir api_fpdf_asset_images
pushd api_fpdf_asset_images
git init
git pull ../api.filtered api_fpdf_asset_images
@hopeseekr
hopeseekr / README.md
Created Mar 14, 2019
Real-World Continuous Integration
View README.md

Real-World Continuous Integration

What is Continuous Integration (CI)?

Continuous Integration (CI) is the process of automating the build and testing of code every time a team member commits changes to version control. 

Here are the basic parts of a modern CI system:

  1. Automated Tests:
@hopeseekr
hopeseekr / strategy_pattern_tutorial.php
Created Mar 13, 2019
Strategy Pattern Educational Code
View strategy_pattern_tutorial.php
<?php
interface RESTAuthDriver
{
public function setApiClient(RESTSpeaker $apiClient);
public function generateGuzzleAuthOptions(): array;
}
interface Foo2
{
@hopeseekr
hopeseekr / 911s_a_lie.md
Created Jun 27, 2018
9/11's a Lie! Lyrics
View 911s_a_lie.md

Lyrics to Deek Jackson's "9/11's a Lie!"

If you think 9/11 was an inside job
You're probably right, but who gives a fuck?
The world moved on and the truth don't count.
If you don't believe me, Take a look about:
At the tyranny in China, for a billion souls;
Economic crisis, adding to our woes!
The economic lies are there to fool the masses,
While they bend us over, and fuck us in our asses!
@hopeseekr
hopeseekr / adv_sql-mat_view_regex.md
Last active May 23, 2018
Advanced SQL: Materialized View with Many-To-Many Squashing and Regexp
View adv_sql-mat_view_regex.md

So say you have a table with a many-many relationship to another, and you want to create a caching table (aka a materialized view):

CREATE TABLE orders_cache (
customer_id int primary_key, 
payment_type varchar(10000),
INDEX(payment_type(255))
) CHARSET=utf8;

You can’t perform that action at this time.