Skip to content

Instantly share code, notes, and snippets.

@omurphy27
omurphy27 / eloquent-nested-orwhere-query.php
Last active July 10, 2017 13:38
Laravel 5.2 - Eloquent query with nested Where and orWhere like variables
<?php
$results = ClinicalStudy::where( function( $query ) use ( $data )
{
$query->where('brief_title', 'like', $data['query'] .'%')
->orWhere('source', 'like', $data['query'] .'%')
->orWhere('brief_summary', 'like', $data['query'] .'%')
->orWhere('detailed_description', 'like', $data['query'] .'%');
});
@omurphy27
omurphy27 / js-find-match-in-array.js
Created July 27, 2016 06:14
JS - Javascript - Finding a match in a JS array with indexOf
// where this.conditionsLetters is
// ["A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z"]
if ( this.conditionsLetters.indexOf( $letter ) > -1 ) { // check if match found
this.selectedConditionsLetter = $letter;
}
// no match returns -1,
// whereas a match returns the zero base position in the array which is always greater than -1
@omurphy27
omurphy27 / php-generate-seo-slug.php
Created July 27, 2016 04:24
PHP - create seo friendly slug from string
<?php // credit: http://stackoverflow.com/questions/11330480/strip-php-variable-replace-white-spaces-with-dashes
function seoUrl($string) {
//Lower case everything
$string = strtolower($string);
//Make alphanumeric (removes all other characters)
$string = preg_replace("/[^a-z0-9_\s-]/", "", $string);
//Clean up multiple dashes or whitespaces
$string = preg_replace("/[\s-]+/", " ", $string);
//Convert whitespaces and underscore to dash
@omurphy27
omurphy27 / local-mysql-vagrant-connect.txt
Created July 14, 2016 04:29
Connecting to local homebrew Mysql from inside Vagrant server
// the below works from the command line after sshing in (vagrant ssh)
mysql -p -u root -h 10.0.2.2
// DB connect creds
10.0.2.2 // Hostname of MySQL server
root // Username for local MySQL
root // Password for local MySQL user
database_name // Database name
// see here for more: http://stackoverflow.com/questions/24037087/how-do-i-connect-to-my-local-macbook-mysql-form-vagrant-vm-box
@omurphy27
omurphy27 / bootstrap-sr-only.css
Created February 11, 2016 08:53
Bootstrap Screen Reader Only Hide CSS
.sr-only {
position: absolute;
width: 1px;
height: 1px;
padding: 0;
margin: -1px;
overflow: hidden;
clip: rect(0,0,0,0);
border: 0;
}
@omurphy27
omurphy27 / slick-slider-prev-next.css
Last active July 29, 2020 19:27
Styling Previous and Next buttons in Slick Slider with Font Awesome Icons
/* Must include Font Awesome (here: https://fortawesome.github.io/Font-Awesome/get-started/) for icons to show up */
.slick-prev,
.slick-next {
font-size: 0;
position: absolute;
bottom: 20px;
color: #d5122f;
border: 0;
background: none;
@omurphy27
omurphy27 / ssh-chmod-change-permissions
Last active January 5, 2016 09:52
SSH - Change Permissions of all directories to 755 and all files to 644
// credit http://stackoverflow.com/questions/3740152/how-to-set-chmod-for-a-folder-and-all-of-its-subfolders-and-files-in-linux-ubunt
find . -type d -exec chmod 755 {} \;
find . -type f -exec chmod 644 {} \;
@omurphy27
omurphy27 / woocommerce-phone-number-not-required.php
Created October 8, 2015 21:11
WooCommerce - make phone number not required on checkout page
// make phone number at checkout not required
add_filter( 'woocommerce_billing_fields', 'jwd_filter_phone' );
function jwd_filter_phone( $address_fields ) {
$address_fields['billing_phone']['required'] = false;
return $address_fields;
}
@omurphy27
omurphy27 / archive-post-type.php
Last active September 29, 2015 16:55 — forked from kopepasah/archive-post-type.php
Order Custom Post Type Archive by Taxonomy in WordPress
<?php
/**
* Template for ordering custom post types by terms on
* on the post types archive.php
*
* @package WordPress
* @author Justin Kopepasah
*
*/
@omurphy27
omurphy27 / WP Events Manager Calendar CSS.css
Created September 2, 2015 21:01
WP Events Manager Calendar CSS.css
.em-calendar-wrapper table {
background:#eaeaea;
width:100%;
border:3px solid #BF2E0D;
border-spacing: 0;
border-collapse: collapse;
}
.em-calendar-wrapper table thead td {
padding:0;