Skip to content

Instantly share code, notes, and snippets.

View calebporzio's full-sized avatar

Caleb Porzio calebporzio

View GitHub Profile
@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>
@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 / PreviewOfUpcomingPackage.php
Last active April 16, 2024 06:26
A model trait that allows child models to use parent table names and relationship keys.
<?php
namespace App\Abilities;
use Illuminate\Support\Str;
use ReflectionClass;
/**
* Note: This is a preview of an upcoming package from Tighten.
**/
@calebporzio
calebporzio / timer_helpers.php
Last active August 18, 2019 00:07
A simple helper function and macro for timing php scripts and eloquent queries
<?php
// Helper function.
if (! function_exists('timer')) {
function timer($expression)
{
$start = microtime(true);
if ($expression instanceof Closure) {
$expression();
<?php
$number = 361527;
$bottomRoot = floor(sqrt($number));
// Skip even numbers because they aren't corners.
if ($bottomRoot % 2 == 0) {
$bottomRoot = $bottomRoot-1;
}
<?php
namespace Tests\Challenges;
use Tests\TestCase;
class DayThreeTest extends TestCase
{
public function testFirstChallenge()
{
@calebporzio
calebporzio / SvgIcon.vue
Created February 19, 2018 19:08
SVG Icon Vue Component
<template>
<div class="inline-block" v-html="require('icon-' + this.icon + '.svg')"></div>
</template>
<style module>
.svg {
fill: currentColor;
height: 1em;
margin-top: -4px;
vertical-align: middle;
@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",
<template>
<div>
<whoops-message v-if="failed"></whoops-message>
<div v-else>
<component :is="fetchedComponent" v-bind="$props" v-if="loadedHtml"/>
<slot v-else></slot>
</div>
</div>
@calebporzio
calebporzio / HiddenInput.vue
Created May 2, 2018 14:47
Little Vue component for turning JSON into native HTML for inputs
<script>
import _ from 'lodash'
export default {
props: [ 'name', 'value' ],
methods: {
flatInputsFromDeepJson(item, key, h) {
if (typeof item === 'object') {
return _.flatMapDeep(item, (value, newKey) => {