Skip to content

Instantly share code, notes, and snippets.

View thinkstylestudio's full-sized avatar

Theron Smith thinkstylestudio

View GitHub Profile
@thinkstylestudio
thinkstylestudio / eloquent-cheatsheet.php
Created May 7, 2018 22:30 — forked from hassansin/eloquent-cheatsheet.php
Laravel 5 Eloquent CheatSheet #laravel #eloquent
Model::
/*Select*/
select('col1','col2')
->select(array('col1','col2'))
->select(DB::raw('businesses.*, COUNT(reviews.id) as no_of_ratings, IFNULL(sum(reviews.score),0) as rating'))
->addSelect('col3','col4')
->distinct() // distinct select
/*From*/
@thinkstylestudio
thinkstylestudio / HigherOrderOptionalProxy.php
Created August 28, 2017 05:54 — forked from derekmd/Optional.php
Laravel global helper function `optional()`
<?php
namespace App\Support;
class HigherOrderOptionalProxy
{
/**
* The target being transformed.
* Use _ prefix to avoid namespace conflict on __get()
*
@thinkstylestudio
thinkstylestudio / null_pattern.php
Created June 13, 2017 01:03 — forked from eric1234/null_pattern.php
A null object pattern implemented in PHP
<?php
# Implements a recursive null object pattern.
#
# Implemented as a trait so any object can make it's properties use
# the null pattern without resorting to inheritance.
#
# The goal is so you can pull data off a partially populated object
# without excessive existance checks.
trait NullPattern {
@thinkstylestudio
thinkstylestudio / launcher.sh
Created June 1, 2017 18:11 — forked from robertoestivill/launcher.sh
Bash alternative to Franz
#!/bin/bash
open -a "Google Chrome" --new --args --new-window \
'https://tweetdeck.twitter.com' \
'https://web.whatsapp.com' \
'https://blastersystems.slack.com/' \
'https://www.messenger.com/' \
'https://web.telegram.org/' \
'https://web.skype.com' \
'https://hangouts.google.com/' \
@thinkstylestudio
thinkstylestudio / maxBy.php
Created May 25, 2017 18:16 — forked from adamwathan/maxBy.php
maxBy/minBy macros
<?php
Collection::macro('maxBy', function ($callback) {
$callback = $this->valueRetriever($callback);
return $this->reduce(function ($result, $item) use ($callback) {
if ($result === null) {
return $item;
}
return $callback($item) > $callback($result) ? $item : $result;
@thinkstylestudio
thinkstylestudio / init.lua
Created February 20, 2017 21:56 — forked from ttscoff/init.lua
Hammerspoon config examples for hyper key
-- A global variable for the Hyper Mode
k = hs.hotkey.modal.new({}, "F17")
-- Trigger existing hyper key shortcuts
k:bind({}, 'm', nil, function() hs.eventtap.keyStroke({"cmd","alt","shift","ctrl"}, 'm') end)
-- OR build your own
launch = function(appname)
@thinkstylestudio
thinkstylestudio / init.lua
Created February 18, 2017 23:17 — forked from hswolff/init.lua
hammerspoon init.lua
-- watch for changes
hs.pathwatcher.new(os.getenv("HOME") .. "/.hammerspoon/", hs.reload):start()
--
-- start custom config
--
@thinkstylestudio
thinkstylestudio / init.lua
Created February 18, 2017 23:15 — forked from amine2233/ init.lua
My Hammerspoon
-- Hotkey mash
local mash = {"cmd", "alt", "ctrl"}
local mash_move = {"cmd", "ctrl"}
local mash_app = {"shift","ctrl","alt"}
hs.alert("Reloaded Config")
-- instant window resizing
hs.window.animationDuration = 0
@thinkstylestudio
thinkstylestudio / saeven.lua
Created February 18, 2017 23:14 — forked from Saeven/saeven.lua
Hammerspoon script to launch and tile apps
local workApplications = { 'Mail','HipChat','PhpStorm','Safari','Charles'}
local workApplicationWatcher;
hs.hotkey.bind({"cmd", "alt", "ctrl"}, "H", function()
hs.notify.new({title="Hammerspoon", informativeText="Setting home layout"}):send()
local homeMonitor = "LG ULTRAWIDE"
local windowLayout = {
{"PhpStorm", nil, homeMonitor, {x=0, y=0, w=0.6, h=1}, nil, nil},
{"Charles", nil, homeMonitor, {x=0.6, y=0.6, w=0.4, h=0.4}, nil, nil},
@thinkstylestudio
thinkstylestudio / cheaphints.lua
Created February 18, 2017 22:24
cheaphints: lightweight hints in hammerspoon
--[[
installation: put this file in ~/.hammerspoon and add this line to your init.lua:
local cheaphints = require "cheaphints"
usage: by default, just hit cmd+alt+E. you'll see a list of keys and associated
windows. if you hit escape, you'll exit hint mode. if you hit one of the keys in
the list, that window gets focused. the hint mode will exit automatically after
a while.
]]