Skip to content

Instantly share code, notes, and snippets.

Avatar

Caleb Porzio calebporzio

View GitHub Profile
@calebporzio
calebporzio / fa.sublime_snippet
Last active Apr 8, 2018
Font Awesome sublime snippet for creating icon tags
View fa.sublime_snippet
<snippet>
<content><![CDATA[
<i class="fa fa-fw fa-${1}"></i>&nbsp;
]]></content>
<tabTrigger>fa</tabTrigger>
<description>Font Awesome Icon</description>
<scope>text.blade, text.html.blade, text.html</scope>
</snippet>
@calebporzio
calebporzio / $this.sublime-snippet
Created Jul 6, 2017
Sublime snippet: $ + tab -> $this->
View $this.sublime-snippet
<snippet>
<content><![CDATA[
\$this->
]]></content>
<tabTrigger>$</tabTrigger>
<scope>embedding.php, meta.embedded.block.php, source.php, meta.class.php, meta.block.php, meta.function.php, meta.block.php</scope>
</snippet>
View day3part2.php
<?php
namespace Tests\Challenges;
use Tests\TestCase;
class DayThreeTest extends TestCase
{
public function testFirstChallenge()
{
View day_three_part_one.php
<?php
$number = 361527;
$bottomRoot = floor(sqrt($number));
// Skip even numbers because they aren't corners.
if ($bottomRoot % 2 == 0) {
$bottomRoot = $bottomRoot-1;
}
@calebporzio
calebporzio / strict_localization_lookup.php
Last active Apr 8, 2018
Throw an error in a testing environment when trans('some-key') doesn't exist
View strict_localization_lookup.php
<?php
namespace Tests;
use Illuminate\Translation\Translator;
use Laravel\BrowserKitTesting\TestCase as BaseTestCase;
abstract class TestCase extends BaseTestCase
{
use CreatesApplication;
View refactor_1.php
<?php
// Refactor the following functions using your new skills from 99-bottles.
// Sorry about the lack of tests - bonus points if you write tests to get started.
function getStartDate() {
return preg_match("/^\d\d\d\d-\d\d-\d\d$/", $_GET['dStartDate']) ? $_GET['dStartDate'] : date("Y-m-d", time() - 60 * 60 * 24 * 7);
}
function getEndDate() {
View refactor_1_solution.php
<?php
// Before:
function getStartDate() {
return preg_match("/^\d\d\d\d-\d\d-\d\d$/", $_GET['dStartDate']) ? $_GET['dStartDate'] : date("Y-m-d", time() - 60 * 60 * 24 * 7);
}
function getEndDate() {
return preg_match("/^\d\d\d\d-\d\d-\d\d$/", $_GET['dEndDate']) ? $_GET['dEndDate'] : date("Y-m-d");
@calebporzio
calebporzio / redirect_message_macro.php
Last active Apr 8, 2018
Simple helper macro for a common Laravel controller pattern (redirecting back with status message)
View redirect_message_macro.php
<?php
namespace App\Providers;
use Illuminate\Support\ServiceProvider;
class AppServiceProvider extends ServiceProvider
{
public function boot()
{
View auth_macro_hack.php
<?php
// Until SessionGuard Macros get pulled into Laravel core from a PR:
// Remove this when Laravel 5.4.18 is released.
$this->app->config->set('auth.guards.hack', [
'driver' => 'modified-session',
'provider' => 'users',
]);
@calebporzio
calebporzio / death_by_arrow_keys.json
Created Apr 13, 2018
Karabiner: Map arrow keys to Q
View death_by_arrow_keys.json
{
"title": "Death by arrow keys",
"rules": [
{
"description": "Map arrow keys to command Q",
"manipulators": [
{
"type": "basic",
"from": {
"key_code": "left_arrow",