Skip to content

Instantly share code, notes, and snippets.

@kkiernan
kkiernan / vuejs-filter-snake-to-title.js
Last active December 6, 2021 12:34
A Vue.js filter that converts snake case to title case.
/**
* Converts a snake case string to title case.
* Example: snake_case => Snake Case
*
* @param {String} str the string to convert
* @return {String}
*/
Vue.filter('snakeToTitle', function (str) {
return str.split('_').map(function (item) {
return item.charAt(0).toUpperCase() + item.substring(1);
@kkiernan
kkiernan / index.html
Last active August 3, 2024 06:38
A Vue.js filter that formats a phone number.
<input type="text"
name="home_phone"
class="form-control"
v-model="homePhone | phone"
lazy>
@kkiernan
kkiernan / create.py
Last active December 27, 2022 09:25
import sublime, sublime_plugin, re
class CreateCommand(sublime_plugin.TextCommand):
# Runs the plugin
def run(self, edit, stub, offset):
self.view.insert(edit, offset, stub)
@kkiernan
kkiernan / ArrayPaginator.php
Last active June 6, 2023 07:48
A reusable helper class for pagination of array items in Laravel.
<?php
namespace App\Http\Utilities;
use Illuminate\Http\Request;
use Illuminate\Pagination\LengthAwarePaginator;
use Illuminate\Support\Collection;
class ArrayPaginator
{
@kkiernan
kkiernan / MySqlDump.php
Last active March 4, 2024 19:19
Laravel Artisan command that runs the mysqldump utility
<?php
namespace App\Console\Commands;
use Illuminate\Console\Command;
class MySqlDump extends Command
{
/**
* The name and signature of the console command.
@kkiernan
kkiernan / file-name-formatter.php
Last active March 1, 2016 18:23
Quick script to clean up file names in a directory
<?php
/*
|---------------------------------------------------------------------
| Rename Files
|---------------------------------------------------------------------
|
| This is a simple script to renames files in the current directory.
| It converts filenames to lowercase, removes non-alphanumeric
| characters and converts spaces to dashes.
@kkiernan
kkiernan / scp-download.sh
Last active October 5, 2017 16:29
Secure copy files from server to local machine using ssh alias
#!/usr/bin/bash
# Copy a directory from the server to the local machine.
scp -r some-server:/some/server/path/ /some/local/path/
@kkiernan
kkiernan / NullableFields.php
Last active April 29, 2016 13:32
A trait to help deal with handling empty strings in Eloquent models
<?php
namespace App\Models;
/**
* Converts empty values to nulls before saving a model to storage.
*/
trait NullableFields
{
/**
@kkiernan
kkiernan / Post.php
Last active November 27, 2021 03:50
Versioning trait for Laravel models
<?php
namespace App;
use App\Traits\Versionable;
use Illuminate\Database\Eloquent\Model;
class Post extends Model
{
use Versionable;
@kkiernan
kkiernan / _panels.scss
Created January 27, 2017 15:51
Collapsable Bootstrap Panel
//
// Mixins
//
@mixin panel-heading-control($content) {
border-right: 1px solid #ccc; // Adjust as needed
content: $content;
font-family: 'fontawesome'; // Adjust as needed
left: 0;