Skip to content

Instantly share code, notes, and snippets.

View calebporzio's full-sized avatar

Caleb Porzio calebporzio

View GitHub Profile
@calebporzio
calebporzio / fa.sublime_snippet
Last active April 8, 2018 01:34
Font Awesome sublime snippet for creating icon tags
<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 July 6, 2017 14:49
Sublime snippet: $ + tab -> $this->
<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>
<?php
namespace Tests\Challenges;
use Tests\TestCase;
class DayThreeTest extends TestCase
{
public function testFirstChallenge()
{
<?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 April 8, 2018 02:28
Throw an error in a testing environment when trans('some-key') doesn't exist
<?php
namespace Tests;
use Illuminate\Translation\Translator;
use Laravel\BrowserKitTesting\TestCase as BaseTestCase;
abstract class TestCase extends BaseTestCase
{
use CreatesApplication;
<?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() {
<?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 April 8, 2018 02:28
Simple helper macro for a common Laravel controller pattern (redirecting back with status message)
<?php
namespace App\Providers;
use Illuminate\Support\ServiceProvider;
class AppServiceProvider extends ServiceProvider
{
public function boot()
{
<?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 April 13, 2018 13:07
Karabiner: Map arrow keys to Q
{
"title": "Death by arrow keys",
"rules": [
{
"description": "Map arrow keys to command Q",
"manipulators": [
{
"type": "basic",
"from": {
"key_code": "left_arrow",