Skip to content

Instantly share code, notes, and snippets.

View patricksamson's full-sized avatar

Patrick Samson patricksamson

View GitHub Profile
<?php
/*
//Normal query
User::all();
//Cached query (default 60min)
User::cached()->all();
//Cached query (5min)
@adamwathan
adamwathan / belongs-to-many.sublime-snippet
Last active August 3, 2024 16:44
Eloquent Relationship snippets for Sublime Text
<snippet>
<content><![CDATA[
public function ${1:relationship}()
{
return \$this->belongsToMany(${1/^(.+)$/(?1\u$1:)/g}::class, {$2:table});
}
]]></content>
<!-- Optional: Set a tabTrigger to define how to trigger the snippet -->
<tabTrigger>belt</tabTrigger>
<!-- Optional: Set a scope to limit where the snippet will trigger -->
@patricksamson
patricksamson / Postgresql pg_upgrade on Ubuntu for pgsql 9.3 to 9.4
Last active January 4, 2017 05:47 — forked from martinseener/postgresql_9.1_to_9.3_on_ubuntu_debian
Postgresql pg_upgrade on Ubuntu for pgsql 9.3 to 9.4
# Add postgresql repo and update apt listing
echo "deb http://apt.postgresql.org/pub/repos/apt/ squeeze-pgdg main" > /etc/apt/sources.list.d/pgdg.
wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add -
sudo apt-get update
sudo apt-get upgrade
# Stop all running postgresql servers -- needed for migration of 9.3 data to 9.4 (pg_upgrade execution)
sudo /etc/init.d/postgresql stop
# Must link conf file into data directory since it's expected there by pg_upgrade.
@mhedges1
mhedges1 / SeedResource.php
Last active June 5, 2020 02:50
Quickly build boilerplate for your Laravel 5.1 application's resources. Builds a Model, Migration, Controller, FormRequests, Commands, and Events in one expression. Simply place this file into App/Console/Commands/ and add " \App\Console\Commands\Resource\SeedResource::class" to your $commands array in App\Console\Kernel.php
<?php
namespace App\Console\Commands;
use Illuminate\Console\Command;
/**
* Class SeedResource
* @package App\Console\Commands\Resource
*/
@mvaneijgen
mvaneijgen / material-theme.terminal
Created June 15, 2015 20:27
material-theme.terminal
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>ANSIBlackColor</key>
<data>
YnBsaXN0MDDUAQIDBAUGKSpYJHZlcnNpb25YJG9iamVjdHNZJGFyY2hpdmVyVCR0b3AS
AAGGoKcHCBMXGyImVSRudWxs1QkKCwwNDg8QERJcTlNDb21wb25lbnRzVU5TUkdCXE5T
Q29sb3JTcGFjZV8QEk5TQ3VzdG9tQ29sb3JTcGFjZVYkY2xhc3NPECgwLjAyNzQ1MTAw
NjcgMC4yMTE3NjQ3MjMxIDAuMjU4ODIzNDg0MiAxTxAoMC4wMzkzODA3NDc4MiAwLjE2
@alfard
alfard / Tree_Cart_clean.py
Last active December 5, 2017 16:11
Cart algorithm
import numpy as np
import random
class Node:
def __init__(self,t,L,R,D,S,V,M,X):
self.t=t
self.L=L
self.R=R
self.D=D
@SimpleHomelab
SimpleHomelab / advancedsettings.xml
Last active November 5, 2021 20:43
AdvacedSettings.xml for Kodi with MySQL and other tweaks.
<!-- General Settings -->
<advancedsettings>
<loglevel hide="true">-1</loglevel> <!-- Comment: Disables logging -->
<playcountminimumpercent>95</playcountminimumpercent>
<skiploopfilter>0</skiploopfilter> <!-- Comment: For RPi or similar use 16 or higher (low CPU usage) -->
<nodvdrom>true</nodvdrom>
<!-- MySQL Library -->
<videodatabase>
<type>mysql</type>
@shphrd
shphrd / How to: Ƀ and ƀ
Last active August 29, 2015 14:13
Easily add it to your tweets, website, email and more!
LATIN CAPITAL LETTER B WITH STROKE
Unicode: U+0243
HTML: &#579;
LATIN SMALL LETTER B WITH STROKE
Unicode: U+0180
HTML: &#384;
@kylenoland
kylenoland / BaseRepository.php
Created October 28, 2014 14:35
Laravel Base Repository
<?php
abstract class BaseRepository implements BaseRepositoryInterface
{
/**
* The repository model
*
* @var \Illuminate\Database\Eloquent\Model
*/
protected $model;
@soldni
soldni / gpu.applescript
Created October 25, 2014 01:51
Toggle between "discrete GPU only" and "automatic switching" on a 15" Retina MacBook Pro.
tell application "System Preferences"
reveal pane "com.apple.preference.energysaver"
end tell
tell application "System Events" to tell process "System Preferences" to tell window "Energy Saver"
set status to value of checkbox "Automatic graphics switching" of group 1
click checkbox "Automatic graphics switching" of group 1
end tell
quit application "System Preferences"
if status is 0 then
return "Automatic switch activated"