Skip to content

Instantly share code, notes, and snippets.

View 1stevengrant's full-sized avatar
🏠
Working from home

Steven Grant 1stevengrant

🏠
Working from home
View GitHub Profile
@dennisfrank
dennisfrank / get_remote_db.sh
Created May 23, 2014 16:49
Shell script to import a remote database into local environment
#!/bin/sh
# Import a remote database into a local database
# ----------------------------------------------
#
# Based on http://danherd.net/quick-script-synchronise-from-a-remote-expressionengine-database/
#
# Don’t forget chmod +x to make the script executable.
#
# Change the extension to .command to run the script directly from OS X Finder.
@hootlex
hootlex / pagination object API example.md
Created June 15, 2016 16:41
pagination object API example
    /**
     * Display a listing of the resource.
     *
     * @return \Illuminate\Http\Response
     */
    public function index()
    {
        $posts = Post::paginate(20);
@aarongustafson
aarongustafson / lazy-loaded-markup.html
Last active March 8, 2018 09:35
Easy Responsive Images in ExpressionEngine with CE Image
<div class="module__image image--lazy"
data-image-src="Tim-Smith_220x140_220_140_int_c1.jpg"></div>
.form-label {
@apply .mb-2 .block .text-sm .text-dark;
}
.form-input,
.form-textarea,
.form-select {
@apply .p-2 .leading-normal .block .w-full .border .text-dark .bg-light .text-sm .font-sans .rounded .text-left .appearance-none;
&:focus {
@timkelty
timkelty / Custom_ElementApiHelper.php
Last active January 22, 2019 06:55
Standardize Element API requests
<?php
namespace Craft;
class Custom_ElementApiHelper
{
public static function getParams($params)
{
$requestParams = array_filter([
'elementType' => craft()->request->getParam('elementType'),
'criteria' => Custom_ElementApiHelper::prepCriteria(craft()->request->getParam('criteria')),
@manuhabitela
manuhabitela / _grid.scss
Last active January 11, 2021 14:15
Making the Bootstrap grid with Susy and sass-mq
// this is (a start of) an example of a Susy+mq() setup that mimics bootstrap grid.
// I work on multiple bootstrap-based projects.
// I want to stop using grid classes in the markup, and start using mixins with susy and sass-mq.
// Since the project is heavily tied to the bootstrap grid, I want to have the exact same behavior
// between bootstrap classes (old code) and susy mixins (new code).
// all the grid classes generated below are here to ease up testing.
// required: susy + sass-mq
@fhferreira
fhferreira / haversine.php
Last active January 19, 2021 14:44
Haversine Method for model Laravel.
<?php
/*
* find the n closest locations
* @param Model $query eloquent model
* @param float $lat latitude of the point of interest
* @param float $lng longitude of the point of interest
* @param float $max_distance distance in miles or km
* @param string $units miles or kilometers
* @param Array $fiels to return
* @return array
@rugor
rugor / gist:6131cd28cb51f0c70238dacb9e1a494b
Created January 31, 2017 00:25
JavaScript: Vue.js v-for with index and last item class #rugor
<div v-for="(item, index) in items" v-bind:class="{last : index === (items.length-1)}">
<p>Foo</p>
</div>
@reinink
reinink / webpack.mix.js
Created November 20, 2017 13:19
Using Purgecss with Tailwind and Laravel Mix
let cssImport = require('postcss-import')
let cssNext = require('postcss-cssnext')
let glob = require('glob-all')
let mix = require('laravel-mix')
let purgeCss = require('purgecss-webpack-plugin')
let tailwind = require('tailwindcss')
mix.js('resources/assets/js/app.js', 'public/js')
.postCss('resources/assets/css/app.css', 'public/css/app.css', [
cssImport(),
@piotrpog
piotrpog / yt_address.twig
Last active July 6, 2021 10:35
Twig macro turning youtube video URL into responsive and lazy-loaded player. More info: http://craftsnippets.com/articles/responsive-and-lazy-loaded-youtube-videos-with-craft-cms
{# v2 #}
{%- macro ytAddress(url, lazy = true) -%}
{% if url is not empty %}
{% set id = url|split('v=')|last %}
{% set id = id|split('&')|first %}
{% set id = id|split('/')|last %}
<div class="youtube-player">
<figure style="position: relative; padding-bottom: 56.25%; height: 0; overflow: hidden; max-width: 100%; margin: 0px;">
<iframe src="https://www.youtube.com/embed/{{id}}" frameborder="0" allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" allowfullscreen style="position: absolute; top: 0; left: 0; width: 100%; height: 100%;"{{ lazy ? ' loading="lazy"'}}></iframe>