Skip to content

Instantly share code, notes, and snippets.

Keybase proof

I hereby claim:

  • I am omurphy27 on github.
  • I am omurphy27 (https://keybase.io/omurphy27) on keybase.
  • I have a public key ASDuCIq83t_gNRhggBHQky1IXF_bTrJZkk8tuJHvapz1BAo

To claim this, I am signing this object:

@omurphy27
omurphy27 / gdocs-formatted-date-macro.js
Created February 23, 2017 01:18
Google Docs Script for Inserting Formatted Date with Month Name via a Macro
/**
* Helper functions to make formatting the date easier
*/
Date.prototype.getMonthNameShort = function() {
return Date.month_names_short[ this.getMonth() ];
};
Date.month_names_short = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'];
Date.prototype.getDateEnding = function() {
@omurphy27
omurphy27 / loop-terms-posts-cpt.php
Last active December 1, 2019 20:26
Wordpress WP - Loop through all Terms associated with CPT Taxonomy and their Associated Posts
<?php
$terms = get_terms( array(
'taxonomy' => 'dojo_category',
) );
foreach( $terms as $term ) : ?>
<div class="dojo-location-block">
<h2><?php echo $term->name; ?></h2>
<?php $posts = new WP_Query( "taxonomy=dojo_category&term=$term->slug&posts_per_page=-1" );
if( $posts->have_posts() ): while( $posts->have_posts() ) : $posts->the_post(); ?>
<div class="dojo-block clearfix">
@omurphy27
omurphy27 / package.json
Last active January 5, 2017 21:31
Package.json file for using gulp
{
"name": "generic-project",
"version": "1.0.0",
"main": "gulpfile.js",
"license": "ISC",
"devDependencies": {
"gulp": "^3.9.1",
"gulp-autoprefixer": "^3.1.1",
"gulp-clean-css": "^2.0.12",
"gulp-concat": "^2.6.1",
@omurphy27
omurphy27 / .gitignore
Last active July 19, 2017 17:49
General Gitignore for Laravel, Laradock, Wordpress, Vim, Mac, and Windows users
/node_modules
/public/storage
/vendor
/laradock
/.idea
Homestead.json
Homestead.yaml
.env
*.swp
*.swn
@omurphy27
omurphy27 / laravel-auth-routes.php
Created December 29, 2016 18:33
Laravel 5.3 - Manually Defining Default Auto Generated Auth Routes
<?php
// in the routes/web.php file
// the auto generated 'Auth::routes()'
// creates the below routes
// Authentication Routes...
Route::get('login', 'Auth\LoginController@showLoginForm')->name('login');
Route::post('login', 'Auth\LoginController@login');
Route::post('logout', 'Auth\LoginController@logout')->name('logout');
@omurphy27
omurphy27 / laravel-eager-passing-parameters.php
Created December 28, 2016 23:24
Laravel Eloquent Eager Loading - Passing Parameters and Data to With Related Queries and Models
<?php
// must first define the relationships between your models
// see here: https://laravel.com/docs/5.3/eloquent-relationships#eager-loading
$result = Topic::where( 'slug', $slug )->approved()->with([
'comments' => function( $query ) use ( $data ) {
$query->take( $data['limit'] )
->skip( $data['limit'] * ( $data['page'] - 1 ) )
->with('user.profile')
@omurphy27
omurphy27 / laravel-eloquent-collection.php
Created December 28, 2016 20:52
Laravel - Determine if an Eloquent Collection from Get has results or is empty
<?php
$result = Model::where(...)->get();
if ($result->first()) { }
if (!$result->isEmpty()) { }
if ($result->count()) { }
if (count($result)) { }
// see here: http://stackoverflow.com/questions/20563166/eloquent-collection-counting-and-detect-empty
@omurphy27
omurphy27 / echo-enqueued-styles-scripts-wordpress.php
Last active March 8, 2024 07:19
Wordpress - Print Out All Enqueued Scripts And Styles On A Page
<?php
// add the below to your functions file
// then visit the page that you want to see
// the enqueued scripts and stylesheets for
function se_inspect_styles() {
global $wp_styles;
echo "<h2>Enqueued CSS Stylesheets</h2><ul>";
foreach( $wp_styles->queue as $handle ) :
echo "<li>" . $handle . "</li>";
@omurphy27
omurphy27 / grep-function-shortcut.sh
Last active June 13, 2019 07:50
Oh My ZSH Recursive Case-insensitive Grep with common File / Folder Exclusions and Line Numbers - Bash Function and alias shortcut for zshrc file
# add any other filename endings you wish to exclude
function mygrep {
grep -inrF "$1" --exclude-dir={node_modules,vendor,.git,.svn} --exclude=\*.{min.js,min.css,map,swp,swn,swo} . --color;
}
# fire the above function in your terminal by doing the below
# in the directory you wish to recursively grep through
mygrep function_name_to_grep
# or wrap your search term in quotes