Skip to content

Instantly share code, notes, and snippets.

View bericp1's full-sized avatar

Brandon Phillips bericp1

View GitHub Profile
class FriendshipRepository implements Contract {
public function countAccepted($user) {
$user = $user instanceof User ? $user->id : $user;
return $this->model->where('user_id', $user)
->where('status', 'accepted')
->count();
}
}
{
"private": true,
"devDependencies": {
"dotenv": "^2.0.0",
"gulp": "^3.8.8",
"gulp-clean": "^0.3.1",
"gulp-exec": "^2.1.2",
"gulp-file": "^0.2.0",
"gulp-filter": "^4.0.0",
"gulp-html-replace": "^1.5.4",
@bericp1
bericp1 / supervisord
Last active February 18, 2017 01:28
A init.d script for supervisor on Amazon Linux AMI
#!/bin/bash
#
# supervisor Start/Stop the supervisor daemon.
#
# chkconfig: 345 90 10
# description: Supervisor is a client/server system that allows its users to
# monitor and control a number of processes on UNIX-like operating
# systems.
. /etc/init.d/functions
@bericp1
bericp1 / scroll-monitor.js
Created April 24, 2017 01:30 — forked from jacob-beltran/scroll-monitor.js
React Performance: Scroll Monitor Example
class ScrollMonitor extends React.Component {
constructor() {
this.handleScrollStart = this.startWatching.bind( this );
this.handleScrollEnd = debounce(
this.stopWatching.bind( this ),
100,
{ leading: false, trailing: true } );
}
componentDidMount() {
@bericp1
bericp1 / homestead.sh
Created August 23, 2017 19:26
Homestead bash function
homestead() {
VAGRANT_CWD=$HOME/Homestead vagrant $@
}
@bericp1
bericp1 / config.ex
Created March 31, 2018 20:30 — forked from gmodarelli/config.ex
Useful config wrapper for Elixir
defmodule Config do
@moduledoc """
This module handles fetching values from the config with some additional niceties
"""
@doc """
Fetches a value from the config, or from the environment if {:system, "VAR"}
is provided.
An optional default value can be provided if desired.
let x = 0;
async function test() {
x += await 2;
console.log(x);
}
test();
x += 1;
console.log(x);
@bericp1
bericp1 / database.php
Created August 28, 2018 22:15
Per-cluster Redis Config For Laravel
<?php
return [
// ...
'redis' => [
'options' => [
// Options can be specified here (with the lowest precedence).
],
@bericp1
bericp1 / custom-search-acf-wordpress.php
Created October 10, 2018 17:07 — forked from charleslouis/custom-search-acf-wordpress.php
PHP - Wordpress - Search - wordpress custom search function that encompasses ACF/advanced custom fields and taxonomies and split expression before request
<?php
/**
* [list_searcheable_acf list all the custom fields we want to include in our search query]
* @return [array] [list of custom fields]
*/
function list_searcheable_acf(){
$list_searcheable_acf = array("title", "sub_title", "excerpt_short", "excerpt_long", "xyz", "myACF");
return $list_searcheable_acf;
}
@bericp1
bericp1 / CurrentUserAwareModel.php
Created January 9, 2019 02:34
A Laravel model abstraction for models whose relationships or dynamic attributes should be current-user-aware. A little better than using global scope (i.e. `\Auth::user();`) but not much better.
<?php
namespace App\Support;
use App\User;
use Illuminate\Database\Eloquent\Model;
abstract class CurrentUserAwareModel extends Model
{
/**