Skip to content

Instantly share code, notes, and snippets.

View DavidStrada's full-sized avatar
:octocat:
Full StackOverflow Developer

David DavidStrada

:octocat:
Full StackOverflow Developer
View GitHub Profile
@DavidStrada
DavidStrada / eager-loading.twig
Created September 7, 2021 23:56 — forked from Chrisedmo/eager-loading.twig
#CraftCMS: Eager-Load Nested Sets of Elements
{#
According to docs (https://craftcms.com/docs/templating/eager-loading-elements),
this is how you Eager-Load Nested Sets of Elements
#}
{% set entries = craft.entries({
section: 'news',
with: [
'entriesField.assetsField'
]
@DavidStrada
DavidStrada / AppServiceProvider.php
Created May 16, 2019 17:37 — forked from simonhamp/AppServiceProvider.php
A pageable Collection implementation for Laravel
<?php
namespace App\Providers;
use Illuminate\Support\Collection;
use Illuminate\Pagination\LengthAwarePaginator;
class AppServiceProvider extends ServiceProvider
{
public function boot()
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
class Article extends Model
{
protected $fillable = ['name', 'content'];
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>JS Bin</title>
<script src="http://d3js.org/d3.v3.min.js"></script>
<script src="http://dimplejs.org/dist/dimple.v2.1.6.min.js"></script>
<style id="jsbin-css">
.dimple-example {
@DavidStrada
DavidStrada / gist:3269058
Last active March 24, 2017 16:15
JS: Animation for a hover with 'mouse direction'
$(".overlayLink").bind("mouseenter mouseleave",function(e){
/** the width and height of the current div **/
var w = $(this).width();
var h = $(this).height();
/** calculate the x and y to get an angle to the center of the div from that x and y. **/
/** gets the x value relative to the center of the DIV and "normalize" it **/
var x = (e.pageX - this.offsetLeft - (w/2)) * ( w > h ? (h/w) : 1 );
var y = (e.pageY - this.offsetTop - (h/2)) * ( h > w ? (w/h) : 1 );